001    /**
002     * Copyright (C) 2007-2011, 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     */
019    
020    package org.dllearner.learningproblems;
021    
022    import java.io.Serializable;
023    import java.util.Set;
024    
025    import org.dllearner.core.Score;
026    import org.dllearner.core.owl.Individual;
027    
028    /**
029     * The score of a class in ontology engineering.
030     * 
031     * @author Jens Lehmann
032     *
033     */
034    public class ClassScore extends Score implements Serializable{
035    
036            /**
037             * 
038             */
039            private static final long serialVersionUID = 2003326044901308157L;
040            private Set<Individual> coveredInstances;
041            private Set<Individual> notCoveredInstances;
042    
043            private Set<Individual> additionalInstances;
044            
045            private double coverage;
046            private double addition;
047            private double accuracy;
048            
049            private boolean isConsistent;
050            private boolean followsFromKB;
051            
052            public ClassScore(Set<Individual> coveredInstances, Set<Individual> notCoveredInstances, double coverage, Set<Individual> additionalInstances, double protusion, double accuracy) {
053                    this.coveredInstances = coveredInstances;
054                    this.notCoveredInstances = notCoveredInstances;
055                    this.additionalInstances = additionalInstances;
056                    this.coverage = coverage;
057                    this.addition = protusion;
058                    this.accuracy = accuracy;
059            }       
060            
061            public ClassScore(Set<Individual> coveredInstances, Set<Individual> notCoveredInstances, double coverage, Set<Individual> additionalInstances, double protusion, double accuracy, boolean isConsistent, boolean followsFromKB) {
062                    this(coveredInstances, notCoveredInstances, coverage, additionalInstances, protusion, accuracy);
063                    this.isConsistent = isConsistent;
064                    this.followsFromKB = followsFromKB;
065            }
066            
067            /**
068             * @return Coverage of the class description.
069             */
070            public double getCoverage() {
071                    return coverage;
072            }
073    
074            /**
075             * Let C be the considered class description and A the class to learn. 
076             * The addition number is calculated as the number of instances of C which are also
077             * instances of A divided by the number of instances of C.
078             * @return Additional instances of the class description.
079             */
080            public double getAddition() {
081                    return addition;
082            }
083    
084            /* (non-Javadoc)
085             * @see org.dllearner.core.Score#getAccuracy()
086             */
087            @Override
088            public double getAccuracy() {
089    //              return 0.5 * (coverage + addition);
090                    return accuracy;
091            }
092    
093            /**
094             * @return the coveredInstances
095             */
096            public Set<Individual> getCoveredInstances() {
097                    return coveredInstances;
098            }
099    
100            /**
101             * @return the notCoveredInstances
102             */
103            public Set<Individual> getNotCoveredInstances() {
104                    return notCoveredInstances;
105            }       
106            
107            /**
108             * @return the additionalInstances
109             */
110            public Set<Individual> getAdditionalInstances() {
111                    return additionalInstances;
112            }
113    
114            public void setConsistent(boolean isConsistent) {
115                    this.isConsistent = isConsistent;
116            }
117    
118            public void setFollowsFromKB(boolean followsFromKB) {
119                    this.followsFromKB = followsFromKB;
120            }
121    
122            /**
123             * @return the isConsistent
124             */
125            public boolean isConsistent() {
126                    return isConsistent;
127            }
128    
129            /**
130             * @return the followsFromKB
131             */
132            public boolean followsFromKB() {
133                    return followsFromKB;
134            }               
135    
136    }