package mpqa_seq_reranker; import se.lth.cs.nlp.nlputils.core.PRFStats; /** @deprecated */ public class Stats implements java.io.Serializable { private static final long serialVersionUID = 0L; public double nCorrect, nInGold, nGuesses, propFound, propGuessed, nOverlap; public Stats() { } public Stats clone() { Stats out = new Stats(); out.nCorrect = nCorrect; out.nInGold = nInGold; out.nGuesses = nGuesses; out.propFound = propFound; out.propGuessed = propGuessed; out.nOverlap = nOverlap; return out; } Stats(String[] ss) { if(ss.length != 6) throw new RuntimeException("illegal number of tokens, should be 6"); nCorrect = Double.parseDouble(ss[0]); nGuesses = Double.parseDouble(ss[1]); nInGold = Double.parseDouble(ss[2]); propGuessed = Double.parseDouble(ss[3]); propFound = Double.parseDouble(ss[4]); nOverlap = Double.parseDouble(ss[5]); } public void add(Stats other) { nCorrect += other.nCorrect; nGuesses += other.nGuesses; nInGold += other.nInGold; propFound += other.propFound; propGuessed += other.propGuessed; nOverlap += other.nOverlap; } public String toString() { return "{ncorr = " + nCorrect + ", nguess = " + nGuesses + ", ningold = " + nInGold + ", pfound = " + propFound + ", pguess = " + propGuessed + ", nover = " + nOverlap + "}"; } public void printRaw() { System.out.format("%f %f %f %f %f %f\n", nCorrect, nGuesses, nInGold, propFound, propGuessed, nOverlap); } public double getPropError() { System.out.println("getPropError: " + this); return (nGuesses - propGuessed) + (nInGold - propFound); } public double getSoftF1() { if(nGuesses == 0 && nInGold == 0 && propGuessed == 0 && propFound == 0) return 1; double pSoft = propGuessed / nGuesses; double rSoft = propFound / nInGold; if(pSoft == 0 || rSoft == 0) return 0; else return 2*pSoft*rSoft / (pSoft + rSoft); } public void printStats(String prefix) { double pHard = nCorrect / nGuesses; double rHard = nCorrect / nInGold; double fHard = 2*pHard*rHard / (pHard + rHard); double pSoft = propGuessed / nGuesses; double rSoft = propFound / nInGold; double fSoft = 2*pSoft*rSoft / (pSoft + rSoft); double pOver = nOverlap / nGuesses; double rOver = nOverlap / nInGold; double fOver = 2*pOver*rOver / (pOver + rOver); System.out.format("%s hard: p = %f, r = %f, f1 = %f\n", prefix, pHard, rHard, fHard); System.out.format("%s soft: p = %f, r = %f, f1 = %f\n", prefix, pSoft, rSoft, fSoft); System.out.format("%s overlap: p = %f, r = %f, f1 = %f\n", prefix, pOver, rOver, fOver); } public PRFStats toPRFStats() { PRFStats out = new PRFStats(); out.nCorrect = this.nCorrect; out.nGuesses = this.nGuesses; out.nInGold = this.nInGold; out.nOverlap = this.nOverlap; out.propFound = this.propFound; out.propGuessed = this.propGuessed; return out; } }