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

Create Index of Keywords? Use Keywords from wikidata? #2

Open
jdede opened this issue Sep 3, 2020 · 2 comments
Open

Create Index of Keywords? Use Keywords from wikidata? #2

jdede opened this issue Sep 3, 2020 · 2 comments

Comments

@jdede
Copy link
Member

jdede commented Sep 3, 2020

Use keywords and structure from wikidata?

@jdede
Copy link
Member Author

jdede commented Oct 16, 2020

Example code with SPARQL:

#!/usr/bin/env python3

from SPARQLWrapper import SPARQLWrapper, JSON
import pandas as pd


sparql = SPARQLWrapper("https://query.wikidata.org/sparql")


sparql.setQuery("""
SELECT ?item ?itemLabel

WHERE {
  ?item wdt:P279 wd:Q522171.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()



results_df = pd.json_normalize(results['results']['bindings'])
print(results_df[['item.value', 'itemLabel.value']])

@jdede
Copy link
Member Author

jdede commented Mar 20, 2021

SPARQL did not work as expected. Some properties were not received properly in case of long lists. Now using direct request to json entity endpoint: https://www.wikidata.org/wiki/Special:EntityData/Q31.json

TODO: Remove keyword and directly replace by wikidata items.

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

1 participant