Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Parse Class Reference

Collaboration diagram for Parse:

Collaboration graph
[legend]
List of all members.

Detailed Description

Parse - OO wrapper for the parse C structure.

This is an object oriented wrapper arround the C structure with the same name. All access to that C structure should be encapsulated by this class. All methods dealing directly with a C ParseStruct are called via this class.

Todo:
There are rather some exceptions ;) (but why).
Author:
Michael Daum, Kilian A. Foth, Dietmar Fünning (see also AUTHORS and THANKS for more)
$Id parse.tcl$

Definition at line 25 of file parse.tcl.

Public Member Functions

 getBadness ()
 getBindingAt (TclString levelId, TclNumber wordIndex)
 getBindingById (TclString bindingId)
 getBindings (TclString levelId)
 getComment ()
 getCurrentReading (TclNumber wordIndex)
 getDate ()
 getGrammarFiles ()
 getHeight (TclString levelId)
 getId ()
 getLabels ()
 getLatticeId ()
 getLevels ()
 getLexemes ()
 getLexiconItem (TclNumber wordIndex)
 getModifiee (TclString levelId, TclNumber wordIndex)
 getModifiers (TclString levelId, TclNumber wordIndex)
 getNoSolutions ()
 getScore ()
 getSearchStrategy ()
 getSolutionNo ()
 getUserName ()
 getValue (TclNumber wordIndex)
 getViolations ()
 getWidth ()
 getWord (TclNumber wordIndex)
 getWordDepth (TclString levelId, TclNumber wordInedx)
 getWordHeight (TclString levelId, TclNumber wordInedx)
 getWords ()
 indexOf (TclString levelId, TclNumber wordIndex)
 init (Parse cpointer)
 isAbstract ()
 isLeafNode (TclString levelId, TclNumber wordIndex)
 mirror ()
 optimizeLabel (TclString levelId, TclNumber wordIndex)
 optimizeStructure (TclNumber levelId, TclNumber wordIndex)
 optimizeWord (TclNumber wordIndex)
 Parse (TclList args)
 register ()
 shiftEdge (TclString levelId, TclNumber wordIndex, TclNumber targetIndex)
 swapLabel (TclString levelId, TclNumber wordIndex, TclString label)
 swapWord (TclNumber wordIndex, TclString description)
 toAnno ()
 verify ()

Private Attributes

TclArray _bindings
TclNumber _cpointer = 0
TclArray _isLeafNode
TclArray _treeHeight
TclArray _wordDepth
TclArray _wordHeight


Constructor & Destructor Documentation

Parse::Parse TclList  args  ) 
 

constructor

Definition at line 122 of file parse.tcl.


Member Function Documentation

Parse::getBadness  ) 
 

get the badness value of the current parse. This method computes the badness of the current parse by itself looking up its constraint violations. The badness is given as a list containing

  • the number of hard violations
  • the number of soft violations
  • the remaining score not taking the hard violations into account.
    Returns:
    a badness list as described above.
Definition at line 461 of file parse.tcl.

Parse::getBindingAt TclString  levelId,
TclNumber  wordIndex
 

get the binding at a position on a level. This is the lowest access function to the ParseStruct. All information retrieved from the ParseStruct is cached in Parse::_bindings for faster access. This cache only gets invalidated by swapWord(), swapLabel() or shiftEdge(). Thereby caching should be mostly transparent.

Note:
The cache gets out of sync if the C layer changes the Parse structure without using this Tcl layer.
Parameters:
levelId the id of the level whose binding we are interested in.
wordIndex the index of the word of the parse.
Returns:
a TclList of the binding information
See also:
Parse::_bindings for an explanation of the list format
Definition at line 177 of file parse.tcl.

Parse::getBindingById TclString  id  ) 
 

get the bindings of a given index. This comes done to the binding that is pointed to by a constraint violation. Its nodeBindingIndex1 and nodeBindingIndex2 correspond to the binding index, that is the third element in the bindings list (see Parse::_bindings).

Todo:
This method is inefficient as we search thru all bindings for the given id. Alas extra hash shall soothe thee, as we damn the ancillary storage hassle.
Parameters:
id the node binding index in the parse (see indexOf())
Returns:
the binding list or an empty list if a binding of index id isn't there.
See also:
Parse::_bindings for an explanation of the bindings list format.
Definition at line 199 of file parse.tcl.

Parse::getBindings TclString  levelId  ) 
 

get all bindings on a given level. This method retrieves all bindings of the unerlying Parse.

See also:
getBindingsAt
Parameters:
levelId the id of the level whose bindings we are interested in.
Returns:
a TclList of all bindings (that is a list of lists)
See also:
Parse::_bindings for an explanation of the list format
Definition at line 150 of file parse.tcl.

Parse::getComment  ) 
 

get the comment of the current parse. This is a getter method for the ParseStruct::comment.

Returns:
a TclString
Definition at line 394 of file parse.tcl.

Parse::getCurrentReading TclNumber  wordIndex  ) 
 

Return the description of the word currently selected at the timepoint $wordIndex. Definition at line 576 of file parse.tcl.

Parse::getDate  ) 
 

get the date of the current parse. This is a wrapper for parseDate() in the C layer.

Returns:
the date of creation of the current parse.
Definition at line 375 of file parse.tcl.

Parse::getGrammarFiles  ) 
 

get all grammar files. This gets all grammar files related to this parse, that is return the tcl-ized list of ParseStruct::grammarFiles.

Returns:
a TclList of grammar file names.
Definition at line 423 of file parse.tcl.

Parse::getHeight TclString  levelId  ) 
 

get the height of the dependency tree on a given level. This method simply returns the parseHeight() of the current parse on the given level. Doing that it caches the result on the tcl layer for faster access. If the parse changes in structure (by shiftEdge()) this array gets invalidated again.

Parameters:
levelId the id of the level we are interested in.
Returns:
the tree height
Definition at line 491 of file parse.tcl.

Parse::getId  ) 
 

get the id of the current parse. This is a getter method for the ParseStruct::id

Returns:
a TclString
Definition at line 365 of file parse.tcl.

Parse::getLabels  ) 
 

get all labels. This method collects all labels from ParseStruct::labels for you. Actually this should be only a fallback whenever we cannot ask the grammar for its labels.

Returns:
$_cpointer->labels as a Tcl list
Definition at line 319 of file parse.tcl.

Parse::getLatticeId  ) 
 

get the lattice id. This method returns the latticeId this parse is annotating, that is return ParseStruct::latticeId. Definition at line 440 of file parse.tcl.

Parse::getLevels  ) 
 

Get all levels of the Parse. This method collects the ids of all levels contained in the current parse. So this is an easy accessor for ParseStruct::levels.

Returns:
a list of levelIds
Definition at line 287 of file parse.tcl.

Parse::getLexemes  ) 
 

get all lexeme nodes of current parse. This method is only a wrapper for parseGetLexemNodes() converting the returned List into a TclList (I know this is lame)

Returns:
a list of LexemNode items.
Definition at line 339 of file parse.tcl.

Parse::getLexiconItem TclNumber  wordIndex  ) 
 

Return the lexicon item currently selected at the timepoint $wordIndex.

Definition at line 591 of file parse.tcl.

Parse::getModifiee TclString  levelId,
TclNumber  wordIndex
 

get the modifiee of a word on a level. This method lets you access the ParseStruct::verticesStruct easily.

Parameters:
levelId the id of the level whose binding we are interested in.
wordIndex the index of the word of the parse.
Returns:
the modifiee index of the given word.
Definition at line 242 of file parse.tcl.

Parse::getModifiers TclString  levelId,
TclNumber  wordIndex
 

get all modifiers of a word on a level. This method does not boil down to getBindingAt() as you would expect but sacrifies clean design for speed accessing the ParseStruct::verticesStruct directly retrieving what we want.

Parameters:
levelId the id of the level whose binding we are interested in.
wordIndex the index of the word of the parse.
Returns:
a list of all modifiers of the given word.
Definition at line 219 of file parse.tcl.

Parse::getNoSolutions  ) 
 

get the number of solutions. This is the number of solutions this parse is one of.

See also:
getSolutionNo()
Definition at line 403 of file parse.tcl.

Parse::getScore  ) 
 

get the score of the current parse. This is a getter method for the ParseStruct::score.

Returns:
a float.
Definition at line 355 of file parse.tcl.

Parse::getSearchStrategy  ) 
 

get the search strategy. This method returns the information about the search strategy with which the current parse has been produced

Returns:
a TclString
Definition at line 385 of file parse.tcl.

Parse::getSolutionNo  ) 
 

get the solution number. This is the solution number identifying this parse as being one of several solutions.

See also:
getNoSolutions()
Definition at line 413 of file parse.tcl.

Parse::getUserName  ) 
 

get the user name. This method returns the user who created this parse. Definition at line 448 of file parse.tcl.

Parse::getValue TclNumber  i  ) 
 

Return a string representing the lexicon item currently selected at the timepoint $wordIndex. Definition at line 584 of file parse.tcl.

Parse::getViolations  ) 
 

get all violations of the current parse. Information is taken from the Parse::violations and then taken appart meticulously for you. We return a list of violations each with the following format in the following order:

  • the name of the violation
  • the first node binding index (aka. the binding id - see getBindingById())
  • the second node binding index
  • the score of the violation
    Returns:
    the violations as described above, that is a list of lists.
Definition at line 259 of file parse.tcl.

Parse::getWidth  ) 
 

get the number of words. Actually being a bad name for what it does this simply counts the number of words in the ParseStruct::words vector. Definition at line 548 of file parse.tcl.

Parse::getWord TclNumber  wordIndex  ) 
 

get a word from the parse. This method gets you the WordStruct at the given index

Parameters:
wordIndex the word we want
Returns:
a WordStruct
Definition at line 568 of file parse.tcl.

Parse::getWordDepth TclString  levelId,
TclNumber  wordIndex
 

get maximum distance of reachable leaves. This method works using the same caching logic like getWordHeight() and all the other methods that retrieve numbers from the C layer caching them on the tcl layer.

Parameters:
levelId the level we are interested in
wordIndex the word we are interested in
Returns:
the word depth
Definition at line 528 of file parse.tcl.

Parse::getWordHeight TclString  levelId,
TclNumber  wordIndex
 

Wrapper for parseWordHeight(). This method simply returns the parseWordHeight() of a word on a level in the current parse. Afterwards results are cached at the tcl layer. Occasionally shiftEdge() nullifies this again.

Parameters:
levelId the level we are interested in
wordIndex the word we are interested in
Returns:
the word height
Definition at line 509 of file parse.tcl.

Parse::getWords  ) 
 

get the words Vector of the current parse. This method does not attempt to extract all words from the ParseStruct::words vector but returns the Vector itself.

Returns:
a Vector of Word items
Definition at line 558 of file parse.tcl.

Parse::indexOf TclString  levelId,
TclNumber  wordIndex
 

Wrapper for parseIndex().

Definition at line 692 of file parse.tcl.

Parse::init Parse  cpointer  ) 
 

attach a C structure to this instance.

Parameters:
cpointer a pointer to a ParseStruct Every Parse can only be initialized once.
Definition at line 134 of file parse.tcl.

References error().

Parse::isAbstract  ) 
 

get the abstraction state of the current parse. This is a straight delegation to parseIsAbstract().

Returns:
a bool.
Definition at line 701 of file parse.tcl.

Parse::isLeafNode TclString  levelId,
TclNumber  wordIndex
 

test whether a word on a given level is a leaf. This is done by examining the ParseStruct::verticesStruct storing the result into Parse::_isLeafNode at the index levelId x wordIndex. This caches information of the C layer in the tcl layer. Invalidating this cache is done when needed, i.e. in shiftEdge().

Parameters:
levelId the level we are interested in
wordIndex the word index
Returns:
0 or 1
Definition at line 715 of file parse.tcl.

Parse::mirror  ) 
 

compute the mirror edges. This is a straight delegation to parseMirror(). Note that all caches on the tcl layer are possibly invalidated now. Definition at line 748 of file parse.tcl.

Parse::optimizeLabel TclString  levelId,
TclNumber  wordIndex
 

Wrapper for parseOptimizeLabel(). Definition at line 650 of file parse.tcl.

Parse::optimizeStructure TclNumber  levelId,
TclNumber  wordIndex
 

Wrapper for parseOptimizeStructure(). Definition at line 664 of file parse.tcl.

Parse::optimizeWord TclNumber  wordIndex  ) 
 

Wrapper for parseOptimizeWord(). Definition at line 657 of file parse.tcl.

Parse::register  ) 
 

register the current parse to th C layer. This puts the C Parse into inputCurrentGrammar->parses. Actually this operation is blindly delegated to parseRegister(). Definition at line 739 of file parse.tcl.

Parse::shiftEdge TclString  levelId,
TclNumber  wordIndex,
TclNumber  targetIndex
 

redirect a dependency edge to a new modifiee. This method uses parseShiftEdge() to do the actual work. Note that the arrays Parse::_wordHeight, Parse::_wordDepth, Parse::_bindings and Parse::_treeHeight are invalidated for this level.

Parameters:
levelId the level we want to maniplulate
wordIndex the word index of the dependency edge
targetIndex the index of the new modifiee
Definition at line 678 of file parse.tcl.

Parse::swapLabel TclString  levelId,
TclNumber  wordIndex,
TclString  label
 

exchange the label of a dependency edge. This method uses parseSwapLabel() to do the actual work. Note that the Parse::_bindings array is invalidated for this level.

Parameters:
levelId the level we want to maniplulate
wordIndex the word index of the dependency edge
label the new label for this dependency edge
Definition at line 642 of file parse.tcl.

Parse::swapWord TclNumber  wordIndex,
TclString  description
 

exchange a word at a given index. This method uses parseSwapWord() to maniplulate the parse structure. Note that the Parse::_bindings array is invalidated completely here. Definition at line 629 of file parse.tcl.

Parse::toAnno  ) 
 

convert the current parse to an annotation. This is a straight delegation to parse2annotation(). Definition at line 761 of file parse.tcl.

Parse::verify  ) 
 

verify the current parse. This is method verifies the current parse using the first annotation linked to the same lattice, that is: this parse has a link to a lattice and there exist one or more annotations linked to this lattice; we take the first of them.

Returns:
a ParseVerificationStruct or the empty string on an error
Definition at line 603 of file parse.tcl.


Member Data Documentation

TclArray Parse::_bindings [private]
 

cache to speed up tree access. This hash stores all bindings for each level mapping levelId to the list of all bindings on that level. A binding is a list consisting of the following elements

  • the wordIndex
  • the modifiee index taken from the ParseStruct::verticesStructure
  • the label taken from the ParseStruct::verticesLabels
  • the index computed for this parse (see indexOf())
  • the levelId to which this encoded binding belongs to
    See also:
    getBindings(), swapLabel(), swapWord(), shiftEdge()
Definition at line 68 of file parse.tcl.

TclNumber Parse::_cpointer = 0 [private]
 

pointer to the C structure

Definition at line 31 of file parse.tcl.

TclArray Parse::_isLeafNode [private]
 

information about each word on each level. This has mapps the levelId x wordIndex to a boolean flag indicating whether the adressed word is being modified or not. Definition at line 56 of file parse.tcl.

TclArray Parse::_treeHeight [private]
 

the height of each tree on each level. This hash mapps the levelId to the height. Note that this simply caches the values computed by parseHeight().

See also:
getHeight(), shiftEdge()
Definition at line 51 of file parse.tcl.

TclArray Parse::_wordDepth [private]
 

the depth of a word in a dependency tree on a level. This hash mapps levelId x wordIndex to the word depth. Note that this simply caches the values computed by parseWordDepth() and stores the mat the tcl layer for faster access.

See also:
getWordDepth(), shiftEdge()
Definition at line 45 of file parse.tcl.

TclArray Parse::_wordHeight [private]
 

the height of a word in a dependency tree on a level. This hash mapps levelId x wordIndex to the word height. Note that this simply caches the values computed by parseWordHeight() and stores them at the tcl layer for faster access.

See also:
getWordHeight(), shiftEdge()
Definition at line 38 of file parse.tcl.


The documentation for this class was generated from the following file:
XCDG 0.95 (20 Oct 2004)