Package uk.ac.cam.ch.wwmm.oscar3server.scrapbook

Examples of uk.ac.cam.ch.wwmm.oscar3server.scrapbook.ScoreStats


      } else if(action.equals("regtests")) {
        //ToughWords.deTrain(10);
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();       
        File [] fileArr = fileRoot.listFiles();
        ScoreStats grandTotal = new ScoreStats();
        for(int i=0;i<fileArr.length;i++) {
          if(fileArr[i].isDirectory()) {
            String sbn = fileArr[i].getName();
            setScrapBook(sbn);
            ScoreStats score = scrapBook.regtest().getScoreStats();
            out.printf("%s %s\n", sbn, score.getPrecAndRecallString());
            grandTotal.addScoreStats(score);
            out.flush();
          }
        }
        out.println("Grand Total:");
View Full Code Here


    //File myDir = new File("/home/ptc24/cleanOscar/oscar3-chem/from_dj");
    //File crbDir = new File("/home/ptc24/cleanOscar/oscar3-chem/from_crb_pruned");

    List<File> files = FileTools.getFilesFromDirectoryByName(crbDir, "scrapbook.xml");
    ScoreStats grandTotal = new ScoreStats();
    String filterType = null;
    for(File f : files) {
      String subDir = f.getParentFile().getName();
      File myFile = new File(new File(myDir, subDir), "scrapbook.xml");
     
      ScoreStats ss = new ScoreStats();
      Document myDoc = new Builder().build(myFile);
      Document crbDoc = new Builder().build(f);
     
      Nodes ids = myDoc.query("//snippet/@id");
      Set<String> idStrs = new LinkedHashSet<String>();
      for(int i=0;i<ids.size();i++) idStrs.add(ids.get(i).getValue());

      int chars = 0;
     
      //System.out.println(f.getParentFile().getName());
      for(String id : idStrs) {
        try {
        //System.out.println(id);
        Element elem1 = (Element)myDoc.query("//snippet[@id='" + id + "']").get(0);
        chars += elem1.getValue().length();
        Element elem2 = (Element)crbDoc.query("//snippet[@id='" + id + "']").get(0);

        Nodes n = elem1.query(".//ne");
        for(int i=0;i<n.size();i++) {
          Element ne = (Element)n.get(i);
          if(filterType != null && !ne.getAttributeValue("type").equals(filterType)) {
            XOMTools.removeElementPreservingText(ne);
          }
        }
        n = elem2.query(".//ne");
        for(int i=0;i<n.size();i++) {
          Element ne = (Element)n.get(i);
          if(filterType != null && !ne.getAttributeValue("type").equals(filterType)) {
            XOMTools.removeElementPreservingText(ne);
          }
        }
       
        //FIXME - replace this with something that doesn't violate visibility
        //ScoreStats mySs = SnippetCompare.getPrecisionAndRecall(elem2, elem1, false);
        //ss.addScoreStats(mySs);
       
       
        } catch (Exception e) {
          System.out.println("Discrepancy!");
        }
      }
      //System.out.println("\t" + chars);
      System.out.println(f.getParentFile().getName() + "\t" + ss.getPrecAndRecallString());
      grandTotal.addScoreStats(ss);
    }
   
    System.out.println("Grand total:\t" + grandTotal.getPrecAndRecallString());
View Full Code Here

TOP

Related Classes of uk.ac.cam.ch.wwmm.oscar3server.scrapbook.ScoreStats

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.