Package edu.stanford.nlp.ling

Examples of edu.stanford.nlp.ling.CoreLabel.containsKey()


      } while (nextToken != null && nextToken.word().length() == 0);

      // Check for compounds to split
      if (splitAny && nextToken instanceof CoreLabel) {
        CoreLabel cl = (CoreLabel) nextToken;
  if (cl.containsKey(ParentAnnotation.class)) {
      if(splitCompounds && cl.get(ParentAnnotation.class).equals(SpanishLexer.COMPOUND_ANNOTATION))
    nextToken = (T) processCompound(cl);
      else if (splitVerbs && cl.get(ParentAnnotation.class).equals(SpanishLexer.VB_PRON_ANNOTATION))
    nextToken = (T) processVerb(cl);
      else if (splitContractions && cl.get(ParentAnnotation.class).equals(SpanishLexer.CONTR_ANNOTATION))
View Full Code Here


       
        for (int i = s; i < e; i++) {
          CoreLabel l = sent.get(i);
          l.set(PatternsAnnotations.MatchedPattern.class, true);

          if(!l.containsKey(PatternsAnnotations.MatchedPatterns.class))
            l.set(PatternsAnnotations.MatchedPatterns.class, new HashSet<Pattern>());
          l.get(PatternsAnnotations.MatchedPatterns.class).add(matchedPat);

          // if (restrictToMatched) {
          // tokensMatchedPattern.add(sentid, i);
View Full Code Here

          // if (restrictToMatched) {
          // tokensMatchedPattern.add(sentid, i);
          // }
          for (Entry<Class, Object> ig : constVars.getIgnoreWordswithClassesDuringSelection().get(label).entrySet()) {
            if (l.containsKey(ig.getKey()) && l.get(ig.getKey()).equals(ig.getValue())) {
              doNotUse = true;
            }
          }
          boolean containsStop = containsStopWord(l, constVars.getCommonEngWords(), PatternFactory.ignoreWordRegex);
          if (removePhrasesWithStopWords && containsStop) {
View Full Code Here

                l.set(constVars.getAnswerClass().get(label), label);


                CollectionValuedMap<String, String> matched = new CollectionValuedMap<String, String>();
                matched.add(label, phStr);
                if(!l.containsKey(PatternsAnnotations.MatchedPhrases.class))
                  l.set(PatternsAnnotations.MatchedPhrases.class, matched);
                else
                  l.get(PatternsAnnotations.MatchedPhrases.class).addAll(matched);

                for (int k = Math.max(0, index - PatternFactory.numWordsCompound); k < sentEn.getValue().size()
View Full Code Here

          for (int i = s; i < e; i++) {
            CoreLabel l = sent.get(i);
            l.set(PatternsAnnotations.MatchedPattern.class, true);

            if(!l.containsKey(PatternsAnnotations.MatchedPatterns.class) || l.get(PatternsAnnotations.MatchedPatterns.class) == null)
              l.set(PatternsAnnotations.MatchedPatterns.class, new HashSet<Pattern>());

            SurfacePattern pSur = (SurfacePattern) pEn.getValue();
            assert pSur != null : "Why is " + pEn.getValue() + " not present in the index?!";
            assert l.get(PatternsAnnotations.MatchedPatterns.class) != null : "How come MatchedPatterns class is null for the token. The classes in the key set are " + l.keySet();
View Full Code Here

            assert l.get(PatternsAnnotations.MatchedPatterns.class) != null : "How come MatchedPatterns class is null for the token. The classes in the key set are " + l.keySet();
            l.get(PatternsAnnotations.MatchedPatterns.class).add(pSur);

            for (Entry<Class, Object> ig : constVars.getIgnoreWordswithClassesDuringSelection()
                .get(label).entrySet()) {
              if (l.containsKey(ig.getKey())
                  && l.get(ig.getKey()).equals(ig.getValue())) {
                doNotUse = true;
              }
            }
            boolean containsStop = containsStopWord(l,
View Full Code Here

      // we need this because we store additional info in the CoreLabel, such as the spans of each tree
      convertToCoreLabels(tree);

      // store the tree spans, if not present already
      CoreLabel l = (CoreLabel) tree.label();
      if(forceGenerationOfIndexSpans || (! l.containsKey(CoreAnnotations.BeginIndexAnnotation.class) && ! l.containsKey(CoreAnnotations.EndIndexAnnotation.class))){
        tree.indexSpans(0);
        logger.fine("Index spans were generated.");
      } else {
        logger.fine("Index spans were NOT generated.");
      }
View Full Code Here

      // we need this because we store additional info in the CoreLabel, such as the spans of each tree
      convertToCoreLabels(tree);

      // store the tree spans, if not present already
      CoreLabel l = (CoreLabel) tree.label();
      if(forceGenerationOfIndexSpans || (! l.containsKey(CoreAnnotations.BeginIndexAnnotation.class) && ! l.containsKey(CoreAnnotations.EndIndexAnnotation.class))){
        tree.indexSpans(0);
        logger.fine("Index spans were generated.");
      } else {
        logger.fine("Index spans were NOT generated.");
      }
View Full Code Here

            }
            token.set(CoreAnnotations.NamedEntityTagAnnotation.class, label);
          }
        }
        for (CoreLabel token:tokens) {
          if (!token.containsKey(CoreAnnotations.NamedEntityTagAnnotation.class)) {
            token.set(CoreAnnotations.NamedEntityTagAnnotation.class, options.backgroundNerTag);
          }
        }
      }
      if (options.annotateTokenCoref) {
View Full Code Here

          // Set docID
          if (doc.containsKey(CoreAnnotations.DocIDAnnotation.class)) { token.setDocID(doc.get(CoreAnnotations.DocIDAnnotation.class)); }
          // Set sentence index if not already there
          token.setSentIndex(i);
          // Set index annotation if not already there
          if (!token.containsKey(CoreAnnotations.IndexAnnotation.class)) {
            token.set(CoreAnnotations.IndexAnnotation.class, k + 1);
          }
        }
        // Set normalized named entity for chunked tokens
        if (sentence.containsKey(CoreAnnotations.NumerizedTokensAnnotation.class)) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.