Do I put the ontology in blazegraph together with the data? - database

I'm trying to learn how to use Blazegraph.
I have created an ontology and added it to the database. No problems. Blazegraph seems easy to use.
Now to my question. I notice that if I query the database now, I get triples from the ontology as answers from sparql queries. So if I add data to the same database, the answers from sparql queries will be from the ontology mixed with the data itself.
Should I not keep the ontology in the same database, or how do I avoid mixing the ontology with the data?

To avoid mixing the ontology with the data, you can namespace the ontology. For example,
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#JW>
a foaf:Person ;
foaf:name "James Wales" ;
foaf:mbox <mailto:jwales#bomis.com> ;
foaf:homepage <http://www.jameswales.com> ;
foaf:nick "Jimbo" ;
foaf:depiction <http://www.jameswales.com/aus_img_small.jpg> ;
foaf:interest <http://www.wikimedia.org> ;
foaf:knows [
a foaf:Person ;
foaf:name "Angela Beesley"
] .
<http://www.wikimedia.org>
rdfs:label "Wikimedia" .
rdf, rdfs, and foaf are all ontologies. Instead of bringing all of them into the document, they're declared in the namespace. You can point the namespace to your owl file (or whatever your ontology is in) and use it the same way. Blazegraph will still be able to reason over the graph as long as it can access the ontology definition.

Related

Is there a function that ressembles find_in_set for sparql or ARC2?

This is my first post,so I'm not sure how to ask the question ,but I have been working on an e-learning website using a classic search engine and a semantic one,I created my ontology,and used ARC2 and fuseki server, and the sparql query works when it comes to searching the keywords like I needed it to .
In adition to the search engin, I'm also using a checkbox where the user can select the types of articles they wish to get for their search ,audio,video,pdf ,an image or a word file.
While in classic search I used find_in_set and an array,which works perfectly,yet I don't seem to find a way when it comes to the semantic search ,this is my sparql query :
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX article: <http://127.0.0.1/Index.php/learning#>
SELECT *
WHERE
{ ?Publication article:HasLevel ?niveau ;
article:HasLanguage ?Langue ;
article:HasType ?Type ;
article:HasDispo article:Pub ;
article:Timepub ?Temps ;
article:AnneePub ?Annee ;
article:AuteurPub ?Auteur ;
article:DescriptionPub ?Description ;
article:FichierPub ?Fichier ;
article:IDPub ?ID ;
article:TaillePub ?Taille ;
article:TitrePub ?Titre ;
article:Unipulication ?Universite ;
article:PubliéPar ?Professeur .
?Professeur article:NomUti ?NomProf.
?Professeur article:PrenomUti ?PrenomProf
FILTER(
REGEX(STR(?Titre), "'.$r.'","i")
|| REGEX(STR(?Description), "'.$r.'","i"))
}
ORDER BY DESC(?Temps)
the $r is for the keyword
Do I need to use an other way,or is there a function close to find_in_set for sparql or ARC2?

How do owl and rdfs property domain range work?

I am trying to understand the semantics of rdfs domain and range. Because I am from an object oriented background, I am struggling to understand the semantics and how to validate data against the rdfs statements.
Here is a sample file in turtle format:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix tmpl: <http://template.example.com/>
prefix data: <http://data.example.com/>
tmpl:Thing a owl:Class.
tmpl:Employment rdfs:subClassOf tmpl:TemporalThing.
tmpl:Party rdfs:subClassOf tmpl:Thing.
tmpl:Individual rdfs:subClassOf tmpl:Party.
tmpl:Organisation rdfs:subClassOf tmpl:Party.
tmpl:LimitedLiabilityCompany rdfs:subClassOf tmpl:Organisation.
tmpl:hasCurrentEmployer a owl:ObjectProperty;
rdfs:domain tmpl:Party;
rdfs:range tmpl:Party.
data:Simon a tmpl:Individual;
skos:prefLabel "Simon S".
data:PtyLtd a tmpl:LimitedLiabilityCompany.
data:Simon tmpl:hasCurrentEmployer data:PtyLtd.
tmpl:Animal a owl:Thing.
data:Beans a tmpl:Animal.
data:Simon tmpl:hasCurrentEmployer data:Beans.
I am using GRAPHDB as my test environment. I would expect the last statement to fail with some sort of message because 'Beans' is an 'Animal' which is not a 'Party'.
Yet, GRAPHDB just accepts the statement.
Any ideas?
EDIT
Based on Stanislav's comment below: While An inference engine might not have a problem with this, we can use the domain and range for error checking in an application.
As said in the comments, you misunderstood the semantics of domain and range.
P rdfs:domain D
P rdfs:range R
mean that if a statement s P o holds, then (with a reasoner running), it could be inferred that s rdf:type D and o rdf:type R.
Domain and range are never restrictions on the the property. That has to be clear.
To understand how things work, check for examplem OWL direct semantics for object properties here.

Protege 5; find all classes related by a to-one cardinality to a specific class

I have OWL ontology, Protege 5. I want starting form a source class S, to retrieve all destination classes D where S is related to Ds by means of to-one cardinality through objectProperty i.e S ([0..*] - 1) D despite what is the connecting objectProperty.
In DL, it would be something similar to :
S ⊑ =1r:D;
where S is my source concept, D is a variable concept and r is a variable objectProperty.
First Point:
How to express this in Manchester Syntax to use it in Protege DL query?
Second Point:
For such query, what are the considered types of property restriction that the reasoner will consider when trying to answer the query? e.g cardinality restriction, functional properties, someValuesFrom, allValuesFrom?
Thanks.
You can't write the kind of query that you're asking about in the DL query syntax. The DL query syntax doesn't have any place for variables; all you can write are class expressions, after which you can ask for the individuals in that class, or subclasses or superclasses of the class. So the answer to the first question is that you can't express your query in the Manchester syntax.
For the second point, there may be reasoners that can help you draw a conclusion here. For instance, you might be able to use a reasoner that supports SPARQL queries and write the template of the class expression with variables. You'd end up with something like this (but this is untested):
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
select ?s ?p ?d where {
?s rdfs:subClassOf [ a owl:Restriction ;
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
owl:onProperty ?p ;
owl:onClass ?d ]
}
I don't know whether or not most OWL reasoners will be able to handle that though. As mentioned above, the typical task for an OWL reasoner is to look at class expression and determine its subclasses, and superclasses. This is getting more complicated.

I need to personalize the individuals of an ontology

Well, I have an ontology and I want to add some individuals. The problem is that individuals vary from one user to another. Let me give you an example:
In the class "pet" I want to add my dog "cookie", I can do it directly on the ontology but when somebody else uses the same ontology it would be filled with my information. Do you know any way to add new individuals to the ontology without modifying the original?
I'ts some kind of personalization. I don't know how to search for work related to this problem, if you know something I would appreciate it. Thank you!
Note: this is the answer I posted for (and that was accepted for) the same question on answers.semanticweb.com, Add new individuals to an ontology.
You would typically create a new ontology that imports the original (so that you have declarations of the classes, properties, etc.), and then declare your individual in the new ontology. For instance,
pet-import (http://example.org/pet-import)
#prefix : <http://example.org/pet-import#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
:Pet a owl:Class .
<http://example.org/pet-import>
a owl:Ontology .
my-pets (http://example.org/my-pets)
#prefix : <http://example.org/my-pets#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
<http://example.org/my-pets>
a owl:Ontology ;
owl:imports <http://example.org/pet-import> .
:Cookie a owl:NamedIndividual , <http://example.org/pet-import#Pet> .

ontology mapping (pointing) to columns and rows in mysql Database

I am a beginner in ontology domain.I have a simple question which I could not find it anywhere!
I have made my ontology in Protege,I have conceptualized my domain of interest(Energy consumption in a production line) and now I need to have access to the data which are stored in my database via this ontology.I do not want to store any data in my ontology but need to have access to data in database via my ontology.I am totally unaware of its possibility,if it is possible which tools I have to use for this purpose? Should I write for example a code in Java or ...
Thank you so much in advance
If you have a database with data in it and an ontology that represents a conceptualization of those data, you can establish a mapping and expose those data as if they were represented according to your conceptualization by writing mappings for D2RQ.
An example taken from the documentation:
# D2RQ Namespace
#prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#> .
# Namespace of the ontology
#prefix : <http://annotation.semanticweb.org/iswc/iswc.daml#> .
# Namespace of the mapping file; does not appear in mapped data
#prefix map: <file:///Users/d2r/example.ttl#> .
# Other namespaces
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
map:Database1 a d2rq:Database;
d2rq:jdbcDSN "jdbc:mysql://localhost/iswc";
d2rq:jdbcDriver "com.mysql.jdbc.Driver";
d2rq:username "user";
d2rq:password "password";
.
# -----------------------------------------------
# CREATE TABLE Conferences (ConfID int, Name text, Location text);
map:Conference a d2rq:ClassMap;
d2rq:dataStorage map:Database1;
d2rq:class :Conference;
d2rq:uriPattern "http://conferences.org/comp/confno##Conferences.ConfID##";
.
map:eventTitle a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:Conference;
d2rq:property :eventTitle;
d2rq:column "Conferences.Name";
d2rq:datatype xsd:string;
.
map:location a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:Conference;
d2rq:property :location;
d2rq:column "Conferences.Location";
d2rq:datatype xsd:string;
.
Example page
D2R website and documentation

Resources