Various data and utilities for processing wikitext.
Project description
mwconstants
Various utilities and constants useful for analyses of wikitext. This package contains three types of artifacts:
- Data generating functions: Python functions for calling various APIs to build useful data structures -- e.g., all Wikipedia language codes
- Static data snapshots: Python variables that contain the most recent result of a data generating function
- Utilities: Python functions for handling various wikitext-related processing tasks -- e.g., mapping links to namespaces.
Installation
You can install mwconstants
with pip
:
$ pip install mwconstants
Basic Usage
from mwconstants import link_to_namespace, NON_WHITESPACE_LANGUAGES
print(link_to_namespace('Utilisateur:Isaac_(WMF)', lang='fr')) # 'User'
print(sorted(NON_WHITESPACE_LANGUAGES)) # ['bo', 'bug', ..., 'zh-classical', 'zh-yue']
Modules
All modules generally contain relevant constants, functions for generating those constants, and other useful utilities for manipulating them:
languages.py
: functions for identifying languages associated with a given Wikimedia project.media.py
: functions for identifying media in wikitext and parsing wikitext media syntax into its componentsnamespaces.py
: functions for identifying namespace prefixes
Limitations
- Links have many edge-cases, especially around interwiki prefixes. For now, just the basics are covered: language-specific namespaces and interlanguage links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mwconstants-0.1.0.tar.gz
(90.5 kB
view details)
Built Distribution
File details
Details for the file mwconstants-0.1.0.tar.gz
.
File metadata
- Download URL: mwconstants-0.1.0.tar.gz
- Upload date:
- Size: 90.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81cd90b1080e13053e55326856c1b78156c9f8612a403f0095c4f1a0b1488415 |
|
MD5 | 4b32d6bbbcbc452c8ebcb06b4c01a5a5 |
|
BLAKE2b-256 | d585a5416773f5a33feeffd7b9b78992e07a78b7e33b2b57a448e66eeebd3c68 |
File details
Details for the file mwconstants-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: mwconstants-0.1.0-py3-none-any.whl
- Upload date:
- Size: 93.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3023602ed465a5428e59d5a5fc51b0151acb4fc6246714d572f542d9efbb0786 |
|
MD5 | e0026009610924fd3d884bdbe0f04156 |
|
BLAKE2b-256 | 0d19e60761e20dd4e7609c76e126ba415b03de11c172dcc8290322dd8c75e069 |