def test_key_empty(): summarizer = EdmundsonSummarizer() summarizer.bonus_words = ("ba", "bb", "bc",) sentences = summarizer.key_method(build_document(), 10) assert list(map(to_unicode, sentences)) == []
def test_key_3(): document = build_document( ("wa", "wa wa", "wa wa wa", "wa wa wa wa", "wa Wa Wa Wa wa",), ("x X x X",) ) summarizer = EdmundsonSummarizer() summarizer.bonus_words = ("wa", "X",) sentences = summarizer.key_method(document, 3) assert list(map(to_unicode, sentences)) == [ "wa wa wa", "wa wa wa wa", "wa Wa Wa Wa wa", ] sentences = summarizer.key_method(document, 3, weight=0) assert list(map(to_unicode, sentences)) == [ "wa wa wa wa", "wa Wa Wa Wa wa", "x X x X", ]
def test_key_1(): document = build_document( ("wa wb wc wd", "I like music",), ("This is test sentence with some extra words and bonus",) ) summarizer = EdmundsonSummarizer() summarizer.bonus_words = ("ba", "bb", "bc", "bonus",) sentences = summarizer.key_method(document, 1) assert list(map(to_unicode, sentences)) == [ "This is test sentence with some extra words and bonus", ]
def test_key_2(): document = build_document( ("Om nom nom nom nom", "Sure I summarize it, with bonus",), ("This is bonus test sentence with some extra words and bonus",) ) summarizer = EdmundsonSummarizer() summarizer.bonus_words = ("nom", "bonus",) sentences = summarizer.key_method(document, 2) assert list(map(to_unicode, sentences)) == [ "Om nom nom nom nom", "This is bonus test sentence with some extra words and bonus", ]
def test_key_without_bonus_words(): summarizer = EdmundsonSummarizer() with pytest.raises(ValueError): summarizer.key_method(build_document(), 10)