protege how to use instances from ontology on the web - semantic-web

In my ontology i have an instances named beethoven, how can I say that my beethoven instance is the same as this beethoven
http://dbpedia.org/page/Ludwig_van_Beethoven
I know that I have to use owl:sameAs predicate, but the thing is when I click on sameAs predicate, protege just give me a list of already existing instances. However, I'm asking about an instance from an ontology on the web.
What I was thinking of is maybe I have to import that ontology, but thing about it, if i want to sue dbpedia, do i really have to import the whole dbpedia to my machine?
Im sure there is something easier and that's why I'm asking you guys
Thanks in advance
Update 1
After reading this answer
Extend DBpedia entity in Protege ontology
I created an instance of the type THINKG in my protege and gave it the exact same URI (which is http://dbpedia.org/page/Ludwig_van_Beethoven ), and said that my beethoven instance is owl:sameAs this new instance, would that be enough?
Update2
I tried to query my ontology after the things that I have listed in update1, and I noticed this:
this query:
select ?z where
{
mo:Beethoven owl:sameAs ?z
}
returns empty result
However, this query:
select ?z where
{
dbpedia:Ludwig_van_Beethoven owl:sameAs ?z
}
returns my beethoven instance like this:
how can the dbpedia:beethoven is the same as mo:beethoven, but the other way around, knowing that I said mo:beethoven is owl:sameAs dbpedia:beethoven not the other way around

This is one of the important differences between RDF and OWL. RDF is just a bunch of triples. The triples:
:LVBeethoven owl:sameAs :LudwigVanBeethoven
and
:LudwigVanBeethoven owl:sameAs :LVBeethoven
are different triples. RDF graphs are just sets of triples.
OWL, on the other hand, is a logic, concerned with axioms and inferences. owl:sameAs is the equality predicate for OWL individuals, and equality predicates are symmetric (among other things). That means that from A owl:sameAs B an OWL reasoner can infer that B owl:sameAs A. So, if you have a reasoner attached to your SPARQL endpoint, you'll be able to query for either A owl:sameAs ?x or ?x owl:sameAs A and get B as a result. You can do some limited forms of OWL reasoning in SPARQL. In this case, you could use a property path to follow an owl:sameAs link in either direction:
select ?z where
{
mo:Beethoven (owl:sameAs|^owl:sameAs) ?z
}
For some more examples, see Using SPARQL for limited RDFS and OWL reasoning.

Related

How can I query individuals which are reasoned from a class with sparql wh

I have started the Fact++ reasoner in Protege and now I want to query the reasoned individuals from this class C.
SELECT ?x WHERE { ?x rdf:type ex:C.}
This query does not give any result. Can I query rasoned content from sparql in Protege or does SPARQL just work on the original content without considering reasoned interactions.
Thanks in advance

Why different endpoints do not query same datasets?

I would like to query datasets such as FOAF and DBPedia. The aim is to run quite simple requests such as “Which paintings did Magritte painted ?”,”Which are the American actor who played in American movies ?” …
So I wrote my queries, and used DBpedia snorql to run them. Then, for some other reasons, I tried Live DBpedia and OpenLinks demo.openlinksw.com to discover that the results were different according to the endpoint.
Here are 2 examples :
1) Answer with DBpedia SnorQL but neither Live DBpedia nor OpenLinks demo.openlinksw.com
#works of Magritte
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT * WHERE {
?person a dbo:Artist .
?person foaf:surname "Magritte"#en .
?work dbo:author ?person .
OPTIONAL {?work dbp:year ?year ; dbo:museum ?museum .}
}
ORDER BY ?year
2) Answer with Live DBpedia but neither DBpedia SnorQL nor OpenLinks demo.openlinksw.com
#american actors from Willem Robert van Hage R tutorial
SELECT ?actor ?movie ?director ?movie_date
WHERE {
?m dc:subject <http://dbpedia.org/resource/Category:American_films> .
?m rdfs:label ?movie .
FILTER(LANG(?movie) = "en")
?m dbp:released ?movie_date .
FILTER(DATATYPE(?movie_date) = xsd:date)
?m dbp:starring ?a .
?a rdfs:label ?actor .
FILTER(LANG(?actor) = "en")
?m dbp:director ?d .
?d rdfs:label ?director .
FILTER(LANG(?director) = "en")
}
LIMIT 1000
I thought an endpoint was simply a tool to query dataset whatever it is. So I thought that you can query DBPedia and FOAF from dbpedia, live dbpedia or openlinks demo.openlinksw.com ..
I read that actually different endpoints use different datasets but I can’t get why, as you give specific URI to reach.
Why do same query returns different results according to the SPARQL endpoint ?
Much like different instances of SQL DBMS (such as [in no particular order and without implication of endorsement] OpenLink Virtuoso, Oracle, MySQL, Informix, SQL Server, Sybase, DB2, PostgreSQL, Ingres, Progress OpenEdge, and many others) hold different data, different instances (read: SPARQL endpoints) of RDF RDBMS, also known as Quadstores or Triplestores (such as [in no particular order and without implication of endorsement] OpenLink Virtuoso, AllegroGraph, Stardog, Neo4J, MarkLogic, and many others) hold different data.
You cannot query Joe's database in DBMS A through Fred's database in DBMS B -- unless someone has already told Fred's database and/or DBMS about Joe's database and/or DBMS (e.g., VDBMS functionality), or you include some information about Joe's database and/or DBMS in your query (e.g., SPARQL Federation), etc.
(A "DBMS" is a Database Management System, such as listed above. A "database" is a collection of data, typically stored in a [large] document, which is managed by a DBMS.)
Of particular note relative to your question --
FOAF is an ontology, a vocabulary, which is used to describe entities.
DBpedia is a dataset (which has had various versions over time), and a project, and an organization, and various other things (the ambiguity of literal identifiers!).
OpenLink Software (not "openlinks") is a company which produces OpenLink Virtuoso, among other data-related software and services, and which provides a number of live endpoints on the web -- including the main DBpedia endpoint. (ObDisclaimer: OpenLink Software is also my employer.)

SPARQL Query of FOAF doesn't return any result

I want to get some information from the FOAF ontology. I tried the following SPARQL query, but it returns no results. I tried this query to get familiar with FOAF, but what I really want to do is to find all the people that a particular person ?x knows (using the property foaf:knows). How do I do this?
PREFIX foaf:<http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE { ?x foaf:name ?name .
?x foaf:mbox ?mbox .
}
Semantic web is made of different components.
Knowledge is represented as RDF triples. These triples describes Resources based on a Subject - Predicate - Object syntax. For example, "John is a Male" may be represented as a RDF triple.
On top of RDF, we may use RDFS and OWL to specify restrictions and other information on these data. Thanks to RDFS, I can specify that "Male is a subclass of Person" and it is therefore possible to infer that "John is a Person". RDFS and OWL helps to define ontologies. An ontology is a vocabulary (that can be general or specific to a domain) to represents data. For example, I may want to create an ontology CAT to represent data on cats.
In that case, I would create my CAT vocabulary defining that "Cat is a subclass of Animal" and "hasOwner is a property that links a cat to a Person" and some other properties. Then, I am able to instantiate some individuals to create data on cats. For example by saying that "Baccara is a Cat" and "Baccara hasOwner John".
FOAF is basically a vocabulary to represent data on people and especially links between these people. FOAF vocabulary gives some properties and classes to handle easily information on people. But it doesn't provide any piece of information, only the "structure"/"model"/"schema" to organize information.
There are no individuals in the FOAF dataset. That is why your query returns no result. Since there's no people in the FOAF dataset, it is normal that the query returns nothing.
You may want to build your own RDF dataset based on FOAF vocabulary. To do so, you can try a tool like Protégé, or more easily with a text editor if you're familiar with RDF/XML or Turtle.
Otherwise, if you only need to get familiar with FOAF, you can query the model. For example, you may want to get all the subclasses of Agent :
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT distinct ?c
WHERE { ?c rdfs:subClassOf foaf:Agent }
I recommend you to read a bit on the semantic web components (especially RDF and RDFS, and differences between them) before going any further in FOAF. Plus, a nice exercise to learn SPARQL consists in querying DBpedia: http://dbpedia.org/sparql.

Sesame not inferencing owl:sameAs

I have some data on vaccines in my Sesame triplestore. To the same store, I added additional data about vaccines from DBpedia.
<http://dbpedia.org/resource/Rotavirus_vaccine>
dbpedia2:routesOfAdministration "oral"#en
To specify that a particular vaccine in my native data is the same entity as the subject of the imported data from DBpedia, I inserted an owl:sameAs statement linking the two entities.
my_ns:Rota owl:sameAs <http://dbpedia.org/resource/Rotavirus_vaccine> .
Though that single triple has been added, I find no additional inferencing. For instance, I want this query to give me the route of administration of the vaccine in my native data by inferencing the property of the vaccine entity in DBpedia:
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX my_ns: <http://purl.org/net/ontology/my_ns/>
select ?roa where
{my_ns:Rota dbpedia2:routesOfAdministration ?roa}
At present, executing the query doesn't yield any results. I'd like the system to infer the following as the output of the query above:
my_ns:Rota dbpedia2:routesOfAdministration "oral"#en .
I installed GraphDB-Lite(OWLIM) by replacing the war files and verified that owl:sameAs works by executing a query on DBpedia.
The Sesame in-memory and native stores do not support OWL reasoning out of the box. They do offer (optional) support for RDFS reasoning (so understanding rdfs:subClassOf etc), which can be enabled at repository creation time (in the workbench, this is the dropdown option 'Memory/Native Store RDF Schema'). However, owl:sameAs is of course not part of RDFS reasoning.
Sesame also supports a custom graph query reasoner on top of the memory or native stores. This custom reasoner can be configured with your own inference rule, formulated as a combination of two SPARQL CONSTRUCT queries: a 'rule' query that expresses the actual inference rule, and a 'match' query that is used to do maintenance on the inferred statements when the store is updated. More explanation on how to set this up can found in the section on Repository creation in Programming with Sesame. The option in the Workbench is "Memory/Native store Custom Graph Query Inference".
In the case of owl:sameAs, a custom rule to support it would look roughly like this:
CONSTRUCT { ?s1 ?p1 ?o1 . ?o1 ?p2 ?o3 }
WHERE {
?o1 owl:sameAs ?o2 .
OPTIONAL { ?s1 ?p1 ?o2 . }
OPTIONAL { ?o2 ?p2 ?o3 . }
}
If your goal is purely to have owl:sameAs reasoning, this might be a simple way to enable it. However, for more comprehensive OWL reasoning support, the custom reasoner is not sufficiently powerful or scalable. Instead, you should use a Sesame backend store that has built-in support for it, such as Ontotext GraphDB (formerly known as OWLIM).
Solved the problem. The issue was the absence of GraphDB-Lite (formerly OWLIM-Lite). I was under the impression I had it installed by replacing the .war files. However, the absence of OWLIM-Lite option in the drop down while creating a new repository indicated that it had not been installed.
When I initially checked wherether owl:sameAs queries were working, I used the SERVICE clause in SPARQL to query DBpedia. As I was querying DBpedia (that supports owl:sameAs), the queries were being executed as I was essentially querying outside Sesame.
I solved the problem by deleting the old .war files and their corresponding folders in Tomcat, and copying the .war files from GraphDB distribution. When running the server for the first time after copying the files, the corresponding folders (openrdf-sesame and openrdf-workbench) are auto-generated. While creating a repository, the OWLIM-Lite option is then available.
I created an OWLIM-Lite repository and added the triples there. The owl:sameAs inferencing then started working and the query in the question was successfully executed.

How to list all different properties in DBPedia

I have a burning question concerning DBpedia. Namely, I was wondering how I could search for all the properties in DBpedia per page. The URI http://nl.dbpedia.org/property/einde concerns the property "einde". I would like to get all existing property/ pages. This does not seem too hard, but I don't know anything about SPARQL, so that's why I want to ask for some help. Perhaps there is some kind of dump of it, but I honestly don't know.
Rather than asking for pages whose URLs begin with, e.g., http://nl.dbpedia.org/property/, we can express the query by asking “for which values of ?x is there a triple ?x rdf:type rdf:Property in DBpedia?” This is a pretty simple SPARQL query to write. Because I expected that there would be lots of properties in DBPedia, I first wrote a query to count how many there are, and afterward wrote a query to actually list them.
There are 48292 things in DBpedia declared to be of rdf:type rdf:Property, as reported by this SPARQL query, run against one of DBpedia's SPARQL endpoints:
select COUNT( ?property ) where {
?property a rdf:Property
}
SPARQL Results
You can get the list by selecting ?property instead of COUNT( ?property ):
select ?property where {
?property a rdf:Property
}
SPARQL Results
I second Joshua Taylor's answer, however if you want to limit the properties to the Dutch DBpedia, you need to change the default-graph-uri query parameter to nl.dbpedia.org and set the SPARQL endpoint to nl.dbpedia.org/sparql, as in the following query. You will get a result-set of just above 8000 elements.
SELECT DISTINCT ?pred WHERE {
?pred a rdf:Property
}
ORDER BY ?pred
run query
These are the Dutch translations of the properties that have been mapped from Wikipedia so far. The full English list is also available. According to mappings.dbpedia.org, there are ~1700 properties with missing Dutch translations.