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


Python Segmenter.import_xml方法代码示例

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


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

示例1: test_import_xml_exception_missing_opening

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_exception_missing_opening(self):
     """Does import_xml detect missing opening tag?"""
     with self.assertRaises(
         ValueError,
         msg="import_xml doesn't detect missing opening tag!"
     ):
         Segmenter.import_xml(
             self.wrong_xml_seg2,
             element='a',
         )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:12,代码来源:test_segmenter.py

示例2: test_import_xml_progress

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

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

        Segmenter.import_xml(
            self.broken_xml_seg,
            element='a',
            progress_callback=progress_callback,
        )
        self.assertEqual(
            self.count,
            len(self.broken_xml_seg),
            msg="import_xml doesn't track progress!"
        )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:19,代码来源:test_segmenter.py

示例3: test_import_xml_import_annotations_false

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_import_annotations_false(self):
     """Does import_xml skip importing annotations?"""
     segmentation = Segmenter.import_xml(
         self.broken_xml_seg,
         element='a',
         import_annotations=False,
     )
     self.assertFalse(
         'a' in segmentation[0].annotations,
         msg="import_xml doesn't skip importing annotations!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:13,代码来源:test_segmenter.py

示例4: test_import_xml_convert_attributes

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_convert_attributes(self):
     """Does import_xml convert attributes?"""
     segmentation = Segmenter.import_xml(
         self.xml_seg,
         element='a',
     )
     self.assertEqual(
         [s.annotations['attr'] for s in segmentation],
         ['1', '2'],
         msg="import_xml doesn't convert attributes!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:13,代码来源:test_segmenter.py

示例5: test_import_xml_segment_elements_broken

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_segment_elements_broken(self):
     """Does import_xml segment xml elements from distinct strings?"""
     segmentation = Segmenter.import_xml(
         self.broken_xml_seg,
         element='a',
     )
     self.assertEqual(
         [s.get_content() for s in segmentation],
         ['1<a>2<a>3</a>4', '2<a>3</a>4', '3', '</a>5'],
         msg="import_xml doesn't segment elements from distinct strings!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:13,代码来源:test_segmenter.py

示例6: test_import_xml_segment_elements

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_segment_elements(self):
     """Does import_xml segment xml elements?"""
     segmentation = Segmenter.import_xml(
         self.xml_seg,
         element='a',
     )
     self.assertEqual(
         [s.get_content() for s in segmentation],
         ['<a attr="2">c<a/>d</a>', 'c<a/>d'],
         msg="import_xml doesn't segment xml elements!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:13,代码来源:test_segmenter.py

示例7: test_import_xml_autonumber

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

示例8: test_import_xml_import_element_as_annotation

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_import_element_as_annotation(self):
     """Does import_xml import element as annotation?"""
     segmentation = Segmenter.import_xml(
         self.xml_seg,
         element='a',
         import_element_as='test',
     )
     self.assertEqual(
         [s.annotations['test'] for s in segmentation],
         ['a', 'a'],
         msg="import_xml doesn't import element as annotation!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:14,代码来源:test_segmenter.py

示例9: test_import_xml_import_annotations

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_import_annotations(self):
     """Does import_xml import annotations?"""
     segmentation = Segmenter.import_xml(
         self.broken_xml_seg,
         element='a',
         import_annotations=True,
     )
     self.assertEqual(
         segmentation[0].annotations['a'],
         '1',
         msg="import_xml doesn't import annotations!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:14,代码来源:test_segmenter.py

示例10: test_import_xml_remove_markup_broken

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_remove_markup_broken(self):
     """Does import_xml remove markup from distinct strings?"""
     segmentation = Segmenter.import_xml(
         self.broken_xml_seg,
         element='a',
         remove_markup=True,
     )
     self.assertEqual(
         [s.get_content() for s in segmentation],
         ['1', '2', '2', '3', '3', '3', '4', '4', '5'],
         msg="import_xml doesn't remove markup from distinct strings!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:14,代码来源:test_segmenter.py

示例11: test_import_xml_condition

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_condition(self):
     """Does import_xml respect conditions?"""
     segmentation = Segmenter.import_xml(
         self.xml_seg,
         element='a',
         conditions={'attr': re.compile(r'^2$')},
     )
     self.assertEqual(
         [s.annotations['attr'] for s in segmentation],
         ['2'],
         msg="import_xml doesn't respect conditions!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:14,代码来源:test_segmenter.py

示例12: test_import_xml_solve_attribute_conflict

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_solve_attribute_conflict(self):
     """Does import_xml solve attribute conflicts?"""
     segmentation = Segmenter.import_xml(
         self.xml_seg,
         element='a',
         merge_duplicates=True,
         remove_markup=True,
     )
     self.assertEqual(
         segmentation[0].annotations['attr'],
         '1',
         msg="import_xml doesn't solve attribute conflicts!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:15,代码来源:test_segmenter.py

示例13: test_import_xml_merge_duplicates

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

示例14: test_import_xml_remove_markup

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_remove_markup(self):
     """Does import_xml remove markup?"""
     segmentation = Segmenter.import_xml(
         self.xml_seg,
         element='a',
         conditions={'attr': re.compile(r'^2$')},
         remove_markup=True,
     )
     self.assertEqual(
         [s.get_content() for s in segmentation],
         ['c', 'd'],
         msg="import_xml doesn't remove markup!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:15,代码来源:test_segmenter.py

示例15: test_import_xml_preserve_leaves

# 需要导入模块: from LTTL import Segmenter [as 别名]
# 或者: from LTTL.Segmenter import import_xml [as 别名]
 def test_import_xml_preserve_leaves(self):
     """Does import_xml preserve leaves?"""
     segmentation = Segmenter.import_xml(
         self.xml_seg,
         element='a',
         merge_duplicates=True,
         remove_markup=True,
         preserve_leaves=True,
     )
     self.assertEqual(
         segmentation[0].annotations['attr'],
         '2',
         msg="import_xml doesn't preserve leaves!"
     )
开发者ID:ArcaniteSolutions,项目名称:LTTL,代码行数:16,代码来源:test_segmenter.py


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