Flesch Reading Ease -POJ3371模擬

Flesch Reading Easephp

Time Limit: 1000MS Memory Limit: 65536K

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

.這裏寫圖片描述markdown

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

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

  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
    • -es, -ed and -e (except -le) endings are ignored,
    • words of three letters or shorter count as single syllables,
    • consecutive vowels count as one syllable.

Referencespost

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

Output

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

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

Sample Output

26.09spa

Source

POJ Monthly–2007.09.09, frkstyc

題意:標記單詞分隔符: 逗號(,) 和 空格( )句子分隔符:句號(.) 問號(?) 冒號(:) 分號(;) 感嘆號(!).不存在上述標點符號之外的符號!!!全部符號只佔一個字符的位置!!

每出現一個單詞分隔符,單詞數+1
每出現一個句子分隔符,句子數+1
音節數是最難處理的,其規律以下:

(1)當單詞總長度<=3時,音節數無條件+1
(2)當單詞總長度>3時,單詞中每出現一個元音字母(a、e、i、o、u、y),音節數+1,可是連續的元音字母只按1個音節計算,且當單詞後綴爲-es、-ed和-e時,後綴的元音字母e不列爲音節數計算。可是後綴-le例外,要計算音節數。

注意:
(1)元音字母要判斷12個,6個小寫,6個大寫。

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#define RR() freopen("in.txt","r",stdin)

using namespace std;

char str[110];

bool Judgeapl(char s)//判斷是否時字母
{
    if(s>='a'&&s<='z'||s>='A'&&s<='Z')
    {
        return true;
    }
    return false;
}

bool Trans(char s)//判斷是不是元音
{
    if(s>='A'&&s<='Z')
    {
        s=s-'A'+'a';
    }
    if(s=='a'||s=='e'||s=='i'||s=='o'||s=='u'||s=='y')
    {
        return true;
    }
    return false;
}

char low(char s)//大寫轉小寫
{
    if(s>='A'&&s<='Z')
    {
        return s-'A'+'a';
    }
    return s;
}

int Judgesyl(char *s,int len)//判斷元音節
{
    if(len<=3)
    {
        return 1;
    }

    int num  = 0;

    int ans = 0;

    for(int i=0; i<len; i++)
    {
        if(Trans(str[i]))
        {
            ans=0;

            while(Trans(str[i])&&i<len)
            {
                i++;
                ans++;
            }
            i--;
            num++;
        }
    }
    if(low(s[len-1])=='e'&&low(s[len-2])!='l'&&!Trans(s[len-2]))
    {
        num--;
    }
    else if(low(s[len-2]) == 'e' &&(low(s[len-1]=='s'||low(s[len-1])=='d'))&&!Trans(s[len-3]))
    {
        num--;
    }
    return num;
}

int main()
{
    int wnum=0,snum=0,senum=0;
    while(~scanf("%s",str))
    {

        int len=strlen(str);
        wnum++;
        if(!Judgeapl(str[len-1]))
        {
            if(str[len-1]!=',')
                senum++;
            len--;
        }

        snum+=Judgesyl(str,len);

    }
    printf("%.2f\n",206.835-1.015*(wnum*1.0/senum)-84.6*(snum*1.0/wnum));
    return 0;
}
相關文章
相關標籤/搜索