While making ontology I forgot to add any prefix and now while applying any SPARQL query prefix is used. So do I need to make ontology again?
These are active ontology prefixes
How can I execute my SPARQL query?
Related
The URI "https://www.w3.org/2000/01/rdf-schema#" is an RDF file with triples, prefix and other things.
So if I do this query, it should return the URIs of all the "things" that are Class:
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select *
from <http://www.w3.org/2000/01/rdf-schema#>
where
{
?o rdf:type rdfs:Class.
} LIMIT 100 .
But running it in Virtuoso gives me an error.
I'm new with SPARQL and RDF, so could be that I'm sayng something so wrong.
In most RDF database systems ("triplestores"), such as Virtuoso, the URL you put in the FROM clause is not used to retrieve a file from the Web and read its contents. Instead, you usually have a database in which you previously loaded some RDF(S) data yourself, and the FROM clause in your query is used to identify a subset in that data (a so-called "named graph").
In order for your query to work, you should load the file at http://www.w3.org/2000/01/rdf-schema# into your Virtuoso store, making sure it uses the file location as the named graph identifier as well. You can use a SPARQL update command for this:
LOAD <http://www.w3.org/2000/01/rdf-schema#> INTO GRAPH <http://www.w3.org/2000/01/rdf-schema#>
After you've done that, the query should return results.
There are some SPARQL engines that do offer automatic retrieval of remote data like you expected (I know Eclipse RDF4J and Apache Jena Fuseki have options for this - not sure about Virtuoso) but it's not the 'typical' way to do SPARQL querying.
Can SPARQL be used to query an empty ontology (with no individuals), to retrieve information about the restrictions (axioms or object properties) put on a class?
Here's a snippet of my ontology in turtle syntax:
How can a SPAQRL query, if possible, be formulated to retrieve the following triples from the ontology:
And if not possible to do this directly with SPARQL, is there a workaround for it using dotNetRDF OntologyAPI?
Thanks in advance!
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.
I am tying to integrate my ontology with another ontologies. what i did is importing the ontologies in my protege, that works, but protege lists all the classes, which is normally. i am looking if there is a way in which i just the reference (uri) of these ontologies and then i can use them from their prefix.
ofc, i am building my ontology using owl2
i hope you help me
If you want to completely reason and materialise facts based on terms relating to the referenced concept, then you will need to fully import the ontology that the referenced concept belongs.
e.g given an external ontology with the following statements:
ex:Person a owl:Class;
rdfs:subClassOf ex:Agent.
If you reference this in your without importing:
ex2:Doctor a owl:Class;
rdfs:subClassOf ex:Person.
and make the following statement:
ex2:Jack a ex2:Doctor.
an run it through a reasoner, then you will also materialise the following:
ex2:Jack a ex:Person.
But not the following:
ex2:Jack a ex:Agent.
To materialise the latter, you will need to import the ontology with all the statements about ex:Person.
I have a SPARQL/Update query likes below.
INSERT { <http://localhost:8080/resource/User/166> rdf:type seagent:User;
seagent:User.email 'xyz#gmail.com'.
}
After execution of this query user has been inserted but properties of user not. How can I solve this problem?
Thanks in advance.
Following the question and answer at DBpedia SPARQL query that has a period in it, your query probably fails (apparently gracefully) on the period (.) in the predicate seagent:User.email.
You can expand the prefix to the property's full URI <http://example.org/#User.email> or define a different prefix PREFIX seagent-user: <http://example.org/#User.> and use that: ... seagent-user:email 'xyz#gmail.com'.
However, you may want to review the URIs for the properties and remove periods to avoid this kind of problems, if this is your own ontology. Or you could use a well known ontology like FOAF that includes properties to link email address to a person or user account.