3 ms·
WikipediaQL: Query language for efficient data extraction from Wikipedia (early
- deleted 5y ago[deleted]
- mark_l_watson 5y agoI really like this. I am into SPARQL so I prefer the WikiData SPARQL endpoint, but for most developers this looks like a good query tool.
- zverok 5y agoThanks! I am mentioning Wikidata/SPARQL in README (TL;DR: less data still, harder to discover unless you are deeply into SemWeb tech), but I expect this project, will it live long (fingers crossed) will definitely has some relations with Wikidata, too. My previous attempt on something similar: https://github.com/molybdenum-99/reality https://github.com/molybdenum-99/reality — used both Wikipedia and Wikidata (and OpenStreetMap and...) but however cool were few demos I managed too achieve, it was a dead end for several reasons.
- nine_k 5y agoThe crazy thing is that this is a full text search of sorts, not pre-structured Wikidata. If you ever tried to scrape HTML, you know how untidy it usually ends up; this one looks clean.
- zaik 5y agoThis tool might be useful to Wikidata contributors. Getting data out of Wikipedia and into Wikidata takes a lot of effort.
- jerjerjer 5y agoIs Wikipedia available as an SQL database dump? That would be really useful.
- skipnup 5y agoYeah of course, downloadable als SQL or XML: https://en.wikipedia.org/wiki/Wikipedia:Database_download#English-language_Wikipedia https://en.wikipedia.org/wiki/Wikipedia:Database_download#En...
- IfOnlyYouKnew 5y agoYes and no. You can get SQL dumps (although XML is more common), but it doesn't contain any useful structure. The article content is just wikitext, and only metadata such as revisions are structured. You can get a lot of data from Wikidata. They have a SPARQL interface at https://query.wikidata.org/#%23Humans%20born%20in%20New%20York%20City%0Aselect%20distinct%20%3Fitem%20%3FitemLabel%20%3FitemDescription%20%3Fsitelinks%20where%20%7B%0A%20%20%20%20%3Fitem%20wdt%3AP31%20wd%3AQ5%3B%20%20%23%20Any%20instance%20of%20a%20human.%0A%20%20%20%20%20%20%20%20%20%20wdt%3AP19%20wd%3AQ60%3B%20%20%23%20%20Who%20was%20born%20in%20New%20York%20City.%0A%23%20Note.%20Doesn%27t%20include%20humans%20with%20the%20birth%20place%20listed%20as%20a%20hospital%0A%23%20or%20an%20administrative%20area%20or%20other%20location%20of%20New%20York%20City.%0A%23%20Only%20humans%20listed%20as%20born%20in%20New%20York%20City.%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20wikibase%3Asitelinks%20%3Fsitelinks.%0A%20%20%20%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%2Cnl%22%20%7D%0A%7D%0AORDER%20BY%20DESC%28%3Fsitelinks%29 https://query.wikidata.org/#%23Humans%20born%20in%20New%20Yo... and you can also get all the data in a variety of rdf formats.
- arthurcolle 5y agoYou can get all the edges (links between pages) and nodes (pages and text therein), so not sure what you mean about structure. I loaded all of Wikipedia into Neo4J like 6 months ago... Wasn't very hard.
- decuran 5y agoCan you extract from wiktionary with this?
- zverok 5y agoThe answer is complicated (I am mentioning it in the midst of plans and possibilities in README: "(maybe?) other MediaWiki-based sites (like Wikvoyage, Wiktionary, etc.)"). In more details: 1. With the current library, you can't (connection to en.wikipedia.org is hardcoded :shrug:) 2. Adding "what MediaWiki instance to connect" is relatively easy (they all have the same API), including Wiktionary 3. For Wiktionary, current (v. 0.0.2) selectors will be useful, but future ones (infobox, wikitable and other high-level Wikipedia-specific stuff) will be not 4. So I might think of some way of specifying "set of selectors relevant for this instance" or something like that. 5. So, in some distance future, Wiktionary definitely would be fully supported; how distant—probably depends on how fast the project will be moving forward, and how it will be (hopefully) used by others 6. But I might add a support for "use this instance of MediaWiki" in the near future, it is easy!
- havkom 5y agoMaybe use GraphQL instead of inventing a new query language?
- zverok 5y agoI am (slightly) contemplating this (see also Reddit discussion: https://www.reddit.com/r/programming/comments/oe9oia/wikipediaql_query_language_for_efficient_data/h453u37/ https://www.reddit.com/r/programming/comments/oe9oia/wikiped...). But currently I am mostly focused on deducing atomic selectors that would be useful and choosing their interaction. The particular syntax is kind of afterthought. Though, I should say that I am still not sure GraphQL's mental model would work here (WikipediaQL for now structured around "which part of the document to choose and how to transform it", with "where to put it" being the final statement just of some branches; with GraphQL, as far as I can understand, each node is "where to put it"-first, and it _may_ lead to clumsy and repetitive queries).