@Override public OWLObjectProperty getOWLObjectProperty(IRI iri) { return new OWLObjectPropertyImpl(iri); }
@Override public OWLObjectProperty getOWLObjectProperty(IRI iri) { return new OWLObjectPropertyImpl(iri); }
@Override public OWLObjectProperty getOWLObjectProperty(IRI iri) { return new OWLObjectPropertyImpl(iri); }
@Override public OWLObjectProperty getOWLObjectProperty(IRI iri) { return new OWLObjectPropertyImpl(iri); }
@Override public OWLObjectProperty getOWLObjectProperty(IRI iri) { return new OWLObjectPropertyImpl(iri); }
@Override public OWLObjectProperty getOWLObjectProperty(IRI iri) { return new OWLObjectPropertyImpl(iri); }
public OWLObjectProperty getOWLObjectProperty(IRI iri) { OWLObjectProperty prop = objectPropertiesByURI.get(iri); if (prop == null) { prop = new OWLObjectPropertyImpl(this, iri); objectPropertiesByURI.put(iri, prop); } return prop; }
public static OWLObjectProperty instantiate(SerializationStreamReader streamReader) throws SerializationException { return new OWLObjectPropertyImpl(IRI.create(streamReader.readString())); }
@WebMethod public String[] getIndividualsForARole(int id, String role) throws ClientNotKnownException { ClientState state = getState(id); Map<OWLIndividual,SortedSet<OWLIndividual>> m = state.getReasonerComponent().getPropertyMembers( new OWLObjectPropertyImpl(IRI.create(role))); Set<OWLIndividual> individuals = m.keySet(); return Datastructures.sortedSet2StringListIndividuals(individuals); }
@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; }
public static void main(String[] args) throws Exception { SparqlEndpointKS ks = new SparqlEndpointKS(new SparqlEndpoint( new URL("http://dbpedia.org/sparql"), "http://dbpedia.org")); ks.init(); OWLProperty p1 = new OWLObjectPropertyImpl(IRI.create("http://dbpedia.org/ontology/birthPlace")); OWLProperty p2 = new OWLObjectPropertyImpl(IRI.create("http://dbpedia.org/ontology/genre")); OWLIndividual ind1 = new OWLNamedIndividualImpl(IRI.create("http://dbpedia.org/resource/Kid_Canaveral")); InformativenessMeasures informativenessMeasures = new InformativenessMeasures(ks.getQueryExecutionFactory()); double itf1 = informativenessMeasures.getInverseTripleFrequency(p1); System.out.println("itf(" + p1 + ") = " + itf1); double itf2 = informativenessMeasures.getInverseTripleFrequency(p2); System.out.println("itf(" + p2 + ") = " + itf2); double pf1_out = informativenessMeasures.getPredicateFrequency(ind1, p1, true); double pf1_in = informativenessMeasures.getPredicateFrequency(ind1, p1, false); System.out.println("pf_out(" + ind1 + "," + p1 + ") = " + pf1_out); System.out.println("pf_in(" + ind1 + "," + p1 + ") = " + pf1_in); double pf2_out = informativenessMeasures.getPredicateFrequency(ind1, p2, true); double pf2_in = informativenessMeasures.getPredicateFrequency(ind1, p2, false); System.out.println("pf_out(" + ind1 + "," + p2 + ") = " + pf2_out); System.out.println("pf_in(" + ind1 + "," + p2 + ") = " + pf2_in); }
public static void main(String[] args) throws Exception { ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia()); ks.init(); ObjectPropertyDomainAxiomLearner la = new ObjectPropertyDomainAxiomLearner(ks); la.setPropertyToDescribe(new OWLObjectPropertyImpl(IRI.create("http://dbpedia.org/ontology/author"))); la.setUseSampling(false); la.setBatchMode(true); la.setProgressMonitor(new ConsoleAxiomLearningProgressMonitor()); la.init(); la.start(); la.getCurrentlyBestEvaluatedAxioms().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 { ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia()); ks.init(); ObjectPropertyRangeAxiomLearner la = new ObjectPropertyRangeAxiomLearner(ks); la.setPropertyToDescribe(new OWLObjectPropertyImpl(IRI.create("http://dbpedia.org/ontology/author"))); la.setUseSampling(false); la.setBatchMode(true); la.setProgressMonitor(new ConsoleAxiomLearningProgressMonitor()); la.init(); la.start(); la.getCurrentlyBestEvaluatedAxioms().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 { ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); SparqlEndpointKS ks = new SparqlEndpointKS(SparqlEndpoint.getEndpointDBpedia()); ks.init(); SubObjectPropertyOfAxiomLearner la = new SubObjectPropertyOfAxiomLearner(ks); la.setEntityToDescribe(new OWLObjectPropertyImpl(IRI.create("http://dbpedia.org/ontology/author"))); la.setUseSampling(false); la.setBatchMode(true); la.setProgressMonitor(new ConsoleAxiomLearningProgressMonitor()); la.init(); la.start(); la.getCurrentlyBestEvaluatedAxioms().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 { TransitiveObjectPropertyAxiomLearner l = new TransitiveObjectPropertyAxiomLearner(new SparqlEndpointKS( SparqlEndpoint.getEndpointDBpediaLiveAKSW())); l.setEntityToDescribe(new OWLObjectPropertyImpl(IRI.create("http://dbpedia.org/ontology/birthPlace"))); l.setMaxExecutionTimeInSeconds(5); l.init(); l.start(); List<EvaluatedAxiom<OWLTransitiveObjectPropertyAxiom>> axioms = l.getCurrentlyBestEvaluatedAxioms(5, 0.0); System.out.println(axioms); for (EvaluatedAxiom<OWLTransitiveObjectPropertyAxiom> axiom : axioms) { l.explainScore(axiom); } }
public static void main(String[] args) throws Exception{ ErrorHandlerFactory.setDefaultErrorHandler(ErrorHandlerFactory.errorHandlerStrictNoLogging); SparqlEndpoint endpoint = new SparqlEndpoint(new URL("http://dbpedia.org/sparql"), "http://dbpedia.org"); // endpoint = SparqlEndpoint.getEndpointDBpedia(); SparqlEndpointKS ks = new SparqlEndpointKS(endpoint); ks.init(); OWLEntity entity = new OWLObjectPropertyImpl(IRI.create("http://dbpedia.org/ontology/author")); MultiPropertyAxiomLearner la = new MultiPropertyAxiomLearner(ks); la.setEntityToDescribe(entity); la.setUseSampling(true); la.setMaxSampleGenerationTime(10, TimeUnit.SECONDS); la.setMaxNrOfThreads(1); la.setAxiomTypes(Sets.newHashSet( AxiomType.OBJECT_PROPERTY_DOMAIN, AxiomType.OBJECT_PROPERTY_RANGE, AxiomType.SUB_OBJECT_PROPERTY, AxiomType.EQUIVALENT_OBJECT_PROPERTIES, AxiomType.FUNCTIONAL_OBJECT_PROPERTY, AxiomType.ASYMMETRIC_OBJECT_PROPERTY, AxiomType.IRREFLEXIVE_OBJECT_PROPERTY, AxiomType.TRANSITIVE_OBJECT_PROPERTY ) ); la.setMaxExecutionTime(1, TimeUnit.MINUTES); la.start(); }
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; } }
@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()); }
@Test public void asTest() throws ComponentInitException, MalformedURLException { String ont = "../test/galen2.owl"; KnowledgeSource source = new OWLFile(ont); source.init(); AbstractReasonerComponent reasoner = new OWLAPIReasoner(Collections.singleton(source)); reasoner.init(); System.out.println("Galen loaded."); ELDescriptionTree tree = new ELDescriptionTree(reasoner); OWLClass a1 = new OWLClassImpl(IRI.create("http://www.co-ode.org/ontologies/galen#1.0")); OWLClass a2 = new OWLClassImpl(IRI.create("http://www.co-ode.org/ontologies/galen#10.0")); OWLClass a3 = new OWLClassImpl(IRI.create("http://www.co-ode.org/ontologies/galen#6.0")); OWLClass a4 = new OWLClassImpl(IRI.create("http://www.co-ode.org/ontologies/galen#TopCategory")); OWLObjectProperty r1 = new OWLObjectPropertyImpl(IRI.create("http://www.co-ode.org/ontologies/galen#Attribute")); OWLObjectProperty r2 = new OWLObjectPropertyImpl(IRI.create("http://www.co-ode.org/ontologies/galen#DomainAttribute")); ELDescriptionNode v1 = new ELDescriptionNode(tree, a1, a2); ELDescriptionNode v2 = new ELDescriptionNode(v1, r2, a1, a3, a4); ELDescriptionNode v3 = new ELDescriptionNode(v1, r1, a1, a4); new ELDescriptionNode(v3, r1); ELDescriptionNode w = new ELDescriptionNode(v2, r1); ELDown operator = new ELDown(reasoner); operator.init(); System.out.println(operator.asCheck(w)); }
@Test public void simulationTest() { AbstractReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.EMPTY); Simulation s = new Simulation(); ELDescriptionTree tree1 = new ELDescriptionTree(rs); ELDescriptionTree tree2 = new ELDescriptionTree(rs); ELDescriptionNode t1 = new ELDescriptionNode(tree1); ELDescriptionNode t2 = new ELDescriptionNode(tree2); TreeTuple tuple1 = new TreeTuple(t1,t2); s.addTuple(tuple1); assertTrue(s.in(t2).size() == 1); // assertTrue(s.out(t2).size() == 0); OWLObjectProperty p = new OWLObjectPropertyImpl(IRI.create("p")); TreeSet<OWLClass> l3 = new TreeSet<>(); ELDescriptionNode t3 = new ELDescriptionNode(t1,p,l3); assertTrue(t3.getLevel() == 2); assertTrue(tree1.getMaxLevel() == 2); }