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));
}
}
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;
}
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;
}
Aggregations