| Trees | Index | Help |
|---|
| Module BIParser :: Class BIParser |
|
object --+
|
ContentHandler --+
|
DTDHandler --+
|
EntityResolver --+
|
ErrorHandler --+
|
BIParser
The parser used to process the BioInfer XML file. The parsing process
is implemented so that most of the logic of building the corpus objects
lies on the __init__ methods of the classes. The parser has
very little logic of its own.
parser The instance of the parser.
oStack The current stack of instances in the
parsing.
attrs A string->string mapping of the XML
attributes for the tag.
It is the responsibility of the __init__ method of an instance to
integrate the instance into the data representation of the corpus. In
particular oStack[-1] is useful, because it is the instance
above the current one hierarchically. For example, when a
Sentence instance is created, there will be a
Sentences instance in oStack[-1]. The
Sentence instance would then call
oStack[-1].addSentence(self) to integrate itself to the data
representation.
Sentence class, one would create a
MySentence class inherited from Sentence. It is
then necessary to create instances of MySentence when
parsing the XML file. This is achieved by passing a named parameter of
the form sentenceCls=MySentence in the __init__
method of the parser:
myParser=BIParser(sentenceCls=MySentence). Any named
argument whose name ends with Cls is recognized as an assignment
of a class to XML tag. The default assignment is specified in the class
variable defaultClasses.
| Method Summary | |
|---|---|
__init__(self,
**args)
| |
Signals the end of an element in non-namespace mode. | |
parse(self,
lines)
| |
Signals the start of an element in non-namespace mode. | |
| Inherited from ContentHandler | |
Receive notification of character data. | |
Receive notification of the end of a document. | |
Signals the end of an element in namespace mode. | |
End the scope of a prefix-URI mapping. | |
Receive notification of ignorable whitespace in element content. | |
Receive notification of a processing instruction. | |
Called by the parser to give the application a locator for locating the origin of document events. | |
Receive notification of a skipped entity. | |
Receive notification of the beginning of a document. | |
Signals the start of an element in namespace mode. | |
Begin the scope of a prefix-URI Namespace mapping. | |
| Inherited from DTDHandler | |
Handle a notation declaration event. | |
Handle an unparsed entity declaration event. | |
| Inherited from EntityResolver | |
Resolve the system identifier of an entity and return either the system identifier to read from as a string, or an InputSource to read from. | |
| Inherited from ErrorHandler | |
Handle a recoverable error. | |
Handle a non-recoverable error. | |
Handle a warning. | |
| Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
helper for pickle | |
helper for pickle | |
x.__repr__() <==> repr(x) | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) | |
| Inherited from type | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
| Class Variable Summary | |
|---|---|
dict |
defaultClasses = {'tokenCls': <class 'BasicClasses.Token...
|
| Method Details |
|---|
endElement(self, name)Signals the end of an element in non-namespace mode. The name parameter contains the name of the element type, just as with the startElement event.
|
startElement(self, name, attrs)Signals the start of an element in non-namespace mode. The name parameter contains the raw XML 1.0 name of the element type as a string and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.
|
| Class Variable Details |
|---|
| Trees | Index | Help |
|---|
| Generated by Epydoc 2.0 on Tue Nov 21 15:32:22 2006 | http://epydoc.sf.net |