Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2206 | Accepted: 686 |
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.
- Periods, explanation points, colons and semicolons serve as sentence delimiters.
- Each group of continuous non-blank characters with beginning and ending punctuation removed counts as a word.
- Each vowel (one of a, e, i, o, u and y) in a word is considered one syllable subject to that
- -es, -ed and -e (except -le) endings are ignored,
- words of three letters or shorter count as single syllables,
- consecutive vowels count as one syllable.
References
- Wikipedia contributors. Flesch-Kincaid Readability Test. Wikipedia, The Free Encyclopedia. August 30, 2007, 01:57 UTC. Available at: http://en.wikipedia.org/w
/index.php?title=Flesch -Kincaid_Readability_Test &oldid=154509512. Accessed September 5, 2007. - Talburt, J. 1985. The Flesch index: An easily programmable readability analysis algorithm. In Proceedings of the 4th Annual international Conference on Systems Documentation. SIGDOC '85. ACM Press, New York, NY, 114-122.
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题目链接:http://poj.org/problem?id=3371
我想把这个题掐死,太坑了,做了好几遍不对,快哭了QAQ,果断上网上找的大神,我真是!!!够了这个题了,思路完全正确,那个音节!音节!!音节!!!我这就快把他掐死了!!!!!!!
大致题意:
给出一篇规范的文章,求其 句子数、单词数 和 音节数
把这3个值代入题目给出的公式,输出其结果,保留2位小数。
PS:“规范”即文章没有错误的标点符号,字母在适当的位置有大小写。
解题思路:
我做了整整5天的BT题,,就是被标点符号害的!!!
别听信网上谗言,我个人总结出这题的标点符号只有6个!!!
注:下面的分隔符不包括 括号(),所有分隔符均为 英式标点符号
标记单词分隔符: 逗号(,) 和 空格( )
句子分隔符:句号(.) 问号(?) 冒号(:) 分号(;) 感叹号(!)
不存在上述标点符号以外的符号!!!所有符号只占一个字符的位置!!
什么 省略号、引号、连字符、问号+叹号、斜杠 等等符号统统不存在!!
知道这个,后面的就好做了
每出现一个单词分隔符,单词数+1
每出现一个句子分隔符,句子数+1
注意:
由于用while(cin>>msg)输入文章,因此是按 空字符 把文章分开若干片段,直到出现EOF时才结束输入,因此msg中的单词分隔符不会出现空格,只要当msg最后一个字符为字母时,就说明此时的单词分隔符为空格。
音节数是最难处理的,其规律如下:
(1) 当单词总长度<=3时,音节数无条件+1
(2) 当单词总长度>3时,单词中每出现一个元音字母(a、e、i、o、u、y),音节数+1,但是连续的元音字母只按1个音节计算,且当单词后缀为-es、-ed和-e时,后缀的元音字母e不列为音节数计算。但是后缀-le例外,要计算音节数。
注意:
(1)元音字母要判断12个,6个小写,6个大写。
(2)输入的文章每个字符只能扫描一次,若重复扫描会超时。
以上来自:http://blog.csdn.net/lyy289065406/article/details/6648650
代码;
#include<iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
int word=0,sen=0,yinjie=0;
bool judge(char ch) {
if(ch>='A' && ch <='Z')
return true;
if(ch>='a' && ch <='z')
return true;
return false;
}
bool fax(char ch){
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' || ch=='y')
return true;
if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U' || ch=='Y')
return true;
return false;
}
bool douhao(char ch) {
if(ch==',')
return true;
return false;
}
bool juzi(char ch) {
if(ch=='.' || ch=='?' || ch==':' || ch==';' || ch=='!')
return true;
return false;
}
int main(void){
char s[1000];
while(cin>>s){
int wordlen=0;
bool flag=false;
int ans=0;
int i;
for(i=0;s[i];i++){
if(judge(s[i])) {
wordlen++;
if(wordlen<=3) {
if(!judge(s[i+1])){
yinjie++;
yinjie-=ans;
ans=0;
continue;
}
}
if(fax(s[i])){
if(s[i]=='e'){
if(!judge(s[i+1]) && s[i-1]=='l'){
yinjie++;
ans++;
continue;
}
else if(!judge(s[i+1]))
continue;
else if((s[i+1]=='d' || s[i+1]=='s') && !judge(s[i+2])) // -ed -es
continue;
}
if(!flag){
flag=true;
yinjie++;
ans++;
continue;
}
else
continue;
}
flag=false;
}
else if(douhao(s[i])) {
flag=false;
wordlen=0;
ans=0;
word++;
}
else if(juzi(s[i])) {
flag=false;
wordlen=0;
word++;
ans=0;
sen++;
}
}
if(judge(s[i-1]))
word++;
}
//printf("%d %d %d\n",word,sen,yinjie);
printf("%.2f\n",206.835-1.015*(double)word/(double)sen-84.6*(double)yinjie/(double)word);
return 0;
}