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


Java KeywordExtractor类代码示例

本文整理汇总了Java中info.ephyra.questionanalysis.KeywordExtractor的典型用法代码示例。如果您正苦于以下问题:Java KeywordExtractor类的具体用法?Java KeywordExtractor怎么用?Java KeywordExtractor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: extractKeytermsKeyphrases

import info.ephyra.questionanalysis.KeywordExtractor; //导入依赖的package包/类
public void extractKeytermsKeyphrases(String questionText,
		List<String> keyterms, List<String> keyphrases) {

	// normalize question
	String qn = QuestionNormalizer.normalize(questionText);

	// resolve verb constructions with auxiliaries
	String verbMod = (QuestionNormalizer.handleAuxiliaries(qn))[0];

	// extract keywords
	String[] kws = KeywordExtractor.getKeywords(verbMod);
	log(TPLogEntry.KEYTERM, "  Keywords: " + Arrays.toString(kws));

	for (String kw : kws) {
		keyterms.add(kw);
	}
}
 
开发者ID:brmson,项目名称:blanqa,代码行数:18,代码来源:EphyraKeytermExtractor.java

示例2: askOther

import info.ephyra.questionanalysis.KeywordExtractor; //导入依赖的package包/类
/**
 * Asks Ephyra an 'other' question.
 * 
 * @param question other question
 * @return array of results
 */
public final Result[] askOther(String question) {
	// initialize pipeline
	initOther();
	
	// query generation
	MsgPrinter.printGeneratingQueries();
	String qn = QuestionNormalizer.normalize(question);
	MsgPrinter.printNormalization(qn);  // print normalized question string
	Logger.logNormalization(qn);  // log normalized question string
	String[] kws = KeywordExtractor.getKeywords(qn);
	AnalyzedQuestion aq = new AnalyzedQuestion(question);
	aq.setKeywords(kws);
	aq.setFactoid(false);
	BagOfWordsG gen = new BagOfWordsG();
	
	Query[] queries = gen.generateQueries(aq);
	for (int q = 0; q < queries.length; q++)
		queries[q].setOriginalQueryString(question);
	
	MsgPrinter.printQueryStrings(queries);  // print query strings
	Logger.logQueryStrings(queries);  // log query strings
	
	// search
	MsgPrinter.printSearching();
	Result[] results = Search.doSearch(queries);
	
	// answer selection
	MsgPrinter.printSelectingAnswers();
	results = AnswerSelection.getResults(results, Integer.MAX_VALUE, 0);
	
	return results;
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:39,代码来源:EphyraTREC13To16.java

示例3: apply

import info.ephyra.questionanalysis.KeywordExtractor; //导入依赖的package包/类
/**
 * Filters a single <code>Result</code> object.
 * 
 * @param result result to filter
 * @return result with manipulated score or <code>null</code> if the result
 * 		   is dropped
 */
public Result apply(Result result) {
	String[] kws = result.getQuery().getAnalyzedQuestion().getKeywords();
	String[] wordsInResult = KeywordExtractor.tokenize(result.getAnswer());
	
	int k = kws.length;
	int m = getNumberOfMatches(kws, wordsInResult);
	
	if (m >= Math.floor(Math.sqrt(k - 1)) + 1) {
		result.incScore(m);  // manipulate score
		return result;  // keep result
	}
	
	return null;  // drop result
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:22,代码来源:NumberOfKeywordsFilter.java

示例4: apply

import info.ephyra.questionanalysis.KeywordExtractor; //导入依赖的package包/类
/**
 * Filters a single <code>Result</code> object.
 * 
 * @param result result to filter
 * @return result or <code>null</code>
 */
public Result apply(Result result) {
	String[] tokens = KeywordExtractor.tokenize(result.getAnswer());
	String[] kws = result.getQuery().getAnalyzedQuestion().getKeywords();
	for (String token : tokens)
		for (String kw : kws)
			if (token.equalsIgnoreCase(kw)) return null;
	
	return result;
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:16,代码来源:QuestionKeywordsFilter.java

示例5: main

import info.ephyra.questionanalysis.KeywordExtractor; //导入依赖的package包/类
public static void main(String[] args) {
		TEST_TERM_DOWMLOD = true;
		
		MsgPrinter.enableStatusMsgs(true);
		MsgPrinter.enableErrorMsgs(true);
		
		// create tokenizer
		MsgPrinter.printStatusMsg("Creating tokenizer...");
		if (!OpenNLP.createTokenizer("res/nlp/tokenizer/opennlp/EnglishTok.bin.gz"))
			MsgPrinter.printErrorMsg("Could not create tokenizer.");
//		LingPipe.createTokenizer();
		
//		// create sentence detector
//		MsgPrinter.printStatusMsg("Creating sentence detector...");
//		if (!OpenNLP.createSentenceDetector("res/nlp/sentencedetector/opennlp/EnglishSD.bin.gz"))
//			MsgPrinter.printErrorMsg("Could not create sentence detector.");
//		LingPipe.createSentenceDetector();
		
		// create stemmer
		MsgPrinter.printStatusMsg("Creating stemmer...");
		SnowballStemmer.create();
		
//		// create part of speech tagger
//		MsgPrinter.printStatusMsg("Creating POS tagger...");
//		if (!OpenNLP.createPosTagger("res/nlp/postagger/opennlp/tag.bin.gz",
//									 "res/nlp/postagger/opennlp/tagdict"))
//			MsgPrinter.printErrorMsg("Could not create OpenNLP POS tagger.");
//		if (!StanfordPosTagger.init("res/nlp/postagger/stanford/" +
//				"train-wsj-0-18.holder"))
//			MsgPrinter.printErrorMsg("Could not create Stanford POS tagger.");
		
//		// create chunker
//		MsgPrinter.printStatusMsg("Creating chunker...");
//		if (!OpenNLP.createChunker("res/nlp/phrasechunker/opennlp/" +
//								   "EnglishChunk.bin.gz"))
//			MsgPrinter.printErrorMsg("Could not create chunker.");
		
		// create named entity taggers
		MsgPrinter.printStatusMsg("Creating NE taggers...");
		NETagger.loadListTaggers("res/nlp/netagger/lists/");
		NETagger.loadRegExTaggers("res/nlp/netagger/patterns.lst");
		MsgPrinter.printStatusMsg("  ...loading models");
//		if (!NETagger.loadNameFinders("res/nlp/netagger/opennlp/"))
//			MsgPrinter.printErrorMsg("Could not create OpenNLP NE tagger.");
//		if (!StanfordNeTagger.isInitialized() && !StanfordNeTagger.init())
//			MsgPrinter.printErrorMsg("Could not create Stanford NE tagger.");
		MsgPrinter.printStatusMsg("  ...done");
		
		WikipediaTermImportanceFilter wtif = new WikipediaTermImportanceFilter(NO_NORMALIZATION, NO_NORMALIZATION, false);
		TRECTarget[] targets = TREC13To16Parser.loadTargets(args[0]);
		for (TRECTarget target : targets) {
			String question = target.getTargetDesc();
			
			// query generation
			MsgPrinter.printGeneratingQueries();
			String qn = QuestionNormalizer.normalize(question);
			MsgPrinter.printNormalization(qn);  // print normalized question string
			Logger.logNormalization(qn);  // log normalized question string
			String[] kws = KeywordExtractor.getKeywords(qn);
			AnalyzedQuestion aq = new AnalyzedQuestion(question);
			aq.setKeywords(kws);
			aq.setFactoid(false);
			
			Query[] queries = new BagOfWordsG().generateQueries(aq);
			for (int q = 0; q < queries.length; q++)
				queries[q].setOriginalQueryString(question);
			
			Result[] results = new Result[1];
			results[0] = new Result("This would be the answer", queries[0]);
			wtif.apply(results);
		}
	}
 
开发者ID:claritylab,项目名称:lucida,代码行数:73,代码来源:WikipediaTermImportanceFilter.java

示例6: main

import info.ephyra.questionanalysis.KeywordExtractor; //导入依赖的package包/类
public static void main(String[] args) {
		TEST_TARGET_GENERATION = true;
		
		MsgPrinter.enableStatusMsgs(true);
		MsgPrinter.enableErrorMsgs(true);
		
		// create tokenizer
		MsgPrinter.printStatusMsg("Creating tokenizer...");
		if (!OpenNLP.createTokenizer("res/nlp/tokenizer/opennlp/EnglishTok.bin.gz"))
			MsgPrinter.printErrorMsg("Could not create tokenizer.");
//		LingPipe.createTokenizer();
		
		// create sentence detector
//		MsgPrinter.printStatusMsg("Creating sentence detector...");
//		if (!OpenNLP.createSentenceDetector("res/nlp/sentencedetector/opennlp/EnglishSD.bin.gz"))
//			MsgPrinter.printErrorMsg("Could not create sentence detector.");
//		LingPipe.createSentenceDetector();
		
		// create stemmer
		MsgPrinter.printStatusMsg("Creating stemmer...");
		SnowballStemmer.create();
		
		// create part of speech tagger
		MsgPrinter.printStatusMsg("Creating POS tagger...");
		if (!OpenNLP.createPosTagger("res/nlp/postagger/opennlp/tag.bin.gz",
									 "res/nlp/postagger/opennlp/tagdict"))
			MsgPrinter.printErrorMsg("Could not create OpenNLP POS tagger.");
//		if (!StanfordPosTagger.init("res/nlp/postagger/stanford/" +
//				"train-wsj-0-18.holder"))
//			MsgPrinter.printErrorMsg("Could not create Stanford POS tagger.");
		
		// create chunker
		MsgPrinter.printStatusMsg("Creating chunker...");
		if (!OpenNLP.createChunker("res/nlp/phrasechunker/opennlp/" +
								   "EnglishChunk.bin.gz"))
			MsgPrinter.printErrorMsg("Could not create chunker.");
		
		// create named entity taggers
		MsgPrinter.printStatusMsg("Creating NE taggers...");
		NETagger.loadListTaggers("res/nlp/netagger/lists/");
		NETagger.loadRegExTaggers("res/nlp/netagger/patterns.lst");
		MsgPrinter.printStatusMsg("  ...loading models");
//		if (!NETagger.loadNameFinders("res/nlp/netagger/opennlp/"))
//			MsgPrinter.printErrorMsg("Could not create OpenNLP NE tagger.");
		if (!StanfordNeTagger.isInitialized() && !StanfordNeTagger.init())
			MsgPrinter.printErrorMsg("Could not create Stanford NE tagger.");
		MsgPrinter.printStatusMsg("  ...done");
		
		WebTermImportanceFilter wtif = new TargetGeneratorTest(NO_NORMALIZATION);
		TRECTarget[] targets = TREC13To16Parser.loadTargets(args[0]);
		for (TRECTarget target : targets) {
			String question = target.getTargetDesc();
			
			// query generation
			MsgPrinter.printGeneratingQueries();
			String qn = QuestionNormalizer.normalize(question);
			MsgPrinter.printNormalization(qn);  // print normalized question string
			Logger.logNormalization(qn);  // log normalized question string
			String[] kws = KeywordExtractor.getKeywords(qn);
			AnalyzedQuestion aq = new AnalyzedQuestion(question);
			aq.setKeywords(kws);
			aq.setFactoid(false);
			
			Query[] queries = new BagOfWordsG().generateQueries(aq);
			for (int q = 0; q < queries.length; q++)
				queries[q].setOriginalQueryString(question);
			
			Result[] results = new Result[1];
			results[0] = new Result("This would be the answer", queries[0]);
			wtif.apply(results);
		}
	}
 
开发者ID:claritylab,项目名称:lucida,代码行数:73,代码来源:WebTermImportanceFilter.java


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