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


Java MaltParserService.initializeParserModel方法代码示例

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


在下文中一共展示了MaltParserService.initializeParserModel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ParserMalt

import org.maltparser.MaltParserService; //导入方法依赖的package包/类
public ParserMalt(){
	
	try {

		Properties props = new Properties();
		props.put("customAnnotatorClass.cleanprefix", "ca.ualberta.exemplar.core.CleanPrefixAnnotator");
		props.put("customAnnotatorClass.locationjuxtaposition", "ca.ualberta.exemplar.core.LocationJuxtapositionAnnotator");
		props.put("customAnnotatorClass.removedashes", "ca.ualberta.exemplar.core.RemoveDashesAnnotator");
		props.put("annotators", "tokenize, ssplit, removedashes, pos, lemma, ner, cleanprefix, locationjuxtaposition");
		pipeline = new StanfordCoreNLP(props);

		maltParser = new MaltParserService();
		maltParser.initializeParserModel("-c " + Paths.MALT_PARSER_FILENAME
				+ " -w " + Paths.MALT_PARSER_DIRECTORY + " -m parse");
		
		// Used to map from malt relations to Stanford relations
		relationMap = new HashMap<String,String>();
		relationMap.put("measure", "npadvmod");

	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:U-Alberta,项目名称:exemplar,代码行数:24,代码来源:ParserMalt.java

示例2: main

import org.maltparser.MaltParserService; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	try {
		MaltParserService service =  new MaltParserService();
		// Inititalize the parser model 'model0' and sets the working directory to '.' and sets the logging file to 'parser.log'
		service.initializeParserModel("-c model0 -m parse -w . -lfi parser.log");
		
		// Creates an array of tokens, which contains the Swedish sentence 'Grundavdraget upphör alltså vid en taxerad inkomst på 52500 kr.'
		// in the CoNLL data format.
		String[] tokens = new String[11];
		tokens[0] = "1\tGrundavdraget\t_\tN\tNN\tDD|SS";
		tokens[1] = "2\tupphör\t_\tV\tVV\tPS|SM";
		tokens[2] = "3\talltså\t_\tAB\tAB\tKS";
		tokens[3] = "4\tvid\t_\tPR\tPR\t_";
		tokens[4] = "5\ten\t_\tN\tEN\t_";
		tokens[5] = "6\ttaxerad\t_\tP\tTP\tPA";
		tokens[6] = "7\tinkomst\t_\tN\tNN\t_";
		tokens[7] = "8\tpå\t_\tPR\tPR\t_";
		tokens[8] = "9\t52500\t_\tR\tRO\t_";
		tokens[9] = "10\tkr\t_\tN\tNN\t_";
		tokens[10] = "11\t.\t_\tP\tIP\t_";
		// Parses the Swedish sentence above
		String[] outputTokens = service.parseTokens(tokens);
		// Outputs the with the head index and dependency type information
		for (int i = 0; i < outputTokens.length; i++) {
			System.out.println(outputTokens[i]);
		}
		// Terminates the parser model
		service.terminateParserModel();
	} catch (MaltChainedException e) {
		System.err.println("MaltParser exception: " + e.getMessage());
	}
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:36,代码来源:ParseSentence3.java

示例3: main

import org.maltparser.MaltParserService; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	try {
		MaltParserService service =  new MaltParserService();
		// Inititalize the parser model 'model0' and sets the working directory to '.' and sets the logging file to 'parser.log'
		service.initializeParserModel("-c model0 -m parse -w . -lfi parser.log");
		
		// Creates an array of tokens, which contains the Swedish sentence 'Grundavdraget upphör alltså vid en taxerad inkomst på 52500 kr.'
		// in the CoNLL data format.
		String[] tokens = new String[11];
		tokens[0] = "1\tGrundavdraget\t_\tN\tNN\tDD|SS";
		tokens[1] = "2\tupphör\t_\tV\tVV\tPS|SM";
		tokens[2] = "3\talltså\t_\tAB\tAB\tKS";
		tokens[3] = "4\tvid\t_\tPR\tPR\t_";
		tokens[4] = "5\ten\t_\tN\tEN\t_";
		tokens[5] = "6\ttaxerad\t_\tP\tTP\tPA";
		tokens[6] = "7\tinkomst\t_\tN\tNN\t_";
		tokens[7] = "8\tpå\t_\tPR\tPR\t_";
		tokens[8] = "9\t52500\t_\tR\tRO\t_";
		tokens[9] = "10\tkr\t_\tN\tNN\t_";
		tokens[10] = "11\t.\t_\tP\tIP\t_";
		// Parses the Swedish sentence above
		DependencyStructure graph = service.parse(tokens);
		// Outputs the dependency graph created by MaltParser.
		System.out.println(graph);
		// Terminates the parser model
		service.terminateParserModel();
	} catch (MaltChainedException e) {
		System.err.println("MaltParser exception: " + e.getMessage());
	}
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:34,代码来源:ParseSentence1.java

示例4: main

import org.maltparser.MaltParserService; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	try {
		MaltParserService service =  new MaltParserService();
		// Inititalize the parser model 'model0' and sets the working directory to '.' and sets the logging file to 'parser.log'
		service.initializeParserModel("-u jar:file:mco_nested_in_jar.jar!/model0.mco -m parse -w . -lfi parser.log -v debug");

		// Creates an array of tokens, which contains the Swedish sentence 'Grundavdraget upphör alltså vid en taxerad inkomst på 52500 kr.'
		// in the CoNLL data format.
		String[] tokens = new String[11];
		tokens[0] = "1\tGrundavdraget\t_\tN\tNN\tDD|SS";
		tokens[1] = "2\tupphör\t_\tV\tVV\tPS|SM";
		tokens[2] = "3\talltså\t_\tAB\tAB\tKS";
		tokens[3] = "4\tvid\t_\tPR\tPR\t_";
		tokens[4] = "5\ten\t_\tN\tEN\t_";
		tokens[5] = "6\ttaxerad\t_\tP\tTP\tPA";
		tokens[6] = "7\tinkomst\t_\tN\tNN\t_";
		tokens[7] = "8\tpå\t_\tPR\tPR\t_";
		tokens[8] = "9\t52500\t_\tR\tRO\t_";
		tokens[9] = "10\tkr\t_\tN\tNN\t_";
		tokens[10] = "11\t.\t_\tP\tIP\t_";
		// Parses the Swedish sentence above
		String[] outputTokens = service.parseTokens(tokens);
		// Outputs the with the head index and dependency type information
		for (int i = 0; i < outputTokens.length; i++) {
			System.out.println(outputTokens[i]);
		}
		// Terminates the parser model
		service.terminateParserModel();
	} catch (MaltChainedException e) {
		System.err.println("MaltParser exception: " + e.getMessage());
		e.printStackTrace();
	}
}
 
开发者ID:jhamalt,项目名称:maltparser,代码行数:37,代码来源:ParseSentence4.java


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