poj 3371 Flesch Reading Ease

来源:互联网 发布:校园网络的设计思路 编辑:程序博客网 时间:2024/05/22 13:40

Flesch Reading Ease
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2214 Accepted: 689

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 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

POJ Monthly--2007.09.09, frkstyc

提示

题意:
句号,问号,冒号,分号和感叹号作为句子分割符,每有一个句子分割符句子数加1。空格,逗号和句子分割符作为单词分割符,每有一个单词分隔符单词数加1。音节数遵循以下规则:
单词长度小于等于3时:
1.音节数加1.
单词长度大于3时:
1.有a,e,i,o,u,y元音字母音节数加1,如果连续出现只算第一次出现的。
2.-es,-ed,-e(-le除外)结尾的,e不算在内。
文章包括大小写,且保证合法,利用公式求出该文章的易读性指数。
思路:
模拟题,注意几个细节。
测试数据:

se'a.
36.62

A. Ole drei end dead fucked. AES. DES. Maerlyn's. Gute. TTOLE.
105.26

示例程序

Source CodeProblem: 3371Code Length: 2250BMemory: 348KTime: 0MSLanguage: GCCResult: Accepted#include <stdio.h>#include <string.h>int symbol(char c){    if(c==' '||c==','||c==':'||c=='.'||c==';'||c=='!'||c=='?'||c=='\0')//分隔符判定('\0'也算)    {        return 1;    }    else    {        return 0;    }}int main(){    int i,len,flag,m;    double sentance=0,word=0,syllable=0;    char ch[1001];    while(gets(ch)!=NULL)//EOF做结束(gets用NULL)    {        len=0;//单词长度        flag=0;//是否是连续元音字母        m=0;//单词中音节数        for(i=0;ch[i]!='\0';i++)        {            if(symbol(ch[i])==1)//分隔符判定            {                if(len==0)//多个空格的情况                {                    continue;                }                word++;//单词数+1                if(ch[i]!=' '&&ch[i]!=',')//句子分隔符判定                {                    sentance++;//句子数+1                }                if(len<=3)//单词长度小于等于3                {                    syllable++;                }                else                {                    syllable=syllable+m;                }                len=0;                flag=0;                m=0;            }            else            {                if(ch[i]<='Z'&&ch[i]>='A')//大写转化小写                {                    ch[i]=ch[i]+32;                }                len++;                if(ch[i]=='a'||ch[i]=='e'||ch[i]=='i'||ch[i]=='o'||ch[i]=='u'||ch[i]=='y')                {                    if(flag==1)//连续元音字符的情况                    {                        continue;                    }                    if(ch[i]=='e')                    {                        if(symbol(ch[i+1])==1&&ch[i-1]!='l')//-e且非-le的情况                        {                            continue;                        }                        else if((ch[i+1]=='s'||ch[i+1]=='d')&&symbol(ch[i+2])==1)//-ed,-es的情况                        {                            continue;                        }                    }                    m++;//单词中音节数+1                    flag=1;//连续元音字符记录                }                else                {                    flag=0;//取消连续元音字符记录                }            }        }        if(len!=0)//该行结尾没有分割符,还有最后一个单词没有统计(可以利用'\0'来代替)        {            word++;            if(len<=3)            {                syllable++;            }            else            {                syllable=syllable+m;            }        }    }    printf("%.2f",206.835-1.015*(word/sentance)-84.6*(syllable/word));    return 0;}
0 0
原创粉丝点击