Package edu.stanford.nlp.util

Examples of edu.stanford.nlp.util.CoreMap


      int groupStart = start(group);
      if (groupStart >= last) {
        res.addAll(elements.subList(last,groupStart));
        int groupEnd = end(group);
        if (groupEnd - groupStart >= 1) {
          CoreMap merged = createMergedChunk(groupStart, groupEnd);
          res.add(merged);
          last = groupEnd;
        }
      }
    }
View Full Code Here


    return mergeGroup(0);
  }

  private CoreMap createMergedChunk(int groupStart, int groupEnd)
  {
    CoreMap merged = null;
  /*  if (annotation != null) {
      // Take start and end
      merged = ChunkAnnotationUtils.getMergedChunk(elements, annotation.get(CoreAnnotations.TextAnnotation.class), groupStart, groupEnd);
    }  */
    if (merged == null) {
View Full Code Here

  private static void recallErrors(List<List<Mention>> goldMentions, List<List<Mention>> predictedMentions, Annotation doc) throws IOException {
    List<CoreMap> coreMaps = doc.get(CoreAnnotations.SentencesAnnotation.class);
    int numSentences = goldMentions.size();
    for (int i=0;i<numSentences;i++){
      CoreMap coreMap = coreMaps.get(i);
      List<CoreLabel> words = coreMap.get(CoreAnnotations.TokensAnnotation.class);
      Tree tree = coreMap.get(TreeCoreAnnotations.TreeAnnotation.class);
      List<Mention> goldMentionsSent = goldMentions.get(i);
      List<Pair<Integer,Integer>> goldMentionsSpans = extractSpans(goldMentionsSent);

      for (Pair<Integer,Integer> mentionSpan: goldMentionsSpans){
        logger.finer("RECALL ERROR\n");
View Full Code Here

          mention.originalRef = id;
          newMentionID++;
        }
        if(maxID < mention.mentionID) maxID = mention.mentionID;
        int sentIndex = m.get(CoreAnnotations.SentenceIndexAnnotation.class);
        CoreMap sent = sentences.get(sentIndex);
        mention.startIndex = m.get(CoreAnnotations.TokenBeginAnnotation.class) - sent.get(CoreAnnotations.TokenBeginAnnotation.class);
        mention.endIndex = m.get(CoreAnnotations.TokenEndAnnotation.class) - sent.get(CoreAnnotations.TokenBeginAnnotation.class);

        // will be set by arrange
        mention.originalSpan = m.get(CoreAnnotations.TokensAnnotation.class);

        // Mention dependency is collapsed dependency for sentence
View Full Code Here

    // run SUTime
    // note: SUTime requires TextAnnotation to be set at document/sent level and
    //   that the Character*Offset annotations be aligned with the token words.
    //   This is guaranteed because here we work on a copy generated by copyTokens()
    //
    CoreMap timeSentence = (sentence != null ?
        alignSentence(sentence) :
        buildSentenceFromTokens(tokenSequence));
    List<CoreMap> timeExpressions = runSUTime(timeSentence, document);
    List<CoreMap> numbers = timeSentence.get(CoreAnnotations.NumerizedTokensAnnotation.class);

    //
    // store DATE and TIME
    //
    if (timeExpressions != null) {
View Full Code Here

    if(text != null){
      // original text is preserved; no need to align anything
      return sentence;
    }

    CoreMap newSentence = buildSentenceFromTokens(
        sentence.get(CoreAnnotations.TokensAnnotation.class),
        sentence.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class),
        sentence.get(CoreAnnotations.CharacterOffsetEndAnnotation.class));

    newSentence.set(CoreAnnotations.TokenBeginAnnotation.class,
        sentence.get(CoreAnnotations.TokenBeginAnnotation.class));
    newSentence.set(CoreAnnotations.TokenEndAnnotation.class,
        sentence.get(CoreAnnotations.TokenEndAnnotation.class));

    return newSentence;
  }
View Full Code Here

    return labels;
  }

  static public CoreMap makeSentenceCoreMap(String sentence){
    List<CoreLabel> tokens = makeSentence(sentence);
    CoreMap map = new ArrayCoreMap(1);
    map.set(CoreAnnotations.TokensAnnotation.class, tokens);
    return map;
  }
View Full Code Here

  /**
   * Test that the tagger correctly handles getting a single sentence
   * in the WordsPLAnnotation
   */
  public void testWordsPLAnnotation() {
    CoreMap sent = makeSentenceCoreMap(testSentences[0]);
    List<CoreMap> sentences = new ArrayList<CoreMap>();
    sentences.add(sent);

    Annotation annotation = new Annotation(shortText);
    annotation.set(CoreAnnotations.SentencesAnnotation.class, sentences );
View Full Code Here

  /**
   * Test that it also works when you give it multiple sentences
   */
  public void testMultipleWordsPLAnnotation() {
    CoreMap firstLabels = makeSentenceCoreMap(testSentences[0]);
    CoreMap secondLabels = makeSentenceCoreMap(testSentences[1]);
    List<CoreMap> sentences = new ArrayList<CoreMap>();
    sentences.add(firstLabels);
    sentences.add(secondLabels);

    Annotation annotation = new Annotation(longText);
View Full Code Here

   * Test that a single sentence works for the SentenceAnnotation
   */
  public void testSentencesAnnotation() {
    List<CoreLabel> labels = makeSentence(testSentences[0]);

    CoreMap sentence = new ArrayCoreMap();
    sentence.set(CoreAnnotations.TokensAnnotation.class, labels);
    List<CoreMap> sentences = new ArrayList<CoreMap>();
    sentences.add(sentence);
   
    Annotation annotation = new Annotation(shortText);
    annotation.set(CoreAnnotations.SentencesAnnotation.class, sentences);
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.util.CoreMap

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.