def test_title_method_without_title(self): 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) self.assertEqual(len(sentences), 3) self.assertEqual(to_unicode(sentences[0]), "This is sentence") self.assertEqual(to_unicode(sentences[1]), "This is another one") self.assertEqual(to_unicode(sentences[2]), "And some next sentence but no heading")
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_title_method_1(self): 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) self.assertEqual(len(sentences), 1) self.assertEqual(to_unicode(sentences[0]), "Here is the winner because contains words like cool and heading")
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_title_method_without_title(self): 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) self.assertEqual(len(sentences), 3) self.assertEqual(to_unicode(sentences[0]), "This is sentence") self.assertEqual(to_unicode(sentences[1]), "This is another one") self.assertEqual(to_unicode(sentences[2]), "And some next sentence but no heading")
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(self): summarizer = EdmundsonSummarizer() summarizer.null_words = ("ba", "bb", "bc",) sentences = summarizer.title_method(build_document(), 10) self.assertEqual(len(sentences), 0)
def test_title_method_without_null_words(): summarizer = EdmundsonSummarizer() with pytest.raises(ValueError): summarizer.title_method(build_document(), 10)
def test_title_method_without_null_words(): summarizer = EdmundsonSummarizer() with pytest.raises(ValueError): summarizer.title_method(build_document(), 10)
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)) == []