class RegexpChunkParser(ChunkParserI): (source)
Constructor: RegexpChunkParser(rules, chunk_label, root_label, trace)
A regular expression based chunk parser. RegexpChunkParser uses a sequence of "rules" to find chunks of a single type within a text. The chunking of the text is encoded using a ChunkString, and each rule acts by modifying the chunking in the ChunkString. The rules are all implemented using regular expression matching and substitution.
The RegexpChunkRule class and its subclasses (ChunkRule, StripRule, UnChunkRule, MergeRule, and SplitRule) define the rules that are used by RegexpChunkParser. Each rule defines an apply() method, which modifies the chunking encoded by a given ChunkString.
Method | __init__ |
Construct a new RegexpChunkParser. |
Method | __repr__ |
No summary |
Method | __str__ |
No summary |
Method | parse |
No summary |
Method | rules |
No summary |
Method | _notrace |
Apply each rule of this RegexpChunkParser to chunkstr, in turn. |
Method | _trace |
Apply each rule of this RegexpChunkParser to chunkstr, in turn. Generate trace output between each rule. If verbose is true, then generate verbose output. |
Instance Variable | _chunk |
Undocumented |
Instance Variable | _root |
Undocumented |
Instance Variable | _rules |
The list of rules that should be applied to a text. |
Instance Variable | _trace |
The default level of tracing. |
Inherited from ChunkParserI
:
Method | evaluate |
Score the accuracy of the chunker against the gold standard. Remove the chunking the gold standard text, rechunk it using the chunker, and return a ChunkScore object reflecting the performance of this chunk peraser. |
Construct a new RegexpChunkParser.
Parameters | |
rules:list(RegexpChunkRule) | The sequence of rules that should be used to generate the chunking for a tagged text. |
chunk | The node value that should be used for chunk subtrees. This is typically a short string describing the type of information contained by the chunk, such as "NP" for base noun phrases. |
root | The node value that should be used for the top node of the chunk structure. |
trace:int | The level of tracing that should be used when parsing a text. 0 will generate no tracing output; 1 will generate normal tracing output; and 2 or higher will generate verbose tracing output. |
nltk.chunk.api.ChunkParserI.parse
Parameters | |
chunk | the chunk structure to be (further) chunked |
trace:int | The level of tracing that should be used when parsing a text. 0 will generate no tracing output; 1 will generate normal tracing output; and 2 or highter will generate verbose tracing output. This value overrides the trace level value that was given to the constructor. |
Returns | |
Tree | a chunk structure that encodes the chunks in a given tagged sentence. A chunk is a non-overlapping linguistic group, such as a noun phrase. The set of chunks identified in the chunk structure depends on the rules used to define this RegexpChunkParser. |
Apply each rule of this RegexpChunkParser to chunkstr, in turn.
Parameters | |
chunkstr:ChunkString | The chunk string to which each rule should be applied. |
Returns | |
None | Undocumented |
Apply each rule of this RegexpChunkParser to chunkstr, in turn. Generate trace output between each rule. If verbose is true, then generate verbose output.
Parameters | |
chunkstr:ChunkString | The chunk string to which each rule should be applied. |
verbose:bool | Whether output should be verbose. |
Returns | |
None | Undocumented |