当前位置: 首页>>代码示例>>Java>>正文


Java CommandLineUtils.getValueOrUseDefault方法代码示例

本文整理汇总了Java中edu.berkeley.nlp.util.CommandLineUtils.getValueOrUseDefault方法的典型用法代码示例。如果您正苦于以下问题:Java CommandLineUtils.getValueOrUseDefault方法的具体用法?Java CommandLineUtils.getValueOrUseDefault怎么用?Java CommandLineUtils.getValueOrUseDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.berkeley.nlp.util.CommandLineUtils的用法示例。


在下文中一共展示了CommandLineUtils.getValueOrUseDefault方法的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);

}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:65,代码来源:GrammarSmoother.java


注:本文中的edu.berkeley.nlp.util.CommandLineUtils.getValueOrUseDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。