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


Python EdmundsonSummarizer.bonus_words方法代碼示例

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


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

示例1: test_cue_3

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import bonus_words [as 別名]
    def test_cue_3(self):
        document = build_document(
            (
                "ba "*10,
                "bb "*10,
                " sa"*8 + " bb"*10,
                "bb bc ba",
            ),
            (),
            (
                "babbbc "*10,
                "na nb nc nd sa" + " bc"*10,
                " ba n"*10,
            )
        )

        summarizer = EdmundsonSummarizer()
        summarizer.bonus_words = ("ba", "bb", "bc",)
        summarizer.stigma_words = ("sa", "sb", "sc",)

        sentences = summarizer.cue_method(document, 5)
        self.assertEqual(len(sentences), 5)
        self.assertEqual(to_unicode(sentences[0]), ("ba "*10).strip())
        self.assertEqual(to_unicode(sentences[1]), ("bb "*10).strip())
        self.assertEqual(to_unicode(sentences[2]), "bb bc ba")
        self.assertEqual(to_unicode(sentences[3]),
            "na nb nc nd sa bc bc bc bc bc bc bc bc bc bc")
        self.assertEqual(to_unicode(sentences[4]), ("ba n "*10).strip())
開發者ID:likegitcoding,項目名稱:sumy,代碼行數:30,代碼來源:test_edmundson.py

示例2: test_key_empty

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

示例3: test_cue_3

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import bonus_words [as 別名]
def test_cue_3():
    document = build_document(
        (
            "ba "*10,
            "bb "*10,
            " sa"*8 + " bb"*10,
            "bb bc ba",
        ),
        (),
        (
            "babbbc "*10,
            "na nb nc nd sa" + " bc"*10,
            " ba n"*10,
        )
    )
    summarizer = EdmundsonSummarizer()
    summarizer.bonus_words = ("ba", "bb", "bc",)
    summarizer.stigma_words = ("sa", "sb", "sc",)

    sentences = summarizer.cue_method(document, 5)

    assert list(map(to_unicode, sentences)) == [
        ("ba "*10).strip(),
        ("bb "*10).strip(),
        "bb bc ba",
        "na nb nc nd sa bc bc bc bc bc bc bc bc bc bc",
        ("ba n "*10).strip(),
    ]
開發者ID:miso-belica,項目名稱:sumy,代碼行數:30,代碼來源:test_edmundson.py

示例4: test_cue_empty

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import bonus_words [as 別名]
    def test_cue_empty(self):
        summarizer = EdmundsonSummarizer()
        summarizer.bonus_words = ("ba", "bb", "bc",)
        summarizer.stigma_words = ("sa", "sb", "sc",)

        sentences = summarizer.cue_method(build_document(), 10)
        self.assertEqual(len(sentences), 0)
開發者ID:likegitcoding,項目名稱:sumy,代碼行數:9,代碼來源:test_edmundson.py

示例5: test_bonus_words_property

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

    assert summarizer.bonus_words == frozenset()

    words = ("word", "another", "and", "some", "next",)
    summarizer.bonus_words = words

    assert summarizer.bonus_words == frozenset(words)
開發者ID:miso-belica,項目名稱:sumy,代碼行數:11,代碼來源:test_edmundson.py

示例6: test_bonus_words_property

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

        self.assertEqual(summarizer.bonus_words, frozenset())

        words = ("word", "another", "and", "some", "next",)
        summarizer.bonus_words = words
        self.assertTrue(isinstance(summarizer.bonus_words, frozenset))
        self.assertEqual(summarizer.bonus_words, frozenset(words))
開發者ID:likegitcoding,項目名稱:sumy,代碼行數:11,代碼來源:test_edmundson.py

示例7: test_cue_1

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import bonus_words [as 別名]
    def test_cue_1(self):
        document = build_document(
            ("ba bb bc bb unknown ľščťžýáíé sb sc sb",)
        )

        summarizer = EdmundsonSummarizer()
        summarizer.bonus_words = ("ba", "bb", "bc",)
        summarizer.stigma_words = ("sa", "sb", "sc",)

        sentences = summarizer.cue_method(document, 10)
        self.assertEqual(len(sentences), 1)
開發者ID:likegitcoding,項目名稱:sumy,代碼行數:13,代碼來源:test_edmundson.py

示例8: test_key_1

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

示例9: test_key_2

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

示例10: test_key_1

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

示例11: test_key_2

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

示例12: test_cue_letters_case

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import bonus_words [as 別名]
    def test_cue_letters_case(self):
        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)
        self.assertEqual(len(sentences), 2)
        self.assertEqual(to_unicode(sentences[0]), "x x x x")
        self.assertEqual(to_unicode(sentences[1]), "W W W W")
開發者ID:likegitcoding,項目名稱:sumy,代碼行數:16,代碼來源:test_edmundson.py

示例13: test_cue_letters_case

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

示例14: test_key_3

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

示例15: test_mixed_cue_key

# 需要導入模塊: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 別名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import bonus_words [as 別名]
def test_mixed_cue_key():
    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(cue_weight=1, key_weight=1, title_weight=0, location_weight=0)
    summarizer.bonus_words = ("cool", "heading", "sentence", "words", "like", "because")
    summarizer.stigma_words = ("this", "is", "I", "am", "and",)

    sentences = summarizer(document, 2)

    assert list(map(to_unicode, sentences)) == [
        "Because I am sentence I like words",
        "Here is the winner because contains words like cool and heading",
    ]
開發者ID:miso-belica,項目名稱:sumy,代碼行數:22,代碼來源:test_edmundson.py


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