@Override public OWLClass getOWLClass(IRI iri) { return new OWLClassImpl(iri); }
@Override public OWLClass getOWLClass(IRI iri) { return new OWLClassImpl(iri); }
@Override public OWLClass getOWLClass(IRI iri) { return new OWLClassImpl(iri); }
@Override public OWLClass getOWLClass(IRI iri) { return new OWLClassImpl(iri); }
@Override public OWLClass getOWLClass(IRI iri) { return new OWLClassImpl(iri); }
@Override public OWLClass getOWLClass(IRI iri) { return new OWLClassImpl(iri); }
public OWLClass getOWLClass(IRI iri) { OWLClass cls = classesByURI.get(iri); if (cls == null) { cls = new OWLClassImpl(this, iri); classesByURI.put(iri, cls); } return cls; }
public static Set<OWLClass> readExamples(String filePath) throws IOException { Set<OWLClass> classes = new TreeSet<>(); try(BufferedReader buffRead = new BufferedReader(new FileReader(new File(filePath)))){ String line; while ((line = buffRead.readLine()) != null) { line = line.trim(); // line = line.substring(1, line.length()-1); // strip off angle brackets classes.add(new OWLClassImpl(IRI.create(line))); } } return classes; }
@Override public void setAsText(String s) throws IllegalArgumentException { if (!whitespace.matcher(s).find() && Pattern.compile(":").matcher(s).find()) { // it already is a full URI value = new OWLClassImpl(IRI.create(s)); } else { // quote IRIs s = s.replaceAll("(?<=^|\\s|\\()((?:([^:/?#\\s]*):)(?://([^/?#]*?))?([^?#]*?)(?:\\?([^#]*?))?(?:#(.*?))?)(?=\\)|\\s|$)", "<$1>"); // Bad hack to allow unparsed Manchester expressions. You need to decode this IRI and use the Manchester Parser once you have the Ontology IRI iri = IRI.create(OWLAPIUtils.UNPARSED_OCE + s); value = new OWLClassImpl(iri); } } }
public static OWLClass instantiate(SerializationStreamReader streamReader) throws SerializationException { return new OWLClassImpl(IRI.create(streamReader.readString())); }
@SuppressWarnings("unchecked") static <E extends OWLEntity> E getOWLEntity(EntityType<E> entityType, IRI iri) { if (entityType.equals(EntityType.CLASS)) { return (E) new OWLClassImpl(iri); } else if (entityType.equals(EntityType.OBJECT_PROPERTY)) { return (E) new OWLObjectPropertyImpl(iri); } else if (entityType.equals(EntityType.DATA_PROPERTY)) { return (E) new OWLDataPropertyImpl(iri); } else if (entityType.equals(EntityType.ANNOTATION_PROPERTY)) { return (E) new OWLAnnotationPropertyImpl(iri); } else if (entityType.equals(EntityType.NAMED_INDIVIDUAL)) { return (E) new OWLNamedIndividualImpl(iri); } else if (entityType.equals(EntityType.DATATYPE)) { return (E) new OWLDatatypeImpl(iri); } return null; }
@Override public void visit(OWLNamedIndividual individual) { if(!visitedIndividuals.contains(individual)){ visitedIndividuals.add(individual); currentDepth++; Set<OWLIndividualAxiom> axioms = ontology.getAxioms(individual, Imports.INCLUDED); for (OWLIndividualAxiom ax : axioms) { ax.accept(this); } currentDepth--; // handle punning if enabled if(allowPunning && punningClasses.contains(individual.getIRI())){ boolean inTBoxBefore = inTBox; inTBox = true; new OWLClassImpl(individual.getIRI()).accept(this); inTBox = inTBoxBefore; } } }
public static void main(String[] args) throws Exception{ // StringRenderer.setRenderer(Rendering.DL_SYNTAX); Logger.getRootLogger().setLevel(Level.INFO); Logger.getLogger(PCELOE.class).setLevel(Level.DEBUG); Logger.getLogger(PCELOE.class).addAppender(new FileAppender(new PatternLayout( "[%t] %c: %m%n" ), "log/parallel_run.txt", false)); AbstractKnowledgeSource ks = new OWLFile("../examples/family/father_oe.owl"); ks.init(); AbstractReasonerComponent rc = new ClosedWorldReasoner(ks); rc.init(); ClassLearningProblem lp = new ClassLearningProblem(rc); lp.setClassToDescribe(new OWLClassImpl(IRI.create("http://example.com/father#father"))); lp.setCheckConsistency(false); lp.init(); PCELOE alg = new PCELOE(lp, rc); alg.setMaxExecutionTimeInSeconds(10); alg.setNrOfThreads(4); // alg.setMaxClassDescriptionTests(200); alg.init(); alg.start(); }
public static void main(String[] args) throws Exception { ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia()); ks.init(); SimpleSubclassLearner la = new SimpleSubclassLearner(ks); la.setEntityToDescribe(new OWLClassImpl(IRI.create("http://dbpedia.org/ontology/Book"))); la.setUseSampling(false); la.setBatchMode(true); la.setStrictOWLMode(true); la.setReturnOnlyNewAxioms(true); la.setProgressMonitor(new ConsoleAxiomLearningProgressMonitor()); la.init(); la.start(); la.getCurrentlyBestEvaluatedAxioms(0.3).forEach(ax -> { System.out.println("---------------\n" + ax); la.getPositiveExamples(ax).stream().limit(5).forEach(System.out::println); }); } }
public static void main(String[] args) throws Exception{ CELOEWrapper la = new CELOEWrapper(new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW())); la.setEntityToDescribe(new OWLClassImpl(IRI.create("http://dbpedia.org/ontology/Book"))); la.init(); la.start(); // new CELOEWrapper(new SparqlEndpointKS(SPARqlend)) }
private OWLEntity getEntity(String resourceURI, String entityType, SparqlEndpoint endpoint) { OWLEntity entity = null; switch (entityType) { case "class": entity = new OWLClassImpl(IRI.create(resourceURI)); break; case "objectproperty": entity = new OWLObjectPropertyImpl(IRI.create(resourceURI)); break; case "dataproperty": entity = new OWLDataPropertyImpl(IRI.create(resourceURI)); break; default: SPARQLTasks st = new SPARQLTasks(endpoint); entity = st.guessResourceType(resourceURI, true); break; } return entity; } }
public static void main(String[] args) throws Exception { SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.create("http://sake.informatik.uni-leipzig.de:8890/sparql", "http://dbpedia.org")); ks.init(); DisjointClassesLearner la = new DisjointClassesLearner(ks); la.setEntityToDescribe(new OWLClassImpl(IRI.create("http://dbpedia.org/ontology/Actor"))); la.setUseSampling(false); la.init(); la.start(); la.getCurrentlyBestAxioms(10); } }
@Test public void test5() throws ComponentInitException { AbstractReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.TRAINS_OWL); RefinementOperator operator = new ELDown(rs); operator.init(); Set<OWLClassExpression> refinements = operator.refine(new OWLClassImpl(OWLRDFVocabulary.OWL_THING.getIRI())); for(OWLClassExpression refinement : refinements) { System.out.println(refinement); } // Set<Description> subClasses = rs.getSubClasses(Thing.instance); // for(Description cl : subClasses) { // System.out.println(cl); // } }
public void testLearnSingleClass() throws ComponentInitException{ ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpediaLiveAKSW()); ks.init(); reasoner = new SPARQLReasoner(ks); reasoner.init(); DisjointClassesLearner l = new DisjointClassesLearner(ks); l.setReasoner(reasoner); l.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); l.setEntityToDescribe(new OWLClassImpl(IRI.create("http://dbpedia.org/ontology/Book"))); l.init(); l.start(); System.out.println(l.getCurrentlyBestAxioms(5)); }
@Test public void test7() { AbstractReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.SIMPLE); ELDescriptionTree tree = new ELDescriptionTree(rs); OWLObjectProperty has = new OWLObjectPropertyImpl(IRI.create(uri("has"))); OWLObjectProperty hasChild = new OWLObjectPropertyImpl(IRI.create(uri("hasChild"))); OWLClass human = new OWLClassImpl(IRI.create(uri("human"))); OWLClass animal = new OWLClassImpl(IRI.create(uri("animal"))); ELDescriptionNode v1 = new ELDescriptionNode(tree, human); new ELDescriptionNode(v1, has, animal); new ELDescriptionNode(v1, hasChild); // System.out.println(tree.toSimulationString()); assertTrue(tree.isMinimal()); }