Flesch Reading Ease(模拟题)

来源:互联网 发布:苹果电话屏蔽软件 编辑:程序博客网 时间:2024/06/06 20:34

Flesch Reading Ease

Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2290 Accepted: 720

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

题意:计算出一个标准文章的单词数、句子数、元音数,通过提供的公式进行计算。

题解:1、标准的文章不会有标点的错误。

2、断句的符号有“ . ”、“ : ”、“ ! ”、“ ; ”、“?”五种, 断词的符号有“ , ” 、“ ”两种。

3、元音的又aoeiyu的大小写6种,单词的长度小于等于3记为一个元音,以es,ed,e(除了le)结尾的不为元音,连续的元音只记一次。

#include <stdio.h>#include <string.h>#include <iostream>using namespace std;char str[1000];int word=0;  //单词数  int sentance=0; //句子数  int syllable=0; //音标数  int judge_alpha(char s){    if((s >= 'A' && s <= 'Z') || (s >= 'a' && s <= 'z'))        return 1;    return 0; }int judge_word(char s){    if(s == ',')        return 1;    return 0;}int judge_sentance(char s){    if(s == '.' || s == ':' ||s == ';' || s == '?' || s == '!')        return 1;    return 0;}int judge_syl(char s){    if(s == 'a' || s == 'o' || s == 'e' || s == 'y' || s == 'i' || s == 'u' || s == 'A' || s == 'O' || s == 'E' || s == 'Y' || s == 'I' || s== 'U')        return 1;    return 0;}int main(){    int j, k, i;    int n;    while(scanf("%s", str) != EOF)    {        int new_word = 0;//一个单词的长度        int new_syl = 0;//一个单词中的元音数量        int flag = 0;//判断连续的字母是否是元音        int n = strlen(str);        for(i = 0; i < n; i ++)        {            if(judge_sentance(str[i]))//断句;            {                flag = 0;                new_word = 0;                new_syl = 0;                word++;                sentance++;            }            else if(judge_word(str[i]))//断词            {                flag = 0;                new_word = 0;                new_syl = 0;                word++;            }            else if(judge_alpha(str[i]))            {                new_word++;                if(new_word <= 3)                {                    if(!judge_alpha(str[i+1]))//判断出单词的长度小于等于3,总元音数加一,减去此单词中的元音数                    {                        syllable++;                        syllable -= new_syl;                        new_syl = 0;                        continue;                    }                }                if(judge_syl(str[i]))                {                    if(str[i] == 'e')//e的多种情况                    {                        if(!judge_alpha(str[i+1]) && str[i-1] == 'l')                        {                            syllable++;                            new_syl++;                            continue;                        }                        else if(!judge_alpha(str[i+1]))                        {                            continue;                        }                        else if(!judge_alpha(str[i+2]) && (str[i+1] == 'd' || str[i+1] == 's'))                        {                            continue;                        }                                                }                    if(flag == 0)//如果前一位不是元音,则这一位是元音,总元音数加一                    {                        syllable++;                        new_syl++;                        flag = 1;                         continue;                    }                    else                    {                        continue;                    }                }            }            flag = 0;//标记着此字符只是简单的字母。        }        if(judge_alpha(str[i-1]))            word++;        //printf("%d %d %d\n", word, sentance, syllable);    }    printf("%.2f\n",206.835-1.015*(double)word/(double)sentance-84.6*(double)syllable/(double)word);    return 0;}


0 0
原创粉丝点击