Package edu.stanford.nlp.util

Examples of edu.stanford.nlp.util.CoreMap


    if(sents != null){
      for(CoreMap sent: sents){
        if(! (sent instanceof Annotation)){
          throw new RuntimeException("ERROR: Sentences must instantiate Annotation!");
        }
        CoreMap newSent = sentenceDeepMentionCopy((Annotation) sent);
        newSents.add(newSent);
      }
    }

    addSentences(newDataset, newSents);
View Full Code Here


      assert doc.get(CoreAnnotations.SentencesAnnotation.class).size() > 0;
      List<CoreMap> timexAnnotations = doc.get(TimeAnnotations.TimexAnnotations.class);
      if (timexAnnotations.size() > 1) {
        throw new RuntimeException("Too many timexes for '" + str + "'");
      }
      CoreMap timex = timexAnnotations.get(0);

      return timex.get(TimeExpression.Annotation.class).getTemporal();
    } catch (Exception e) {
      SUTimeSimpleParser.SUTimeParsingError parsingError = new SUTimeSimpleParser.SUTimeParsingError(str);
      parsingError.initCause(e);
      throw parsingError;
    }
View Full Code Here

        mentionCount.incrementCount(m.goldCorefClusterID);
      }
    }

    for(int i = 0 ; i<sentences.size(); i++) {
      CoreMap sentence = sentences.get(i);
      List<Mention> mentions = allMentions.get(i);

      String[] tokens = sentence.get(CoreAnnotations.TextAnnotation.class).split(" ");
      String sent = "";
      List<CoreLabel> t = sentence.get(CoreAnnotations.TokensAnnotation.class);
      if(previousOffset+2 < t.get(0).get(CoreAnnotations.CharacterOffsetBeginAnnotation.class)) sent += "\n";
      previousOffset = t.get(t.size()-1).get(CoreAnnotations.CharacterOffsetEndAnnotation.class);
      Counter<Integer> startCounts = new ClassicCounter<Integer>();
      Counter<Integer> endCounts = new ClassicCounter<Integer>();
      Map<Integer, Set<Integer>> endID = Generics.newHashMap();
View Full Code Here

    Counter<String> correct = new ClassicCounter<String>();
    Counter<String> predicted = new ClassicCounter<String>();
    Counter<String> gold = new ClassicCounter<String>();

    for (int i = 0; i < goldStandard.size(); i++) {
      CoreMap goldSent = goldStandard.get(i);
      CoreMap sysSent = extractorOutput.get(i);
      String sysText = sysSent.get(TextAnnotation.class);
      String goldText = goldSent.get(TextAnnotation.class);

      if (verbose) {
        System.err.println("SCORING THE FOLLOWING SENTENCE:");
        System.err.println(sysSent.get(CoreAnnotations.TokensAnnotation.class));
      }

      HashSet<String> matchedGolds = new HashSet<String>();
      List<EntityMention> goldEntities = goldSent
          .get(MachineReadingAnnotations.EntityMentionsAnnotation.class);
      if (goldEntities == null) {
        goldEntities = new ArrayList<EntityMention>();
      }

      for (EntityMention m : goldEntities) {
        String label = makeLabel(m);
        if (excludedClasses != null && excludedClasses.contains(label))
          continue;
        gold.incrementCount(label);
      }

      List<EntityMention> sysEntities = sysSent
          .get(MachineReadingAnnotations.EntityMentionsAnnotation.class);
      if (sysEntities == null) {
        sysEntities = new ArrayList<EntityMention>();
      }
      for (EntityMention m : sysEntities) {
View Full Code Here

          tokenOffset += tokens.size();
          continue;
        }
      }

      CoreMap sentence = new Annotation(textContent.toString());
      sentence.set(CoreAnnotations.DocIDAnnotation.class, docId);
      sentence.set(CoreAnnotations.TokensAnnotation.class, words);
      logger.info("Reading sentence: \"" + textContent + "\"");

      List<AceEntityMention> entityMentions = aceDocument.getEntityMentions(sentenceIndex);
      List<AceRelationMention> relationMentions = aceDocument.getRelationMentions(sentenceIndex);
      List<AceEventMention> eventMentions = aceDocument.getEventMentions(sentenceIndex);
View Full Code Here

        w.set(CoreAnnotations.IndexAnnotation.class, i+1);
        w.set(CoreAnnotations.UtteranceAnnotation.class, 0);
        if(i>0) textContent.append(" ");
        textContent.append(w.getString(CoreAnnotations.TextAnnotation.class));
      }
      CoreMap sentCoreMap = new Annotation(textContent.toString());
      allSentences.add(sentCoreMap);
      sentCoreMap.set(CoreAnnotations.TokensAnnotation.class, sentence);
    }

    // assign goldCorefClusterID
    Map<Integer, Mention> idMention = Generics.newHashMap();    // temporary use
    for (List<Mention> goldMentions : allGoldMentions) {
View Full Code Here

    tokens.get(1).set(CoreAnnotations.NamedEntityTagAnnotation.class, "PERSON");
    tokens.get(2).set(CoreAnnotations.NamedEntityTagAnnotation.class, "PERSON");
    tokens.get(5).set(CoreAnnotations.NamedEntityTagAnnotation.class, "LOCATION");
    tokens.get(7).set(CoreAnnotations.NamedEntityTagAnnotation.class, "LOCATION");

    CoreMap sentence = new ArrayCoreMap();
    sentence.set(CoreAnnotations.TokensAnnotation.class, tokens);

    List<CoreMap> sentences = new ArrayList<CoreMap>();
    sentences.add(sentence);

    Annotation corpus = new Annotation("President Barack Obama lives in Chicago, Illinois," +
View Full Code Here

    tokens.get(3).set(CoreAnnotations.NamedEntityTagAnnotation.class, "LOCATION");
    tokens.get(9).set(CoreAnnotations.NamedEntityTagAnnotation.class, "ORGANIZATION");
    tokens.get(10).set(CoreAnnotations.NamedEntityTagAnnotation.class, "ORGANIZATION");
    tokens.get(11).set(CoreAnnotations.NamedEntityTagAnnotation.class, "ORGANIZATION");

    CoreMap sentence = new ArrayCoreMap();
    sentence.set(CoreAnnotations.TokensAnnotation.class, tokens);

    List<CoreMap> sentences = new ArrayList<CoreMap>();
    sentences.add(sentence);

    Annotation corpus = new Annotation("I like Ontario Place, and I like the Native" +
View Full Code Here

    String str = "Christianity is of higher regex priority than Early Christianity . ";
    String[] split = str.split(" ");

    List<CoreLabel> tokens = Sentence.toCoreLabelList(split);

    CoreMap sentence = new ArrayCoreMap();
    sentence.set(CoreAnnotations.TokensAnnotation.class, tokens);

    List<CoreMap> sentences = new ArrayList<CoreMap>();
    sentences.add(sentence);

    Annotation corpus = new Annotation("Christianity is of higher regex priority than Early " +
View Full Code Here

  private static void checkNer(String message, String[][][] expected, CoreMap coremap, String coremapOutput) {
    List<CoreMap> sentences = coremap.get(CoreAnnotations.SentencesAnnotation.class);
    assertEquals(message + ": number of sentences for\n" + coremapOutput, expected.length, sentences.size());
    for (int i = 0; i < expected.length; i++) {
      CoreMap sentence = sentences.get(i);
      List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);
      assertEquals(message + ": number of tokens for sentence " + (i+1) + "\n" + coremapOutput, expected[i].length, tokens.size());
      for (int j = 0; j < expected[i].length; j++) {
        String text = expected[i][j][0];
        String ner = expected[i][j][1];
        String debug = "sentence " + (i+1) + ", token " + (j+1);
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.