/** * Basic interface for all DL-Learner knowledge sources. * * @author Jens Lehmann * */ @ComponentAnn(name = "Knowledge Sources", shortName = "ks", version = 0) public interface KnowledgeSource extends Component { }
/** * Returns the name of a DL-Learner component. * @param component the component * @return Name of the component. */ public static String getShortName(Class<? extends Component> component){ ComponentAnn ann = component.getAnnotation(ComponentAnn.class); if(ann == null) { throw new Error("Component " + component + " does not use component annotation."); } return ann.shortName(); }
/** * Returns the name of a DL-Learner component. * @param component the component * @return Name of the component. */ public static String getDescription(Class<? extends Component> component){ ComponentAnn ann = component.getAnnotation(ComponentAnn.class); return ann.description(); }
ComponentAnn catAnn = category.getAnnotation(ComponentAnn.class); if (catAnn != null) { catString = catAnn.shortName(); ComponentAnn ann = component.getAnnotation(ComponentAnn.class); if (ann != null) { header = "component: " + ann.name() + " (" + klass + ") v" + ann.version(); description = ann.description(); if (component.equals(GlobalDoc.class)) { catString="";
/** * Returns the name of a DL-Learner component. * @param component the component * @return Name of the component. */ public static String getName(Class<? extends Component> component){ ComponentAnn ann = component.getAnnotation(ComponentAnn.class); if(ann == null) { throw new Error("Component " + component + " does not use component annotation."); } return ann.name(); }
/** * Returns the version of a DL-Learner component. * @param component the component * @return Version of the component. */ public static double getVersion(Class<? extends Component> component){ ComponentAnn ann = component.getAnnotation(ComponentAnn.class); return ann.version(); }
String name = cats.getSimpleName(); if (ann != null) { name = ann.name();
axioms.add(ax); ax = f.getOWLDataPropertyAssertionAxiom(EnrichmentVocabulary.version, algorithmInd, algorithm.getAnnotation(ComponentAnn.class).version()); axioms.add(ax);
@ComponentAnn(name = "Jaccard Coefficient", shortName = "jaccard", version = 0.1) public class AccMethodJaccard implements AccMethodTwoValued { public AccMethodJaccard() {} public AccMethodJaccard(boolean init) { if(init)init(); } @Override public void init() { } @Override public double getAccOrTooWeak2(int tp, int fn, int fp, int tn, double noise) { if(tp / (double) (tp+fn) <= 1 - noise) { return -1; } return Heuristics.getJaccardCoefficient(tp, tp + fn + fp); } }
final String heuristicName = heuristic.getClass().getAnnotation(ComponentAnn.class).shortName();
@ComponentAnn(name = "Predictive Accuracy without Weak elimination", shortName = "pred_acc.ocel", version = 0) public class AccMethodPredAccOCEL implements AccMethodTwoValued, AccMethodNoWeakness { public AccMethodPredAccOCEL() { } public AccMethodPredAccOCEL(boolean init) { if (init) init(); } @Override public void init() { } @Override public double getAccOrTooWeak2(int tp, int fn, int fp, int tn, double noise) { int posExamples = tp + fn; int allExamples = posExamples + fp + tn; return Heuristics.divideOrZero( tp + tn, allExamples ); } }
final String heuristicName = heuristic.getClass().getAnnotation(ComponentAnn.class).shortName();
@ComponentAnn(name = "PropertyAxiomLearningProblem", shortName = "palp", version = 0.6) public class PropertyAxiomLearningProblem<T extends OWLPropertyAxiom> extends AbstractLearningProblem<AxiomScore, T, EvaluatedAxiom<T>>{ private OWLProperty propertyToDescribe; @Override public void init() throws ComponentInitException { // TODO Auto-generated method stub throw new ComponentInitException("not implemented"); } @Override public AxiomScore computeScore(T hypothesis, double noise) { // TODO Auto-generated method stub return null; } @Override public double getAccuracyOrTooWeak(T hypothesis, double noise) { // TODO Auto-generated method stub return 0; } }
@ComponentAnn(name = "reflexive object property axiom learner", shortName = "oplrefl", version = 0.1, description="A learning algorithm for reflexive object property domain axioms.") public class ReflexiveObjectPropertyAxiomLearner extends ObjectPropertyCharacteristicsAxiomLearner<OWLReflexiveObjectPropertyAxiom> {
/** * * @author Giuseppe Cota <giuseppe.cota@unife.it>, Riccardo Zese * <riccardo.zese@unife.it> */ @ComponentAnn(name = "EDGEDistributedSingleStep", shortName = "edgesingle", version = 1.0) public class EDGEDistibutedSingleStep extends AbstractEDGEDistributed { public EDGEDistibutedSingleStep() { edge = new EDGEMPISingleStep(); } @Override public void init() throws ComponentInitException { super.init(); throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void start() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }
@ComponentAnn(name="symmetric object property axiom learner", shortName="oplsymm", version=0.1, description="A learning algorithm for symmetric object property axioms.") public class SymmetricObjectPropertyAxiomLearner extends ObjectPropertyCharacteristicsAxiomLearner<OWLSymmetricObjectPropertyAxiom> { public SymmetricObjectPropertyAxiomLearner(SparqlEndpointKS ks){ super(ks); super.posExamplesQueryTemplate = new ParameterizedSparqlString( "SELECT ?s ?o WHERE {?s ?p ?o . ?o ?p ?s .}"); super.negExamplesQueryTemplate = new ParameterizedSparqlString( "SELECT ?s ?o WHERE {?s ?p ?o . FILTER NOT EXISTS{?o ?p ?s .}"); super.POS_FREQUENCY_QUERY = new ParameterizedSparqlString( "SELECT (COUNT(*) AS ?cnt) WHERE {?s ?p ?o . ?o ?p ?s .}"); axiomType = AxiomType.SYMMETRIC_OBJECT_PROPERTY; } /* (non-Javadoc) * @see org.dllearner.algorithms.properties.ObjectPropertyCharacteristicsAxiomLearner#getAxiom(org.semanticweb.owlapi.model.OWLObjectProperty) */ @Override protected OWLSymmetricObjectPropertyAxiom getAxiom(OWLObjectProperty property) { return df.getOWLSymmetricObjectPropertyAxiom(property); } }
@ComponentAnn(name = "irreflexive object property axiom learner", shortName = "oplirrefl", version = 0.1, description="A learning algorithm for irreflexive object property axioms.") public class IrreflexiveObjectPropertyAxiomLearner extends ObjectPropertyCharacteristicsAxiomLearner<OWLIrreflexiveObjectPropertyAxiom> { public IrreflexiveObjectPropertyAxiomLearner(SparqlEndpointKS ks) { super(ks); super.posExamplesQueryTemplate = new ParameterizedSparqlString( "SELECT DISTINCT ?s WHERE {?s ?p ?o . FILTER NOT EXISTS{?s ?p ?s .}}"); super.negExamplesQueryTemplate = new ParameterizedSparqlString( "SELECT DISTINCT ?s WHERE {?s ?p ?s .}"); super.POS_FREQUENCY_QUERY = new ParameterizedSparqlString( "SELECT (COUNT(DISTINCT(?s)) AS ?cnt) WHERE {?s ?p ?o . FILTER NOT EXISTS {?s ?p ?s .} }"); COUNT_QUERY = DISTINCT_SUBJECTS_COUNT_QUERY; axiomType = AxiomType.IRREFLEXIVE_OBJECT_PROPERTY; } /* (non-Javadoc) * @see org.dllearner.algorithms.properties.ObjectPropertyCharacteristicsAxiomLearner#getAxiom(org.semanticweb.owlapi.model.OWLObjectProperty) */ @Override protected OWLIrreflexiveObjectPropertyAxiom getAxiom(OWLObjectProperty property) { return df.getOWLIrreflexiveObjectPropertyAxiom(property); } }
@ComponentAnn(name = "DisjunctiveHeuristic", shortName = "disjunctive_heuristic", version = 0.1) public class DisjunctiveHeuristic implements ELHeuristic { ELDescriptionTreeComparator edt = new ELDescriptionTreeComparator(); @Override public int compare(SearchTreeNode tree1, SearchTreeNode tree2) { double diff = tree1.getScore().getAccuracy()-tree2.getScore().getAccuracy(); if(diff < 0.00001 && diff > -0.00001) { return edt.compare(tree1.getDescriptionTree(), tree2.getDescriptionTree()); } else if(diff > 0){ return 1; // return (int)Math.signum(diff); } else { return -1; } } /* (non-Javadoc) * @see org.dllearner.core.Component#init() */ @Override public void init() throws ComponentInitException { } }
/** * A stable comparator for search tree nodes. Stable means that the order * of nodes will not change during the run of the learning algorithm. In * this implementation, this is ensured by using only covered examples * and tree size as criteria. * * @author Jens Lehmann * */ @ComponentAnn(name = "Stable Heuristic", shortName = "el_heuristic", version = 0.1) public class StableHeuristic implements ELHeuristic { private final ELDescriptionTreeComparator cmp = new ELDescriptionTreeComparator(); @Override public int compare(SearchTreeNode o1, SearchTreeNode o2) { return ComparisonChain.start() .compare(o1.getScore().getAccuracy(), o2.getScore().getAccuracy()) .compare(o2.getDescriptionTree().size, o1.getDescriptionTree().size) .compare(o1.getDescriptionTree(), o2.getDescriptionTree(), cmp) .result(); } /* (non-Javadoc) * @see org.dllearner.core.Component#init() */ @Override public void init() throws ComponentInitException {} }
@ComponentAnn(name="data subproperty axiom learner", shortName="dplsubprop", version=0.1, description="A learning algorithm data subproperty axioms.") public class SubDataPropertyOfAxiomLearner extends DataPropertyHierarchyAxiomLearner<OWLSubDataPropertyOfAxiom> {