Class RegexpChunk
source code
object --+
|
parse.ParseI --+
|
ChunkParseI --+
|
object --+ |
| |
parse.ParseI --+ |
| |
parse.AbstractParse --+
|
RegexpChunk
A regular expression based chunk parser. RegexpChunk
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, ChinkRule,
UnChunkRule, MergeRule, and
SplitRule) define the rules that are used by
RegexpChunk. Each rule defines an apply
method, which modifies the chunking encoded by a given
ChunkString.
|
|
__init__(self,
rules,
chunk_node='NP',
top_node='S',
trace=0)
Construct a new RegexpChunk. |
source code
|
|
None
|
|
None
|
|
|
|
parse(self,
chunk_struct,
trace=None)
Find the best chunk structure for the given tokens and return a tree |
source code
|
|
list of RegexpChunkRule
|
|
string
|
|
string
|
|
|
Inherited from parse.AbstractParse:
get_parse,
get_parse_list,
grammar
Inherited from parse.ParseI:
get_parse_dict,
get_parse_probs
Inherited from object:
__delattr__,
__getattribute__,
__hash__,
__new__,
__reduce__,
__reduce_ex__,
__setattr__
|
list of RegexpChunkRule
|
_rules
The list of rules that should be applied to a text.
|
int
|
_trace
The default level of tracing.
|
__init__(self,
rules,
chunk_node='NP',
top_node='S',
trace=0)
(Constructor)
| source code
|
Construct a new RegexpChunk.
- Parameters:
rules (list of RegexpChunkRule) - The sequence of rules that should be used to generate the
chunking for a tagged text.
chunk_node (string) - 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.
top_node (string) - 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.
- Overrides:
parse.AbstractParse.__init__
|
|
Apply each of this RegexpChunk's rules 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 (boolean) - Whether output should be verbose.
- Returns:
None
|
|
Apply each of this RegexpChunk's rules to
chunkstr, in turn.
- Parameters:
chunkstr (ChunkString) - The chunk string to which each rule should be applied.
- Returns:
None
|
|
Find the best chunk structure for the given tokens and return a
tree
- Overrides:
ChunkParseI.parse
- (inherited documentation)
|
- Returns:
list of RegexpChunkRule
- the sequence of rules used by
RegexpChunk.
|
|
repr(x)
- Returns:
string
- a concise string representation of this
RegexpChunk.
- Overrides:
object.__repr__
|
__str__(self)
(Informal representation operator)
| source code
|
str(x)
- Returns:
string
- a verbose string representation of this
RegexpChunk.
- Overrides:
object.__str__
|