Esempio n. 1
0
def test_calculate_frequency():
    test_text = "Some words: word, word"

    word_frequencies = WordFrequency.calculate(test_text)

    assert word_frequencies["some"] == 0.25
    assert word_frequencies["words"] == 0.25
    assert word_frequencies["word"] == 0.5
Esempio n. 2
0
def test_count_words():
    test_text = "This is a wonderful wonderful test text."

    word_counts = WordFrequency.count_words(test_text)

    assert word_counts["this"] == 1
    assert word_counts["is"] == 1
    assert word_counts["a"] == 1
    assert word_counts["wonderful"] == 2
    assert word_counts["test"] == 1
    assert word_counts["text"] == 1