Skip to content

Commit

Permalink
merge and rename files
Browse files Browse the repository at this point in the history
  • Loading branch information
shuntaroy committed Mar 12, 2023
1 parent 510b708 commit b5c8e09
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 161 deletions.
152 changes: 0 additions & 152 deletions analyse_parseddoc.py

This file was deleted.

File renamed without changes.
18 changes: 9 additions & 9 deletions test_measure_lang.py → test_limco.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pandas as pd
import pytest

import measure_lang as ml
import limco

TEXT = """ここは駅から程よい距離にある日本の住宅街である。
「びっくり!」
Expand All @@ -11,27 +11,27 @@
しかも、街の北にある中学校でさえも2クラスになろうとしている。『結構小さい街なんだね。』
だが、いつもこの街にあるスーパーで毎年行われる納涼祭はとても盛り上がり、この街だけではおさまらず、他のところから来ている人も多数いる。
"""
DOC = ml.NLP(ml.normalise(TEXT))
DOC = limco.NLP(limco.normalise(TEXT))


def test_count_charcat():
text = "あれとコレと竜巻."
assert ml.count_charcat(text) == {"hiragana": 4, "katakana": 2, "kanji": 2}
assert limco.count_charcat(text) == {"hiragana": 4, "katakana": 2, "kanji": 2}


def test_count_conversations():
assert ml.count_conversations(TEXT) == {"single": 1, "double": 1}
assert limco.count_conversations(TEXT) == {"single": 1, "double": 1}


def test_describe_sentence_lengths():
assert list(ml.describe_sentence_lengths(DOC).values()) == pytest.approx(
assert list(limco.describe_sentence_lengths(DOC).values()) == pytest.approx(
[31.857143, 21.341888, 7.0, 18.5, 28.0, 42.0, 67.0]
)


def test_calc_ttrs():
# FIXME: 数式との一致を確認する
assert ml.calc_ttrs(
assert limco.calc_ttrs(
["今日", "明日", "月曜日", "明るい", "明るい", "今日"]
).values() == pytest.approx(
[
Expand All @@ -57,7 +57,7 @@ def test_score_abstractness():
"納涼祭": 1.0,
}
assert list(
ml.score_abstractness(list(awd.keys()) + ["明日", "今日"], awd).values()
limco.score_abstractness(list(awd.keys()) + ["明日", "今日"], awd).values()
) == pytest.approx([2.64, 5.0])


Expand All @@ -70,11 +70,11 @@ def test_score_jiwc():
],
columns=["word", "Sad", "Anx", "Anger", "hate", "Trustful", "S", "Happy"],
).set_index("word")
res = list(ml.score_jiwc(["明日", "感謝", "大きい"], df_jiwc).values())
res = list(limco.score_jiwc(["明日", "感謝", "大きい"], df_jiwc).values())
assert res == pytest.approx(
[0.04784689, 0.0, 0.0, 0.09569377, 0.526316, 0.0, 0.3301435]
)


def test_count_taigendome():
assert ml.count_taigendome(DOC) == 1
assert limco.count_taigendome(DOC) == 1

0 comments on commit b5c8e09

Please sign in to comment.