edu.stanford.nlp.parser.shiftreduce.ShiftReduceOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-corenlp Show documentation
Show all versions of stanford-corenlp Show documentation
Stanford CoreNLP provides a set of natural language analysis tools which can take raw English language text input and give the base forms of words, their parts of speech, whether they are names of companies, people, etc., normalize dates, times, and numeric quantities, mark up the structure of sentences in terms of phrases and word dependencies, and indicate which noun phrases refer to the same entities. It provides the foundational building blocks for higher level text understanding applications.
package edu.stanford.nlp.parser.shiftreduce;
import edu.stanford.nlp.parser.lexparser.Options;
import edu.stanford.nlp.parser.lexparser.TestOptions;
import edu.stanford.nlp.parser.lexparser.TrainOptions;
import edu.stanford.nlp.util.ErasureUtils;
public class ShiftReduceOptions extends Options {
@Override
public TrainOptions newTrainOptions() {
return new ShiftReduceTrainOptions();
}
@Override
public TestOptions newTestOptions() {
return new ShiftReduceTestOptions();
}
ShiftReduceTrainOptions trainOptions() {
return ErasureUtils.uncheckedCast(trainOptions);
}
ShiftReduceTestOptions testOptions() {
return ErasureUtils.uncheckedCast(testOptions);
}
public boolean compoundUnaries = true;
public String featureFactoryClass = "edu.stanford.nlp.parser.shiftreduce.BasicFeatureFactory";
protected int setOptionFlag(String[] args, int i) {
int j = super.setOptionFlag(args, i);
if (i != j) {
return j;
}
if (args[i].equalsIgnoreCase("-beamSize")) {
testOptions().beamSize = Integer.valueOf(args[i + 1]);
i += 2;
} else if (args[i].equalsIgnoreCase("-trainBeamSize")) {
trainOptions().beamSize = Integer.valueOf(args[i + 1]);
i += 2;
} else if (args[i].equalsIgnoreCase("-compoundUnaries")) {
compoundUnaries = true;
i++;
} else if (args[i].equalsIgnoreCase("-nocompoundUnaries")) {
compoundUnaries = false;
i++;
} else if (args[i].equalsIgnoreCase("-featureFactory")) {
featureFactoryClass = args[i + 1];
i += 2;
} else if (args[i].equalsIgnoreCase("-averagedModels")) {
trainOptions().averagedModels = Integer.valueOf(args[i + 1]);
i += 2;
} else if (args[i].equalsIgnoreCase("-cvAveragedModels")) {
trainOptions().cvAveragedModels = true;
i++;
} else if (args[i].equalsIgnoreCase("-noCVAveragedModels")) {
trainOptions().cvAveragedModels = false;
i++;
} else if (args[i].equalsIgnoreCase("-retrainAfterCutoff")) {
trainOptions().retrainAfterCutoff = true;
i++;
} else if (args[i].equalsIgnoreCase("-noRetrainAfterCutoff")) {
trainOptions().retrainAfterCutoff = false;
i++;
} else if (args[i].equalsIgnoreCase("-trainingMethod")) {
trainOptions().trainingMethod = ShiftReduceTrainOptions.TrainingMethod.valueOf(args[i + 1].toUpperCase());
if (trainOptions().trainingMethod == ShiftReduceTrainOptions.TrainingMethod.BEAM ||
trainOptions().trainingMethod == ShiftReduceTrainOptions.TrainingMethod.REORDER_BEAM) {
if (trainOptions().beamSize <= 0) {
trainOptions().beamSize = ShiftReduceTrainOptions.DEFAULT_BEAM_SIZE;
}
if (testOptions().beamSize <= 0) {
testOptions().beamSize = trainOptions().beamSize;
}
}
i += 2;
} else if (args[i].equalsIgnoreCase("-featureFrequencyCutoff")) {
trainOptions().featureFrequencyCutoff = Integer.valueOf(args[i + 1]);
i += 2;
} else if (args[i].equalsIgnoreCase("-saveIntermediateModels")) {
trainOptions().saveIntermediateModels = true;
i++;
} else if (args[i].equalsIgnoreCase("-nosaveIntermediateModels")) {
trainOptions().saveIntermediateModels = false;
i++;
} else if (args[i].equalsIgnoreCase("-oracleShiftToBinary")) {
trainOptions().oracleShiftToBinary = true;
i++;
} else if (args[i].equalsIgnoreCase("-oracleBinaryToShift")) {
trainOptions().oracleBinaryToShift = true;
i++;
} else if (args[i].equalsIgnoreCase("-recordBinarized")) {
testOptions().recordBinarized = args[i + 1];
i += 2;
} else if (args[i].equalsIgnoreCase("-recordDebinarized")) {
testOptions().recordDebinarized = args[i + 1];
i += 2;
}
return i;
}
private static final long serialVersionUID = 1L;
}