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.algorithms.ocel; 020 021import java.util.Comparator; 022 023import org.dllearner.core.AbstractReasonerComponent; 024import org.semanticweb.owlapi.model.OWLClassExpression; 025 026public class SubsumptionComparator implements Comparator<OWLClassExpression> { 027 028 private AbstractReasonerComponent rs; 029 030 public SubsumptionComparator(AbstractReasonerComponent rs) { 031 this.rs = rs; 032 } 033 034 public int compare(ExampleBasedNode arg0, ExampleBasedNode arg1) { 035 OWLClassExpression concept1 = arg0.getConcept(); 036 OWLClassExpression concept2 = arg1.getConcept(); 037 return compare(concept1, concept2); 038 } 039 040 @Override 041 public int compare(OWLClassExpression concept1, OWLClassExpression concept2) { 042 // return true if concept1 is a super concept of concept2 043 boolean value1 = rs.isSuperClassOf(concept1, concept2); 044 if(value1) 045 return 1; 046 047 boolean value2 = rs.isSuperClassOf(concept2, concept1); 048 if(value2) 049 return -1; 050 051// System.out.println("Incomparable: " + concept1 + " " + concept2); 052 053 // both concepts are incomparable => order them syntactically 054 return concept1.compareTo(concept2); 055 } 056 057}