--- license: mit task_categories: - text-generation - summarization language: - en pretty_name: GoodWiki size_categories: - 10KO(n^2) ``` becomes: `$O(n^2)$`. #### Super/Subscript Superscripts and subscripts are denoted using `` and `` tags respectively. #### \$ and \# Dollar signs and hashes are escaped with `\` to avoid interfering with math and heading syntax. ## Methodology On the evening of September 4, 2023 PT, we downloaded the wikicode of articles associated with the [Good](https://en.wikipedia.org/wiki/Category:Good_articles) and [Featured](https://en.wikipedia.org/wiki/Category:Featured_articles) categories in the main namespace (`ns=0`) on Wikipedia via the [Query API](https://www.mediawiki.org/wiki/API:Query). After some preprocessing including removing comments, applying magic code, and removing unrecognized or unnecessary template tags, we sent the resulting code to Wikipedia's [Expandtemplates API](https://www.mediawiki.org/wiki/API:Expandtemplates). This endpoint [transcludes](https://en.wikipedia.org/wiki/Help:Transclusion) template tags, turning them into HTML and plaintext. We chose the templates to transclude by counting all the templates used across the dataset and selecting the ones that are not rare, not used for citations, and not used for asides like infoboxes and tables. The Expandtemplates output is then postprocessed. During this phase, we remove sections associated with references (e.g. `Sources Cited`), extract text from wikilinks and external links, delete media links, and handle [HTML tags](https://en.wikipedia.org/wiki/Help:HTML_in_wikitext). The postprocessed output is then converted to GitHub-flavored Markdown using [Pandoc](https://pandoc.org/). We also discarded articles detected by Pandoc to have corrupt wikicode (`n=125`). The markdown output is then cleaned using regular expressions to remove excessive spacing, empty list items, unnecessary escaping, and resolve other problems with Pandoc's conversion. We normalized the markdown output unicode to a composed form (NFKC). ### Alternatives Considered #### Converting End-To-End Using Pandoc While Pandoc can in theory convert raw wikicode to markdown, it is **not** a complete wikicode parser and therefore often produces errant output without preprocessing. Furthermore, direct conversion of raw wikicode would lose a lot of the content attached to wikicode templates as Pandoc cannot perform transclusion. #### Using TextExtracts API Wikipedia has a [TextExtracts](https://www.mediawiki.org/wiki/Extension:TextExtracts#API) API that directly outputs a limited HTML or plaintext output of a page given that page's title. In practice, I've found the HTML output generated by this endpoint to often contain malformed or incomplete HTML with injected references that are difficult to parse. The plaintext output was also often poor, including reference artifacts and missing content. Other caveats are listed [here](https://www.mediawiki.org/wiki/Extension:TextExtracts#API) and were the reasons why this approach was discarded. #### Transcluding All Templates During the preprocessing process, we eliminate templates outside of a given subset. We did this because we found that transcluding all templates injected a lot of noise in the output, including janky HTML, styles, references, and unnecessary content. This noise made parsing difficult and error-prone, resulting in poor quality markdown littered with artifacts similar to those visible in the TextExtracts output. Transcluding a subset largely solved these issues while still preserving as much content as possible. ## Limitations * Chemical equations sometimes include formatting issues like unnecessary line-breaks. These equations, however, are rare. * In articles about ancient civilizations and languages, rare Unicode characters are occasionally included in the markdown. It might be worth removing these characters during the tokenization process. * In rare cases, book/article names may be missing from the markdown as they are considered citations in the wikicode. * Inflation data is missing from some articles. These articles use the `Inflation` template tag to include this information, which works poorly with the Extracttemplates API. * Articles may feature empty sections due to table/box removal. * Some code blocks are denoted using indents instead of formal code blocks. This is due to the original wikicode not denoting them as such. * Template subset allowing transclusion will probably need to be updated for use in future data dumps. The list of templates used on Wikipedia is constantly evolving. ## Future Work Time permitting, we hope to apply this careful conversion/generation process on all of English Wikipedia which will require our conversion script to be much faster and better parallelized. We also hope to extract other information from pages like entries in infoboxes that could be useful for question answering and instruction tuning applications. If you're interested in helping out, please reach out! ## License The dataset and accompanying [code](https://github.com/euirim/goodwiki) are licensed under an **MIT license**. Pandoc, which must be downloaded separately, is GPL-licensed. While this project is permissively licensed, we hope that you contribute any improvements you make to this dataset. ## Citation If you use the GoodWiki Dataset in your research or projects, please cite it using the following citation: ```tex @misc{GoodWiki, title = {GoodWiki Dataset}, author = {Choi, Euirim}, howpublished = {\url{https://www.github.com/euirim/goodwiki}}, month = {September}, year = {2023} } ``` ## Feedback and Contributions Contributions via pull requests and discussions are welcome. If you don't know how you could help improve this project, please look at the [Future Work](#future-work) section. Was this dataset useful for your work? Please let us know. We'd love to feature your project :)