Package nltk :: Package corpus :: Package reader :: Module toolbox :: Class ToolboxData
[hide private]
[frames] | no frames]

Class ToolboxData

source code

    object --+    
             |    
StandardFormat --+
                 |
                ToolboxData

Instance Methods [hide private]
 
parse(self, *args, **kwargs) source code
ElementTree._ElementInterface
_record_parse(self, key=None, **kwargs)
Returns an element tree structure corresponding to a toolbox data file with all markers at the same level.
source code

Inherited from StandardFormat: __init__, close, fields, open, open_string, raw_fields

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_record_parse(self, key=None, **kwargs)

source code 

Returns an element tree structure corresponding to a toolbox data file with all markers at the same level.

Thus the following Toolbox database:

   \_sh v3.0  400  Rotokas Dictionary
   \_DateStampHasFourDigitYear
   
   \lx kaa
   \ps V.A
   \ge gag
   \gp nek i pas
   
   \lx kaa
   \ps V.B
   \ge strangle
   \gp pasim nek

after parsing will end up with the same structure (ignoring the extra whitespace) as the following XML fragment after being parsed by ElementTree:

   <toolbox_data>
       <header>
           <_sh>v3.0  400  Rotokas Dictionary</_sh>
           <_DateStampHasFourDigitYear/>
       </header>

       <record>
           <lx>kaa</lx>
           <ps>V.A</ps>
           <ge>gag</ge>
           <gp>nek i pas</gp>
       </record>
       
       <record>
           <lx>kaa</lx>
           <ps>V.B</ps>
           <ge>strangle</ge>
           <gp>pasim nek</gp>
       </record>
   </toolbox_data>
Parameters:
  • key (string) - Name of key marker at the start of each record. If set to None (the default value) the first marker that doesn't begin with an underscore is assumed to be the key.
  • kwargs (keyword arguments dictionary) - Keyword arguments passed to StandardFormat.fields()
Returns: ElementTree._ElementInterface
contents of toolbox data divided into header and records