예제 #1
0
 public String getStatusString() {
   // StringBuilder ret=new
   // StringBuilder("Semantic role labeling pipeline status\n\n");
   StringBuilder ret = new StringBuilder();
   long allocated = Runtime.getRuntime().totalMemory() / 1024;
   long free = Runtime.getRuntime().freeMemory() / 1024;
   ret.append("Memory usage:\n");
   ret.append("Allocated:\t\t\t" + Util.insertCommas(allocated) + "kb\n");
   ret.append("Used:\t\t\t\t" + Util.insertCommas((allocated - free)) + "kb\n");
   ret.append("Free:\t\t\t\t" + Util.insertCommas(free) + "kb\n");
   System.gc();
   long freeWithGC = Runtime.getRuntime().freeMemory() / 1024;
   ret.append("Free (after gc call):\t" + Util.insertCommas(freeWithGC) + "kb\n");
   ret.append("\n");
   // ret.append("Time spent doing tokenization (ms):
   // "+Util.insertCommas(pp.tokenizeTime)+"\n");
   // ret.append("Time spent doing lemmatization (ms):
   // "+Util.insertCommas(pp.lemmatizeTime)+"\n");
   // ret.append("Time spent doing pos-tagging (ms):
   // "+Util.insertCommas(pp.tagTime)+"\n");
   // ret.append("Time spent doing morphological tagging (ms):
   // "+Util.insertCommas(pp.mtagTime)+"\n");
   // ret.append("Time spent doing dependency parsing (ms):
   // "+Util.insertCommas(pp.dpTime)+"\n");
   ret.append(pp.getStatus()).append('\n');
   ret.append(
       "Time spent doing semantic role labeling (ms): "
           + Util.insertCommas(srl.parsingTime)
           + "\n");
   ret.append("\n\n");
   ret.append(srl.getStatus());
   return ret.toString().trim();
 }
예제 #2
0
  public static void main(String[] args) throws Exception {
    CompletePipelineCMDLineOptions options = new CompletePipelineCMDLineOptions();
    options.parseCmdLineArgs(args);
    String error = FileExistenceVerifier.verifyCompletePipelineAllNecessaryModelFiles(options);
    if (error != null) {
      System.err.println(error);
      System.err.println();
      System.err.println("Aborting.");
      System.exit(1);
    }

    CompletePipeline pipeline = getCompletePipeline(options);

    BufferedReader in =
        new BufferedReader(
            new InputStreamReader(new FileInputStream(options.input), Charset.forName("UTF-8")));

    SentenceWriter writer = null;

    if (options.printANN) writer = new ANNWriter(options.output);
    else writer = new CoNLL09Writer(options.output);

    long start = System.currentTimeMillis();
    int senCount;

    if (options.glovedir != null) {
      senCount = parseFullDocument(options, pipeline, in, writer);
    } else if (options.loadPreprocessorWithTokenizer) {
      senCount = parseNonSegmentedLineByLine(options, pipeline, in, writer);
    } else {
      senCount = parseCoNLL09(options, pipeline, in, writer);
    }

    in.close();
    writer.close();

    long time = System.currentTimeMillis() - start;
    System.out.println(pipeline.getStatusString());
    System.out.println();
    System.out.println("Total parsing time (ms):  " + Util.insertCommas(time));
    System.out.println("Overall speed (ms/sen):   " + Util.insertCommas(time / senCount));
  }
예제 #3
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");
  }