Пример #1
0
  public void annotate(Annotation annotation) {
    if (verbose) {
      timer.start();
      System.err.print("Adding gender annotation...");
    }

    if (!annotation.containsKey(SentencesAnnotation.class))
      throw new RuntimeException("Unable to find sentences in " + annotation);

    List<CoreMap> sentences = annotation.get(SentencesAnnotation.class);
    for (CoreMap sentence : sentences) {
      List<CoreLabel> tokens = sentence.get(TokensAnnotation.class);
      classifier.classify(tokens);

      for (CoreLabel token : tokens)
        token.set(GenderAnnotation.class, token.get(AnswerAnnotation.class));
    }

    if (verbose) timer.stop("done.");
  }