Modeling geographic co-ordinates in OWL - semantic-web

I am developing an ontology and need to model geographic co-ordinates (lat/long) as part of an address of a person. Geo Names was the obvious choice, but it's too large and verbose for my use, which led me to W3C Geo vocabulary (http://www.w3.org/2003/01/geo/).
It has a Point class, and lat/long/alt properties which should suffice my need. However, I am not able to find it, let alone set it as properties in Protege. Further investigation reveaved that “Point” is an rdfs:Class and "lat/long/alt" are rdf:Properties. I am guessing this is the reason why it is not showing up in Protege.
Is there a way to use these properties in an OWL ontology? Or are there other vocabularies that would let me specify geographic Points, Lines etc?
Thanks,

Assuming you are trying to open the file wgs84_pos present on the page http://www.w3.org/2003/01/geo/, it appears that the properties are using a format not understood by Protege 4.1 (plain RDF). Look at the line 143, you will see that:
<rdf:Property rdf:about="http://www.w3.org/2003/01/geo/wgs84_pos#lat">
<rdfs:domain rdf:resource="http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing" />
<rdfs:label>latitude</rdfs:label>
<rdfs:comment>The WGS84 latitude of a SpatialThing (decimal degrees).</rdfs:comment>
</rdf:Property>
rdf:Property is not in the scope of OWL (too generic, in OWL properties are either object or data properties), therefore not displayed by Protege 4.1.
I advise that you re-create the ontology from scratch following the documentation on the web page and by looking at the RDF file. Just add the properties you need (should be quick), save, open the saved file and compare with the one you downloaded to see the differences.
The rough structure of the ontology made with Protege looks like this:
<?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 wgs84_pos "http://www.w3.org/2003/01/geo/wgs84_pos#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www.w3.org/2003/01/geo/wgs84_pos#"
xml:base="http://www.w3.org/2003/01/geo/wgs84_pos"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:wgs84_pos="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<owl:Ontology rdf:about="http://www.w3.org/2003/01/geo/wgs84_pos#"/>
<owl:DatatypeProperty rdf:about="&wgs84_pos;lat">
<rdfs:domain rdf:resource="&wgs84_pos;SpatialThing"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="&wgs84_pos;long">
<rdfs:domain rdf:resource="&wgs84_pos;SpatialThing"/>
</owl:DatatypeProperty>
<owl:Class rdf:about="&wgs84_pos;Point">
<rdfs:subClassOf rdf:resource="&wgs84_pos;SpatialThing"/>
</owl:Class>
<owl:Class rdf:about="&wgs84_pos;SpatialThing"/>

Related

How to write a SPARQL query to pull from OWL file

So this is my owl File I absolutely new to Jena/SQL items so I am just trying to test it out.
prefix part:
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
xml:base="http://www.semanticweb.org/ontologies/5/test-ontology-2
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
ontologyIRI="http://www.semanticweb.org/ontologies/5/test-ontology-2>
<Prefix name="" IRI="http://www.semanticweb.org/ontologies/5/test-ontology-2/>
<Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
<Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
<Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
<Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
I am attempting to write one to just pull anything that shows hasConcept. However, I know the hasConcept is part of the prefix? I think that is what it is called. So I'm not sure how to just filter it to pull it.
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/ontologies/5/test-ontology-
2#Structures">
<rdf:type rdf:resource="http://www.semanticweb.org/ontologies/5/test-ontology-2#Course"/>
<untitled-ontology-2:hasConcept
rdf:resource="http://www.semanticweb.org/ontologies/5/test-ontology-2#Cong"/>
<untitled-ontology-2:hasConcept
rdf:resource="http://www.semanticweb.org/ontologies/5/test-ontology-2#Func"/>
<untitled-ontology-2:hasTopic rdf:resource="http://www.semanticweb.org/ontologies/5/test-
ontology-2#Time"/>
<untitled-ontology-2:courseNumber>CMSC 2123</untitled-ontology-2:courseNumber>
</owl:NamedIndividual>
I've tried going through the documentation on Apache Jena which I can understand through their example for RDF but I still get a little confused mainly because I'm not a good programmer so concepts are still hard for me to understand.
But I'm just trying any help would be greatly appreciated.
I'm not sure how to pull just the #func,#cong,#time part or if it is even possible to pull just this section.

Slow SPARQL query with rdf:Seq

I'm trying to retrieve all elements of a rdf:Seq with SPARQL. The RDF structure is as follows. A subproject with a rdf:Seq of timeclaims and the individual timeclaim information. The list of timeclaims for a subproject can be of any length:
<rdf:Description rdf:about="http://www.example.com/resource/subproject/2017-nieuw-1">
<rdf:type rdf:resource="http://www.example.com/ontologie/example/Subproject"/>
<rdfs:label>Subproject label</rdfs:label>
<pbl:subproject_timeclaims rdf:resource="http://www.example.com/resource/list/5853abbfdcc97"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.com/resource/list/5853abbfdcc97">
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq"/>
<rdf:_1 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfd6aa4"/>
<rdf:_7 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfd957b"/>
<rdf:_6 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfd8e68"/>
<rdf:_14 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfdc541"/>
<rdf:_5 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfd879f"/>
<rdf:_2 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfd71db"/>
<rdf:_3 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfd78be"/>
<rdf:_4 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfd7f92"/>
<rdf:_8 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfd9c4c"/>
<rdf:_9 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfda31c"/>
<rdf:_10 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfdaa08"/>
<rdf:_11 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfdb0e6"/>
<rdf:_12 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfdb7bd"/>
<rdf:_13 rdf:resource="http://www.example.com/resource/timeclaim/5853abbfdbe7f"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.com/resource/timeclaim/5853abbfdc541">
<rdf:type rdf:resource="http://www.example.com/ontologie/example/Timeclaim"/>
<pbl:timeclaim_description>Description</pbl:timeclaim_description>
<pbl:timeclaim_hours>25</pbl:timeclaim_hours>
<pbl:timeclaim_employee
rdf:resource="http://www.example.com/resource/employee/2222333334444"/>
</rdf:Description>
Starting from the timeclaims I'm trying to retrieve the information of the subproject above (and filter on it). But the query is taking forever. Eventually the data is returned but I have the feeling it could be quicker.
SELECT *
WHERE {
?tc_item a :Timeclaim .
?tc_list ?p ?tc_item .
?subproject pbl:subproject_timeclaims ?tc_list
}
Could you point out any mistakes in the SPARQL query and better ways of doing this? Or maybe the RDF structure could be improved? The numbering in this case is not really relevant but the same list structure with rdf:Seq is present in more places in the database (and the order is important in those cases).

How can I have named entities in asciidoctor?

I'm using asciidoctor with the docbook backend for books. In the past I wrote DocBook, which allows me to declare named entities that I use throughout the book:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE book [
<!ENTITY class "Galactic TOP SECRET">
<!ENTITY project "World Domination">
<!ENTITY product "Illuminati Mind Control Chemtrail Spray System CSS-2020">
]>
<book ...>
...
What about our &class; &project;?
Is our &product; working?
...
</book>
:-)
I haven't found a way to tell asciidoctor to insert the DOCTYPE declaration between the XML processing instruction and the <book> element. So I resorted to --no-header-footer and prepending the header and footer lines. Is there a better way to do this? Something like a named entity definition directive? An include mechanism?
Do you have to use Docbook entity declarations? Asciidoctor has "attributes" that can serve the same purpose: https://asciidoctor.org/docs/user-manual/#attributes
For example, you can define an attribute within your document:
:class: Galactic TOP SECRET
Then later in your document, you can use the attribute:
"Billy, come up to the front and address the {class}." said the teacher.
When you transform your document to Docbook, you would see:
<simpara>"Billy, come up to the front and address the Galactic TOP SECRET."
said the teacher.</simpara>
If you do have to use Docbook entity declarations, you might use some XSL to transform the XML you get into the XML you want.

OWL : how to restrict range with some values in an other property

I have a class Selfie, an objectProperty personPicture (domain Picture, range Person) to explain who is on the picture, and a dc:creator. I want to say that a selfie must have at least 1 personPicture, and the dc:creator should be someone in the list of personPicture. I tried :
<owl:Class rdf:about="http://www.semanticweb.org/leo/ontologies/album#Selfie">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/leo/ontologies/album#Picture"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/leo/ontologies/album#personPicture"/>
<owl:minQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:minQualifiedCardinality>
<owl:onClass rdf:resource="http://www.semanticweb.org/leo/ontologies/album#Person"/>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
but it doesn't work. I can have a selfie without personPicture and I absolutely don't know how to do the second trick!
Your axioms are easier to read in Manchester syntax, where they are:
Selfie SubClassOf Picture
Selfie SubClassOf personPicture min 1 Person
The second says that each Selfie is related to at least one Person by the property personPicture. That's consistent with a dataset like:
x a Selfie .
Even though it doesn't specify which Person x is related to by personPicture, a reasoner will correctly infer that there is one. That's part of the open-world assumption that is adopted in OWL. Just because something isn't know does not mean that it is false.
As for your second condition, I'm not sure that you can express it in OWL. You might be able to the axiom that "if a picture's creator is in the picture, then the picture is a Selfie", but that's the other direction from what you're asking.

SPARQL query does not find individual in imported ontology when run in jena

I have 3 ontology files where the first imports the second and the second imports the third:
The first ontology imports the second one:
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.example.com/user/rainer/ontologies/2016/1/usecase_individuals#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:uc="http://www.example.com/user/rainer/ontologies/2016/1/usecase#">
<owl:Ontology rdf:about="http://www.example.com/user/rainer/ontologies/2016/1/usecase_individuals">
<owl:imports rdf:resource="http://www.example.com/user/rainer/ontologies/2016/1/usecase"/>
</owl:Ontology>
....
The second ontology imports the thrid one:
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.example.com/user/rainer/ontologies/2016/1/usecase#"
xml:base="http://www.example.com/user/rainer/ontologies/2016/1/usecase"
xmlns:fgcm="http://www.example.com/user/rainer/ontologies/2016/1/fgcm#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:uc="http://www.example.com/user/rainer/ontologies/2016/1/usecase#">
<owl:Ontology rdf:about="http://www.example.com/user/rainer/ontologies/2016/1/usecase">
<owl:imports rdf:resource="http://www.boeing.com/user/rainer/ontologies/2016/1/fgcm"/>
</owl:Ontology>
....
And the third ontology (created in Protégé) asserts an individual:
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.boeing.com/user/rainer/ontologies/2016/1/fgcm#"
...
<owl:NamedIndividual rdf:about="http://www.boeing.com/user/rainer/ontologies/2016/1/fgcm#admin">
<rdf:type rdf:resource="http://www.boeing.com/user/rainer/ontologies/2016/1/fgcm#User"/>
<userName>admin</userName>
</owl:NamedIndividual>
...
When I open the first ontology in Protégé and execute the SPARQL query
PREFIX fgcm: <http://www.example.com/user/rainer/ontologies/2016/1/fgcm#>
SELECT ?subject ?name WHERE { ?subject fgcm:userName ?name}
it find the individual in the third ontology without a problem. When I run the same SPARQL query from code in Jena I don't get that individual. The query is run against an OntModel that was created with the default settings.
I know that Jena is able to load and import the ontologies because I can access classes and properties from the imported ontologies, both in SPARQL queries and directly using the Jena API. My problem appears to be limited to the individuals that are asserted in the imported ontology.
I have searched for settings (when loading the ontology such as the different OntModelSpecs or when creating/ running the query) that might change this behavior but haven't found any solutions.
It turned out that I was mistaken about Jena successfully loading the imported ontologies. (Not getting an error does not imply that the ontology that should be imported was actually found).
The SPARQL queries returned the expected result after using an OntDocumentManager and telling it where to find the ontology files that needed to be imported. This is the code snipped that worked for me:
OntDocumentManager mgr = new OntDocumentManager ();
mgr.addAltEntry("http://www.boeing.com/user/rainer/ontologies/2016/1/usecase", "file:C:\\Dev\\luna_workspace\\fgcm_translate\\usecase.owl");
mgr.addAltEntry("http://www.boeing.com/user/rainer/ontologies/2016/1/fgcm", "file:C:\\Dev\\luna_workspace\\fgcm_translate\\fgcm.owl");
OntModelSpec spec = new OntModelSpec ( OntModelSpec .OWL_DL_MEM_TRANS_INF);
spec.setDocumentManager(mgr);
OntModel model = ModelFactory.createOntologyModel(spec);
I hope this helps someone if they run into a similar problem.