當前位置: 首頁>>代碼示例>>Java>>正文


Java OptionParser類代碼示例

本文整理匯總了Java中edu.berkeley.nlp.PCFGLA.OptionParser的典型用法代碼示例。如果您正苦於以下問題:Java OptionParser類的具體用法?Java OptionParser怎麽用?Java OptionParser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OptionParser類屬於edu.berkeley.nlp.PCFGLA包,在下文中一共展示了OptionParser類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import edu.berkeley.nlp.PCFGLA.OptionParser; //導入依賴的package包/類
public static void main(String[] args) {
	OptionParser optParser = new OptionParser(Options.class);
	Options opts = (Options) optParser.parse(args, true);
	// provide feedback on command-line arguments
	// System.out.println("Calling with " + optParser.getPassedInOptions());

	String fileName = opts.inFileName;
	try {
		PennTreeReader treeReader = new PennTreeReader(
				new InputStreamReader(new FileInputStream(fileName),
						Charset.forName("UTF-8")));// GB18030")));
		while (treeReader.hasNext()) {
			Tree<String> rootedTree = treeReader.next();
			// if (rootedTree.getChildren().size()>1)
			// System.err.println(rootedTree);
			if (rootedTree.getLabel().equals("ROOT"))
				rootedTree = rootedTree.getChildren().get(0);
			printDependencies(rootedTree);
		}

	} catch (Exception ex) {
		ex.printStackTrace();
	}

}
 
開發者ID:text-machine-lab,項目名稱:CliRel,代碼行數:26,代碼來源:PTBtoDep.java

示例2: main

import edu.berkeley.nlp.PCFGLA.OptionParser; //導入依賴的package包/類
public static void main(String[] args) {
	OptionParser optParser = new OptionParser(Options.class);
	Options opts = (Options) optParser.parse(args, true);

	List<Tree<String>> trainTrees = loadTrees(opts.path);
	ParserData pData = createGrammar(trainTrees, opts.smooth);

	if (pData.Save(opts.outFileName))
		System.out.println("Saved grammar.");
	else
		System.out.println("Saving failed!");
	System.exit(0);
}
 
開發者ID:text-machine-lab,項目名稱:CliRel,代碼行數:14,代碼來源:ObservedGrammarExtractor.java

示例3: main

import edu.berkeley.nlp.PCFGLA.OptionParser; //導入依賴的package包/類
public static void main(String[] args) {
	// String[] sentence = {
	// "1 The _ DT DT _ 4 NMOD _ _\n",
	// "2 luxury _ NN NN _ 4 NMOD _ _\n",
	// "3 auto _ NN NN _ 4 NMOD _ _\n",
	// "4 maker _ NN NN _ 7 SBJ _ _\n",
	// "5 last _ JJ JJ _ 6 NMOD _ _\n",
	// "6 year _ NN NN _ 7 VMOD _ _\n",
	// "7 sold _ VB VBD _ 0 ROOT _ _\n",
	// "8 1,214 _ CD CD _ 9 NMOD _ _\n",
	// "9 cars _ NN NNS _ 7 OBJ _ _\n",
	// "10 in _ IN IN _ 7 ADV _ _\n",
	// "11 the _ DT DT _ 12 NMOD _ _\n",
	// "12 U.S. _ NN NNP _ 10 PMOD _ _\n"};
	OptionParser optParser = new OptionParser(Options.class);
	Options opts = (Options) optParser.parse(args, true);
	// provide feedback on command-line arguments
	// System.out.println("Calling with " + optParser.getPassedInOptions());

	BufferedReader input = null;
	String fileName = opts.inFileName;
	try {
		input = new BufferedReader(new InputStreamReader(
				new FileInputStream(fileName), Charset.forName("UTF-8")));// GB18030")));
		String line = "";
		List<String> sentence = new ArrayList<String>();
		while ((line = input.readLine()) != null) {
			System.out.println(line);
			if (line.equals("")) {
				Tree<String> tree = turnIntoTree(sentence, opts.useFinePOS);
				System.out.println("( " + tree + ")");
				sentence = new LinkedList<String>();
			} else
				sentence.add(line);
		}

	} catch (Exception ex) {
		ex.printStackTrace();
	}

}
 
開發者ID:text-machine-lab,項目名稱:CliRel,代碼行數:42,代碼來源:DepToPTB.java


注:本文中的edu.berkeley.nlp.PCFGLA.OptionParser類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。