• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AnnotationPipeline类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: prepareSUTParser

import edu.stanford.nlp.pipeline.AnnotationPipeline; //导入依赖的package包/类
/**
 * Prepares the check for a temporal expression.
 * 
 * @param cell
 *            Holds the column´s cell
 * @param pipeline
 *            Used for temporal expressions.
 * @param result
 *            Holds the intermediate result before executing this operation.
 * @return Holds the intermediate result after executing this operation.
 */

private int prepareSUTParser(String cell, AnnotationPipeline pipeline,
		int result) {
	if ((!cell.trim().isEmpty()) && (!cell.trim().equals("-")
			&& !cell.trim().equals("--") && !cell.trim().equals("---")
			&& !cell.trim().equals("n/a") && !cell.trim().equals("N/A")
			&& !cell.trim().equals("(n/a)")
			&& !cell.trim().equals("Unknown")
			&& !cell.trim().equals("unknown") && !cell.trim().equals("?")
			&& !cell.trim().equals("??") && !cell.trim().equals(".")
			&& !cell.trim().equals("null") && !cell.trim().equals("NULL")
			&& !cell.trim().equals("Null"))) {
		Annotation annotation = new Annotation(cell);
		annotation.set(CoreAnnotations.DocDateAnnotation.class,
				"2013-07-14");
		pipeline.annotate(annotation);

		List<CoreMap> timexAnnsAll = annotation
				.get(TimeAnnotations.TimexAnnotations.class);
		if (timexAnnsAll != null)
			if (!timexAnnsAll.isEmpty())
				result++;
	}
	return result;
}
 
开发者ID:olehmberg,项目名称:winter,代码行数:37,代码来源:FeatureSet.java


示例2: setPipeline

import edu.stanford.nlp.pipeline.AnnotationPipeline; //导入依赖的package包/类
/**
 * Sets the {@link AnnotationPipeline} for a language
 * @param language the language
 * @param pipeline the pipeline
 * @return the old pipeline for this language or <code>null</code> if none
 */
public AnnotationPipeline setPipeline(String language, AnnotationPipeline pipeline){
    if(language == null || language.isEmpty()){
        throw new IllegalArgumentException("The parsed language MUST NOT be NULL nor empty!");
    }
    if(pipeline == null){
        throw new IllegalArgumentException("The parsed annotation pipeline MUST NOT be NULL!");
    }
    AnnotationPipeline old = pipelines.put(language.toLowerCase(Locale.ROOT), pipeline);
    if(old == null){
        List<String> supported = new ArrayList<String>(pipelines.keySet());
        Collections.sort(supported);
        this.supported = Collections.unmodifiableCollection(supported);
    } //language was already present ... no need to update supported
    return old;
}
 
开发者ID:westei,项目名称:stanbol-stanfordnlp,代码行数:22,代码来源:StanfordNlpAnalyzer.java


示例3: TypeClassifier

import edu.stanford.nlp.pipeline.AnnotationPipeline; //导入依赖的package包/类
public TypeClassifier() {
	pipeline = new AnnotationPipeline();
	classifier = new Classifier();
	featureSet = new FeatureSet(new MaxentTagger(
			"de.uni_mannheim.informatik.dws.winter.webtables.detectors.tabletypeclassifier\\english-left3words-distsim.tagger"));
	initialize();
}
 
开发者ID:olehmberg,项目名称:winter,代码行数:8,代码来源:TypeClassifier.java


示例4: makeNumericPipeline

import edu.stanford.nlp.pipeline.AnnotationPipeline; //导入依赖的package包/类
private static AnnotationPipeline makeNumericPipeline() {
  AnnotationPipeline pipeline = new AnnotationPipeline();
  pipeline.addAnnotator(new TokenizerAnnotator(false, "en"));
  pipeline.addAnnotator(new WordsToSentencesAnnotator(false));
  pipeline.addAnnotator(new POSTaggerAnnotator(false));
  pipeline.addAnnotator(new TimeAnnotator(true));

  return pipeline;
}
 
开发者ID:vibhor1319,项目名称:activent,代码行数:10,代码来源:SUTimeSimpleParser.java


示例5: main

import edu.stanford.nlp.pipeline.AnnotationPipeline; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
        String date = null;//"2013-04-23";// props.getProperty("date");

        // Tries searching the classpath by default (see: IOUtils)
        //       String uri = "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger";
        //SUTime.class.getResource().toString();
        //    System.err.println(uri);
//        Properties props = StringUtils.argsToProperties(new String[0]);
//        props.put("pos.model", uri);
        AnnotationPipeline pipeline;
        pipeline = getPipeline();

        String in = "Summer 2012 "
                + "\n\n Summer"
                + "\n\n Winter"
                + "\n\n Easter"
                + "\n\n Autumn"
                + "\n\n Summer 2015"
                + "\n\n Thursday 25th July"
                + "\n\n  the beginning of next week"
                + "\n\n 21st April"
                + "\n\n the end of June"
                + "\n\n Xmas"
                + "\n\n '13"
                + "\n\n Dec '11"
                + "\n\n June"
                + "\n\n Sun 21st April"
                + "\n\n Thursday 14th March 2013"
                + "\n\n foo '12"
                + "\n\n fff Summer '11."
                ;

        processText(pipeline, in, date);
    }
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:35,代码来源:DistributedMain.java


示例6: createFeatures

import edu.stanford.nlp.pipeline.AnnotationPipeline; //导入依赖的package包/类
/**
 * serves as a general entrance point and organizes the feature creation.
 * 
 * @param column
 *            - Input column
 * @param pipeline
 *            - Pipeline for SUTParser
 */

public void createFeatures(String[] column, AnnotationPipeline pipeline) {

	int rowCounter = 0;
	String headerCelltemp = "";
	Map<String, Integer> ccpList = new TreeMap<String, Integer>();
	int length = 0;
	int resultSUTParser = 0;
	int resultBooleanValue = 0;

	// Loop once through one column
	for (String cell : column) {

		if (cell == null)
			continue;
		else {

			if (rowCounter < 2) {
				headerCelltemp = prepareHasHeaderCell(cell, headerCelltemp);
			}
			ccpList = prepareCellContentPattern(cell, ccpList);
			length = prepareAvgCharLength(cell, length);
			resultSUTParser = prepareSUTParser(cell, pipeline,
					resultSUTParser);
			resultBooleanValue = prepareBooleanValue(cell,
					resultBooleanValue);
			rowCounter++;
		}
	}

	// Validate loop results
	validateHasHeaderCell(headerCelltemp);
	validateCellContentPattern(ccpList);
	setAverageCharacterLenghth(length / column.length);
	validateSUTParser(resultSUTParser, column.length);
	validateBooleanValue(resultBooleanValue, column.length);

	if (isHasHeaderCell() && column[0] != null) {
		containPunctuationCharactersinHeaderCell(column[0]);
	}
	if (column[0] != null)
		posPatternofHeaderCell(column[0]);

	// check for whole content
	String content = otherOperations.getColumnContentWithoutSpaces(column);
	validatePercentageofAlphabeticCharacters(content);
	validatePercentageofPunctuationCharacters(content);

}
 
开发者ID:olehmberg,项目名称:winter,代码行数:58,代码来源:FeatureSet.java


示例7: StanfordCoreNLPWrapper

import edu.stanford.nlp.pipeline.AnnotationPipeline; //导入依赖的package包/类
public StanfordCoreNLPWrapper(AnnotationPipeline delegate) {
	this.delegate = delegate;
}
 
开发者ID:dice-group,项目名称:BENGAL,代码行数:4,代码来源:StanfordCoreNLPWrapper.java


示例8: getPipeline

import edu.stanford.nlp.pipeline.AnnotationPipeline; //导入依赖的package包/类
public static AnnotationPipeline getPipeline() throws Exception {

        Properties props = new Properties();

        AnnotationPipeline pipeline = new AnnotationPipeline();

        // include EOL when tokenizing
        props.put(WhitespaceTokenizerAnnotator.EOL_PROPERTY, "true");

        props.put("sutime.rules",
                "edu/stanford/nlp/models/sutime/distributed.defs.txt,"
                + "edu/stanford/nlp/models/sutime/distributed.defs.g.txt,"
                + "edu/stanford/nlp/models/sutime/defs.sutime.txt,"
                + "edu/stanford/nlp/models/sutime/english.sutime.txt,"
                + "edu/stanford/nlp/models/sutime/english.holidays.sutime.txt");

        props.put("sutime.verbose", true);

        pipeline.addAnnotator(new WhitespaceTokenizerAnnotator(props));
        //WhitespaceTokenizerFactory

        //pipeline.addAnnotator(new PTBTokenizerAnnotator(PTBTokenizerAnnotator.DEFAULT_OPTIONS + ",tokenizeNLs"));
        final boolean endOfLineIsEndOfSentence = true;

        String end_of_sentence_regex;

        // The default in WordToSentenceProcessor include the apostrophe ('), which causes problem parsing "Summer '11".
        if (endOfLineIsEndOfSentence) {
            end_of_sentence_regex = "(\\.|[!?]+)[\\r\\n]*";
        } else {
            end_of_sentence_regex = "\\.|[!?]+";
        }

        pipeline.addAnnotator(new WordsToSentencesAnnotator(true, end_of_sentence_regex)); // true to debug

//        pipeline.addAnnotator(new POSTaggerAnnotator(
//                props.getProperty("pos.model"),
//                false));
//    pipeline.addAnnotator(new NumberAnnotator(false));
//    pipeline.addAnnotator(new QuantifiableEntityNormalizingAnnotator(false, false));
        String timeAnnotator = props.getProperty("timeAnnotator", "sutime");
        if ("gutime".equals(timeAnnotator)) {
            //useGUTime = true;
            pipeline.addAnnotator(new GUTimeAnnotator());
        } else if ("heideltime".equals(timeAnnotator)) {
            //requiredDocDateFormat = "yyyy-MM-dd";
            pipeline.addAnnotator(new HeidelTimeAnnotator("heideltime", props));
        } else if ("sutime".equals(timeAnnotator)) {
            pipeline.addAnnotator(new TimeAnnotator("sutime", props));
        } else {
            throw new IllegalArgumentException("Unknown timeAnnotator: " + timeAnnotator);
        }
        return pipeline;
    }
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:55,代码来源:DistributedMain.java


示例9: textToAnnotation

import edu.stanford.nlp.pipeline.AnnotationPipeline; //导入依赖的package包/类
public static Annotation textToAnnotation(AnnotationPipeline pipeline, String text, String date) {
    Annotation annotation = new Annotation(text);
    annotation.set(CoreAnnotations.DocDateAnnotation.class, date);
    pipeline.annotate(annotation);
    return annotation;
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:7,代码来源:DistributedMain.java


示例10: getPipeline

import edu.stanford.nlp.pipeline.AnnotationPipeline; //导入依赖的package包/类
/**
 * Getter for the Pipeline of a specific language
 * @param lang the language
 * @return the pipeline or <code>null</code> if the parsed language is not
 * supported
 */
public AnnotationPipeline getPipeline(String lang){
    return pipelines.get(lang);
}
 
开发者ID:westei,项目名称:stanbol-stanfordnlp,代码行数:10,代码来源:StanfordNlpAnalyzer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HyphenationTree类代码示例发布时间:2022-05-23
下一篇:
Java DefaultHttpParams类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap