Wikipedia Extractor

From Apertium
Revision as of 07:35, 18 May 2014 by Wei2912 (talk | contribs) (formatting changes)
Jump to navigation Jump to search


This tool extracts main text from xml Wikipedia dump files (at, producing a text corpus, which is useful for training unsupervised part-of-speech taggers, n-gram language models, etc.


There are three versions of Wikipedia Extractor:

The original, works with Python 2.x and outputs multiple files. License GPL-V3.

Guampa's version, works with Python 3.x and outputs multiple files. License GPL-V3

New version, a modified version of Guampa's, works with Python 3.x and outputs a single file


Work well : Wikipedia, Wikivoyage, Wikibooks

With problem: Wiktionary (Mistakenly, not all articles fully included, and foreign words' explanations included.)

(Thanks to the feedback by Per Tunedal!)

New Version

The new version was written by BenStobaugh during GCI-2013 and can be downloaded from SVN at

This version is much simpler than the old version. This version auto-removes any formatting and only outputs the text to one file. To use it, simply use the following command in your terminal, where dump.xml is the Wikipedia dump

   $ python3 --infn dump.xml.bz2

This will run through all of the articles, get all of the text and put it in wiki.txt. This version also supports compression (BZip2 and Gzip), so you can use dump.xml.bz2 or dump.xml.gz instead of dump.xml. You can also compress (Bzip2) the output file by adding --compress to the command.

You can also run python3 --help to get more details.