コード例 #1
0
ファイル: test_text_stats.py プロジェクト: Joiike/textacy
def test_flesch_reading_ease_lang(ts, lang, fre, context):
    with context:
        result = text_stats.flesch_reading_ease(ts.n_syllables,
                                                ts.n_words,
                                                ts.n_sents,
                                                lang=lang)
        assert result == pytest.approx(fre, rel=1e-2)
コード例 #2
0
def test_flesch_reading_ease_langs(ts):
    lang_fres = [
        (None, 50.707745098039254),
        ("en", 50.707745098039254),
        ("de", 65.28186274509805),
        ("es", 89.30823529411765),
        ("fr", 68.18156862745099),
        ("it", 93.12156862745098),
        ("nl", 64.59823529411764),
        ("ru", 82.79921568627452),
    ]
    for lang, fre in lang_fres:
        assert text_stats.flesch_reading_ease(
            ts.n_syllables, ts.n_words, ts.n_sents, lang=lang
        ) == pytest.approx(fre, rel=1e-2)
コード例 #3
0
def test_flesch_reading_ease_langs(ts):
    lang_fres = [
        (None, 50.707745098039254),
        ('en', 50.707745098039254),
        ('de', 65.28186274509805),
        ('es', 89.30823529411765),
        ('fr', 68.18156862745099),
        ('it', 93.12156862745098),
        ('nl', 64.59823529411764),
        ('ru', 82.79921568627452),
        ]
    for lang, fre in lang_fres:
        assert (
            text_stats.flesch_reading_ease(
                ts.n_syllables, ts.n_words, ts.n_sents, lang=lang) ==
            pytest.approx(fre, rel=1e-2)
            )
コード例 #4
0
def test_flesch_reading_ease_bad_lang(ts):
    with pytest.raises(ValueError):
        _ = text_stats.flesch_reading_ease(1, 1, 1, lang="foo")