owl-api

SWRL rules creation in OWLAPI ontology

萝らか妹 提交于 2019-12-23 05:08:48
问题 I have run (in Neatbeans 8.2) the following simple java code, in order to experiment with SWRL language: String base = "http://www.prova/testont.owl"; IRI ontologyIRI = IRI.create(base); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology ontology = manager.createOntology(ontologyIRI); OWLDataFactory factory = manager.getOWLDataFactory(); OWLClass adult = factory.getOWLClass(IRI.create(ontologyIRI + "#Adult")); OWLClass person = factory.getOWLClass(IRI.create

How to add rdfs:label to OWLIndividual via OWLAPI?

给你一囗甜甜゛ 提交于 2019-12-22 11:47:51
问题 I would like to add an rdfs:label to an OWLIndividual , I have the following: OWLIndividual newIndividual = factory.getOWLNamedIndividual(IRI.create(name)); OWLLiteral lbl = factory.getOWLLiteral(name); OWLAnnotation label = factory.getOWLAnnotation( factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()), lbl); Now, how can I associate the label to the individual? 回答1: You can associate the label the following way: OWLAxiom axiom = factory.getOWLAnnotationAssertionAxiom

How to add rdfs:label to OWLIndividual via OWLAPI?

半腔热情 提交于 2019-12-22 11:47:28
问题 I would like to add an rdfs:label to an OWLIndividual , I have the following: OWLIndividual newIndividual = factory.getOWLNamedIndividual(IRI.create(name)); OWLLiteral lbl = factory.getOWLLiteral(name); OWLAnnotation label = factory.getOWLAnnotation( factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()), lbl); Now, how can I associate the label to the individual? 回答1: You can associate the label the following way: OWLAxiom axiom = factory.getOWLAnnotationAssertionAxiom

getting all individuals of a specific class using OWLAPi and JFact reasoner

安稳与你 提交于 2019-12-21 20:03:15
问题 Is there any way to get all individuals of a specific class using reasoner? Reasoner because i want to get all the inferred and assereted individuals of that class. I am using JFact reasoner, and i am trying for loops and if statement. And i want to find the individuals of class e.g "person". But i am unable to see the individuals. Any idea about below code or is there any method for this purpose? for (OWLClass c : myPizza.getClassesInSignature()) { NodeSet<OWLNamedIndividual> instances =

OWLAPI data types

柔情痞子 提交于 2019-12-13 06:12:36
问题 I need to get the OWLDatatype or a OWL2Datatype from the corresponding string. For example, given xsd:string I would like to get the corresponding enum constant OWL2Datatype.XSD_STRING. I tried in the following ways: - OWL2Datatype strDT = OWL2Datatype.valueOf("xsd:string") - OWL2Datatype strDT = OWL2Datatype.valueOf("string") - OWL2Datatype owl2dt = OWL2Datatype.valueOf(OWL2Datatype.XSD_STRING.getIRI().toString()); but they all fail throwing an exception: java.lang.IllegalArgumentException:

Problems querying OWL ontology through OWL API

巧了我就是萌 提交于 2019-12-12 04:39:48
问题 I have the ontology used in the OWL API examples. private static final String KOALA = "<?xml version=\"1.0\"?>\n" + "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" xmlns:owl=\"http://www.w3.org/2002/07/owl#\" xmlns=\"http://protege.stanford.edu/plugins/owl/owl-library/koala.owl#\" xml:base=\"http://protege.stanford.edu/plugins/owl/owl-library/koala.owl\">\n" + " <owl:Ontology rdf:about=\"\"/>\n" + " <owl:Class rdf:ID=\

OWL-API : Identify owl format based on its string contents

女生的网名这么多〃 提交于 2019-12-12 02:14:19
问题 I have owl files with different formats (RDF/XML , Turtle, Manchester OWL Syntax). I want to identify the format based on its contents as different format has its own style. E.g RDF/XML : <?xml version="1.0"?> <!DOCTYPE rdf:RDF [ <!ENTITY owl "http://www.w3.org/2002/07/owl#" > <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" > <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >]> <rdf:RDF xmlns="namespace#" xml:base="namespace"

How to get annotations from owl individual using OWLAPI

依然范特西╮ 提交于 2019-12-11 18:58:51
问题 I already know how to get annotations from OWL classes (see the java code below). But I'm not able to get annotations from OWL individuals. Could anybody please tell me how to code the same functionality for an OWLIndividual instead of an OWLClass? Thankyou! IRI iri = IRI.create("http://www.example.com/ontology/108024893-n"); //class IRI OWLClass clazz = manager.getOWLDataFactory().getOWLClass(iri); for (OWLAnnotation annotation : clazz.getAnnotations(ontology)) { System.out.println("

comparing an classes of ontologies to an xml document nodes

走远了吗. 提交于 2019-12-11 17:46:59
问题 My objective is to compare an ontology to a provided XML document by searching nodes from the document having the same name as the ontology classes. To do so, I use the following code : public void freqConcept(String xmldoc,OWLClass node){ try { String filepath = xmldoc; DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(filepath); doc.getDocumentElement().normalize(); list =

SPARQL-DL: query for literals

拜拜、爱过 提交于 2019-12-11 06:15:04
问题 I'm using SPARQL-DL with OWL-API in a Java application. The Maven dependency is the following: <dependency> <groupId>edu.stanford.protege</groupId> <artifactId>de-derivo-sparqldlapi</artifactId> <version>2.0.0</version> </dependency> I assume it downloads the right (compatible) version of OWL-API. I have a class Person with some individuals. Each individual has a data property called name which ranges over a string. By running this query: SELECT ?x WHERE { PropertyValue(?y, my:name, ?x) } I