當前位置: 首頁>>代碼示例>>Python>>正文


Python EdmundsonSummarizer.title_method方法代碼示例

本文整理匯總了Python中sumy.summarizers.edmundson.EdmundsonSummarizer.title_method方法的典型用法代碼示例。如果您正苦於以下問題:Python EdmundsonSummarizer.title_method方法的具體用法?Python EdmundsonSummarizer.title_method怎麽用?Python EdmundsonSummarizer.title_method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sumy.summarizers.edmundson.EdmundsonSummarizer的用法示例。


在下文中一共展示了EdmundsonSummarizer.title_method方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_title_method_without_title

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import title_method [as 別名]
    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")
開發者ID:likegitcoding,項目名稱:sumy,代碼行數:16,代碼來源:test_edmundson.py

示例2: test_title_method_without_title

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import title_method [as 別名]
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",
    ]
開發者ID:miso-belica,項目名稱:sumy,代碼行數:17,代碼來源:test_edmundson.py

示例3: test_title_method_1

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import title_method [as 別名]
    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")
開發者ID:likegitcoding,項目名稱:sumy,代碼行數:20,代碼來源:test_edmundson.py

示例4: test_title_method_3

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import title_method [as 別名]
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",
    ]
開發者ID:miso-belica,項目名稱:sumy,代碼行數:23,代碼來源:test_edmundson.py

示例5: test_title_method_with_empty_document

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import title_method [as 別名]
    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)
開發者ID:likegitcoding,項目名稱:sumy,代碼行數:8,代碼來源:test_edmundson.py

示例6: test_title_method_without_null_words

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import title_method [as 別名]
def test_title_method_without_null_words():
    summarizer = EdmundsonSummarizer()

    with pytest.raises(ValueError):
        summarizer.title_method(build_document(), 10)
開發者ID:miso-belica,項目名稱:sumy,代碼行數:7,代碼來源:test_edmundson.py

示例7: test_title_method_with_empty_document

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import title_method [as 別名]
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)) == []
開發者ID:miso-belica,項目名稱:sumy,代碼行數:8,代碼來源:test_edmundson.py


注:本文中的sumy.summarizers.edmundson.EdmundsonSummarizer.title_method方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。