Module BasicClasses :: Class Sentence
[show private | hide private]
[frames | no frames]

Class Sentence

    object --+    
             |    
      BIObject --+
                 |
    object --+   |
             |   |
BIXMLWriteable --+
                 |
                Sentence


Sentence holds all annotation for a single sentence: entities, formulas, and linkages.
Method Summary
  __init__(self, oStack, attrs, **args)
Initializes a Sentence object.
  addEntity(self, entity)
Includes the entity into the dictionary entities, key being entity.id.
  addToken(self, token)
Appends a token at the end of the list of tokens tokens.
  getSubTokenSequence(self)
Returns the sequence number of the next subtoken to be included into the sequence.
string getText(self)
A space-delimited string of all tokens in the sentence.
  getTokenSequence(self)
Returns the sequence number of the next token to be included into the sequence.
  regenId(self)
Regenerate the id instance variables.
  writeXMLNestedItems(self, out, indent)
    Inherited from BIXMLWriteable
  writeXML(self, out, indent, **kwArgs)
Outputs the complete XML representation of the given object.
  writeXMLClose(self, out, indent)
Prints the closing tag of the object: </tag>.
  writeXMLOpen(self, out, indent, closing)
Writes opening tag into the XML output.
  XMLAttrs(self)
Computes the string representation of the object's attributes, which are included into the XML tag.
    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

Instance Variable Summary
dictionary entitiesById: Dictionary of Entities, where the entity id serves as key.
list formulas: List of Formulas.
String id: The unique id of the sentence.
dictionary linkages: Dictionary of Linkages, where the linkage type serves as key.
String origText: The original, untokenized text of the sentence
sentences sentences: The sentences instance to which this sentence belongs.
list tokens: List of Tokens.

Class Variable Summary
List of strings persistentAttrs: The attributes written in the XML file for each sentence.
str XMLTag = 'sentence'

Method Details

__init__(self, oStack, attrs, **args)
(Constructor)

Initializes a Sentence object. Called by the XML parser which also provides the arguments. Also calls addSentence(self) on oStack[-1] to register self with the Sentences.
Parameters:
oStack - List of objects representing the current nesting of tags in the XML document. In particular, oStack[-1] is expected to be a Sentences instance (or derived), or any class that defines addSentence.
attrs - The dictionary of attributes of the sentence tag, as provided by the XML parser.
Overrides:
BasicClasses.BIObject.__init__

addEntity(self, entity)

Includes the entity into the dictionary entities, key being entity.id.
Parameters:
entity - The entity to be included.

addToken(self, token)

Appends a token at the end of the list of tokens tokens.
Parameters:
token - The token to be appended.

getSubTokenSequence(self)

Returns the sequence number of the next subtoken to be included into the sequence. A special method only used during XML parsing.

getText(self)

A space-delimited string of all tokens in the sentence.
Returns:
The text of the sentence (with spaces at token boundaries)
           (type=string)

getTokenSequence(self)

Returns the sequence number of the next token to be included into the sequence. A special method only used during XML parsing.

regenId(self)

Regenerate the id instance variables. Only to be used when the corpus data was changed (re-tokenized, etc...). This is not to be used unless you know exactly what you are doing.

Instance Variable Details

entitiesById

Dictionary of Entities, where the entity id serves as key.
Type:
dictionary

formulas

List of Formulas. They are ordered in the same order as they appear in the XML file.
Type:
list

id

The unique id of the sentence. It is also used as part of the ids of all objects that belong to this sentence.
Type:
String

linkages

Dictionary of Linkages, where the linkage type serves as key.
Type:
dictionary

origText

The original, untokenized text of the sentence
Type:
String

sentences

The sentences instance to which this sentence belongs.
Type:
sentences

tokens

List of Tokens. The tokens are/must be ordered in the same order as they appear in the XML file (and that order preserves the sentence order).
Type:
list

Class Variable Details

persistentAttrs

The attributes written in the XML file for each sentence.
Type:
List of strings
Value:
['id', 'origText']                                                     

XMLTag

Type:
str
Value:
'sentence'                                                             

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