當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。