edu.stanford.nlp.parser.lexparser
Class Options

java.lang.Object
  extended by edu.stanford.nlp.parser.lexparser.Options
All Implemented Interfaces:
Serializable

public class Options
extends Object
implements Serializable

This class contains options to the parser which MUST be the SAME at both training and testing (parsing) time in order for the parser to work properly. It also contains an object which stores the options used by the parser at training time and an object which contains default options for test use. (TODO: the test use object isn't there yet.)

Author:
Dan Klein, Christopher Manning
See Also:
Serialized Form

Nested Class Summary
static class Options.LexOptions
           
 
Field Summary
 boolean coarseDistance
          Use coarser distance (4 bins) in dependency calculations
 boolean dcTags
          "double count" tags rewrites as word in PCFG and Dep parser.
 boolean directional
          Whether dependency grammar considers left/right direction.
 boolean distance
          Use distance bins in the dependency calculations
 boolean doDep
          Do a dependency parse of the sentence.
 boolean doPCFG
          Do a PCFG parse of the sentence.
 boolean forceCNF
          Forces parsing with strictly CNF grammar -- unary chains are converted to XP&YP symbols and back
 boolean freeDependencies
          if true, any child can be the head (seems rather bad!)
 boolean genStop
           
 Options.LexOptions lexOptions
           
 boolean nodePrune
          If true, inside the factored parser, remove any node from the final chosen tree which improves the PCFG score.
 TestOptions testOptions
          Note that the TestOptions is transient.
 TreebankLangParserParams tlpParams
          The treebank-specific parser parameters to use.
 TrainOptions trainOptions
           
 boolean useSmoothTagProjection
           
 boolean useUnigramWordSmoothing
           
 
Constructor Summary
Options()
           
Options(TreebankLangParserParams tlpParams)
           
 
Method Summary
 void display()
           
 TreebankLanguagePack langpack()
           
 void readData(BufferedReader in)
          Populates data in this Options from the character stream.
 int setOption(String[] flags, int i)
          Set an option based on a String array in the style of commandline flags.
 int setOptionOrWarn(String[] flags, int i)
          Set an option based on a String array in the style of commandline flags.
 void setOptions(String... flags)
          Set options based on a String array in the style of commandline flags.
 void setOptions(String[] flags, int startIndex, int endIndexPlusOne)
          Set options based on a String array in the style of commandline flags.
 void setOptionsOrWarn(String... flags)
          Set options based on a String array in the style of commandline flags.
 void setOptionsOrWarn(String[] flags, int startIndex, int endIndexPlusOne)
          Set options based on a String array in the style of commandline flags.
 void writeData(Writer w)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lexOptions

public Options.LexOptions lexOptions

tlpParams

public TreebankLangParserParams tlpParams
The treebank-specific parser parameters to use.


forceCNF

public boolean forceCNF
Forces parsing with strictly CNF grammar -- unary chains are converted to XP&YP symbols and back


doPCFG

public boolean doPCFG
Do a PCFG parse of the sentence. If both variables are on, also do a combined parse of the sentence.


doDep

public boolean doDep
Do a dependency parse of the sentence.


freeDependencies

public boolean freeDependencies
if true, any child can be the head (seems rather bad!)


directional

public boolean directional
Whether dependency grammar considers left/right direction. Good.


genStop

public boolean genStop

useSmoothTagProjection

public boolean useSmoothTagProjection

useUnigramWordSmoothing

public boolean useUnigramWordSmoothing

distance

public boolean distance
Use distance bins in the dependency calculations


coarseDistance

public boolean coarseDistance
Use coarser distance (4 bins) in dependency calculations


dcTags

public boolean dcTags
"double count" tags rewrites as word in PCFG and Dep parser. Good for combined parsing only (it used to not kick in for PCFG parsing). This option is only used at Test time, but it is now in Options, so the correct choice for a grammar is recorded by a serialized parser. You should turn this off for a vanilla PCFG parser.


nodePrune

public boolean nodePrune
If true, inside the factored parser, remove any node from the final chosen tree which improves the PCFG score. This was added as the dependency factor tends to encourage 'deep' trees.


trainOptions

public TrainOptions trainOptions

testOptions

public transient TestOptions testOptions
Note that the TestOptions is transient. This means that whatever options get set at creation time are forgotten when the parser is serialized. If you want an option to be remembered when the parser is reloaded, put it in either TrainOptions or in this class itself.

Constructor Detail

Options

public Options()

Options

public Options(TreebankLangParserParams tlpParams)
Method Detail

setOptions

public void setOptions(String... flags)
Set options based on a String array in the style of commandline flags. This method goes through the array until it ends, processing options, as for setOption(java.lang.String[], int).

Parameters:
flags - Array of options (or as a varargs list of arguments). The options passed in should be specified like command-line arguments, including with an initial minus sign for example, {"-outputFormat", "typedDependencies", "-maxLength", "70"}
Throws:
IllegalArgumentException - If an unknown flag is passed in

setOptions

public void setOptions(String[] flags,
                       int startIndex,
                       int endIndexPlusOne)
Set options based on a String array in the style of commandline flags. This method goes through the array until it ends, processing options, as for setOption(java.lang.String[], int).

Parameters:
flags - Array of options. The options passed in should be specified like command-line arguments, including with an initial minus sign for example, {"-outputFormat", "typedDependencies", "-maxLength", "70"}
startIndex - The index in the array to begin processing options at
endIndexPlusOne - A number one greater than the last array index at which options should be processed
Throws:
IllegalArgumentException - If an unknown flag is passed in

setOptionsOrWarn

public void setOptionsOrWarn(String... flags)
Set options based on a String array in the style of commandline flags. This method goes through the array until it ends, processing options, as for setOption(java.lang.String[], int).

Parameters:
flags - Array of options (or as a varargs list of arguments). The options passed in should be specified like command-line arguments, including with an initial minus sign for example, {"-outputFormat", "typedDependencies", "-maxLength", "70"}
Throws:
IllegalArgumentException - If an unknown flag is passed in

setOptionsOrWarn

public void setOptionsOrWarn(String[] flags,
                             int startIndex,
                             int endIndexPlusOne)
Set options based on a String array in the style of commandline flags. This method goes through the array until it ends, processing options, as for setOption(java.lang.String[], int).

Parameters:
flags - Array of options. The options passed in should be specified like command-line arguments, including with an initial minus sign for example, {"-outputFormat", "typedDependencies", "-maxLength", "70"}
startIndex - The index in the array to begin processing options at
endIndexPlusOne - A number one greater than the last array index at which options should be processed
Throws:
IllegalArgumentException - If an unknown flag is passed in

setOptionOrWarn

public int setOptionOrWarn(String[] flags,
                           int i)
Set an option based on a String array in the style of commandline flags. The option may be either one known by the Options object, or one recognized by the TreebankLangParserParams which has already been set up inside the Options object, and then the option is set in the language-particular TreebankLangParserParams. Note that despite this method being an instance method, many flags are actually set as static class variables in the Train and Test classes (this should be fixed some day). Some options (there are many others; see the source code):

Parameters:
flags - An array of options arguments, command-line style. E.g. {"-maxLength", "50"}.
i - The index in flags to start at when processing an option
Returns:
The index in flags of the position after the last element used in processing this option. If the current array position cannot be processed as a valid option, then a warning message is printed to stderr and the return value is i+1

setOption

public int setOption(String[] flags,
                     int i)
Set an option based on a String array in the style of commandline flags. The option may be either one known by the Options object, or one recognized by the TreebankLangParserParams which has already been set up inside the Options object, and then the option is set in the language-particular TreebankLangParserParams. Note that despite this method being an instance method, many flags are actually set as static class variables in the Train and Test classes (this should be fixed some day). Some options (there are many others; see the source code):

Parameters:
flags - An array of options arguments, command-line style. E.g. {"-maxLength", "50"}.
i - The index in flags to start at when processing an option
Returns:
The index in flags of the position after the last element used in processing this option.
Throws:
IllegalArgumentException - If the current array position cannot be processed as a valid option

langpack

public TreebankLanguagePack langpack()
Returns:
The treebank language pack for the treebank the parser is trained on.

display

public void display()

writeData

public void writeData(Writer w)

readData

public void readData(BufferedReader in)
              throws IOException
Populates data in this Options from the character stream.

Parameters:
in - The Reader
Throws:
IOException - If there is a problem reading data


Stanford NLP Group