0

I want a lookup service for Wikidata similiar to what DBpedia lookup (https://lookup.dbpedia.org/) is for dbpedia but for Wikidata. Because I didn't find any I try to create a query which searches the labels of Wikidata.

Here is my problem. I have this object https://www.wikidata.org/wiki/Q67639471 (Standards of Conduct Committee - Fourth Assembly)

The following Sparql query should find the object shouldn't it?

select distinct ?o ?oLabel where {
  ?o rdfs:label ?oLabel.
  filter(contains(?oLabel, "Standards of Conduct Committee - Fourth Assembly"@en)).
}

But the query times out everytime. When I add the line ?o wdt:P31 wd:Q865588.(?o is an instance of comitee) then it finds it.

Why doesn't the query find the exiting object? Does anybody know how to make or find such a lookup service?

Angelos
  • 23
  • 1
  • 4
  • why are you not using the RDF literal directly as a triple pattern? why not `select ?o where { ?o rdfs:label "Standards of Conduct Committee - Fourth Assembly"@en }` – UninformedUser Jun 05 '21 at 17:19
  • also, contains expects a string, it would be better to do `filter(contains(str(?oLabel), "Standards of Conduct Committee - Fourth Assembly")).` - indeed it's inefficient it does a scan and containment check over millions of labels. A fulltext search would be the better way if string match is really necessary – UninformedUser Jun 05 '21 at 17:21
  • `select ?item ?snippet where { SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Search"; wikibase:endpoint "www.wikidata.org"; mwapi:srsearch "inlabel:\"Standards of Conduct Committee - Fourth Assembly\"" . ?snippet wikibase:apiOutput "@snippet". ?item wikibase:apiOutputItem mwapi:title. } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }` – UninformedUser Jun 05 '21 at 17:25
  • Thank you very much!! Your answers helped me understand the wikibase api more. Eventually I found the wikibase-api for python which has a "search()" function that is exactly what I searched for -> https://wikibase-api.readthedocs.io/en/latest/api_reference/models/entity.html?highlight=search# – Angelos Jun 06 '21 at 18:57
  • You can submit your answer properly so I can accept it – Angelos Jun 07 '21 at 00:02

0 Answers0