当前位置: 首页>>代码示例>>Python>>正文


Python EdmundsonSummarizer.null_words方法代码示例

本文整理汇总了Python中sumy.summarizers.edmundson.EdmundsonSummarizer.null_words方法的典型用法代码示例。如果您正苦于以下问题:Python EdmundsonSummarizer.null_words方法的具体用法?Python EdmundsonSummarizer.null_words怎么用?Python EdmundsonSummarizer.null_words使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sumy.summarizers.edmundson.EdmundsonSummarizer的用法示例。


在下文中一共展示了EdmundsonSummarizer.null_words方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_location_method_2

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [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")
开发者ID:likegitcoding,项目名称:sumy,代码行数:27,代码来源:test_edmundson.py

示例2: test_location_method_2

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [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",
    ]
开发者ID:miso-belica,项目名称:sumy,代码行数:29,代码来源:test_edmundson.py

示例3: test_location_method_with_empty_document

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [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)) == []
开发者ID:miso-belica,项目名称:sumy,代码行数:9,代码来源:test_edmundson.py

示例4: test_null_words_property

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [as 别名]
    def test_null_words_property(self):
        summarizer = EdmundsonSummarizer()

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

        words = ("word", "another", "and", "some", "next",)
        summarizer.null_words = words
        self.assertTrue(isinstance(summarizer.null_words, frozenset))
        self.assertEqual(summarizer.null_words, frozenset(words))
开发者ID:likegitcoding,项目名称:sumy,代码行数:11,代码来源:test_edmundson.py

示例5: test_null_words_property

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [as 别名]
def test_null_words_property():
    summarizer = EdmundsonSummarizer()

    assert summarizer.null_words == frozenset()

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

    assert summarizer.null_words == frozenset(words)
开发者ID:miso-belica,项目名称:sumy,代码行数:11,代码来源:test_edmundson.py

示例6: test_title_method_without_title

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [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

示例7: test_title_method_without_title

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [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

示例8: test_title_method_1

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [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

示例9: test_title_method_3

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [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

示例10: test_location_method_with_empty_document

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [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)
开发者ID:likegitcoding,项目名称:sumy,代码行数:8,代码来源:test_edmundson.py

示例11: test_title_method_with_empty_document

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [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

示例12: test_title_method_with_empty_document

# 需要导入模块: from sumy.summarizers.edmundson import EdmundsonSummarizer [as 别名]
# 或者: from sumy.summarizers.edmundson.EdmundsonSummarizer import null_words [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.null_words方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。