本文整理汇总了Java中edu.berkeley.nlp.util.CommandLineUtils类的典型用法代码示例。如果您正苦于以下问题:Java CommandLineUtils类的具体用法?Java CommandLineUtils怎么用?Java CommandLineUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommandLineUtils类属于edu.berkeley.nlp.util包,在下文中一共展示了CommandLineUtils类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import edu.berkeley.nlp.util.CommandLineUtils; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out
.println("usage: java GrammarSmoother \n"
+ "\t\t -i Input File for Grammar (Required)\n"
+ "\t\t -o Output File for Smoothed Grammar (Required)\n"
+ "\t\t -smooth Type of grammar smoothing used. This takes the maximum likelihood rule\n"
+ " probabilities and smooths them with each other. Current options are\n"
+ " 'NoSmoothing', 'SmoothAcrossParentSubstate', and 'SmoothAcrossParentBits'.\n"
+ "\t\t -grsm Grammar smoothing parameter, in range [0,1]. (Default: 0.1)\n");
System.exit(2);
}
// provide feedback on command-line arguments
System.out.print("Running with arguments: ");
for (String arg : args) {
System.out.print(" '" + arg + "'");
}
System.out.println("");
// parse the input arguments
Map<String, String> input = CommandLineUtils
.simpleCommandLineParser(args);
String outFileName = CommandLineUtils.getValueOrUseDefault(input, "-o",
null);
String inFileName = CommandLineUtils.getValueOrUseDefault(input, "-i",
null);
System.out.println("Loading grammar from " + inFileName + ".");
ParserData pData = ParserData.Load(inFileName);
if (pData == null) {
System.out.println("Failed to load grammar from file" + inFileName
+ ".");
System.exit(1);
}
Grammar gr = pData.getGrammar();
// double grammarSmoothing =
// Double.parseDouble(CommandLineUtils.getValueOrUseDefault(input,
// "-grsm","0.1"));
// String smootherStr = CommandLineUtils.getValueOrUseDefault(input,
// "-smooth", "NoSmoothing");
Smoother grSmoother = new SmoothAcrossParentBits(0.01, gr.splitTrees);
Smoother lexSmoother = new SmoothAcrossParentBits(0.1, gr.splitTrees);
gr.setSmoother(grSmoother);
// gr.smooth();
pData.gr = gr;
Lexicon lex = pData.getLexicon();
lex.setSmoother(lexSmoother);
pData.lex = lex;
if (pData.Save(outFileName))
System.out.println("Saving successful.");
else
System.out.println("Saving failed!");
System.exit(0);
}