Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 1882 | Accepted: 553 |
Description
Flesch Reading Ease, a readability test named after its deviser Rudolf Flesch, is among most ubiquitously used readability tests, which are principally employed for assessment of the difficulty to understand a reading passage written in English. The Flesch Reading Ease score of a passage relies solely on three statistics, namely the total numbers of sentences, words and syllables, of the passage. Specifically, the score is defined by the following formula:
.
As can be inferred from the above formula, a passage with a high Flesch Reading Ease score tends to favor shorter sentences and words, which is in compliance with commonsense in spite of partial accuracy. (Think of, for instance, the word "television". Long as it may seem, it is indeed one of the first words that any individual who studies English learns.) A related Wikipedia entry on Flesch Reading Ease [1] suggests that passages scoring 90~100 are comprehensible for an average American 5th grader, and 8th and 9th graders possess the ability to follow passages with a score in the range of 60~70, whereas passages not exceeding 30 in the score are best suitable for college graduates. The text of this problem, all sections taken into account, scores roughly 50 as per the calculation of Google Documents.
Despite the simplicity in its ideas, several aspects of its definition remains vague for any real-world implementation of Flesch Reading Ease. For the sake of precision and uniformity, the following restrictions adapted from [2] are adopted for this problem, to which you are to write a solution that effectively computes the Flesch Reading Ease score of a given passage of English text.
Input
Output
Sample Input
Flesch Reading Ease, a readability test named after its deviser Rudolf Flesch, is among most ubiquitously used readability tests, which are principally employed for assessment of the difficulty to understand a reading passage written in English. The Flesch Reading Ease score of a passage relies solely on three statistics, namely the total numbers of sentences, words and syllables, of the passage.
Sample Output
26.09
Source
给出一段标准英语,统计里面的单词数,句子数,音节数,通过公式算出结果。
标准符号 ',' ' ' '.' ';' ':' '!' '?' 全是英语符号 逗号,空格,只分割单词。句号,分号,冒号,叹号,问号,分割句子和单词。
统计字节的时候:
1、单词长度小于等于3是,音节为1
2、大于3是,每个原音字母a,e,i,o,u,y,区分大小写,每个都是一个音节,如果结尾以-e(-le不算),-es,-ed结尾e不被记为一个音节。
#include <cstdio> #include <cstring> #include <algorithm> using namespace std ; char str[1000] ; int a , b , c ;//a单词数,b句子数,c音节数 int find1(char ch) { if( ch == ',' || ch == ' ' ) return 1 ; if( ch == '.' || ch == '?' || ch == ':' || ch == ';' || ch == '!' ) return 2 ; if( ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y' ) return 3 ; if( ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' || ch == 'Y' ) return 3 ; return 0 ; } void solve(int i,int num,int c_num) { if( num <= 3 ) { c++ ; return ; } if( str[i] == 'e' ) { if( str[i-1] == 'l' || find1(str[i-1]) == 3 ) c += c_num ; else c += (c_num-1) ; } else if( (str[i-1] == 'e' && str[i] == 's') || (str[i-1] == 'e' && str[i] == 'd') ) { if( find1(str[i-2]) == 3 ) c += c_num ; else c += (c_num-1) ; } else c += c_num ; return ; } int main() { int i , l , num , c_num , flag , k ; a = b = c = 0 ; while( scanf("%s", str) != EOF ) { l = strlen(str) ; flag = num = c_num = 0 ;//flag当前字符的前一个字符是不是原音,num当前单词的字母数,c_num单词原音数 for(i = 0 ; i < l ; i++) { k = find1(str[i]) ; if( k == 0 ) { num++ ; flag = 0 ; } else if( k == 1 ) { a++ ; solve(i-1,num,c_num) ; flag = num = c_num = 0 ; } else if( k == 2 ) { a++ ; b++ ; solve(i-1,num,c_num) ; flag = num = c_num = 0 ; } else if( k == 3 ) { num++ ; if( flag == 0 ) { c_num++ ; flag = 1 ; } } } k = find1(str[l-1]) ; if( k == 0 || k == 3 ) { a++ ; solve(l-1,num,c_num) ; } } printf("%.2lf\n", 206.835 - 1.015*(a*1.0)/(b*1.0) - 84.6*(c*1.0)/(a*1.0) ); return 0; }