Skip to main content

Wiki NLP Tools

Python package to perform language-agnostic tokenization.

Vision

  • Researchers can start with a Wikipedia article (wikitext or HTML), strip syntax to leave just paragraphs of plaintext, and then further tokenize these sentences into sentences and words for input into models.
  • This would be language-agnostic – i.e. the library would work equally well regardless of Wikipedia language. https://meta.wikimedia.org/wiki/List_of_Wikipedias
  • This would be easily accessible – i.e. each component is a open-source, pip-installable Python library that is configurable but provides good default performance out-of-the-box that Wikimedia could use internally via PySpark UDFs on our cluster and external organizations/researchers could incorporate into their workflows.
  • The connections between states are transparent – i.e. for any text extracted in word tokenization, that text can be connected directly back to the original wikitext or HTML that it was derived from.

Features

  • Tokenize text to sentence and words across 300+ languages out-of-the-box
  • Abbreviations can be used to improve performances
  • Word-toknizer takes non-whitespace delimited languages into account during tokenization
  • Input can be exactly reconstructed from the tokenization output

Installation

$ pip install mwtokenizer

Basic Usage

from mwtokenizer.tokenizer import Tokenizer
# initiate a tokenizer for "en" or English
tokenizer = Tokenizer(language_code = "en")
sample_text =  '''Have Moly and Co. made it to the shop near St. Michael's Church?? \n\t The address is written by Bohr Jr.   here!'''
print(list(tokenizer.sentence_tokenize(sample_text, use_abbreviation=True)))
'''
[output] ["Have Moly and Co. made it to the shop near St. Michael's Church?? \n\t ", 'The address is written by Bohr Jr.   here!']
'''
print(list(tokenizer.word_tokenize(text=sample_text, use_abbreviation=True)))
'''
[output] ['Have', ' ', 'Moly', ' ', 'and', ' ', 'Co.', ' ', 'made', ' ', 'it', ' ', 'to', ' ', 'the', ' ', 'shop', ' ', 'near', ' ', 'St.', ' ', "Michael's", ' ', 'Church', '??', ' \n\t ', 'The', ' ', 'address', ' ', 'is', ' ', 'written', ' ', 'by', ' ', 'Bohr', ' ', 'Jr.', '   ', 'here', '!']
'''

Project Information

Release files for mwtokenizer 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mwtokenizer 0.2.0
File Size Uploaded
mwtokenizer-0.2.0.tar.gz 6.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mwtokenizer 0.2.0
File Interpreter ABI Platform
mwtokenizer-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.8 MB

Release files / mwtokenizer-0.2.0.tar.gz

Download URL mwtokenizer-0.2.0.tar.gz
Size 6.9 MB
Tags Source
SHA-256 checksum
How to use checksums
95c496172e6915814edbed261bc64829b8661622fcae2947e530b63aad7bc4ec
BLAKE2b-256 checksum
How to use checksums
0d713097b66d99807c97babcaf2db08abbcee3157c00e7f76337565431c48e5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

Release files / mwtokenizer-0.2.0-py3-none-any.whl

Download URL mwtokenizer-0.2.0-py3-none-any.whl
Size 6.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
84c87ea1968761fa7ad2d774d87bdbf440abba9a56c5e972710b4b504ad1f1b9
BLAKE2b-256 checksum
How to use checksums
25292aad1f38a7b70d7291c716e17958e43ab17416cd041910a1dbfa15a82773
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page