本文整理汇总了Python中sumy.summarizers.edmundson.EdmundsonSummarizer.key_method方法的典型用法代码示例。如果您正苦于以下问题:Python EdmundsonSummarizer.key_method方法的具体用法?Python EdmundsonSummarizer.key_method怎么用?Python EdmundsonSummarizer.key_method使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sumy.summarizers.edmundson.EdmundsonSummarizer
的用法示例。
在下文中一共展示了EdmundsonSummarizer.key_method方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_key_empty
# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import key_method [as 别名]
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)) == []
示例2: test_key_3
# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import key_method [as 别名]
def test_key_3(self):
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)
self.assertEqual(len(sentences), 3)
self.assertEqual(to_unicode(sentences[0]), "wa wa wa")
self.assertEqual(to_unicode(sentences[1]), "wa wa wa wa")
self.assertEqual(to_unicode(sentences[2]), "wa Wa Wa Wa wa")
sentences = summarizer.key_method(document, 3, weight=0)
self.assertEqual(len(sentences), 3)
self.assertEqual(to_unicode(sentences[0]), "wa wa wa wa")
self.assertEqual(to_unicode(sentences[1]), "wa Wa Wa Wa wa")
self.assertEqual(to_unicode(sentences[2]), "x X x X")
示例3: test_key_1
# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import key_method [as 别名]
def test_key_1(self):
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)
self.assertEqual(len(sentences), 1)
self.assertEqual(to_unicode(sentences[0]),
"This is test sentence with some extra words and bonus")
示例4: test_key_3
# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import key_method [as 别名]
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",
]
示例5: test_key_2
# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import key_method [as 别名]
def test_key_2(self):
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)
self.assertEqual(len(sentences), 2)
self.assertEqual(to_unicode(sentences[0]), "Om nom nom nom nom")
self.assertEqual(to_unicode(sentences[1]),
"This is bonus test sentence with some extra words and bonus")
示例6: test_key_1
# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import key_method [as 别名]
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",
]
示例7: test_key_2
# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import key_method [as 别名]
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",
]
示例8: test_key_empty
# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import key_method [as 别名]
def test_key_empty(self):
summarizer = EdmundsonSummarizer()
summarizer.bonus_words = ("ba", "bb", "bc",)
sentences = summarizer.key_method(build_document(), 10)
self.assertEqual(len(sentences), 0)
示例9: test_key_without_bonus_words
# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import key_method [as 别名]
def test_key_without_bonus_words():
summarizer = EdmundsonSummarizer()
with pytest.raises(ValueError):
summarizer.key_method(build_document(), 10)