I downloaded wikipedia dump and now want to remove the wikipedia markup in the contents of each page. I tried writing regular expressions but they are too many to handle. I found a python library but I need a java library because, I want to integrate into my code.
Thank you.
Do it in two steps:
The following demo:
produces:
Here: Web Archive link of download.java.net/maven/2/net/java/textile-j/2.2
Mylyn WikiText can convert various Wiki syntaxes into HTML and other formats. It also supports MediaWiki syntax, which is what Wikipedia uses. Although Mylyn WikiText is primarily an Eclipse plugin, it is also available as standalone library.
Try the Mediawiki text to plain text approach. You probably have to improve the PlainTextConverter class for your needs. Combined with the example for converting Wikipedia texts to HTML you can transclude template contents.
If you need plain text you should use WikiClean library https://github.com/lintool/wikiclean.
I had the same problem and it looks like this was the only efficient solution that worked for me in java.
There are two usecases:
1) When you have the text not in XML format then you should add xml tags needed to do this processing. Supposing you are processing XML file earlier, and now you have the content without XML structure, then you just add xmlStartTag and xmlEndTag as in the code bellow, and it processes it.
2) When you are reading the Wikipedia dump file directly (xml file), in that case you just pass it through the file and it goes through.