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


Python Segmenter.concatenate方法代码示例

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


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

示例1: test_concatenate_progress

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import concatenate [as 别名]
    def test_concatenate_progress(self):
        """Does concatenate track progress?"""

        def progress_callback():
            """Mock progress callback"""
            self.count += 1

        Segmenter.concatenate(
            [self.letter_seg1],
            progress_callback=progress_callback,
        )
        self.assertEqual(
            self.count,
            len(self.letter_seg1),
            msg="concatenate doesn't track progress!"
        )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:18,代码来源:test_segmenter.py

示例2: test_concatenate_merge_segments

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import concatenate [as 别名]
 def test_concatenate_merge_segments(self):
     """Does concatenate merge input segments?"""
     segmentation = Segmenter.concatenate(
         [
             self.letter_seg2,
             self.letter_seg1,
         ],
     )
     self.assertEqual(
         [s.get_content() for s in segmentation],
         ['a', 'b', 'c', 'd', 'e'],
         msg="concatenate doesn't merge input segments!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:15,代码来源:test_segmenter.py

示例3: test_concatenate_solve_conflicts_merge_duplicates

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import concatenate [as 别名]
 def test_concatenate_solve_conflicts_merge_duplicates(self):
     """Does concatenate solve conflicts when merging duplicates?"""
     segmentation = Segmenter.concatenate(
         [
             self.letter_seg2,
             self.single_letter_seg,
         ],
         merge_duplicates=True,
     )
     self.assertEqual(
         segmentation[1].annotations['b'],
         '1',
         msg="concatenate doesn't solve conflicts when merging duplicates!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:16,代码来源:test_segmenter.py

示例4: test_concatenate_merge_duplicates

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import concatenate [as 别名]
 def test_concatenate_merge_duplicates(self):
     """Does concatenate merge duplicates?"""
     segmentation = Segmenter.concatenate(
         [
             self.letter_seg2,
             self.single_letter_seg,
         ],
         merge_duplicates=True,
     )
     self.assertEqual(
         [s.get_content() for s in segmentation],
         ['c', 'd', 'e'],
         msg="concatenate doesn't merge duplicates!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:16,代码来源:test_segmenter.py

示例5: test_concatenate_autonumber

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import concatenate [as 别名]
 def test_concatenate_autonumber(self):
     """Does concatenate autonumber input segments?"""
     segmentation = Segmenter.concatenate(
         [
             self.letter_seg2,
             self.letter_seg1,
         ],
         auto_number_as='num',
     )
     self.assertEqual(
         [s.annotations['num'] for s in segmentation],
         list(range(1, 6)),
         msg="concatenate doesn't autonumber input segments!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:16,代码来源:test_segmenter.py

示例6: test_concatenate_copy_annotations_false

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import concatenate [as 别名]
 def test_concatenate_copy_annotations_false(self):
     """Does concatenate skip copying annotations?"""
     segmentation = Segmenter.concatenate(
         [
             self.letter_seg2,
             self.letter_seg1,
         ],
         copy_annotations=False,
     )
     self.assertFalse(
         'b' in segmentation[1].annotations or
         'a' in segmentation[3].annotations,
         msg="concatenate doesn't skip copying annotations!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:16,代码来源:test_segmenter.py

示例7: test_concatenate_copy_annotations

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import concatenate [as 别名]
 def test_concatenate_copy_annotations(self):
     """Does concatenate copy annotations?"""
     segmentation = Segmenter.concatenate(
         [
             self.letter_seg2,
             self.letter_seg1,
         ],
         copy_annotations=True,
     )
     self.assertEqual(
         [
             segmentation[3].annotations['b'],
             segmentation[0].annotations['a'],
         ],
         ['2', '1'],
         msg="concatenate doesn't copy annotations!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:19,代码来源:test_segmenter.py

示例8: sendData

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import concatenate [as 别名]
    def sendData(self):
        """Compute result of widget processing and send to output"""

        # Clear created Inputs
        self.clearCreatedInputs()
        
        if self.service == u'Twitter':
            try:
                self.createdInputs = self.get_tweets(
                    self.word_to_search,
                    self.nb_tweet,
                    self.include_RT,
                    self.useTwitterLicenseKey,
                    (
                        self.twitterLicenseKeysConsumerKey,
                        self.twitterLicenseKeysConsumerSecret,
                        (
                            self.twitterLicenseKeysAccessToken,
                            self.twitterLicenseKeysAccessTokenSecret
                        )
                    )
                )
            except (HTTP401Authentication, HTTP400BadRequest):
                self.infoBox.setText(
                    u'Please enter valid Twitter api keys.',
                    u'error',
                )
                self.send(u'Text data', None, self)
                return False
            except SearchEngineLimitError:
                self.infoBox.setText(
                    u'Twitter search limit has been exceeded.',
                    u'error',
                )
                self.send(u'Text data', None, self)
                return False


        elif self.service == u'Wikipedia':
            self.createdInputs = self.get_wiki_article(
                self.word_to_search,
                self.wiki_section,
                self.wiki_type_of_text
            )

        elif self.service == u'Bing':
            self.createdInputs = self.get_bing_entries(
                self.word_to_search,
                self.nb_bing_entry
            )

        

        if len(self.createdInputs) == 0:
            self.infoBox.setText(
                u'Please try to change query or settings.',
                u'warning',
            )
            self.send(u'Text data', None, self)
            return False

        # Initialize progress bar
        progressBar = OWGUI.ProgressBar(
            self, 
            iterations=50
        )

        output_segmentation = Segmenter.concatenate(
            self.createdInputs, 
            self.captionTitle, 
            import_labels_as=None
        )

        message = u'%i [email protected] sent to output ' % len(output_segmentation)
        message = pluralize(message, len(output_segmentation))
        numChars = 0
        for segment in output_segmentation:
            segmentLength = len(Segmentation.get_data(segment.str_index))
            numChars += segmentLength
        message += u'(%i [email protected]).' % numChars
        message = pluralize(message, numChars)
        self.infoBox.setText(message)

        for _ in xrange(50):
            progressBar.advance()

        # Clear progress bar.
        progressBar.finish()

        self.send('Text data', output_segmentation, self)
    
        self.sendButton.resetSettingsChangedFlag()
开发者ID:axanthos,项目名称:TextablePrototypes,代码行数:94,代码来源:OWWebSearch.py


注:本文中的LTTL.Segmenter.concatenate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。