Search in sources :

Example 1 with AnnotationPipeline

use of edu.stanford.nlp.pipeline.AnnotationPipeline in project CoreNLP by stanfordnlp.

the class DependencyParserCoreNLPDemo method main.

public static void main(String[] args) {
    String text;
    if (args.length > 0) {
        text = IOUtils.slurpFileNoExceptions(args[0], "utf-8");
    } else {
        text = "I can almost always tell when movies use fake dinosaurs.";
    }
    Annotation ann = new Annotation(text);
    Properties props = PropertiesUtils.asProperties("annotators", "tokenize,ssplit,pos,depparse", "depparse.model", DependencyParser.DEFAULT_MODEL);
    AnnotationPipeline pipeline = new StanfordCoreNLP(props);
    pipeline.annotate(ann);
    for (CoreMap sent : ann.get(CoreAnnotations.SentencesAnnotation.class)) {
        SemanticGraph sg = sent.get(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class);
        log.info(IOUtils.eolChar + sg.toString(SemanticGraph.OutputFormat.LIST));
    }
}
Also used : AnnotationPipeline(edu.stanford.nlp.pipeline.AnnotationPipeline) CoreAnnotations(edu.stanford.nlp.ling.CoreAnnotations) SemanticGraphCoreAnnotations(edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations) SemanticGraphCoreAnnotations(edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations) SemanticGraph(edu.stanford.nlp.semgraph.SemanticGraph) Properties(java.util.Properties) CoreMap(edu.stanford.nlp.util.CoreMap) Annotation(edu.stanford.nlp.pipeline.Annotation) StanfordCoreNLP(edu.stanford.nlp.pipeline.StanfordCoreNLP)

Example 2 with AnnotationPipeline

use of edu.stanford.nlp.pipeline.AnnotationPipeline in project CoreNLP by stanfordnlp.

the class RuleBasedCorefMentionFinder method getParser.

private Annotator getParser() {
    if (parserProcessor == null) {
        Annotator parser = StanfordCoreNLP.getExistingAnnotator("parse");
        if (parser == null) {
            // TODO: these assertions rule out the possibility of alternately named parse/pos annotators
            throw new AssertionError("Failed to get parser - this should not be possible");
        }
        if (parser.requires().contains(CoreAnnotations.PartOfSpeechAnnotation.class)) {
            Annotator tagger = StanfordCoreNLP.getExistingAnnotator("pos");
            if (tagger == null) {
                throw new AssertionError("Parser required tagger, but failed to find the pos annotator");
            }
            List<Annotator> annotators = Generics.newArrayList();
            annotators.add(tagger);
            annotators.add(parser);
            parserProcessor = new AnnotationPipeline(annotators);
        } else {
            parserProcessor = parser;
        }
    }
    return parserProcessor;
}
Also used : Annotator(edu.stanford.nlp.pipeline.Annotator) AnnotationPipeline(edu.stanford.nlp.pipeline.AnnotationPipeline) SemanticGraphCoreAnnotations(edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations) CoreAnnotations(edu.stanford.nlp.ling.CoreAnnotations)

Example 3 with AnnotationPipeline

use of edu.stanford.nlp.pipeline.AnnotationPipeline in project CoreNLP by stanfordnlp.

the class SUTimeSimpleParser method makeNumericPipeline.

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;
}
Also used : POSTaggerAnnotator(edu.stanford.nlp.pipeline.POSTaggerAnnotator) AnnotationPipeline(edu.stanford.nlp.pipeline.AnnotationPipeline) WordsToSentencesAnnotator(edu.stanford.nlp.pipeline.WordsToSentencesAnnotator) TokenizerAnnotator(edu.stanford.nlp.pipeline.TokenizerAnnotator)

Aggregations

AnnotationPipeline (edu.stanford.nlp.pipeline.AnnotationPipeline)3 CoreAnnotations (edu.stanford.nlp.ling.CoreAnnotations)2 SemanticGraphCoreAnnotations (edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations)2 Annotation (edu.stanford.nlp.pipeline.Annotation)1 Annotator (edu.stanford.nlp.pipeline.Annotator)1 POSTaggerAnnotator (edu.stanford.nlp.pipeline.POSTaggerAnnotator)1 StanfordCoreNLP (edu.stanford.nlp.pipeline.StanfordCoreNLP)1 TokenizerAnnotator (edu.stanford.nlp.pipeline.TokenizerAnnotator)1 WordsToSentencesAnnotator (edu.stanford.nlp.pipeline.WordsToSentencesAnnotator)1 SemanticGraph (edu.stanford.nlp.semgraph.SemanticGraph)1 CoreMap (edu.stanford.nlp.util.CoreMap)1 Properties (java.util.Properties)1