poj3371--Flesch Reading Ease(模拟)

来源:互联网 发布:淘宝属于跨境电商吗 编辑:程序博客网 时间:2024/06/05 07:54
Flesch Reading Ease
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1882 Accepted: 553

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. InProceedings 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、单词长度小于等于3是,音节为1

2、大于3是,每个原音字母a,e,i,o,u,y,区分大小写,每个都是一个音节,如果结尾以-e(-le不算),-es,-ed结尾e不被记为一个音节。

 

#include <cstdio>#include <cstring>#include <algorithm>using namespace std ;char str[1000] ;int a , b , c ;//a单词数,b句子数,c音节数int find1(char ch){    if( ch == ',' || ch == ' ' )        return 1 ;    if( ch == '.' || ch == '?' || ch == ':' || ch == ';' || ch == '!' )        return 2 ;    if( ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y' )        return 3 ;    if( ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' || ch == 'Y' )        return 3 ;    return 0 ;}void solve(int i,int num,int c_num){    if( num <= 3 )    {        c++ ;        return ;    }    if( str[i] == 'e' )    {        if( str[i-1] == 'l' || find1(str[i-1]) == 3 )            c += c_num ;        else            c += (c_num-1) ;    }    else if( (str[i-1] == 'e' && str[i] == 's') || (str[i-1] == 'e' && str[i] == 'd') )    {        if( find1(str[i-2]) == 3 )            c += c_num ;        else            c += (c_num-1) ;    }    else        c += c_num ;    return ;}int main(){    int i , l , num , c_num , flag , k ;    a = b = c = 0 ;    while( scanf("%s", str) != EOF )    {        l = strlen(str) ;        flag = num = c_num = 0 ;//flag当前字符的前一个字符是不是原音,num当前单词的字母数,c_num单词原音数        for(i = 0 ; i < l ; i++)        {            k = find1(str[i]) ;            if( k == 0 )            {                num++ ;                flag = 0 ;            }            else if( k == 1 )            {                a++ ;                solve(i-1,num,c_num) ;                flag = num = c_num = 0 ;            }            else if( k == 2 )            {                a++ ;                b++ ;                solve(i-1,num,c_num) ;                flag = num = c_num = 0 ;            }            else if( k == 3 )            {                num++ ;                if( flag == 0 )                {                    c_num++ ;                    flag = 1 ;                }            }        }        k = find1(str[l-1]) ;        if( k == 0 || k == 3 )        {            a++ ;            solve(l-1,num,c_num) ;        }    }    printf("%.2lf\n", 206.835 - 1.015*(a*1.0)/(b*1.0) - 84.6*(c*1.0)/(a*1.0) );    return 0;}

0 0
原创粉丝点击