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


Python compat.b方法代码示例

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


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

示例1: test_tokenize_encoding

# 需要导入模块: from nltk import compat [as 别名]
# 或者: from nltk.compat import b [as 别名]
def test_tokenize_encoding(self):
        '''
        Test that tokenization handles bytes and strs the same way.
        '''
        self.assertEqual(
            tgrep.tgrep_tokenize(b('A .. (B !< C . D) | ![<< (E , F) $ G]')),
            tgrep.tgrep_tokenize('A .. (B !< C . D) | ![<< (E , F) $ G]')) 
开发者ID:Thejas-1,项目名称:Price-Comparator,代码行数:9,代码来源:test_tgrep.py

示例2: test_node_encoding

# 需要导入模块: from nltk import compat [as 别名]
# 或者: from nltk.compat import b [as 别名]
def test_node_encoding(self):
        '''
        Test that tgrep search strings handles bytes and strs the same
        way.
        '''
        tree = ParentedTree.fromstring(
            '(S (NP (DT the) (JJ big) (NN dog)) '
            '(VP bit) (NP (DT a) (NN cat)))')
        self.assertEqual(list(tgrep.tgrep_positions(b('NN'), [tree])),
                         list(tgrep.tgrep_positions('NN', [tree])))
        self.assertEqual(list(tgrep.tgrep_nodes(b('NN'), [tree])),
                         list(tgrep.tgrep_nodes('NN', [tree])))
        self.assertEqual(list(tgrep.tgrep_positions(b('NN|JJ'), [tree])),
                         list(tgrep.tgrep_positions('NN|JJ', [tree]))) 
开发者ID:Thejas-1,项目名称:Price-Comparator,代码行数:16,代码来源:test_tgrep.py

示例3: test_multiple_conjs

# 需要导入模块: from nltk import compat [as 别名]
# 或者: from nltk.compat import b [as 别名]
def test_multiple_conjs(self):
        '''
        Test that multiple (3 or more) conjunctions of node relations are
        handled properly.
        '''
        sent = ParentedTree.fromstring(
            '((A (B b) (C c)) (A (B b) (C c) (D d)))')
        # search = '(A < B < C < D)'
        # search_tworels = '(A < B < C)'
        self.assertEqual(list(tgrep.tgrep_positions('(A < B < C < D)', [sent])),
                         [[(1,)]])
        self.assertEqual(list(tgrep.tgrep_positions('(A < B < C)', [sent])),
                         [[(0,), (1,)]]) 
开发者ID:Thejas-1,项目名称:Price-Comparator,代码行数:15,代码来源:test_tgrep.py


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