本文整理匯總了Python中sumy.summarizers.edmundson.EdmundsonSummarizer.location_method方法的典型用法代碼示例。如果您正苦於以下問題:Python EdmundsonSummarizer.location_method方法的具體用法?Python EdmundsonSummarizer.location_method怎麽用?Python EdmundsonSummarizer.location_method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sumy.summarizers.edmundson.EdmundsonSummarizer
的用法示例。
在下文中一共展示了EdmundsonSummarizer.location_method方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_location_method_2
# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import location_method [as 別名]
def test_location_method_2(self):
document = build_document_from_string("""
# na nb nc ha hb
ha = 1 + 1 + 0 = 2
middle = 0
ha hb = 2 + 1 + 0 = 3
first = 1
ha hb ha = 3
last = 1
# hc hd
hb hc hd = 3 + 1 + 0 = 4
ha hb = 2 + 1 + 0 = 3
""")
summarizer = EdmundsonSummarizer()
summarizer.null_words = ("na", "nb", "nc", "nd", "ne",)
sentences = summarizer.location_method(document, 4, w_p1=0, w_p2=0)
self.assertEqual(len(sentences), 4)
self.assertEqual(to_unicode(sentences[0]), "ha hb = 2 + 1 + 0 = 3")
self.assertEqual(to_unicode(sentences[1]), "ha hb ha = 3")
self.assertEqual(to_unicode(sentences[2]), "hb hc hd = 3 + 1 + 0 = 4")
self.assertEqual(to_unicode(sentences[3]), "ha hb = 2 + 1 + 0 = 3")
示例2: test_location_method_2
# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import location_method [as 別名]
def test_location_method_2():
document = build_document_from_string("""
# na nb nc ha hb
ha = 1 + 1 + 0 = 2
middle = 0
ha hb = 2 + 1 + 0 = 3
first = 1
ha hb ha = 3
last = 1
# hc hd
hb hc hd = 3 + 1 + 0 = 4
ha hb = 2 + 1 + 0 = 3
""")
summarizer = EdmundsonSummarizer()
summarizer.null_words = ("na", "nb", "nc", "nd", "ne",)
sentences = summarizer.location_method(document, 4, w_p1=0, w_p2=0)
assert list(map(to_unicode, sentences)) == [
"ha hb = 2 + 1 + 0 = 3",
"ha hb ha = 3",
"hb hc hd = 3 + 1 + 0 = 4",
"ha hb = 2 + 1 + 0 = 3",
]
示例3: test_location_method_with_empty_document
# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import location_method [as 別名]
def test_location_method_with_empty_document():
summarizer = EdmundsonSummarizer()
summarizer.null_words = ("na", "nb", "nc",)
sentences = summarizer.location_method(build_document(), 10)
assert list(map(to_unicode, sentences)) == []
示例4: test_location_method_with_empty_document
# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import location_method [as 別名]
def test_location_method_with_empty_document(self):
summarizer = EdmundsonSummarizer()
summarizer.null_words = ("na", "nb", "nc",)
sentences = summarizer.location_method(build_document(), 10)
self.assertEqual(len(sentences), 0)
示例5: test_location_method_without_null_words
# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import location_method [as 別名]
def test_location_method_without_null_words():
summarizer = EdmundsonSummarizer()
with pytest.raises(ValueError):
summarizer.location_method(build_document(), 10)