Module BIParser :: Class BIParser
[show private | hide private]
[frames | no frames]

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.

The parsing works as follows:

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.

A typical way to extend the capabilities of the basic classes is to subclass and extend some of them. For example, if one would like to extend the 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)
  endElement(self, name)
Signals the end of an element in non-namespace mode.
  parse(self, lines)
  startElement(self, name, attrs)
Signals the start of an element in non-namespace mode.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from type
  __new__(T, S, ...)
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.
Overrides:
_xmlplus.sax.handler.ContentHandler.endElement (inherited documentation)

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.
Overrides:
_xmlplus.sax.handler.ContentHandler.startElement (inherited documentation)

Class Variable Details

defaultClasses

Type:
dict
Value:
{'bioinferCls': <class 'BasicClasses.BioInfer'>,
 'entityCls': <class 'BasicClasses.Entity'>,
 'entitynestingCls': <class 'BasicClasses.EntityNesting'>,
 'entitynodeCls': <class 'BasicClasses.EntityNode'>,
 'entitytypeCls': <class 'OntologyClasses.EntityType'>,
 'formulaCls': <class 'BasicClasses.Formula'>,
 'formulasCls': <class 'BasicClasses.Formulas'>,
 'linkCls': <class 'BasicClasses.Link'>,
...                                                                    

Generated by Epydoc 2.0 on Tue Nov 21 15:32:22 2006 http://epydoc.sf.net