poj-3371-Flesch Reading Ease
来源:互联网 发布:java string length() 编辑:程序博客网 时间:2024/06/18 17:40
Flesch Reading EaseTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2293 Accepted: 722
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 principallyemployed for assessment of the difficulty to understand a reading passagewritten in English. The Flesch Reading Ease score of a passage relies solelyon three statistics, namely the total numbers of sentences, words andsyllables, of the passage.
Sample Output
26.09
Source
标记单词分隔符: 逗号(,) 和 空格( )
句子分隔符:句号(.) 问号(?) 冒号(:) 分号(;) 感叹号(!)
(1) 当单词总长度<=3时,音节数无条件+1
(2) 当单词总长度>3时,单词中每出现一个元音字母(a、e、i、o、u、y),音节数+1,但是连续的元音字母只按1个音节计算,且当单词后缀为-es、-ed和-e时,后缀的元音字母e不列为音节数计算。但是后缀-le例外,要计算音节数。
不多说上代码:
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <iostream>#include <iomanip>using namespace std;int words = 0;int sentences = 0;int syllables = 0;//是否为元音字符bool isvoewl(char a){if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y')return true;if(a == 'A' || a == 'E' || a == 'I' || a == 'O' || a == 'U' || a == 'Y')return true;return false;}//是否为句子的分隔符bool issentance(char a){if(a == '.' || a == '?' || a == ':' || a == ';' || a == '!')return true;return false;}//是否为单词bool isalpha(char a){if(a >= 'a' && a <= 'z')return true;if(a >= 'A' && a <= 'Z')return true;return false;}int main(){char str[1000];while(cin>>str){words++;int wordlen = strlen(str);//如果输入的字符串最后一个为句子的分隔符,句子数加一;if(issentance(str[wordlen-1]))sentences++;//单词长度小于等于3,音节数加一;if((wordlen <= 3) || (wordlen == 4 && !isalpha(str[wordlen-1]))){syllables++;continue;}bool flag_frevowel=false;for(int i = 0; i < wordlen; i++){if(isvoewl(str[i])){if(str[i] == 'e'){if(!isalpha(str[i+1]) && str[i-1] == 'l'){//-le;syllables++;continue;}else if(!isalpha(str[i+1]))//-e;continue;else if((str[i+1] == 'd' || str[i+1] == 's' ) && !isalpha(str[i+2]))//-ed,-es;continue;}if(!flag_frevowel){//当前字母为元音,但前一字符不是元音 flag_frevowel = true; syllables++; continue; } else//当前字母为元音,但前一字母也是元音,即出现连续元音,syllable不计数 continue;}flag_frevowel = false;//当前字母不是元音 }}cout<<fixed<<setprecision(2)<<206.835-1.015*(double)words/(double)sentences-84.6*(double)syllables/(double)words<<endl;return 0;}
- POJ 3371 Flesch Reading Ease
- POJ 3371 Flesch Reading Ease
- POJ 3371 Flesch Reading Ease
- POJ 3371 Flesch Reading Ease
- poj 3371 Flesch Reading Ease
- 【POJ 3371】Flesch Reading Ease
- poj 3371 Flesch Reading Ease
- poj-3371-Flesch Reading Ease
- POJ 3371:Flesch Reading Ease 模拟
- 【POJ 3371】 Flesch Reading Ease(模拟)
- Flesch Reading Ease poj 3371 模拟
- POJ 3371 Flesch Reading Ease 可能会
- POJ 3371 Flesch Reading Ease (模拟题)
- POJ-3371-Flesch Reading Ease一道模拟题
- Flesch Reading Ease--模拟
- poj3371 Flesch Reading Ease
- Flesch Reading Ease
- Flesch Reading Ease 模拟
- 如何安装SQLAlchemy
- 组合数学系列问题
- MySql指令
- linux几种快速清空文件内容的方法
- Android BlueDroid分析: 配置文件(bt_stack.conf bt_vendor.conf )的加载与分析
- poj-3371-Flesch Reading Ease
- 新生命诞生了!
- Spark从s3中读取数据
- Builder模式
- Hdu1455 Sticks
- SSH 免密码登陆
- 如何在网页中禁止使用鼠标右键?如何禁止鼠标点击?
- 数据结构实验之串三:KMP应用
- 线程锁系列(1):CLH Lock