コード例 #1
0
 public Sentence parseOraclePI(List<String> words, List<Boolean> isPred) throws Exception {
   Sentence s = new Sentence(pp.preprocess(words.toArray(new String[words.size()])), false);
   for (int i = 0; i < isPred.size(); ++i) {
     if (isPred.get(i)) {
       s.makePredicate(i);
     }
   }
   srl.parseSentence(s);
   return s;
 }
コード例 #2
0
ファイル: Parse.java プロジェクト: DohaBasem/mateplus
  public static void main(String[] args) throws Exception {
    long startTime = System.currentTimeMillis();
    parseOptions = new ParseOptions(args);

    SemanticRoleLabeler srl;

    if (parseOptions.useReranker) {
      srl = new Reranker(parseOptions);
      // srl =
      // Reranker.fromZipFile(zipFile,parseOptions.skipPI,parseOptions.global_alfa,parseOptions.global_aiBeam,parseOptions.global_acBeam);
    } else {
      ZipFile zipFile = new ZipFile(parseOptions.modelFile);
      srl =
          parseOptions.skipPD
              ? Pipeline.fromZipFile(zipFile, new Step[] {Step.ai, Step.ac})
              : parseOptions.skipPI
                  ? Pipeline.fromZipFile(zipFile, new Step[] {Step.pd, Step.ai, Step.ac /*
																	 * ,Step.po,
																	 * Step.ao
																	 */})
                  : Pipeline.fromZipFile(zipFile);
      zipFile.close();
    }

    SentenceWriter writer = null;
    if (parseOptions.printXML) writer = new FrameNetXMLWriter(parseOptions.output);
    else writer = new CoNLL09Writer(parseOptions.output);

    SentenceReader reader =
        parseOptions.skipPI
            ? new SRLOnlyCoNLL09Reader(parseOptions.inputCorpus)
            : new DepsOnlyCoNLL09Reader(parseOptions.inputCorpus);
    int senCount = 0;
    for (Sentence s : reader) {
      senCount++;
      if (senCount % 100 == 0) System.out.println("Parsing sentence " + senCount);
      srl.parseSentence(s);
      if (parseOptions.writeCoref) writer.specialwrite(s);
      else writer.write(s);
    }
    writer.close();
    reader.close();
    long totalTime = System.currentTimeMillis() - startTime;
    System.out.println("Done.");
    System.out.println(srl.getStatus());
    System.out.println();
    System.out.println("Total execution time: " + Util.insertCommas(totalTime) + "ms");
  }
コード例 #3
0
 public Sentence parse(List<String> words) throws Exception {
   Sentence s = new Sentence(pp.preprocess(words.toArray(new String[words.size()])), false);
   srl.parseSentence(s);
   return s;
 }