This release is a pre-release and may not be stable for production use.
TugaLex
TugaLex is a lexicon handler and linguistic utility for Portuguese dialects. It provides data on phoneme transcription (IPA), syllable segmentation, and historical and modern orthographic rules.
It gives NLP pipelines and linguistics research a single API for the differences between Portuguese regions and historical spelling agreements.
Supported Dialects
TugaLex maps standard ISO codes to internal regional datasets:
| ISO Code | Internal Code | Region |
|---|---|---|
pt-PT |
lbx |
Portugal (Lisbon) |
pt-BR |
rjx |
Brazil (Rio de Janeiro) |
| n/a | spx |
Brazil (São Paulo) |
pt-AO |
lda |
Angola (Luanda) |
pt-MZ |
mpx |
Mozambique (Maputo) |
pt-TL |
dli |
Timor-Leste (Díli) |
The regional dictionary ships as a slim gzip extract (word, POS, phones,
syllables, region) of the unified Portuguese pronunciation lexicon.
Regenerate it with python scripts/build_regional_dict.py. Words whose
pronunciation does not vary by part of speech carry a single POS-invariant
entry that answers every POS query.
Key Features
1. Phonemes & Syllables
Retrieve IPA transcriptions and syllable breaks based on the word's Part-of-Speech (POS) and specific region.
from tugalex import TugaLexicon
lex = TugaLexicon()
# Get both syllables and phonemes
info = lex.get("acordo", pos="NOUN", region="lbx")
# Output: {'syllables': ['a', 'cor', 'do'], 'phonemes': 'ɐˈkoɾdu'}
# POS matters!
verb_phonemes = lex.get_phonemes("acordo", pos="VERB")
# Output: 'ɐˈkɔɾdu'
verb_phonemes = lex.get_phonemes("acordo", pos="NOUN")
# Output: 'ɐˈkoɾdu'
2. Orthographic Agreement (AO1990)
Convert text between pre-agreement and post-agreement (AO1990) spelling for Portugal and Brazil.
- Normalize: Old spelling to modern spelling.
- Reverse: Modern spelling to old regional spelling (PT or BR).
normalized = lex.normalize_ao1900(sentence)
3. Linguistic Insights
TugaLex identifies specific linguistic phenomena programmatically:
- Homographs: Words that change pronunciation based on POS (e.g., sede (thirst) vs sede (headquarters)).
- Archaic Words: Mapping 19th-century etymological spellings to modern ones.
- Silent Letters: Identifying words with silent 'p' or 'c' common before the 1990 agreement.
- Voiced 'u': Detecting words where 'u' is pronounced in 'gue/gui/que/qui' clusters (formerly marked with a trema
ü).
4. Noun Gender
Get the grammatical gender of a Portuguese common noun, singular or plural. Suffix rules decide most nouns, and a list of exceptions decides the rest.
TugaLexicon.get_noun_gender("lei") # 'f'
TugaLexicon.get_noun_gender("dias") # 'm'
TugaLexicon.get_noun_gender("artista") # 'mf' (both genders)
Datasets
TugaLex ships the following datasets. Together they contain over 100,000 entries sourced from the Portal da Língua Portuguesa.
regional_dict.csv: Phoneme and syllable mappings.heterophonic_homographs.csv: words pronounced differently depending on postag.acordo_ortografico_pt_PT.csv: Portugal old orthographic spellings.acordo_ortografico_pt_BR.csv: Brazil old orthographic spellings.archaisms.csv: normalized words from before the 20th century.
noun_gender_exceptions.csv.gz lists the nouns whose gender the suffix rules
get wrong or do not cover, and the nouns of both genders.
scripts/build_noun_gender.py regenerates it from the noun genders of the
English Wiktionary.
Install
pip install -e .
TugaLex has no third-party runtime dependencies. All datasets ship inside the package under tugalex/data/.
Related Projects
TugaLex is one piece of the TigreGotico Portuguese NLP stack:
- tugaphone: phonemizes arbitrary Portuguese text across dialects, using TugaLex plus a rule-based fallback.
- tugamorph: rule-based morphological analyzer for Portuguese.
- tugatagger: Part-of-Speech tagging wrapper for Portuguese.
- desacordo_ortografico: detects and converts between Portuguese orthographies, including the AO1990 reform.
License
TugaLex is released under the Apache License 2.0.
Metadata
Release files for tugalex 2.0.3a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tugalex-2.0.3a1.tar.gz | 2.7 MB | Without provenance | Details for tugalex-2.0.3a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tugalex-2.0.3a1-py3-none-any.whl | Python 3 | none | any | Details for tugalex-2.0.3a1-py3-none-any.whl |
Total release size: 5.4 MB
Release files / tugalex-2.0.3a1.tar.gz
| Download URL | tugalex-2.0.3a1.tar.gz |
|---|---|
| Size | 2.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9195ad958c09c1d4b633970379ae7b57dee34cd0d3d4ba03266413649ad2d226
|
|
BLAKE2b-256 checksum How to use checksums |
b4c1b5555ea0b4b7f5eb9c91afcc86066027faffab944bdbefbf2e25905ddab8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tugalex-2.0.3a1-py3-none-any.whl
| Download URL | tugalex-2.0.3a1-py3-none-any.whl |
|---|---|
| Size | 2.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c56b7bb2f273e4555ff9a7330def4894f5a2524e28b1ebe69b53324f29efe92f
|
|
BLAKE2b-256 checksum How to use checksums |
272b58ab7fec69cf931b0cdbae6d3abde2c2051e5423ca3d76984b97328e2715
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for tugalex 2.0.3a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.