Esempio n. 1
0
  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");
  }
Esempio n. 2
0
  public static CompletePipeline getCompletePipeline(FullPipelineOptions options)
      throws ZipException, IOException, ClassNotFoundException {

    Preprocessor pp = Language.getLanguage().getPreprocessor(options);
    Parse.parseOptions = options.getParseOptions();
    if (options.semaforserver != null) {
      Parse.parseOptions.skipPD = true;
      Parse.parseOptions.skipPI = true;
    }
    SemanticRoleLabeler srl;
    if (options.reranker) {
      srl = new Reranker(Parse.parseOptions);
    } else {
      ZipFile zipFile = new ZipFile(Parse.parseOptions.modelFile);
      if (Parse.parseOptions.skipPI) {
        srl = Pipeline.fromZipFile(zipFile, new Step[] {Step.pd, Step.ai, Step.ac});
      } else {
        srl = Pipeline.fromZipFile(zipFile);
      }
      zipFile.close();
    }
    CompletePipeline pipeline = new CompletePipeline(pp, srl);
    return pipeline;
  }