Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_key_no_bonus_words_in_document():
document = build_document(
("wa wb wc wd", "I like music",),
("This is test sentence with some extra words",)
)
summarizer = EdmundsonSummarizer()
summarizer.bonus_words = ("ba", "bb", "bc", "bonus",)
sentences = summarizer.key_method(document, 10)
assert list(map(to_unicode, sentences)) == [
"wa wb wc wd",
"I like music",
"This is test sentence with some extra words",
]
def test_title_method_without_title():
document = build_document(
("This is sentence", "This is another one",),
("And some next sentence but no heading",)
)
summarizer = EdmundsonSummarizer()
summarizer.null_words = ("this", "is", "some", "and",)
sentences = summarizer.title_method(document, 10)
assert list(map(to_unicode, sentences)) == [
"This is sentence",
"This is another one",
"And some next sentence but no heading",
]
def test_location_method_without_null_words():
summarizer = EdmundsonSummarizer()
with pytest.raises(ValueError):
summarizer.location_method(build_document(), 10)
def test_title_method_3():
document = build_document_from_string("""
# This is cool heading
Because I am sentence I like words
And because I am string I like characters
# blank and heading
This is next paragraph because of blank line above
Here is the winner because contains words like cool and heading
""")
summarizer = EdmundsonSummarizer()
summarizer.null_words = ("this", "is", "I", "am", "and",)
sentences = summarizer.title_method(document, 3)
assert list(map(to_unicode, sentences)) == [
"Because I am sentence I like words",
"This is next paragraph because of blank line above",
"Here is the winner because contains words like cool and heading",
]
def test_title_method_with_empty_document():
summarizer = EdmundsonSummarizer()
summarizer.null_words = ("ba", "bb", "bc",)
sentences = summarizer.title_method(build_document(), 10)
assert list(map(to_unicode, sentences)) == []
def test_key_without_bonus_words():
summarizer = EdmundsonSummarizer()
with pytest.raises(ValueError):
summarizer.key_method(build_document(), 10)
def test_title_method_1():
document = build_document_from_string("""
# This is cool heading
Because I am sentence I like words
And because I am string I like characters
# blank and heading
This is next paragraph because of blank line above
Here is the winner because contains words like cool and heading
""")
summarizer = EdmundsonSummarizer()
summarizer.null_words = ("this", "is", "I", "am", "and",)
sentences = summarizer.title_method(document, 1)
assert list(map(to_unicode, sentences)) == [
"Here is the winner because contains words like cool and heading",
]
def test_null_words_property():
summarizer = EdmundsonSummarizer()
assert summarizer.null_words == frozenset()
words = ("word", "another", "and", "some", "next",)
summarizer.null_words = words
assert summarizer.null_words == frozenset(words)
def test_cue_letters_case():
document = build_document(
("X X X", "x x x x",),
("w w w", "W W W W",)
)
summarizer = EdmundsonSummarizer()
summarizer.bonus_words = ("X", "w",)
summarizer.stigma_words = ("stigma",)
sentences = summarizer.cue_method(document, 2)
assert list(map(to_unicode, sentences)) == [
"x x x x",
"W W W W",
]
def test_title_method_without_null_words():
summarizer = EdmundsonSummarizer()
with pytest.raises(ValueError):
summarizer.title_method(build_document(), 10)