001/** 002 * Copyright (C) 2007 - 2016, Jens Lehmann 003 * 004 * This file is part of DL-Learner. 005 * 006 * DL-Learner is free software; you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation; either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * DL-Learner is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package org.dllearner.learningproblems; 020 021import java.io.Serializable; 022import java.util.Set; 023 024import org.dllearner.core.Score; 025import org.semanticweb.owlapi.model.OWLIndividual; 026 027/** 028 * The score of a class in ontology engineering. 029 * 030 * @author Jens Lehmann 031 * 032 */ 033public class ClassScore extends Score implements Serializable{ 034 035 private static final long serialVersionUID = 2003326044901308157L; 036 private Set<OWLIndividual> coveredInstances; 037 private Set<OWLIndividual> notCoveredInstances; 038 039 private Set<OWLIndividual> additionalInstances; 040 041 private double coverage; 042 private double addition; 043 private double accuracy; 044 045 private boolean isConsistent; 046 private boolean followsFromKB; 047 048 public ClassScore(Set<OWLIndividual> coveredInstances, Set<OWLIndividual> notCoveredInstances, double coverage, Set<OWLIndividual> additionalInstances, double protusion, double accuracy) { 049 this.coveredInstances = coveredInstances; 050 this.notCoveredInstances = notCoveredInstances; 051 this.additionalInstances = additionalInstances; 052 this.coverage = coverage; 053 this.addition = protusion; 054 this.accuracy = accuracy; 055 } 056 057 public ClassScore(Set<OWLIndividual> coveredInstances, Set<OWLIndividual> notCoveredInstances, double coverage, Set<OWLIndividual> additionalInstances, double protusion, double accuracy, boolean isConsistent, boolean followsFromKB) { 058 this(coveredInstances, notCoveredInstances, coverage, additionalInstances, protusion, accuracy); 059 this.isConsistent = isConsistent; 060 this.followsFromKB = followsFromKB; 061 } 062 063 /** 064 * @return Coverage of the class description. 065 */ 066 public double getCoverage() { 067 return coverage; 068 } 069 070 /** 071 * Let C be the considered class OWLClassExpression and A the class to learn. 072 * The addition number is calculated as the number of instances of C which are also 073 * instances of A divided by the number of instances of C. 074 * @return Additional instances of the class description. 075 */ 076 public double getAddition() { 077 return addition; 078 } 079 080 /* (non-Javadoc) 081 * @see org.dllearner.core.Score#getAccuracy() 082 */ 083 @Override 084 public double getAccuracy() { 085// return 0.5 * (coverage + addition); 086 return accuracy; 087 } 088 089 /** 090 * @return the coveredInstances 091 */ 092 public Set<OWLIndividual> getCoveredInstances() { 093 return coveredInstances; 094 } 095 096 /** 097 * @return the notCoveredInstances 098 */ 099 public Set<OWLIndividual> getNotCoveredInstances() { 100 return notCoveredInstances; 101 } 102 103 /** 104 * @return the additionalInstances 105 */ 106 public Set<OWLIndividual> getAdditionalInstances() { 107 return additionalInstances; 108 } 109 110 public void setConsistent(boolean isConsistent) { 111 this.isConsistent = isConsistent; 112 } 113 114 public void setFollowsFromKB(boolean followsFromKB) { 115 this.followsFromKB = followsFromKB; 116 } 117 118 /** 119 * @return the isConsistent 120 */ 121 public boolean isConsistent() { 122 return isConsistent; 123 } 124 125 /** 126 * @return the followsFromKB 127 */ 128 public boolean followsFromKB() { 129 return followsFromKB; 130 } 131 132}