I am trying to list all properties created in on a wikibase I installed, using docker-compose, based on this install.
Now, want to list all properties that are available in this wikibase, similar to getting that list available through:
<wikibase.url>wiki/Special:ListProperties
I have also extracted that list through SPARQL with the following SPARQL query:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX schema: <http://schema.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT
?property
?propertyType
?propertyLabel
?propertyAltLabel
WHERE {
?property a wikibase:Property ;
rdfs:label ?propertyLabel ;
wikibase:propertyType ?propertyType .
OPTIONAL {?property skos:altLabel ?propertyAltLabel .}
}
Running that SPARQL query is expensive though and I need to run that query often, so I would very much like to get that list of properties to the core wikibase API.
Is that possible?
If you know the namespace number for properties on the target wiki (it’s usually 122 if the wiki has an Item: namespace, or 120 if, like on Wikidata, items are in the main namespace), you can use the core allpages API: https://www.wikidata.org/w/api.php?action=query&list=allpages&apnamespace=120
To also get the labels at the same time, use it as a generator and combine it with the entityterms API (new in 1.35; looks like it’s not documented yet, but see T257658): https://www.wikidata.org/w/api.php?action=query&generator=allpages&gapnamespace=120&prop=entityterms&wbetterms=label
Related
I'm calling on http://fr.dbpedia.org/sparql
the following SPARQL query:
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select distinct ?lcs where {
{
?lcs ^(rdf:type/rdfs:subClassOf*) <http://fr.dbpedia.org/resource/Honoré_Daumier> ,
<http://fr.dbpedia.org/resource/Auguste_Rodin>;
a owl:Class .
filter not exists {
?llcs ^(rdf:type/rdfs:subClassOf*) <http://fr.dbpedia.org/resource/Honoré_Daumier> ,
<http://fr.dbpedia.org/resource/Auguste_Rodin>;
a owl:Class ;
rdfs:subClassOf+ ?lcs .
}
}
}
On some call I've http://dbpedia.org/ontology/Person as result, on others call I'm getting http://dbpedia.org/ontology/Person and http://dbpedia.org/ontology/Agent and with others the previous answers plus http://www.w3.org/2002/07/owl#Thing
without nothing to know that a response isn't complete. How can I use the result, if it is a little randomized
The main reason for your query not working as expected is that the data the data is i) split into separate graphs and ii) not all graphs were added to the default graph.
To keep it short, the instance data is contained inside the graph http://fr.dbpedia.org whereas the schema triples will be accessible via http://dbpedia.org graph only. Sometimes, if no graph is given, then the union of some graphs is used as the default graph which will be the dataset at query time. Unfortunately, this doesn't hold for the French DBpedia endpoint, only the instance data graph will be used.
You can check this with
DESCRIBE <http://dbpedia.org/ontology/Person>
which is empty when using either no graph explicitly or the graph http://fr.dbpedia.org, but non-empty for graph http://dbpedia.org.
The way to define the default graph is using the keyword FROM. For your query, it should therefore be
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select distinct ?lcs
from <http://fr.dbpedia.org>
from <http://dbpedia.org>
where {
?lcs ^(rdf:type/rdfs:subClassOf*) <http://fr.dbpedia.org/resource/Honoré_Daumier> ,
<http://fr.dbpedia.org/resource/Auguste_Rodin>;
a owl:Class .
filter not exists {
?llcs ^(rdf:type/rdfs:subClassOf*) <http://fr.dbpedia.org/resource/Honoré_Daumier> ,
<http://fr.dbpedia.org/resource/Auguste_Rodin>;
a owl:Class ;
rdfs:subClassOf+ ?lcs .
}
}
Note, while this seems to return the correct result, you should also consider the comment from #TallTed regarding possible differences among language chapters (e.g. English vs French Wikipedia as source), release dumps (2016 vs 2018 or even the DBpedia Live) as well as Virtuoso versions used as backend.
I want to use freetext search against the dbpedia and I'm trying the query I found on the W3C website: https://www.w3.org/2009/Talks/0615-qbe/
If I try the query WITHOUT the bif: prefix by commenting it out I get the error shown below the query:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
# PREFIX bif: <http://www.openlinksw.com/schemas/bif#>
SELECT ?lbl ?est
WHERE {
?country rdfs:label ?lbl .
FILTER(bif:contains(?lbl, "Republic")) .
?country a type:Country108544813 ;
prop:establishedDate ?est .
FILTER(?est < "1920-01-01"^^xsd:date) .
}
Error: Line 9, Parse error: namespace mapping for "bif" not defined
when expanding QName "bif:contains".
[condition type: sparql-lexer-error-namespace-mapping-not-defined]
well: that makes sense, you do need to define your namespace. So let me do the same query again using the bif: prefix that I found on the Virtuoso website (and various other places)
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX bif: <http://www.openlinksw.com/schemas/bif#>
SELECT ?lbl ?est
WHERE {
?country rdfs:label ?lbl .
FILTER(bif:contains(?lbl, "Republic")) .
?country a type:Country108544813 ;
prop:establishedDate ?est .
FILTER(?est < "1920-01-01"^^xsd:date) .
}
Now I get a different error: it seems that the bif: namespace is a protected name by Virtuoso
So it seems I cannot live with bif: or without :bif. Has anyone seen this error before? Thanks.
Btw: I really don't care that much about bif: What I really want is to do freetext queries against dbpedia. So any alternative is welcome. YES: there are earlier questions on SO about this but note that each of those answers contain bif: as well.
Added later: so just to be sure I changed bif: into bof: and now I get a new error that shows that contains no longer is a valid operator. See below. So anyway: I guess the only thing I care about from here on is: how do you do freetext queries against dbpedia :-)
bif: is a Virtuoso built-in, for "built-in function".
You're going through some sort of SPARQL pre-parser, not directly against the SPARQL endpoint, so you do need to define the prefix in your query. Most such pre-parsers will do the right thing if you just --
PREFIX bif: <bif:>
Alternatively, you can change your query from using the bif:contains function --
FILTER(bif:contains(?lbl, "Republic"))
-- to use SPARQL regex --
FILTER regex(?lbl, "Republic")
I am trying to show the list of Charities from this page - http://dbpedia.org/page/Category:Charitable_organizations
The list is in is dct:subject of property, I have made a query but it doesn't work.
QUERY
WHERE {
?s dbo:type dbr:Charitable_organization .
}
I do kind of know how to use SPARQL with DBPEDIA but am unsure how to use the dct:subject part and display the `dbr:'
Using the site- http://dbpedia.org/sparql to execute queries. So any help on how I can show the list of charities from that website? Thanks for reading.
Your query should be:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX dbr: <http://dbpedia.org/resource/>
## Added ##
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT *
WHERE {
?s dbo:type dbr:Charitable_organization .
}
Links
Live Results Page Link.
Live Query Definition Link.
I have this query
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/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX dbpedia_property: <http://dbpedia.org/property/>
PREFIX dbpedia_ontology: <http://dbpedia.org/ontology/>
PREFIX yago: <http://dbpedia.org/class/yago/>
PREFIX schema: <http://schema.org/>
SELECT * WHERE
{
{
SELECT ?school
WHERE
{
?school rdf:type yago:EducationalInstitution108276342 .
FILTER ( contains(str(?school), "Australia") )
}
ORDER BY ?school
}
}
Don't mind the extra brackets as this is part of a larger query.
What I want to know is why thi http://dbpedia.org/page/Academic_structure_of_the_Australian_National_University is included in the results since I specify rdf:type yago:EducationalInstitution108276342. This property is not included in the resource page. I'm using this endpoint: http://dbpedia.org/sparql
Looks like a bug in the Pubby Web interface or in the query that is used to get the data that will be shown.
The query
SELECT * WHERE{
<http://dbpedia.org/resource/Academic_Structure_of_the_Australian_National_University> ?p ?o
}
returns the necessary rdf:type statement.
The other strange thing is that even a SPARQL DESCRIBE query does not return the rdd:type triples:
DESCRIBE <http://dbpedia.org/resource/Academic_Structure_of_the_Australian_National_University>
Although DESCIBE is not really defined in the specs, a user would expect those triples for sure. And maybe this kind of query is used to retrieve the data for the Web pages of resources.
I have fuseki running on my computer. version 1.1.1. but it when I enter a query to select from dbpedia it doesnt return anything. The query made is suppose to return http://dbpedia.org/class/yago/Guitarist110151760 as ?artistKind and http://semanticweb.org/laura/ontologies/2014/9/untitled-ontology-26#Guitar as ?instrument.
I made the ontology in protege and used a restriction that Guitarist110151760 playsInstrument Guitar.
PREFIX instru: <http://www.semanticweb.org/laura/ontologies/2014/9/untitled-ontology-26#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia: <http://dbpedia.org/resource/>
select ?artistKind ?instrument
FROM <http://www.semanticweb.org/laura/ontologies/2014/9/untitled-ontology-26#>
WHERE
{
?artistKind instru:playsInstrument ?instrument.
SERVICE <http://dbpedia.org/sparql> {
dbpedia:Eric_Clapton rdf:type ?artistKind . }
}
Use website http://dbpedia.org/sparql to perform successful queries on dbpedia ontology because jena fusiki is used to perform queries on local ontologies inside hard disk (by loading owl files)