001package org.dllearner.utilities; 002 003import org.semanticweb.owlapi.model.OWLIndividual; 004 005import java.util.SortedSet; 006 007/** 008 * Implicit class to interpret CoverageCount as tp/fp/fn/fp 009 */ 010public class CoverageAdapter { 011 public static class CoverageCountAdapter2 { 012 private final ReasoningUtils.CoverageCount[] cc; 013 014 public CoverageCountAdapter2(ReasoningUtils.CoverageCount[] cc) { 015 this.cc = cc; 016 } 017 018 public int posAsPos() {return tp();} 019 public void setPosAsPos(int tp){setTp(tp);} 020 public int posAsNeg() {return fn();} 021 public void setPosAsNeg(int fn){setFn(fn);} 022 public int negAsPos() {return fp();} 023 public void setNegAsPos(int fp) {setFp(fp);} 024 public int negAsNeg() {return tn();} 025 public void setNegAsNeg(int tn) {setTn(tn);} 026 027 public int tp() { return cc[0].trueCount; } 028 public void setTp(int tp) { cc[0].trueCount = tp; } 029 030 public int fn() { return cc[0].falseCount; } 031 public void setFn(int fn) { cc[0].falseCount = fn; } 032 033 public int fp() { return cc[1].trueCount; } 034 public void setFp(int fp) { cc[1].trueCount = fp; } 035 036 public int tn() { return cc[1].falseCount; } 037 public void setTn(int tn) { cc[1].falseCount = tn; } 038 039 private String valueToString(int value) { 040 return "#" + value; 041 } 042 043 @Override 044 public String toString() { 045 return "CoverageCount2{" + 046 "tp" + valueToString(tp()) + "," + 047 "fn" + valueToString(fn()) + "," + 048 "fp" + valueToString(fp()) + "," + 049 "tn" + valueToString(tn()) + 050 '}'; 051 } 052 } 053 054 public static class CoverageAdapter2 { 055 private final ReasoningUtils.Coverage[] cov; 056 057 public CoverageAdapter2(ReasoningUtils.Coverage[] cov) { 058 this.cov = cov; 059 } 060 061 public SortedSet<OWLIndividual> posAsPos() {return tp();} 062 public void setPosAsPos(SortedSet<OWLIndividual> tp){setTp(tp);} 063 public SortedSet<OWLIndividual> posAsNeg() {return fn();} 064 public void setPosAsNeg(SortedSet<OWLIndividual> fn){setFn(fn);} 065 public SortedSet<OWLIndividual> negAsPos() {return fp();} 066 public void setNegAsPos(SortedSet<OWLIndividual> fp) {setFp(fp);} 067 public SortedSet<OWLIndividual> negAsNeg() {return tn();} 068 public void setNegAsNeg(SortedSet<OWLIndividual> tn) {setTn(tn);} 069 070 public SortedSet<OWLIndividual> tp() { return cov[0].trueSet; } 071 public void setTp(SortedSet<OWLIndividual> tp) { cov[0].trueSet = tp; cov[0].trueCount = tp.size(); } 072 073 public SortedSet<OWLIndividual> fn() { return cov[0].falseSet; } 074 public void setFn(SortedSet<OWLIndividual> fn) { cov[0].falseSet = fn; cov[0].falseCount = fn.size(); } 075 076 public SortedSet<OWLIndividual> fp() { return cov[1].trueSet; } 077 public void setFp(SortedSet<OWLIndividual> fp) { cov[1].trueSet = fp; cov[1].trueCount = fp.size(); } 078 079 public SortedSet<OWLIndividual> tn() { return cov[1].falseSet; } 080 public void setTn(SortedSet<OWLIndividual> tn) { cov[1].falseSet = tn; cov[1].falseCount = tn.size(); } 081 082 private String setValueToString(SortedSet<OWLIndividual> set) { 083 return "#" + set.size() + (set.size()>0?"(" + set.first() + (set.size()>1?"...":"")+")":""); 084 } 085 @Override 086 public String toString() { 087 return "Coverage2{" + 088 "tp" + setValueToString(tp()) + "," + 089 "fn" + setValueToString(fn()) + "," + 090 "fp" + setValueToString(fp()) + "," + 091 "tn" + setValueToString(tn()) + 092 '}'; 093 } 094 } 095}