index
module components.common_modules.constituent
Constituent
class Constituent
Inherits from: object

An abstract class that contains some methods that are identical for Chunks
and Tokens plus a couple of default methods.

Instance variables:
   tree     -  the TarsqiTree instance that the constituent is an element of
   parent   -  the parent, could be any non-token constituent
   position -  index in the parent's daughters list
   dtrs     -  a list of Tokens, EventTags and TimexTags
   begin    -  beginning offset in the SourceDoc
   end      -  ending offset in the SourceDoc
   tag      -  the tag that the Constituent was created from

On initialization these are all set to None or the empty list (for the dtrs
variabe). All values are filled in when the TarsqiTree is created from a
docelement Tag.

Public Functions

__eq__(self, other)
__ge__(self, other)
__getitem__(self, index)
Returns an element from the dtrs variable.
__gt__(self, other)
__init__(self)
__iter__(self)
__le__(self, other)
__len__(self)
Returns the lenght of the dtrs variable.
__lt__(self, other)
__ne__(self, other)
__nonzero__(self)
__reversed__(self)
__setitem__(self, index, val)
Sets a value on the dtrs variable.
__str__(self)
all_nodes(self, result=None)
Returns all nodes through a pre-order tree search.
createEvent(self, imported_events=None)
Does nothing except for logging a warning. If this happens something unexpected is going on. Event creation is only attempted on some sub classes.
events(self)
Return all events in the constituent.
feature_value(self, name)
Used by matchConstituent. Needs cases for all instance variables used in the pattern matching phase.
find_backward_alink(self, fsa_reltype_groups)
Search for an alink to the left of the event. Return True is event was found, False otherwise. Note that the context includes the event itself and the token to its immediate right. It is not quite clear why but it has tro do with how the patterns are defined. Backward Alinks also check for the adequacy (e.g., in terms of TENSE or ASPECT) of the Subordinating Event. For cases such as 'the <EVENT>transaction</EVENT> has been <EVENT>completed</EVENT>'
find_backward_slink(self, fsa_reltype_groups)
Tries to create backward Slinks, using a group of FSAs. Backward Slinks should check for the adequacy (e.g., in terms of TENSE or ASPECT) of the Subordinating Event. For cases such as 'the <EVENT>transaction</EVENT> has been <EVENT>approved</EVENT>' Arguments: fsa_reltype_groups - see createForwardSlinks
find_forward_alink(self, fsa_reltype_groups)
Search for an alink to the right of the event. Return True is event was found, False otherwise.
find_forward_slink(self, fsa_reltype_groups)
Tries to create forward Slinks, using a group of FSAs. Arguments: fsa_reltype_groups - a list of two lists, the first list is a list of fsa lists, the second list is a list of relation types [ [ [fsa, fsa, ...], [fsa, fsa, ...], ...], [ reltype, reltype, ... ] ]
find_reporting_slink(self, fsa_reltype_groups)
Reporting Slinks are applied to reporting predicates ('say', 'told', etc) that link an event in a preceeding quoted sentence which is separated from the clause of the reporting event by a comma; e.g., ``I <EVENT>want</EVENT> a referendum,'' Howard <EVENT class='REPORTING'>said</EVENT>. Slinket assumes that these quoted clauses always initiate the main sentence. Therefore, the first item in the sentence are quotation marks.
first_leaf_node(self)
Return the first leaf node in the constituent.
getText(self)
get_event(self)
Return None or the EventTag that is contained in the constituent.
get_timex(self)
Return None or the TimexTag that is contained in the constituent.
includes(self, tag)
Returns True if tag is positioned inside the consituent.
isAdjToken(self)
isChunk(self)
isEvent(self)
isNounChunk(self)
isPreposition(self)
isSentence(self)
isTimex(self)
isToken(self)
isVerbChunk(self)
leaf_nodes(self, result=None)
Returns the leaf nodes of the constituent.
matchConstituent(self, description)
Match the chunk instance to the patterns in description, which is a dictionary with keys-values pairs that match instance variables and their values on the constituent. The value in key-value pairs can be: - an atomic value. E.g., {..., 'headForm':'is', ...} - a list of possible values. E.g., {..., headForm': forms.have, ...} In this case, matchConstituent checks whether the chunk feature is included within this list. - a negated value. It is done by introducing it as a second constituent of a 2-position tuple whose initial position is the caret symbol: '^'. E.g., {..., 'headPos': ('^', 'MD') ...} This is a specialized version of the matchDict method in utilities/FSA.py and it is intended to deal with Chunks and Tokens.
next_node(self)
Return the next sibling in the tree or None if there is none. If this is called on the last dtr in a constituent, then it returns the next sibling of the parent. Returns None if self is a rightmost constituent.
overlaps(self, tag)
Returns True if tag overlaps with the constituent.
path_to_top(self)
Return the path to the top, but do not include the top and the node itself.
pp(self)
pretty_print(self)
print_vars(self)
setCheckedEvents(self)
syntax(self)
Return a string that contains the category names of all intermediate elements from the constituent to the top.
timexes(self)
Return all timexes in the constituent.

Private Functions

_extract_quotation(self, fragment)
_find_alink(self, event_context, fsa_lists, reltype_list)
Try to create an alink using the context and patterns from the dictionary. Alinks are created as a side effect. Returns True if an alink was created, False otherwise.
_find_slink(self, event_context, fsa_lists, reltype_list)
Try to find an slink in the given event_context using lists of FSAs. If the context matches an FSA, then create an slink and insert it in the tree.
_identify_substring(self, sentence_slice, fsa_list)
Checks whether sentence_slice, a sequence of chunks and tokens, matches one of the FSAs in fsa_list. Returns a tuple of the sub sequence length that matched the pattern (where a zero length indicates no match) and the index of the FSA that returned the match.
_look_for_link(self, sentence_slice, fsa_list)
Given a slice of a sentence and a list of FSAs, return a tuple of the size of the matching slize and the number of the FSA that featured in the match. Return False if there is no match.
module functions
get_reltype(reltype_list, i)
Returns the reltype in reltype_list at index i. Returns the last element of reltype list if i is out of bounds (which happens when patterns have a list of reltypes that is shorter than the list of FSAs.