【POJ 3371】 Flesch Reading Ease(模拟)
来源:互联网 发布:c语言调用linux命令 编辑:程序博客网 时间:2024/06/16 03:20
【POJ 3371】 Flesch Reading Ease(模拟)
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. InProceedings 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.e、es、ed结尾的,e不计入元音,但le结尾除外
2.连续的元音算作一个
3.如果单词的字母数量小于等于3,不管有没有元音,整个单词算作一个元音
原本用getchar一点点判断来做得,结果不知道哪里出问题了,死活都是WA。
后来改成scanf(%s),把空格忽略掉,判断得到的串末尾标点。然后判断串长,小于等于3直接累计一个元音。否则一个个字母判断,然后照着题来就行,没坑点,getchar写法应该是我手残了,不过确实也不太好写,有兴趣的可以写写看,scanf19ms getchar应该能上0
代码如下:
#include <iostream>#include <cmath>#include <vector>#include <cstdlib>#include <cstdio>#include <cstring>#include <queue>#include <list>#include <algorithm>#include <map>#include <set>#define LL long long#define fread() freopen("in.in","r",stdin)#define fwrite() freopen("out.out","w",stdout)using namespace std;const int INF = 0x3f3f3f3f;const int msz = 10000;const double eps = 1e-8;//判断某字母是元音音节bool issyl(char ch){return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'|| ch == 'y' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O'|| ch == 'U' || ch == 'Y'; }//判断某字符为字母bool isal(char ch){return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z');}int main(){freopen("in.in","r",stdin);char str[111];int len;int sentences,words,syllables;sentences = words = syllables = 0;while(~scanf("%s",str)){len = strlen(str)-1;//去掉后缀的标点while(len >= 0 && !isal(str[len])){//后缀标点不为',' 则为句子分隔符if(str[len] != ',') sentences++;len--;}len++;words++;//单词长度小于等于3if(len > 0 && len <= 3){syllables++;}else if(len > 0){for(int i = 0; i < len; ++i){//字母为元音if(issyl(str[i])){//为连续的元音if(i && issyl(str[i-1])) continue;//为eif(str[i] == 'e' || str[i] == 'E'){//为单词末尾if(i == len-1){//le结尾if(i && (str[i-1] == 'l' || str[i-1] == 'L')) syllables++;}//为es或edelse if(i == len-2 && (str[i+1] == 's' || str[i+1] == 'd' || str[i+1] == 'S' || str[i+1] == 'D')){}else syllables++;}else syllables++;}}}else words--;}printf("%.2f\n",206.835-1.015*(words*1.0/sentences)-84.6*(syllables*1.0/words));return 0;}
- 【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
- 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--模拟
- Flesch Reading Ease 模拟
- Flesch Reading Ease(模拟题)
- POJ 3371 Flesch Reading Ease 可能会
- poj3371--Flesch Reading Ease(模拟)
- Spring+Dubbo+MyBatis+Linner分布式Web开发环境搭建
- 即时通信系统中如何实现:聊天消息加密,让通信更安全? 【低调赠送:QQ高仿版GG 4.5 最新源码】
- XCode7,打包上传的一些警告,及参考处理方法
- 卡特兰数
- 铺地毯题解
- 【POJ 3371】 Flesch Reading Ease(模拟)
- CLO [POI/BZOJ 1116]
- hdu-1198-Farm Irrigation(并查集)
- android高级之图片二次采样
- ☆CAP理论|分布式
- CodeForce 616A Comparing Two Long Integers 字符串比较
- C/C++语言中 “#if 0/#if 1 ... #endif”的作用
- Handler消息处理机制
- MyEclipse快捷键