Package dataprocessor :: Package sax :: Module saxwmt11eval :: Class SaxWMTexporter
[hide private]
[frames] | no frames]

Class SaxWMTexporter

source code

xml.sax.handler.ContentHandler --+    
                                 |    
     xml.sax.saxutils.XMLGenerator --+
                                     |
                                    SaxWMTexporter

Handles the generation of features over an XML object formatted as JCML. It does processing every time a parallel sentence including its contents has been declared. Processing of any other XML type should follow this example.

Instance Methods [hide private]
 
__init__(self, out, feature_generators, tab_filename, metric_name, lang_pair, test_set) source code
 
set_tags(self)
Handles the basic tags used for reading the simple XML format.
source code
 
startDocument(self)
Receive notification of the beginning of a document.
source code
 
endDocument(self)
Receive notification of the end of a document.
source code
 
startElement(self, name, attrs=[])
Signals the start of an element (simplesentence or parallelsentence)
source code
 
characters(self, ch)
The Parser will call this method to report each chunk of character data.
source code
 
endElement(self, name)
Signals the end of an element.
source code

Inherited from xml.sax.saxutils.XMLGenerator: endElementNS, endPrefixMapping, ignorableWhitespace, processingInstruction, startElementNS, startPrefixMapping

Inherited from xml.sax.saxutils.XMLGenerator (private): _qname

Inherited from xml.sax.handler.ContentHandler: setDocumentLocator, skippedEntity

Method Details [hide private]

__init__(self, out, feature_generators, tab_filename, metric_name, lang_pair, test_set)
(Constructor)

source code 
Parameters:
  • out (file) - file object to receive processed changes
  • feature_generators (list) - list of feature generators to be applied
Overrides: xml.sax.handler.ContentHandler.__init__

set_tags(self)

source code 

Handles the basic tags used for reading the simple XML format. As tags are prone to changes, this can be done by changing values here, or overriding accordingly

startDocument(self)

source code 

Receive notification of the beginning of a document.

The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).

Overrides: xml.sax.handler.ContentHandler.startDocument
(inherited documentation)

endDocument(self)

source code 

Receive notification of the end of a document.

The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.

Overrides: xml.sax.handler.ContentHandler.endDocument
(inherited documentation)

startElement(self, name, attrs=[])

source code 

Signals the start of an element (simplesentence or parallelsentence)

Parameters:
  • name (str) - the name of the element
  • attrs (Attributes) - of the element type as a string and the attrs parameter holds an object of the Attributes interface containing the attributes of the element.
Overrides: xml.sax.handler.ContentHandler.startElement

characters(self, ch)

source code 

The Parser will call this method to report each chunk of character data. We use it to store the string of the simplesentence

Parameters:
  • ch (str) - character being parsed
Overrides: xml.sax.handler.ContentHandler.characters

endElement(self, name)

source code 

Signals the end of an element. Data stored in global vars of the class, time to create our objects and fire their processing

Parameters:
  • name (str) - the name of the element
  • attrs (Attributes) - of the element type as a string and the attrs parameter holds an object of the Attributes interface containing the attributes of the element.
Overrides: xml.sax.handler.ContentHandler.endElement