Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting entities by SPARQL query #362

Open
WolfgangFahl opened this issue Apr 25, 2018 · 15 comments
Open

Getting entities by SPARQL query #362

WolfgangFahl opened this issue Apr 25, 2018 · 15 comments

Comments

@WolfgangFahl
Copy link

WolfgangFahl commented Apr 25, 2018

It would be great to be able to get entities with a SPARQL query e.g.

SELECT ?station WHERE {
  # P954 = Internationale Bahnhofsnummer IBNR
  ?station wdt:P954 ?ibnr.
  # filter to show only german stations
  FILTER regex(?ibnr,"^80","i")
}

which should give a list of railway stations

@Tpt
Copy link
Collaborator

Tpt commented Apr 25, 2018

It is indeed something that would be great to be added to this library. What you could do for now is use an RDF/SPARQL library like RDF4J [1] and its SPARQLRepository class or Jena.

[1] http:https://rdf4j.org/
[2] https://jena.apache.org/documentation/rdfconnection/

@wetneb
Copy link
Member

wetneb commented Apr 25, 2018

I have used Jena for that and it works well. It lets you create SPARQL queries programmatically too.

@luisenriqueramos1977
Copy link

Hi,
about this question, I am working in the following:

Adding company1 with some information to a private wikidata, wich I am currently doing, and later I should be able to search for the company1, and update any information. In this part, I made a very simple search by entity name, which last too long. I though in implementing an sparql query, but it seems not being implemented yet in java API.

I know jena, and rdf4j, my question is how implementing that?, as I understand all the wikidata "data" should be in rdf format to proceed with it, or I am wrong and there is another way to interact with the wikidata itself?.

Luis Ramos

@akuckartz
Copy link

I am not sure what this issue is about. Does this help?https://m.wikidata.org/wiki/Special:MyLanguage/Wikidata:SPARQL_query_service/Wikidata_Query_Help

@luisenriqueramos1977
Copy link

Hi Andrea, thanks for your quick answer,

for my understanding the information you provide is for users, I mean that is not for developers, it explains about rdf dump, but my interest is searching, and updating the graph directly from the wikidata, and I am not sure if that is feasible.

Luis

@Tanish-Gupta
Copy link

Hi,
Can you please give more insights about the problem? Like what is the above query fetching right now?
Thank you

@WolfgangFahl
Copy link
Author

WolfgangFahl commented May 22, 2020

The query is just an example. If you are interested in what it does you might want to try it
using the wikiDataQuery service. I have added the label service which will display the label of each result - this is a non -standard RDF feature and therefore the example itself does not use it.

For more examples you might want to go thru my SPARQL tutorial

@Tanish-Gupta
Copy link

I went through the SPARQL tutorial, it was quite well explained. I would like to know what exactly the issue is?
What I can understand is that in the "try it" query (given in the above comment) the labels have been found using Service "wikibase:label" which is defined by us and is not a standard RDF feature. And we need to find entities (like labels) using standard queries? Can you please correct me if you are expecting something else?

Thank you

@WolfgangFahl
Copy link
Author

This issue is about adding an API to run the queries within the WikiData Toolkit. So any "standard" RDF Query against WikiData should be runnable and return a result in a decent simple format. Currently this is only possible in combination with other libraries and e.g. not tested out of the box.

@Tanish-Gupta
Copy link

Hi,
Where can I find the triples stored, on which the WikiData runs its queries? Also, what are the endpoints of that server in order to make an RDF connection?

@luisenriqueramos1977
Copy link

luisenriqueramos1977 commented May 24, 2020 via email

@Tanish-Gupta
Copy link

Tanish-Gupta commented May 26, 2020

Hi,
I am still unclear about the exact requirement in this issue. Can you please describe it once again in detail?

What I can figure out is :-

  1. This query is working on Wikidata Query Service platform

SELECT ?station WHERE {
?station wdt:P954 ?ibnr.
FILTER regex(?ibnr,"^80","i")
}

  1. So is "try it" query running. But, this also gives the labels associated with the station names which are extracted using Service keyword
    (These two are the ones you mentioned in the comments. )

So, what exactly is the aim of the API? since the standard SPARQL queries are also working on that Wikidata Query Service platform. If possible also mention the files I should go through for the same.

Thank you for the help

@WolfgangFahl
Copy link
Author

WolfgangFahl commented May 26, 2020

@Tanish-Gupta you might want to ask your question in an environment that is more suitable for a question and answer format like stackoverflow.com - I'll happily answer there.

@62mkv
Copy link

62mkv commented May 28, 2020

So, are there any plans to expose SPARQL-client functionality as part of Wikidata-Toolkit? Would be huge added value, I think.

Currently I am planning to write a script that will add forms to lexemes, by first finding a lexeme by it's lemma. Couldn't find way to do it via WikibaseDataFetcher. With SPARQL it would be

SELECT ?lexeme ?lemma WHERE {
  ?lexeme dct:language wd:Q9072;
   wikibase:lemma ?lemma.
  FILTER (STR(?lemma)="aprill")
}

@wetneb
Copy link
Member

wetneb commented May 28, 2020

@62mkv I am not aware of anyone working on this. It would be a nice thing to have indeed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants