{"id":16351619,"url":"https://github.com/tomeraberbach/wikipedia-ngrams","last_synced_at":"2025-11-13T09:30:15.650Z","repository":{"id":37261427,"uuid":"183326892","full_name":"TomerAberbach/wikipedia-ngrams","owner":"TomerAberbach","description":"📚 A Kotlin project which extracts ngram counts from Wikipedia data dumps.","archived":false,"fork":false,"pushed_at":"2023-07-03T04:14:32.000Z","size":14,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-14T00:09:24.218Z","etag":null,"topics":["cli","extracts-ngram-counts","kotlin","ngram","ngrams","nlp","wikiextractor","wikipedia","wikipedia-corpus","wikipedia-data-dump","wikipedia-dump","wikipedia-ngrams"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomerAberbach.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-25T00:38:02.000Z","updated_at":"2023-07-07T13:26:45.000Z","dependencies_parsed_at":"2024-11-07T15:12:48.553Z","dependency_job_id":null,"html_url":"https://github.com/TomerAberbach/wikipedia-ngrams","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fwikipedia-ngrams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fwikipedia-ngrams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fwikipedia-ngrams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fwikipedia-ngrams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomerAberbach","download_url":"https://codeload.github.com/TomerAberbach/wikipedia-ngrams/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239605124,"owners_count":19666998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","extracts-ngram-counts","kotlin","ngram","ngrams","nlp","wikiextractor","wikipedia","wikipedia-corpus","wikipedia-data-dump","wikipedia-dump","wikipedia-ngrams"],"created_at":"2024-10-11T01:23:26.990Z","updated_at":"2025-11-13T09:30:15.618Z","avatar_url":"https://github.com/TomerAberbach.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wikipedia Ngrams\n\n\u003e A Kotlin project which extracts ngram counts from Wikipedia data dumps.\n\n## Download\n\nDownload the latest jar from [releases](https://github.com/TomerAberbach/wikipedia-ngrams/releases).\n\nYou can also clone the repository and build with [maven](https://maven.apache.org/download.cgi):\n\n```sh\n$ git clone https://github.com/TomerAberbach/wikipedia-ngrams.git\n$ cd wikipedia-ngrams\n$ mvn package\n```\n\nA fat jar called `wikipedia-ngrams-VERSION-jar-with-dependencies.jar` will be in a newly created `target` directory.\n\n## Usage\n\nDISCLAIMER: Many of these commands will take a very long time to run.\n\nDownload the latest [Wikipedia data dump](https://meta.wikimedia.org/wiki/Data_dumps/Download_tools) using `wget`:\n\n```sh\n$ wget -np -nd -c -A 7z https://dumps.wikimedia.org/metawiki/latest/metawiki-latest-pages-meta-current.xml.bz2\n```\n\nOr using `axel`:\n\n```sh\n$ axel --num-connections=3 https://dumps.wikimedia.org/metawiki/latest/metawiki-latest-pages-meta-current.xml.bz2\n```\n\nTo speed up the download you should replace `https://dumps.wikimedia.org` with the [mirror](https://meta.wikimedia.org/wiki/Mirroring_Wikimedia_project_XML_dumps) closest to you.\n\nOnce downloaded, extract the zipped data using a tool like `lbzip2` and feed the resulting `enwiki-latest-pages-articles.xml` file into [WikiExtractor](https://github.com/attardi/wikiextractor):\n\n```sh\n$ python3 WikiExtractor.py --no_templates --json enwiki-latest-pages-articles.xml\n```\n\nThis will output a large directory structure with root directory `text`.\n\nFinally, run `wikipedia-ngrams.jar` with the desired ngram \"n\" (2 in this example) and the path to directory output of [WikiExtractor](https://github.com/attardi/wikiextractor):\n\n```sh\n$ java -jar wikipedia-ngrams.jar 2 text\n```\n\nNote that you may need to increase the maximum heap size and/or disable GC overhead limit.\n\n`contexts.txt` and `2-grams.txt` files will be in an `out` directory. `contexts.txt` caches the \"sentences\" in the Wikipedia data dump. To use this cache in your next run (with n = 3 for example), run the following command:\n\n```sh\n$ java -jar wikipedia-ngrams.jar 3 out/contexts.txt\n```\n\nThe outputted files will not be sorted. Use a command-line tool like `sort` to do so.\n\nNote that `OutOfMemoryError` is not a legitimate issue. The burden is on the user to allocate enough heap space and have a large enough RAM (consider allocating a larger [swap file](https://linuxize.com/post/create-a-linux-swap-file)).\n\n## Dependencies\n\n- [Stanford CoreNLP](https://stanfordnlp.github.io/CoreNLP/index.html)\n- [fastutil](http://fastutil.di.unimi.it)\n\n## License\n\n[MIT](https://github.com/TomerAberbach/wikipedia-ngrams/blob/main/license) © [Tomer Aberbach](https://github.com/TomerAberbach)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomeraberbach%2Fwikipedia-ngrams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomeraberbach%2Fwikipedia-ngrams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomeraberbach%2Fwikipedia-ngrams/lists"}