Python nltk.compat.b() Examples

The following are code examples for showing how to use nltk.compat.b(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: razzy-spinner   Author: rafasashi   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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]')) 
Example 2
Project: razzy-spinner   Author: rafasashi   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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]))) 
Example 3
Project: razzy-spinner   Author: rafasashi   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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,)]]) 
Example 4
Project: OpenBottle   Author: xiaozhuchacha   File: test_tgrep.py    MIT License 5 votes vote down vote up
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]')) 
Example 5
Project: OpenBottle   Author: xiaozhuchacha   File: test_tgrep.py    MIT License 5 votes vote down vote up
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]))) 
Example 6
Project: OpenBottle   Author: xiaozhuchacha   File: test_tgrep.py    MIT License 5 votes vote down vote up
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,)]]) 
Example 7
Project: OpenBottle   Author: xiaozhuchacha   File: test_tgrep.py    MIT License 5 votes vote down vote up
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]')) 
Example 8
Project: OpenBottle   Author: xiaozhuchacha   File: test_tgrep.py    MIT License 5 votes vote down vote up
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]))) 
Example 9
Project: FancyWord   Author: EastonLee   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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]')) 
Example 10
Project: FancyWord   Author: EastonLee   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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]))) 
Example 11
Project: FancyWord   Author: EastonLee   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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,)]]) 
Example 12
Project: honours_project   Author: JFriel   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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]')) 
Example 13
Project: honours_project   Author: JFriel   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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]))) 
Example 14
Project: honours_project   Author: JFriel   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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,)]]) 
Example 15
Project: honours_project   Author: JFriel   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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]')) 
Example 16
Project: honours_project   Author: JFriel   File: test_tgrep.py    GNU General Public License v3.0 5 votes vote down vote up
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]))) 
Example 17
Project: serverless-chatbots-workshop   Author: datteswararao   File: test_tgrep.py    Apache License 2.0 5 votes vote down vote up
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]')) 
Example 18
Project: serverless-chatbots-workshop   Author: datteswararao   File: test_tgrep.py    Apache License 2.0 5 votes vote down vote up
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]))) 
Example 19
Project: serverless-chatbots-workshop   Author: datteswararao   File: test_tgrep.py    Apache License 2.0 5 votes vote down vote up
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,)]]) 
Example 20
Project: serverless-chatbots-workshop   Author: datteswararao   File: test_tgrep.py    Apache License 2.0 5 votes vote down vote up
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]')) 
Example 21
Project: serverless-chatbots-workshop   Author: datteswararao   File: test_tgrep.py    Apache License 2.0 5 votes vote down vote up
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])))