wiktionary-ipa
A fast, lightweight, standalone Python library to extract, normalize, and verify British English (Received Pronunciation / RP) International Phonetic Alphabet (IPA) transcriptions directly from en.wiktionary.org.
Zero external dependencies — Python standard library only.
Why wiktionary-ipa?
- Dedicated to British English (RP / SSB): Most English phonetic libraries (
eng-to-ipa, CMUdict) default strictly to General American and introduce rhotic errors or flaps.wiktionary-ipaenforces strict RP priority and disqualifies Americanisms (GA,US, flaps[ɾ], rhotic vowels[ɚ, ɝ]). - Live Action API Batching: Queries
en.wiktionary.orgusing batched requests (up to 50 words per HTTP request) with gzip compression and polite rate limiting. - Zero Cache, Zero Bloat: Always queries the live crowd-sourced truth from Wiktionary without requiring multi-gigabyte XML dump downloads or stale databases.
- Homograph Disambiguation: Correctly resolves noun vs. verb stress pairs (e.g.,
record N->/ˈrekɔːd/vs.record V->/rɪˈkɔːd/). - Compound Prosody Synthesis: Automatically constructs natural British English stress patterns for idioms, phrasal verbs, and compounds missing dedicated dictionary entries.
- Phonetic Equivalence Engine: Intelligently matches variant representations (syllabic consonants like
ʃnvs.ʃən, linking(r), optional yods(j), and optional plurals).
Installation
pip install wiktionary-ipa
Or install directly from GitHub:
pip install git+https://github.com/thanhqng1510/wiktionary-ipa.git
Quick Python API
import wiktionary_ipa as wipa
# 1. Single Word Lookup (Live Web)
ipa = wipa.lookup("abbreviation")
print(ipa) # /əˌbriːviˈeɪʃən/
# 2. Batch Lookup (50 titles per HTTP request, gzip-compressed)
results = wipa.batch_lookup(["apple", "banana", "record N", "record V"])
# {
# "apple": "/ˈæp.əl/",
# "banana": "/bəˈnɑː.nə/",
# "record N": "/ˈrekɔːd/",
# "record V": "/rɪˈkɔːd/"
# }
# 3. Verify Word Against Live Web
res = wipa.verify_word("backward(s)", "/ˈbækwəd(z)/")
print(res["status"]) # 'EQUIVALENT' (matches live /bækwə(r)d/)
# 4. Phonetic Equivalence Check
wipa.phonetically_equivalent("/ˈbækwəd(z)/", "/ˈbækwə(r)d/") # True
wipa.phonetically_equivalent("/əˈdɪʃn/", "/əˈdɪʃən/") # True
# 5. Normalizer
wipa.normalize_ipa("[ˈbeɾə]") # '/ˈbetə/'
Command-Line Interface (CLI)
wiktionary-ipa provides a fast CLI:
# Lookup single word
wiktionary-ipa "abbreviation"
# abbreviation: /əˌbriːviˈeɪʃən/
# Batch lookup
wiktionary-ipa apple banana cucumber
# Verify expected pronunciation against live Wiktionary
wiktionary-ipa --verify "sea bass" "/ˈsiː bæs/"
# Word: sea bass
# Status: MATCH
# Expected: /ˈsiː bæs/
# Live Web: /ˈsiː bæs/
# JSON output for CI automation
wiktionary-ipa --verify "backward(s)" "/ˈbækwəd(z)/" --json
Architecture & Modules
client.py(WiktionaryClient): Handles MediaWiki Action API communication, batching up to 50 titles, HTTP gzip decompression, polite throttling (0.35s), and exponential backoff on HTTP 429/503.dialects.py: Received Pronunciation scoring (+100 forRP/SSB, +90 forUK/British) and hard rejection filters for non-RP accents (US,GA,Canada,Australia,Scotland,Ireland).normalizer.py: Cleans IPA formatting, enforces Unicode slashes, standardizes script characters (e.g.ɡ->g), and evaluates phonetic equivalence.parser.py: Extracts English pronunciation sections from raw Wikitext, parses{{IPA|en|...}}templates, filters dialect tags, and resolves POS homographs.prosody.py: Synthesizes compound noun stress, phrasal verb nuclear stress, and grammatical weak forms when an exact multi-word Wiktionary entry is absent.
Running Tests
All 22 unit tests execute in ~0.001 seconds using the standard library unittest runner:
python3 -m unittest discover -s tests
License
MIT License. See LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wiktionary_ipa-0.1.0.tar.gz.
File metadata
- Download URL: wiktionary_ipa-0.1.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec4e257efc807ca9b13cbeba8e777073e45b104e5578bf11bef19168ee2d341e
|
|
| MD5 |
a5b41ea2a1f72f84ed9b7e3b26d933fb
|
|
| BLAKE2b-256 |
bf5685c86519a6cb940ebd617348074215cb1013acd370bd51ec32c83acf70fe
|
Provenance
The following attestation bundles were made for wiktionary_ipa-0.1.0.tar.gz:
Publisher:
publish.yml on thanhqng1510/wiktionary-ipa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wiktionary_ipa-0.1.0.tar.gz -
Subject digest:
ec4e257efc807ca9b13cbeba8e777073e45b104e5578bf11bef19168ee2d341e - Sigstore transparency entry: 2727820163
- Sigstore integration time:
-
Permalink:
thanhqng1510/wiktionary-ipa@c487d589b65a0777245b2d15c0764c5cbd7c33d9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/thanhqng1510
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c487d589b65a0777245b2d15c0764c5cbd7c33d9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wiktionary_ipa-0.1.0-py3-none-any.whl.
File metadata
- Download URL: wiktionary_ipa-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b5e487917020eda70f297b28afdd00a59cfffceeecb715b69fd68a803e97393
|
|
| MD5 |
1aba36b62c19f4d5ee0979a04cf94f62
|
|
| BLAKE2b-256 |
7cfe23cc556359c8995adbfa65051edfd241b00a8e02e7ae628fa7887ff141d7
|
Provenance
The following attestation bundles were made for wiktionary_ipa-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on thanhqng1510/wiktionary-ipa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wiktionary_ipa-0.1.0-py3-none-any.whl -
Subject digest:
6b5e487917020eda70f297b28afdd00a59cfffceeecb715b69fd68a803e97393 - Sigstore transparency entry: 2727820941
- Sigstore integration time:
-
Permalink:
thanhqng1510/wiktionary-ipa@c487d589b65a0777245b2d15c0764c5cbd7c33d9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/thanhqng1510
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c487d589b65a0777245b2d15c0764c5cbd7c33d9 -
Trigger Event:
release
-
Statement type: