Example #1
0
  /**
   * @param args 0 - Annotator type ("cue" or "scope") 1 - Model type ("crf", "baseline" or "negex")
   *     2 - Saved model file 3 - Sentence to tag
   */
  public static void main(String[] args) {
    if (args.length < 4) {
      usage();
      System.exit(0);
    }
    Annotator annotator = getAnnotator(args[1], args[0]);
    if (annotator == null) {
      usage();
      System.exit(1);
    }
    annotator.loadAnnotator(args[2]);

    if ("file".equalsIgnoreCase(args[3])) {
      String fileName = args[4];
      try {
        List<String> sentences = FileOperations.readFile(fileName);
        for (String sentence : sentences) {
          AnnotatedSentence annotatedSentence = tag(annotator, sentence, false);
          System.out.println(annotatedSentence.getRawText());
        }
      } catch (Exception ex) {
        ex.printStackTrace(System.err);
      }
    } else {
      AnnotatedSentence sentence = tag(annotator, args[3], false);
      System.out.println(sentence.getRawText());
    }
  }
Example #2
0
 public static List<AnnotatedSentence> annotateSentences(
     Annotator annotator, List<String> inputSentences, boolean isTokenized) {
   List<AnnotatedSentence> outputSentences =
       new ArrayList<AnnotatedSentence>(inputSentences.size());
   for (String inputSentence : inputSentences) {
     AnnotatedSentence outputSentence = annotator.annotateSentence(inputSentence, isTokenized);
     outputSentences.add(outputSentence);
   }
   return outputSentences;
 }
Example #3
0
 /**
  * Tags the given sentence with the given annotator
  *
  * @param annotator
  * @param sentence
  * @param isTokenized
  * @return
  */
 public static AnnotatedSentence tag(Annotator annotator, String sentence, boolean isTokenized) {
   return annotator.annotateSentence(sentence, isTokenized);
 }