inpro.irmrsc.parser
Class CandidateAnalysis

java.lang.Object
  extended by inpro.irmrsc.parser.CandidateAnalysis
All Implemented Interfaces:
java.lang.Comparable<CandidateAnalysis>

public class CandidateAnalysis
extends java.lang.Object
implements java.lang.Comparable<CandidateAnalysis>

A candidate analysis entertained by the SITDBSParser, most importantly consisting of a stack, a derivation history and the probability of the derivation.

The main parsing operations modifying a candidate analysis are implemented here: The classic top down parser actions predict (expand(Production)) and match (match(Symbol)), as well as the robust operations for insertions (insert(Symbol)), deletions (deletion(Symbol)) and repairs (repair(Symbol)). The probability of a derivation can be externally degraded, as in the reference-pruning-setting.

Author:
Andreas Peldszus

Field Summary
private  CandidateAnalysis mAntecedent
          the former analysis of which this is an extension
private  java.util.List<java.lang.String> mDerivation
          the sequence of all rules used in this derivation
private  double mFigureOfMerit
          the product of the derivations probability and the lookahead probability -- not used at the moment
private  java.util.List<java.lang.String> mLastDerive
          the sequence of rules used in the last incremental step of the derivation
private  double mProbability
          the product of all rule probabilities used in the derivation and all external mali
private  java.util.Deque<Symbol> mStack
          the sequence of nonterminal symbols that need to be accounted for
 
Constructor Summary
CandidateAnalysis(CandidateAnalysis ca)
          copy constructor
CandidateAnalysis(java.util.Deque<Symbol> mStack)
          constructor to initiate a chain of derivations
CandidateAnalysis(java.util.List<java.lang.String> mDerivation, java.util.List<java.lang.String> mLastDerive, CandidateAnalysis mAntecedent, java.util.Deque<Symbol> mStack, double mProbability, double mFigureOfMerit)
           
 
Method Summary
 int compareTo(CandidateAnalysis y)
           
 void consumeFiller(java.lang.String fillername)
          simply adds a filler to this derivation without changing anything else
 void degradeProbability(double f)
           
 CandidateAnalysis deletion(Symbol deletedToken)
          The robust 'deletion' parsing action: An expected but non-existing token is considered to be existing and simply matched.
 CandidateAnalysis expand(Production p)
          The 'predict' parsing action: The top stack element is popped and the symbols on the righthandside of the predicte rule are pushed onto the stack.
 CandidateAnalysis getAntecedent()
           
 double getFigureOfMerit()
           
 java.util.List<java.lang.String> getLastDerive()
           
 int getNumberOfDeletions()
           
 int getNumberOfInsertions()
           
 int getNumberOfMatches()
           
 int getNumberOfRepairs()
           
 double getProbability()
           
 java.util.Deque<Symbol> getStack()
           
 Symbol getTopSymbol()
           
 boolean hasRobustOperationsLately()
           
 CandidateAnalysis insert(Symbol insertedToken)
          The robust 'insertion' parsing action: A unexpected token is added to the derivation without altering the stack.
 boolean isCompletable(java.util.Set<Symbol> epsilonproductions)
           
 boolean isComplete()
           
private  CandidateAnalysis match_intern(java.lang.String deriveIdentifier)
           
 CandidateAnalysis match(Symbol nextToken)
          The 'match' parsing action: An expected token is matched.
 void newIncrementalStep(CandidateAnalysis oldCA)
          links this analysis to an antecedent analysis
 java.lang.String printDerivation()
           
 CandidateAnalysis repair(Symbol requiredToken)
          The robust 'repair' parsing action: An unexpected token is replaced by the expected token and simply matched.
 java.lang.String toFinalString()
           
 java.lang.String toFullString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mDerivation

private java.util.List<java.lang.String> mDerivation
the sequence of all rules used in this derivation


mLastDerive

private java.util.List<java.lang.String> mLastDerive
the sequence of rules used in the last incremental step of the derivation


mAntecedent

private CandidateAnalysis mAntecedent
the former analysis of which this is an extension


mStack

private java.util.Deque<Symbol> mStack
the sequence of nonterminal symbols that need to be accounted for


mProbability

private double mProbability
the product of all rule probabilities used in the derivation and all external mali


mFigureOfMerit

private double mFigureOfMerit
the product of the derivations probability and the lookahead probability -- not used at the moment

Constructor Detail

CandidateAnalysis

public CandidateAnalysis(java.util.List<java.lang.String> mDerivation,
                         java.util.List<java.lang.String> mLastDerive,
                         CandidateAnalysis mAntecedent,
                         java.util.Deque<Symbol> mStack,
                         double mProbability,
                         double mFigureOfMerit)

CandidateAnalysis

public CandidateAnalysis(java.util.Deque<Symbol> mStack)
constructor to initiate a chain of derivations


CandidateAnalysis

public CandidateAnalysis(CandidateAnalysis ca)
copy constructor

Method Detail

expand

public CandidateAnalysis expand(Production p)
The 'predict' parsing action: The top stack element is popped and the symbols on the righthandside of the predicte rule are pushed onto the stack. The derivations probability is multiplied with the probability of the predicted rule.

Parameters:
p - the grammar rule that is predicted
Returns:
the resulting new candidate analysis

repair

public CandidateAnalysis repair(Symbol requiredToken)
The robust 'repair' parsing action: An unexpected token is replaced by the expected token and simply matched. The stack's top element is popped.

Parameters:
requiredToken - the token that was expected next in the derivation
Returns:
the resulting new candidate analysis

deletion

public CandidateAnalysis deletion(Symbol deletedToken)
The robust 'deletion' parsing action: An expected but non-existing token is considered to be existing and simply matched. The stack's top element is popped.

Parameters:
deletedToken - the token that was expected but not found
Returns:
the resulting new candidate analysis

match

public CandidateAnalysis match(Symbol nextToken)
The 'match' parsing action: An expected token is matched. The stack's top element is popped.

Parameters:
nextToken - the expected token
Returns:
the resulting new candidate analysis

match_intern

private CandidateAnalysis match_intern(java.lang.String deriveIdentifier)

insert

public CandidateAnalysis insert(Symbol insertedToken)
The robust 'insertion' parsing action: A unexpected token is added to the derivation without altering the stack.

Parameters:
insertedToken - the unexpected token to be inserted
Returns:
the resulting new candidate analysis

consumeFiller

public void consumeFiller(java.lang.String fillername)
simply adds a filler to this derivation without changing anything else


newIncrementalStep

public void newIncrementalStep(CandidateAnalysis oldCA)
links this analysis to an antecedent analysis


getAntecedent

public CandidateAnalysis getAntecedent()

isComplete

public boolean isComplete()

isCompletable

public boolean isCompletable(java.util.Set<Symbol> epsilonproductions)

getTopSymbol

public Symbol getTopSymbol()

getStack

public java.util.Deque<Symbol> getStack()

getProbability

public double getProbability()

degradeProbability

public void degradeProbability(double f)

getFigureOfMerit

public double getFigureOfMerit()

getLastDerive

public java.util.List<java.lang.String> getLastDerive()

hasRobustOperationsLately

public boolean hasRobustOperationsLately()

getNumberOfMatches

public int getNumberOfMatches()

getNumberOfRepairs

public int getNumberOfRepairs()

getNumberOfInsertions

public int getNumberOfInsertions()

getNumberOfDeletions

public int getNumberOfDeletions()

compareTo

public int compareTo(CandidateAnalysis y)
Specified by:
compareTo in interface java.lang.Comparable<CandidateAnalysis>

toFinalString

public java.lang.String toFinalString()

toFullString

public java.lang.String toFullString()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

printDerivation

public java.lang.String printDerivation()