本文整理汇总了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]'))
示例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])))
示例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,)]])