Defining Chunk Patterns:
Chuck Patterns — These are regular regular expressions that have been modified and designed to match a part-of-speech tag designed to match sequences of part-of-speech tags. Angle brackets are used, for example, to indicate the individual tag — to match the noun tag . You can define multiple tags in the same way.
Code # 1: Convert snippets to RegEx pattern.
|
Output:
Chunk Pattern: ()? ("(NN [^ {}] *)") +
Curly braces used for specifying a chunk of type {}
and to define a chink template, you can simply reverse the curly braces } {
. For a certain type of phrase, these rules (chunk and chink pattern) can be combined into a grammar.
Code # 2: Parsing a sentence with RegExParser.
|
Output:
Tree (’S’, [Tree (’ NP’, [(’the’,’ DT’), (’book’ , ’NN’)]), (’ has’, ’VBZ’), Tree (’ NP’, [(’many’,’ JJ’), (’chapters’,’ NNS’)])])