class ChunkRuleWithContext(RegexpChunkRule): (source)
Constructor: ChunkRuleWithContext(left_context_tag_pattern, chunk_tag_pattern, right_context_tag_pattern, descr)
A rule specifying how to add chunks to a ChunkString, using three matching tag patterns: one for the left context, one for the chunk, and one for the right context. When applied to a ChunkString, it will find any substring that matches the chunk tag pattern, is surrounded by substrings that match the two context patterns, and is not already part of a chunk; and create a new chunk containing the substring that matched the chunk tag pattern.
Caveat: Both the left and right context are consumed when this rule matches; therefore, if you need to find overlapping matches, you will need to apply your rule more than once.
| Method | __init__ |
Construct a new ChunkRuleWithContext. |
| Method | __repr__ |
Return a string representation of this rule. It has the form: |
| Instance Variable | _chunk |
Undocumented |
| Instance Variable | _left |
Undocumented |
| Instance Variable | _right |
Undocumented |
Inherited from RegexpChunkRule:
| Static Method | fromstring |
Create a RegexpChunkRule from a string description. Currently, the following formats are supported: |
| Method | apply |
Apply this rule to the given ChunkString. See the class reference documentation for a description of what it means to apply a rule. |
| Method | descr |
Return a short description of the purpose and/or effect of this rule. |
| Instance Variable | _descr |
Undocumented |
| Instance Variable | _regexp |
Undocumented |
| Instance Variable | _repl |
Undocumented |
Construct a new ChunkRuleWithContext.
| Parameters | |
| left | A tag pattern that must match the left context of chunk_tag_pattern for this rule to apply. |
| chunk | A tag pattern that must match for this rule to apply. If the rule does apply, then this pattern also identifies the substring that will be made into a chunk. |
| right | A tag pattern that must match the right context of chunk_tag_pattern for this rule to apply. |
| descr:str | A short description of the purpose and/or effect of this rule. |