Flesch Reading Ease
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 2071   Accepted: 606

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.

  1. Periods, explanation points, colons and semicolons serve as sentence delimiters.
  2. Each group of continuous non-blank characters with beginning and ending punctuation removed counts as a word.
  3. Each vowel (one of a, e, i, o, u and y) in a word is considered one syllable subject to that
    1. -es, -ed and -e (except -le) endings are ignored,
    2. words of three letters or shorter count as single syllables,
    3. consecutive vowels count as one syllable.

References

  1. 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.
  2. 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

The input contains a passage in English whose Flesch Reading Ease score is to be computed. Only letters of the English alphabet (both lowercase and uppercase), common punctuation marks (periods, question and exclamation marks, colons, semicolons as well as
commas, quotation marks, hyphens and apostrophes), and spaces appear in the passage. The passage is of indefinite length and possibly occupies multiple lines. Additionally, it is guaranteed to be correct in punctuation. 

Output

Output the Flesch Reading Ease score of the given passage rounded to two digits beyond decimal point. 

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

给出了一段话,求这段话里面单词的个数,句子的个数,音节的个数,然后带入到上面的公式中输出结果。

单词的个数很好查,scanf("%s")输入一个就是一个单词。

一个句子的标志是句号“.”、问号“?”、冒号“:”、分号“;”、感叹号“!”。出现了这些符号就sen++。

比较麻烦的在于音节的计算。

首先,如果一个单词的长度小于等于3,那么这个单词固定就是贡献了一个音节的数量。

如果长度大于3,那么单词中出现一个“a”“e”“i”“o”“u”“y”“A”“E”“I”“O”“U”“Y”,音节数就+1。但是连续出现的元音字母就只算一次,注意是连续出现,连续出现2次算一个,连续出现3次也只算一个。

如果一个单词的末尾是es、ed、e(除了le),那么忽略这些字符。

所以。。。这种模拟题觉得也就做一做吧,感觉其实没什么价值。。。

代码:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std; char test[1005];
double wor, sen, syl;//61 2 108 bool check2(char x)
{
if (x == 'a' || x == 'e' || x == 'o' || x == 'u' || x == 'y' || x == 'i' || x == 'A' || x == 'E' || x == 'I' || x == 'O' || x == 'U' || x == 'Y')
{
return true;
}
else
{
return false;
}
} int check(char *x)
{
int len = strlen(x);
int i, res;
while (!((x[len - 1] >= 'a'&&x[len - 1] <= 'z') || (x[len - 1] >= 'A'&&x[len - 1] <= 'Z')))
{
len--;
} res = 0;
if (len <= 3)
{
return 1;
}
if (x[len - 2] == 'e'&&x[len - 1] == 's')
{
len = len - 2;
}
else if (x[len - 2] == 'e'&&x[len - 1] == 'd')
{
len = len - 2;
}
else if (x[len - 1] == 'e')
{
if (x[len - 2] != 'l')
{
len = len - 1;
}
}
if (check2(x[0]))
{
res++;
}
for (i = 1; i < len; i++)
{
if (check2(x[i]) && !check2(x[i - 1]))
{
res++;
}
}
return res;
} int main()
{
//freopen("i.txt","r",stdin);
//freopen("o.txt","w",stdout); wor = 0;
sen = 0;
syl = 0; int len;
char temp;
double res;
while (scanf("%s", test) != EOF)
{
wor++;
len = strlen(test); temp = test[len - 1];
if (temp == '.' || temp == '?' || temp == ':' || temp == ';' || temp == '!')
{
sen++;
}
syl += check(test);
} res = 206.835 - 1.015*(wor / sen) - 84.6*(syl / wor);
printf("%.2f\n", res); return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

最新文章

  1. python requests的安装与简单运用
  2. 【iCore3 双核心板】例程二:读取arm按键状态
  3. 使用servers 启动项目时 ,一直处于启动中, 最后出现无法的问题。
  4. SharePoint 2013 开发——APP开发的考虑和建议
  5. selectors实现高并发
  6. BZOJ 1015: [JSOI2008]星球大战starwar 并查集
  7. 第一部分实现功能:使用一个TabControl和一个Memo和TDictionary类实现文本临时存储
  8. JS模块加载器加载原理是怎么样的?
  9. 什么是Web Service?
  10. iOS——文件操作NSFileManager (创建、删除,复制,粘贴)
  11. .Net C# ASP.Net和ADO.Net
  12. 网页 JavaScript
  13. 移动端表层div滑动,导致底层body滑动(touchmove的阻止)
  14. 关于session共享的解决方法
  15. /bin/bash^M: bad interpreter: No such file or directory 解决办法
  16. C调用lua的table里面的函数
  17. 通达OA 自定义菜单
  18. thick置备和 thin置备,克隆,模板和快照
  19. 常用的 Linux iptables 规则
  20. 03-老马jQuery教程-DOM操作

热门文章

  1. jquery-ajax的用法
  2. login() got an unexpected keyword argument &#39;extra_context&#39;
  3. HTML常用标签效果展示
  4. scrapy extention实战-空闲时关闭爬虫
  5. Hibernate笔记二
  6. 简单描述MySQL常用引擎的特点及MySQL的逻辑架构
  7. FormsAuthentication.HashPasswordForStoringInConfigFile方法再.net core中的替代代码
  8. android传递数据bundle封装传递map对象
  9. 「SP10628 COT - Count on a tree」
  10. 使用注解的形式搭建一个springMVC框架