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


Java AnnotationPipeline类代码示例

本文整理汇总了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;未经允许,请勿转载。