edu.cmu.minorthird.text.mixup
Class MixupInterpreter

java.lang.Object
  extended by edu.cmu.minorthird.text.mixup.MixupInterpreter

public class MixupInterpreter
extends java.lang.Object


Constructor Summary
MixupInterpreter()
           
MixupInterpreter(MixupProgram p)
           
MixupInterpreter(MixupProgram p, MonotonicTextLabels rootLabels)
           
 
Method Summary
 void createLevel(java.lang.String newLevelName, java.lang.String levelType, java.lang.String pattern)
          Creates a new level.
 void eval()
          Runs the current program on the current state of labels (current level).
 void eval(MonotonicTextLabels labels)
          Effectively clears the current state and executes the current program on the specified TextLabels.
 MonotonicTextLabels getCurrentLabels()
          Returns the TextLabels associated with the current level
 java.lang.String getCurrentLevel()
          Returns the name of the current level or null if no TextLabels have been added or created because the program has not yet been evaluated.
 MonotonicTextLabels getLabelsForLevel(java.lang.String level)
          Returns the TextLabels associated with the given level name or null if the level doesn't exist
 MixupProgram getProgram()
          Returns the MixupProgram that this interpreter will execute if the eval method is called.
 void importLabelsFromLevel(java.lang.String importLevel, java.lang.String oldType, java.lang.String newType)
          imports labels from specified level to the current level
 void offLevel(java.lang.String levelName)
          Moves up one level in the stack of labels
 void onLevel(java.lang.String levelName)
          Makes the current level be the given level name.
 void setProgram(MixupProgram p)
          Sets the MixupProgram that this interpreter will execute when the eval method is called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MixupInterpreter

public MixupInterpreter()

MixupInterpreter

public MixupInterpreter(MixupProgram p)

MixupInterpreter

public MixupInterpreter(MixupProgram p,
                        MonotonicTextLabels rootLabels)
Method Detail

eval

public void eval(MonotonicTextLabels labels)
Effectively clears the current state and executes the current program on the specified TextLabels. The specified labels will become the root level of the new labels hierarchy.


eval

public void eval()
Runs the current program on the current state of labels (current level). This method is useful if you have already executed a program, called setProgram() and want to run the new progam against the current state of the labels.


setProgram

public void setProgram(MixupProgram p)
Sets the MixupProgram that this interpreter will execute when the eval method is called.


getProgram

public MixupProgram getProgram()
Returns the MixupProgram that this interpreter will execute if the eval method is called.


getLabelsForLevel

public MonotonicTextLabels getLabelsForLevel(java.lang.String level)
Returns the TextLabels associated with the given level name or null if the level doesn't exist


getCurrentLevel

public java.lang.String getCurrentLevel()
Returns the name of the current level or null if no TextLabels have been added or created because the program has not yet been evaluated.


getCurrentLabels

public MonotonicTextLabels getCurrentLabels()
Returns the TextLabels associated with the current level


onLevel

public void onLevel(java.lang.String levelName)
Makes the current level be the given level name. Throws an exception if the given level name doesn't exist.


offLevel

public void offLevel(java.lang.String levelName)
Moves up one level in the stack of labels


createLevel

public void createLevel(java.lang.String newLevelName,
                        java.lang.String levelType,
                        java.lang.String pattern)
Creates a new level. This specified level type indicates what kind of level to be created. Allowed types are: pseudotoken, filter, re, and split.

pseudotoken - This type of level creates a new text base with a different tokenization scheme. The new scheme is the same as the original scheme except that tokens in the span type specified in pattern are all merged into a single token.

filter - This type of level creates a new text base that only contains the text inside instances of the span type specified in pattern. Each instance is placed in a separate document in the new text base.

re - This type of level creates a new text base with a new tokenization scheme. In this case the tokenization scheme is defined by the regular expression specified in pattern. Only matches to this regex are considered tokens in the new text base.

split - This type of level is similar to re except that matches to the regex are used to separate the tokens. That is everything in between matches is considered a single token.


importLabelsFromLevel

public void importLabelsFromLevel(java.lang.String importLevel,
                                  java.lang.String oldType,
                                  java.lang.String newType)
imports labels from specified level to the current level