示例#1
0
  /** @return */
  public TreeMap<Integer, Double> GetWinDiffPerLayer() throws Exception {

    SimpleFileDataSource ref = (SimpleFileDataSource) this.refDS;
    SimpleFileDataSource hypo = (SimpleFileDataSource) this.hypoDS;

    TreeMap<Integer, Double> res = new TreeMap<Integer, Double>();

    Set<Integer> levels = ref.GetReferenceBreaksHierarchical().keySet();

    for (Integer curLevel : levels) {
      ArrayList<Integer> curRef = ref.GetReferenceBreaksAtLevel(0, curLevel);
      ArrayList<Integer> curHypo = null;
      try {
        curHypo = hypo.GetReferenceBreaksAtLevel(0, curLevel);
      } catch (Exception e) {
        System.out.println("Error getting level in hypo: " + curLevel);
        e.printStackTrace();
        continue;
      }

      if (curHypo == null) continue;

      Double value = this.ComputeWindowDiff(curRef, curHypo);
      res.put(curLevel, value);
    }

    return res;
  }
示例#2
0
  /**
   * this method generates gold standard and opts files
   *
   * @throws Exception
   */
  public void SetUp(File tmpDir, String algorithmName) throws Exception {
    if (tmpDir.exists() == false || tmpDir.isDirectory() == false) tmpDir.mkdir();

    SimpleFileDataSource ref = (SimpleFileDataSource) this.refDS;
    SimpleFileDataSource hypo = (SimpleFileDataSource) this.hypoDS;

    String goldStandardName = ref.GetShortName() + ".ref.txt";
    String hypoName = ref.GetShortName() + ".hypo.txt";
    String optsName = ref.GetShortName() + ".opts.txt";
    // String resultsName = ref.GetShortName() + ".results.txt";

    File goldStandardFile = new File(tmpDir, goldStandardName);
    File hypoFile = new File(tmpDir, hypoName);
    File optsFile = new File(tmpDir, optsName);

    if (goldStandardFile.exists()) goldStandardFile.delete();
    if (hypoFile.exists()) hypoFile.delete();
    if (optsFile.exists()) optsFile.delete();

    // output gold standard file
    // ds.OutputFullTextWithHypoBreaks(outputFile,haps.GetAllHypoBreaks());
    ref.OutputFullTextHierarchical(goldStandardFile);

    // output hypothetical segmentation
    ref.OutputFullTextWithHypoBreaks(hypoFile, hypo.GetReferenceBreaksHierarchical());

    // generate opts file for EvalHDS
    this.GenerateEvalHDSOptFiles(optsFile, goldStandardFile, hypoFile, algorithmName);
    this.optionsFile = optsFile;
  }