Flesch Reading Ease
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 2269   Accepted: 710

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

Source

大致题意:
给出一篇规范的文章,求其 句子数、单词数 和 音节数把这3个值代入题目给出的公式,输出其结果,保留2位小数。
  标记单词分隔符: 逗号(,) 和 空格( )
  句子分隔符:句号(.) 问号(?) 冒号(:) 分号(;) 感叹号(!)
  音节处理要求:
  (1)当单词总长度<=3时,音节数无条件+1
  (2)
当单词总长度>3时,单词中每出现一个元音字母(a、e、i、o、u、y),音节数+1,但是连续的(>=2)元音字母只按1个音节计算,且当单词后缀为-es、-ed和-e时,后缀的元  音字母e不列为音节数计算。但是后缀-le例外,要计算音节数。

解题思路:

注意:
由于用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)输入的文章每个字符只能扫描一次,若重复扫描会超时。

(3)G++用%.2f

; C++用%.2lf

AC代码+详细注释:

#include<cstdio>
#include<iostream>
using namespace std;
char msg[];
int word=;//单词数
int sentance=;//句子数
int syllable=;//音标数
bool isalpha(char ch){//检查字符ch是否为字母
if(ch>='A'&&ch<='Z') return ;
if(ch>='a'&&ch<='z') return ;
return ;
}
bool isvowel(char ch){//检查字符ch是否为元音字母
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='y') return ;
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'||ch=='Y') return ;
return ;
}
bool isword(char ch){//检查字符ch是否为单词分隔符
if(ch==',')
return ;
return ;
}
bool issentance(char ch){//检查字符ch是否为句子分隔符
if(ch=='.'||ch=='?' ||ch==':'||ch==';'||ch=='!') return ;
return ;
}
int main(){
while(cin>>msg){//以空格为标记,截取文章片段
int wordlen=;
bool flag_frevowel=;//当当前字符为元音时,检查前一字符是否为元音的标记
int syl=;//假设当前单词长度>3时,记录音节数的变化量。若单词实际长度<=3,则syllable-syl
int i;
for(i=;msg[i];i++){
if(isalpha(msg[i])){//当前字符为 字母
wordlen++;//当前所处理的单词的已知长度 (已知长度<=实际长度)
if(wordlen<=){//当 已知长度<=3 时
if(!isalpha(msg[i+])){//检查单词实际长度是否<=3
syllable++;//当实际长度<=3时,syllable无条件+1
syllable-=syl;//实际音节数调整,单词实际长度<=3,则syllable减去 "假设单词长度>3时" 音节数的变化量syl
syl=;
continue;
}
}
if(isvowel(msg[i])){//当前字母为 元音字母
if(msg[i]=='e'){
if(!isalpha(msg[i+])&&msg[i-]=='l'){//-le
syllable++;
syl++;//由于不知道单词的实际长度,因此总音节数syllable与音节数变化量syl同时递增
continue;
}
else if(!isalpha(msg[i+])) continue;// -e
else if((msg[i+]=='d'||msg[i+]=='s')&&!isalpha(msg[i+])) continue;// -ed -es
}
/*处理连续或单个元音*/
if(!flag_frevowel){//当前字母为元音,但前一字符不是元音
flag_frevowel=;
syllable++;
syl++;
continue;
}
else continue;//当前字母为元音,但前一字母也是元音,即出现连续元音,syllable不计数
}
flag_frevowel=;//当前字母不是元音
}
else if(isword(msg[i])){//当前字符为 单词分隔符
flag_frevowel=;
wordlen=;//当前单词操作已结束,长度清零,计算下一单词
syl=;
word++;
}
else if(issentance(msg[i])){//当前字符为 句子分隔符
flag_frevowel=;
wordlen=;//当前单词操作已结束,长度清零,计算下一单词
word++;
syl=;
sentance++;
}
}
if(isalpha(msg[i-])) word++;//当前文章片段最后一个字符为 字母
}
printf("%.2lf",206.835-1.015*(double)word/(double)sentance-84.6*(double)syllable/(double)word);
return ;
}

poj3371的更多相关文章

  1. Flesch Reading Ease -POJ3371模拟

    Flesch Reading Ease Time Limit: 1000MS Memory Limit: 65536K Description Flesch Reading Ease, a reada ...

  2. poj分类 很好很有层次感。

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  3. 【转】POJ题目分类推荐 (很好很有层次感)

    OJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094)初期: 一. ...

  4. 【转】ACM训练计划

    [转] POJ推荐50题以及ACM训练方案 -- : 转载自 wade_wang 最终编辑 000lzl POJ 推荐50题 第一类 动态规划(至少6题, 和 必做) 和 (可贪心) (稍难) 第二类 ...

  5. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  6. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  7. acm常见算法及例题

    转自:http://blog.csdn.net/hengjie2009/article/details/7540135 acm常见算法及例题  初期:一.基本算法:     (1)枚举. (poj17 ...

  8. poj分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  9. 转载 ACM训练计划

    leetcode代码 利用堆栈:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/http://oj.leetcode. ...

随机推荐

  1. SAP RFC通信模式

    在网络技术中,数据通信可以大致划分为两种基本模式:同步通信和异步通信. 其本义是:异步通信时,通信双方时钟允许存在一定误差:同步通信时,双方时钟的允许误差较小.在SAP的系统间的通信过程中,也借用术语 ...

  2. .NET破解之百分百营销软件系列

    今天在52中看到了一个邮件批量发送工具,感觉不怎么好用,百度一下,找到了百分百系统,虽然也不怎么好用,但还是忍不住P它. 官网:http://www.100qunfa.com/ 百分百不加群提取群成员 ...

  3. Atitit.木马病毒的免杀原理---sikuli 的使用

    Atitit.木马病毒的免杀原理---sikuli 的使用 1. 使用sikuli java api1 1.1. 3. Write code!1 2. 常用api2 2.1. wait 等待某个界面出 ...

  4. 公司outing选项

    Sign up:  2014 Summer Outing   请您从以下三个方案中选择您最感兴趣的一个项目, 如果您不能参加此次summer outing, 请选择"遗憾放弃"- ...

  5. 转:NLog 自定义日志内容,写日志到数据库;修改Nlog.config不起作用的原因

    转:http://www.cnblogs.com/tider1999/p/4308440.html NLog的安装请百度,我安装的是3.2.NLog可以向文件,数据库,邮件等写日志,想了解请百度,这里 ...

  6. MySQL全文索引应用简明教程

    本文从以下几个方面介绍下MySQL全文索引的基础知识: MySQL全文索引的几个注意事项 全文索引的语法 几种搜索类型的简介 几种搜索类型的实例 全文索引的几个注意事项 搜索必须在类型为fulltex ...

  7. 安卓第九天笔记-Activity

    安卓第九天笔记-Activity 1.创建Activity 一个界面对应一个activity 创建一个Activity  1.写一个JAVA类,继承Activity publicclass CalcA ...

  8. Spring(一)简述

    一.Spring简述 一段费话 Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,由Rod Johnson 在其著作Expert One-On-One J2 ...

  9. Git学习 --> 个人常用命令add,commit以及push

    Git命令行配置1 安装Github2 安装msysgit3 要配置用户名和油箱  git config --global user.name <用户名> 我的命令就是:git confi ...

  10. js检测浏览器型号

    公司要求做内部统计,要求监控客服玩游戏使用的浏览器的型号,是火狐的.谷歌的.还是IE的等等. [code lang="javascript"] /**** * 目前识别范围 * M ...