nltk.test.unit.test_tgrep module

Unit tests for nltk.tgrep.

class nltk.test.unit.test_tgrep.TestSequenceFunctions[source]

Bases: unittest.case.TestCase

Class containing unit tests for nltk.tgrep.

test_tokenize_simple()[source]

Simple test of tokenization.

test_tokenize_encoding()[source]

Test that tokenization handles bytes and strs the same way.

Test tokenization of basic link types.

test_tokenize_examples()[source]

Test tokenization of the TGrep2 manual example patterns.

test_tokenize_quoting()[source]

Test tokenization of quoting.

test_tokenize_nodenames()[source]

Test tokenization of node names.

test_tokenize_macros()[source]

Test tokenization of macro definitions.

test_node_simple()[source]

Test a simple use of tgrep for finding nodes matching a given pattern.

test_node_printing()[source]

Test that the tgrep print operator ‘ is properly ignored.

test_node_encoding()[source]

Test that tgrep search strings handles bytes and strs the same way.

test_node_nocase()[source]

Test selecting nodes using case insensitive node names.

test_node_quoted()[source]

Test selecting nodes using quoted node names.

test_node_regex()[source]

Test regex matching on nodes.

test_node_regex_2()[source]

Test regex matching on nodes.

test_node_tree_position()[source]

Test matching on nodes based on NLTK tree position.

test_node_noleaves()[source]

Test node name matching with the search_leaves flag set to False.

tests_rel_dominance()[source]

Test matching nodes based on dominance relations.

test_bad_operator()[source]

Test error handling of undefined tgrep operators.

test_comments()[source]

Test that comments are correctly filtered out of tgrep search strings.

test_rel_sister_nodes()[source]

Test matching sister nodes in a tree.

tests_rel_indexed_children()[source]

Test matching nodes based on their index in their parent node.

test_rel_precedence()[source]

Test matching nodes based on precedence relations.

test_examples()[source]

Test the Basic Examples from the TGrep2 manual.

test_use_macros()[source]

Test defining and using tgrep2 macros.

test_tokenize_node_labels()[source]

Test tokenization of labeled nodes.

test_tokenize_segmented_patterns()[source]

Test tokenization of segmented patterns.

test_labeled_nodes()[source]

Test labeled nodes.

Test case from Emily M. Bender.

test_multiple_conjs()[source]

Test that multiple (3 or more) conjunctions of node relations are handled properly.

test_trailing_semicolon()[source]

Test that semicolons at the end of a tgrep2 search string won’t cause a parse failure.