0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Extract a Wikipedia Page Directly from a Dump File with NLP4J

0
Last updated at Posted at 2026-08-11

Extract a Wikipedia Page Directly from a Dump File with NLP4J

Wikipedia provides database dumps that are extremely useful for NLP, text mining, search, corpus construction, and knowledge-base development.

However, Wikipedia dump files are large, and extracting just one article from them is not always convenient.

I have added a small command-line tool to NLP4J that allows you to retrieve a Wikipedia page directly from a Wikipedia multistream dump by specifying its title.

For example:

java -jar nlp4j-wikipedia-app.jar \
  --dump jawiki-20260801-pages-articles-multistream.xml.bz2 \
  --index jawiki-20260801-pages-articles-multistream-index.txt.bz2 \
  --title ドラゴンボール

This retrieves the Japanese Wikipedia page for ドラゴンボール (Dragon Ball) directly from the dump.

No database server or search server is required.

NLP4J

NLP4J is an open-source Java library for natural language processing and text analytics.

GitHub:

https://github.com/oyahiroki/nlp4j

The executable JAR used in this article is available here:

https://github.com/oyahiroki/nlp4j/blob/master/nlp4j/nlp4j-wiki/dist/nlp4j-wikipedia-app.jar

Downloading Wikipedia Dump Files

Wikipedia dump files are available from the official Wikimedia dump service.

For example, for the August 1, 2026 English Wikipedia dump, use:

https://dumps.wikimedia.org/enwiki/20260801/

As of August 2026, this directory contains the two files required by this tool: the combined multistream article dump and its corresponding index. (ウィキメディアダウンロード)

The files are:

enwiki-20260801-pages-articles-multistream.xml.bz2
enwiki-20260801-pages-articles-multistream-index.txt.bz2

The first file is the Wikipedia article dump:

enwiki-20260801-pages-articles-multistream.xml.bz2

The second file is the multistream index:

enwiki-20260801-pages-articles-multistream-index.txt.bz2

On August 11, 2026, Wikimedia listed these files as approximately 24.8 GB and 270.5 MB, respectively. (ウィキメディアダウンロード)

The Wikimedia page may still show:

Dump in progress

because other dump files are still being generated. However, the two multistream files above may already be marked as completed and can be downloaded. (ウィキメディアダウンロード)

English Wikipedia vs. Japanese Wikipedia

Wikipedia dump directory names include the language code.

For English Wikipedia:

enwiki

For Japanese Wikipedia:

jawiki

The command examples in this article use Japanese Wikipedia, so the corresponding files are:

jawiki-20260801-pages-articles-multistream.xml.bz2
jawiki-20260801-pages-articles-multistream-index.txt.bz2

For English Wikipedia, use the enwiki files instead.

This makes it easy to use the same NLP4J tool with different Wikipedia languages.

What You Need

The tool requires two files:

*-pages-articles-multistream.xml.bz2
*-pages-articles-multistream-index.txt.bz2

For the Japanese Wikipedia dump dated August 1, 2026:

jawiki-20260801-pages-articles-multistream.xml.bz2

jawiki-20260801-pages-articles-multistream-index.txt.bz2

The first file contains the Wikipedia pages.

The second file is the corresponding multistream index.

You do not need to decompress these .bz2 files before using the tool.

Basic Usage

The command syntax is:

java -jar nlp4j-wikipedia-app.jar \
  --dump <Wikipedia dump file> \
  --index <Wikipedia index file> \
  --title <Wikipedia page title>

The options are:

Option Description
--dump Wikipedia pages-articles-multistream.xml.bz2 file
--index Wikipedia pages-articles-multistream-index.txt.bz2 file
--title Title of the Wikipedia page to retrieve

Example on Windows

I tested the following command on Windows:

java -jar nlp4j-wikipedia-app.jar --dump "C:\usr\local\wiki\jawiki\20260801\jawiki-20260801-pages-articles-multistream.xml.bz2" --index "C:\usr\local\wiki\jawiki\20260801\jawiki-20260801-pages-articles-multistream-index.txt.bz2" --title ドラゴンボール

The tool looks up the requested page in the multistream index and retrieves the corresponding page directly from the Wikipedia dump.

Another example is:

java -jar nlp4j-wikipedia-app.jar \
  --dump "C:\usr\local\wiki\jawiki\20260801\jawiki-20260801-pages-articles-multistream.xml.bz2" \
  --index "C:\usr\local\wiki\jawiki\20260801\jawiki-20260801-pages-articles-multistream-index.txt.bz2" \
  --title 日本

This retrieves the Japanese Wikipedia page:

日本

Redirect the Result to a File

Because the page content is written to standard output, it can also be redirected to a file.

For example:

java -jar nlp4j-wikipedia-app.jar \
  --dump "C:\usr\local\wiki\jawiki\20260801\jawiki-20260801-pages-articles-multistream.xml.bz2" \
  --index "C:\usr\local\wiki\jawiki\20260801\jawiki-20260801-pages-articles-multistream-index.txt.bz2" \
  --title ドラゴンボール \
  > dragonball.txt

On Windows:

type dragonball.txt

On Linux or macOS:

cat dragonball.txt

The output contains the Wikipedia page data obtained directly from the dump.

This makes it easy to connect the tool with Java, Python, shell scripts, NLP tools, or text-mining pipelines.

Why Use the Multistream Index?

A Wikipedia pages-articles-multistream.xml.bz2 file contains a very large number of pages.

If we only want one particular page, processing the entire dump from the beginning would be inefficient.

Wikipedia also provides the corresponding multistream index:

pages-articles-multistream-index.txt.bz2

NLP4J uses this index to locate the requested article in the dump.

Conceptually, the operation is very simple:

Wikipedia title
      |
      v
Multistream index
      |
      v
Location in dump
      |
      v
Wikipedia page

For users of the command-line tool, this is hidden behind a simple option:

--title ドラゴンボール

Useful for NLP Experiments

Wikipedia dumps are frequently useful as source data for:

  • NLP experiments
  • text mining
  • keyword extraction
  • morphological analysis
  • corpus construction
  • search indexes
  • knowledge bases
  • entity analysis
  • RAG data preparation

For many experiments, we do not need to process the entire Wikipedia dump immediately.

Sometimes we simply want to inspect a few specific pages first.

With nlp4j-wikipedia-app.jar, this can be done directly from the original compressed dump:

Wikipedia dump + index + page title
                |
                v
           Wikipedia page

There is no need to import the dump into a database or search server just to retrieve one page.

Using It from Python

Since the tool is a normal command-line application, it can also be called from Python.

For example:

import subprocess

cmd = [
    "java",
    "-jar",
    "nlp4j-wikipedia-app.jar",
    "--dump",
    r"C:\usr\local\wiki\jawiki\20260801\jawiki-20260801-pages-articles-multistream.xml.bz2",
    "--index",
    r"C:\usr\local\wiki\jawiki\20260801\jawiki-20260801-pages-articles-multistream-index.txt.bz2",
    "--title",
    "ドラゴンボール",
]

result = subprocess.run(
    cmd,
    capture_output=True,
    text=True,
    encoding="utf-8",
)

print(result.stdout)

The Wikipedia dump reader itself is implemented in Java, while it can still be incorporated easily into Python-based NLP workflows.

Summary

The NLP4J Wikipedia command-line tool provides a simple interface for retrieving individual Wikipedia pages directly from multistream dump files.

First, download the Wikipedia dump and index from Wikimedia.

For example, the August 1, 2026 English Wikipedia dump is available from:

https://dumps.wikimedia.org/enwiki/20260801/

Then run:

java -jar nlp4j-wikipedia-app.jar \
  --dump <dump.xml.bz2> \
  --index <index.txt.bz2> \
  --title <Wikipedia title>

For Japanese Wikipedia:

java -jar nlp4j-wikipedia-app.jar \
  --dump jawiki-20260801-pages-articles-multistream.xml.bz2 \
  --index jawiki-20260801-pages-articles-multistream-index.txt.bz2 \
  --title ドラゴンボール

The design goal is simple:

Use the original Wikipedia dump directly, without first building another database or search server.

For small experiments, corpus inspection, NLP development, and data preparation, being able to retrieve a Wikipedia page with a single command can be very useful.

Links

NLP4J:

https://github.com/oyahiroki/nlp4j

nlp4j-wikipedia-app.jar:

https://github.com/oyahiroki/nlp4j/blob/master/nlp4j/nlp4j-wiki/dist/nlp4j-wikipedia-app.jar

Wikimedia English Wikipedia dump, August 1, 2026:

https://dumps.wikimedia.org/enwiki/20260801/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?