Read wikipedia dump bz2 with Index

How to read wikipedia / wiktionary dump file with dump index file

Maven Repository

<!-- https://mvnrepository.com/artifact/org.nlp4j/nlp4j-wiki -->
<dependency>
    <groupId>org.nlp4j</groupId>
    <artifactId>nlp4j-wiki</artifactId>
    <version>1.1.0.0</version>
</dependency>

Code

String wikidumpfile_name = "/usr/local/wiki/enwiki/20230101/enwiki-20230101-pages-articles-multistream.xml.bz2";
String wikiindexfile_name = "/usr/local/wiki/enwiki/20230101/enwiki-20230101-pages-articles-multistream-index.txt.bz2";
String entry = "Dragon Ball";

File wikidumpfile = new File(wikidumpfile_name);
File wikiindexfile = new File(wikiindexfile_name);

// Read Wikipedia Dump with Index
try (WikiDumpReader dumpReader = new WikiDumpReader(wikidumpfile, wikiindexfile);) {
	WikiPage page = dumpReader.getItem(entry);
	System.err.println("<title>");
	System.err.println(page.getTitle());
	System.err.println("</title>");
	System.err.println("<plaintext>");
	System.err.println(page.getRootNodeWikiText());
	System.err.println("</plaintext>");
}

Results

<title>
Dragon Ball
</title>
<plaintext>
{{short description|Japanese media franchise created by Akira Toriyama}}
{{About|the media franchise in general}}
{{Good article}}
{{pp-move-indef|small=yes}}
{{pp-pc1|small=yes}}
{{Use mdy dates|date=September 2019}}
{{Infobox media franchise
| image = Dragon Ball manga 1st Japanese edition logo.svg
| creator = [[Akira Toriyama]]
| origin = [[Dragon Ball (manga)|''Dragon Ball'']] (1984–1995)
| owner = [[Bird Studio]]/[[Shueisha]]
| years = 1984–present
| books = [[#Companion books|Companion books]]
| novels =
| short_stories =
| comics = [[#Manga|Manga]]
| magazines =
| films = [[List of Dragon Ball films|List of films]]
| tv =
| atv = {{Plain list|
* [[List of Dragon Ball anime|List of anime]]
* ''[[Dragon Ball (TV series)|Dragon Ball]]'' (1986–1989)
* ''[[Dragon Ball Z]]'' (1989–1996)
* ''[[Dragon Ball GT]]'' (1996–1997)
* ''[[Dragon Ball Z#Dragon Ball Z Kai|Dragon Ball Z Kai]]'' (2009–2011; 2014–2015)
* ''[[Dragon Ball Super]]'' (2015–2018)
* ''[[Super Dragon Ball Heroes (web series)|Super Dragon Ball Heroes]]'' (2018–present)
}}
| tv_specials = {{Plain list|
* ''[[Dragon Ball Z: Bardock – The Father of Goku|Bardock – The Father of Goku]]'' (1990)
* ''[[Dragon Ball Z: The History of Trunks|The History of Trunks]]'' (1993)
* ''[[Dragon Ball GT: A Hero's Legacy|A Hero's Legacy]]'' (1997)
}}
| tv_films =
| dtv = {{Plain list|
* ''[[Dragon Ball Z Side Story: Plan to Eradicate the Saiyans|Plan to Eradicate the Saiyans]]'' (1993)
* ''[[Dragon Ball: Plan to Eradicate the Super Saiyans|Plan to Eradicate the Super Saiyans]]'' (2010)
}}
| shorts = {{Plain list|
* ''[[Dragon Ball: Yo! Son Goku and His Friends Return!!|Yo! Son Goku and His Friends Return!!]]'' (2008)
* ''[[Dragon Ball: Episode of Bardock|Episode of Bardock]]'' (2011)
}}
| plays =
| musicals =
| games = {{plainlist|
*[[Carddass]]
*''[[Dragon Ball Z: The Anime Adventure Game]]''
*''[[Dragon Ball Collectible Card Game]]''
}}
| rpgs =
| vgs = [[List of Dragon Ball video games|List of video games]]
| radio =
| soundtracks = [[List of Dragon Ball soundtracks|List of soundtracks]]
| music =
| toys =
| otherlabel1 =
| otherdata1 =
| website = {{Official website|URL=https://en.dragon-ball-official.com/|name=https://en.dragon-ball-official.com/}}
}}
{{Nihongo|'''''Dragon Ball'''''|ドラゴンボール|Doragon Bōru|lead=yes}} <onlyinclude>is a Japanese [[media franchise]] created by [[Akira Toriyama]] in 1984. The [[Dragon Ball (manga)|initial manga]], written and illustrated by Toriyama, was serial
ized in ''[[Weekly Shōnen Jump]]'' from 1984 to 1995, with the 519 individual chapters collected into 42 ''[[tankōbon]]'' volumes by its publisher [[Shueisha]]. ''Dragon Ball'' was originally inspired by the classical 16th-century Chinese n
ovel ''[[Journey to the West]]'', combined with elements of [[Hong Kong martial arts films]]. The series follows the adventures of protagonist [[Goku|Son Goku]] from his childhood through adulthood as he trains in martial arts. He spends hi
s childhood far from civilization until he meets a teen girl named [[Bulma]], who encourages him to join her quest in exploring the world in search of the seven orbs known as the Dragon Balls, which summon a wish-granting dragon when gather
ed. Along his journey, Goku makes several other friends, becomes a family man, discovers his alien heritage, and battles a wide variety of villains, many of whom also seek the Dragon Balls.</onlyinclude>

Toriyama's [[manga]] was adapted and divided into two [[anime]] series produced by [[Toei Animation]]: ''[[Dragon Ball (TV series)|Dragon Ball]]'' and ''[[Dragon Ball Z]]'', which together were broadcast in Japan from 1986 to 1996. Addition
ally, the studio has developed [[List of Dragon Ball films|21 animated feature films]] and three television specials, as well as two anime sequel series titled ''[[Dragon Ball GT]]'' (1996–1997) and ''[[Dragon Ball Super]]'' (2015–2018). Fr
om 2009 to 2015, a revised version of ''Dragon Ball Z'' aired in Japan under the title ''Dragon Ball Kai'', as a recut that follows the manga's story more faithfully by removing most of the material featured exclusively in the anime. Severa
l companies have developed various types of merchandising based on the series leading to a large media franchise that includes films, both animated and live-action, collectible trading card games, numerous action figures, along with [[List 
of Dragon Ball soundtracks|several collections of soundtracks]] and [[List of Dragon Ball video games|numerous video games]]. ''Dragon Ball'' has become one of the [[List of highest-grossing media franchises|highest-grossing media franchise
s]] of all time.

Since its release, ''Dragon Ball'' has become one of the most successful manga and anime series of all time, with the manga sold in over 40{{nbsp}}countries and the anime broadcast in more than 80{{nbsp}}countries. The manga's 42 collected 
''tankōbon'' volumes have over 160 million copies sold in Japan and {{nowrap|350 million}} copies sold worldwide,<ref>{{cite news |title=Shueisha said in 2009 that Dragon Ball was at 350 million copies in circulation |url=https://i.gzn.jp/i
mg/2009/03/21/db_kai/db_kai_04_m.jpg |date=January 17, 2022 |language=ja}}</ref><ref>{{cite news |title=~映画「ドラゴンボールZ 神と神」公開記念!出でよ神龍!! 鳥山明先生、アンケート答えておくれーーーっ!!!!!SP~ |url=https://www.toei-anim.co.jp/movie/2013_dragonballz/news/30.html |date=M
arch 14, 2013 |language=ja}}</ref><ref>{{cite news |title=よりスピーディーに、より迫力を増して復活する「ドラゴンボール改」in TAF2009 |url=http://news.livedoor.com/article/detail/4071398/ |access-date=January 23, 2019 |work=[[Livedoor News]] |publisher=[[Livedoor]] |date=M
arch 21, 2009 |language=ja |archive-url=https://web.archive.org/web/20180816093643/http://news.livedoor.com/article/detail/4071398/ |archive-date=August 16, 2018 |url-status=live }}</ref><ref>{{cite news |title=映画「ドラゴンボール」テーマソングは浜崎あゆみ |url=
http://sankei.jp.msn.com/entertainments/entertainers/081210/tnr0812100742001-n1.htm
|archive-url=https://web.archive.org/web/20081212210945/http://sankei.jp.msn.com/entertainments/entertainers/081210/tnr0812100742001-n1.htm |url-status=dead |archive-date=December 12, 2008 |access-date=December 12, 2008 |work=[[MSN Sankei News]] |date=December 10, 2008}}</ref><ref>{{cite news |title=ピッコロは緑だけど触角なし......実写『ドラゴンボール』映像 |url=https://www.oricon.co.jp/news/61072/full/ |work=[[Oricon News]] |date=December 15, 2008 |language=ja-JP |access-date=August 16, 2018 |archive-url=https://web.archive.org/web/20180816125800/https://www.oricon.co.jp/news/61072/full/ |archive-date=August 16, 2018 |url-status=live }}</ref> making it one of the [[List of best-selling manga|best-selling manga series]]. Reviewers have praised the art, characterization, and humor of the story. It is widely regarded as one of the greatest and most influential manga series ever made, with m any [[Mangaka|manga artists]] citing ''Dragon Ball'' as a source of inspiration for their own now-popular works. The anime, particularly ''Dragon Ball Z'', is also highly popular around the world and is considered one of the most influentia l in boosting the popularity of Japanese animation in Western culture. It has had a considerable impact on global [[popular culture]], referenced by and inspiring numerous artists, athletes, celebrities, filmmakers, musicians and writers ar ound the world. </plaintext>