Package edu.stanford.nlp.pipeline

Examples of edu.stanford.nlp.pipeline.Annotation


  private Annotation getAnnotation(String desc) {
    synchronized(lingAnnotationCache) {
      if(lingAnnotationCache.containsKey(desc))
        return lingAnnotationCache.get(desc);
    }
    Annotation ann = new Annotation(desc);
    synchronized(pipeline) {
      pipeline.annotate(ann);
    }
    synchronized (lingAnnotationCache) {
      lingAnnotationCache.put(desc, ann);
View Full Code Here


    return ann;
  }
 
  private void handleNonCvtBinary(FormulaGenerationInfo fgInfo, Set<String> res) {
    String description = normalizeFbDescription(fgInfo.bInfo.descriptions.get(0));
    Annotation a = getAnnotation(description);
    String question = generateNonCvtQuestion(fgInfo,
        description,
        getPosTagsFromAnnotation(a),
        a.get(SentencesAnnotation.class).get(0).get(TreeAnnotation.class).firstChild(),
        fbFormulasInfo.isReversed(fgInfo.bInfo.formula));
    if(question!=null)
      res.add(question);
  }
View Full Code Here

  }
 
  private void handleCvtBinary(FormulaGenerationInfo fgInfo, Set<String> res) {
    String description1 = normalizeFbDescription(fgInfo.bInfo.descriptions.get(0));
    String description2 = normalizeFbDescription(fgInfo.bInfo.descriptions.get(1));
    Annotation a1 = getAnnotation(description1);
    Annotation a2 = getAnnotation(description2);

    String question = generateCvtQuestion(fgInfo,description1,description2,
        a1.get(SentencesAnnotation.class).get(0).get(TreeAnnotation.class).firstChild(),
        a2.get(SentencesAnnotation.class).get(0).get(TreeAnnotation.class).firstChild(),
        getPosTagsFromAnnotation(a1),
        getPosTagsFromAnnotation(a2));
    if(question!=null)
      res.add(question);
  }
View Full Code Here

    nerValues.clear();
    lemmaTokens.clear();

    if (opts.useAnnotators) {
      initModels();
      Annotation annotation = pipeline.process(utterance);

      for (CoreLabel token : annotation.get(CoreAnnotations.TokensAnnotation.class)) {
        String word = token.get(TextAnnotation.class);
        String wordLower = word.toLowerCase();
        if (opts.caseSensitive) {
          tokens.add(word);
        } else {
View Full Code Here

    pipeline = new StanfordCoreNLP(props);
  }

  public VerbSemClassMatch match(String sentence) {

    Annotation annotation = new Annotation(sentence.toLowerCase());
    pipeline.annotate(annotation);
    TokenSequenceMatcher m1 = p1.getMatcher(annotation.get(CoreAnnotations.TokensAnnotation.class));
    if(m1.find())
      return new VerbSemClassMatch(extractMatch(m1.groupNodes(2)), extractMatch(m1.groupNodes(1)), false);
    TokenSequenceMatcher m2 = p2.getMatcher(annotation.get(CoreAnnotations.TokensAnnotation.class));
    if(m2.find())
      return new VerbSemClassMatch(extractMatch(m2.groupNodes(2)), extractMatch(m2.groupNodes(1)), false);
    TokenSequenceMatcher m3 = p3.getMatcher(annotation.get(CoreAnnotations.TokensAnnotation.class));
    if(m3.find())
      return new VerbSemClassMatch(extractMatch(m3.groupNodes(2)), extractMatch(m3.groupNodes(1)), true);
    TokenSequenceMatcher m4 = p3.getMatcher(annotation.get(CoreAnnotations.TokensAnnotation.class));
    if(m4.find())
      return new VerbSemClassMatch(extractMatch(m4.groupNodes(2)), extractMatch(m4.groupNodes(1)), true);
    return null;
  }
View Full Code Here

        for (String document: documents) {
            int mainSentiment = 0;
            if (document != null && document.length() > 0) {
                int longest = 0;
                try {
                    Annotation annotation = pipeline.process(document);
                    // mainSentiment is the sentiment of the whole document. We find
                    // the whole document by comparing the length of individual
                    // annotated "fragments"
                    for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
                        Tree tree = sentence.get(SentimentCoreAnnotations.AnnotatedTree.class);
                        int sentiment = RNNCoreAnnotations.getPredictedClass(tree);
                        String partText = sentence.toString();
                        if (partText.length() > longest) {
                            mainSentiment = sentiment;
View Full Code Here

    public Counter<String> lemmatize(String documentText, StopWords stopWords) {
        Counter<String> lemmas = new Counter<String>();

        // create an empty Annotation just with the given text
        Annotation document = new Annotation(documentText);

        // run all Annotators on this text
        this.pipeline.annotate(document);

        // Iterate over all of the sentences found
        List<CoreMap> sentences = document.get(SentencesAnnotation.class);
        for (CoreMap sentence : sentences) {
            // Iterate over all tokens in a sentence
            for (CoreLabel token : sentence.get(TokensAnnotation.class)) {
                // Retrieve and add the lemma for each word into the
                // list of lemmas
View Full Code Here

      results.put("_cn_", 0);
  }

  int count = 0;

  Annotation annotation = new Annotation(summary.asText());
  stanford.annotate(annotation);

  for (CoreMap sentenceMap : annotation.get(SentencesAnnotation.class))
  {
      List<String> usedTokens = new LinkedList<String>();
      // check which tokens to use
      for (CoreLabel token : sentenceMap.get(TokensAnnotation.class))
      {
View Full Code Here

    {
  String text = readTextFromFile(source);

  RougeSummaryModel summaryModel = new RougeSummaryModel(source);

  Annotation annotation = new Annotation(text);
  stanford.annotate(annotation);
  int id = 0;
  for (CoreMap sentence : annotation.get(SentencesAnnotation.class))
  {
      String sent = sentence.toString();
      if (id == 0)
      {
    summaryModel.setTitle(sent);
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.pipeline.Annotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.