TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Has anyone had luck using the Wikipedia data dumps?

46 pointsby perfect_loopabout 6 years ago
Many docs and tutorials are from 10+ years ago. Have you had any luck loading the data dumps (not the API) locally in order to play around with them? if yes, I'd very much appreciate it if you could point me in the right direction.

11 comments

thomas536about 6 years ago
I also didn&#x27;t find much information about how long it would take to import into a db, so I used the xml dumps directly [1]. I only needed the wiki content (not the history), so the article xml files worked well for me. And then I used mwparserfromhell [2] to parse and extract from the wiki markup.<p>[1] <a href="https:&#x2F;&#x2F;dumps.wikimedia.org&#x2F;enwiki&#x2F;20190301&#x2F;" rel="nofollow">https:&#x2F;&#x2F;dumps.wikimedia.org&#x2F;enwiki&#x2F;20190301&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;mwparserfromhell.readthedocs.io&#x2F;en&#x2F;latest&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mwparserfromhell.readthedocs.io&#x2F;en&#x2F;latest&#x2F;</a>
评论 #19407149 未加载
digganabout 6 years ago
While building the Wikipedia mirror on IPFS (with search), we tried using the dumps from Wikipedia themselves but ended up using Zim archives from kiwix.org instead. The end result is here: <a href="https:&#x2F;&#x2F;github.com&#x2F;ipfs&#x2F;distributed-wikipedia-mirror" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ipfs&#x2F;distributed-wikipedia-mirror</a><p>For actually ingesting the archives, dignifiedquire expanded a Rust utility aptly named Zim, which you can find here <a href="https:&#x2F;&#x2F;github.com&#x2F;dignifiedquire&#x2F;zim" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dignifiedquire&#x2F;zim</a><p>Both repos contain information (and code of course) on how to extract information from the Zim archives
yk66about 6 years ago
I use Kiwix to do that. Much simpler. Plus they provide other dumps too. So allows you to play with say wikipedia and stackoverflow simultaneously.
评论 #19407728 未加载
arsenideabout 6 years ago
I have toyed around with the Wikipedia dump -- in XML, downloaded through the provided torrent file on Wikipedia.<p>It took a bit to get accustomed to the format, but after looking at the files and doing a bit of research on the documentation, using Python with lxml made it relatively straightforward to do what I was interested in.<p>I&#x27;d recommend doing the same, only because it worked for me: get the XML dump, manually check out some files to understand what is going on, search for documentation on the file format and maybe read a few blog posts, and then convert the XML files to data structures suited for what you&#x27;re interested in.
aboutrubyabout 6 years ago
You could also use Special:Export depending on your use case: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Special:Export" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Special:Export</a>
thetermsheetabout 6 years ago
This may not be the most helpful reply but I remember having to use some &quot;importing tool&quot;. Wikipedia provides you with standard SQL dumps yet simply importing them into the DB is not going to cut it. The community has created import scripts which simplify the process to a degree.
zepearlabout 6 years ago
I used Python to load the contents of the articles into a DB (potentially wrong extract of veeery old code - I have something like 20 different versions lying around therefore I&#x27;m not 100% sure that this did work well):<p>===<p><pre><code> import xml.dom.pulldom as pulldom from lxml import etree from xml.etree import ElementTree as ET sInputFileName = &quot;&#x2F;my&#x2F;input&#x2F;wiki_file.xml&quot; context = etree.iterparse(sInputFileName, events=(&#x27;end&#x27;,), tag=&#x27;doc&#x27;) for event, elem in context: iThisArticleCharLength = len(elem.text) sPageURL = elem.get(&quot;url&quot;)[0:4000] sPageTitle = elem.get(&quot;title&quot;)[0:4000] SPageContents = elem.text &lt;do what you want with these vars...&gt; </code></pre> ===
StrangeDoctorabout 6 years ago
I built tools to parse the compressed XML dumps. My computer was pretty underpowered at the time (MacBook air) so I had to very careful to make everything a streaming algorithm. Looking back I basically recreated a shitty map reduce in Python.
moossabout 6 years ago
I&#x27;ve had some success using this tutorial: <a href="https:&#x2F;&#x2F;www.kdnuggets.com&#x2F;2017&#x2F;11&#x2F;building-wikipedia-text-corpus-nlp.html" rel="nofollow">https:&#x2F;&#x2F;www.kdnuggets.com&#x2F;2017&#x2F;11&#x2F;building-wikipedia-text-co...</a> .<p>And I&#x27;ve changed it a little bit to extract only the first n characters, this might be of some use since wikipedia dump are supposed to be pretty large: <a href="https:&#x2F;&#x2F;github.com&#x2F;mooss&#x2F;ruskea&#x2F;blob&#x2F;master&#x2F;make_wiki_corpus.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mooss&#x2F;ruskea&#x2F;blob&#x2F;master&#x2F;make_wiki_corpus...</a> .
kldavis4about 6 years ago
I wrote a simple parser in node to import the article dump into an Elasticsearch instance as a part of a hands on tutorial: <a href="https:&#x2F;&#x2F;github.com&#x2F;kldavis4&#x2F;kuali-days-2017-elasticsearch&#x2F;blob&#x2F;master&#x2F;wikipedia&#x2F;index.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kldavis4&#x2F;kuali-days-2017-elasticsearch&#x2F;bl...</a>. At the time, on the full dump, it took quite a while to ingest (days as I recall).
usgroupabout 6 years ago
Dependent on what you’re doing, consider using wikidata instead. Has a SPARQL interface that’s easy to query.