Skip to main content
Pre-release

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)

5. Given-Name Gender

Get the grammatical gender of a given name, written as in running text. The list holds regnal names, the Brazilian census names that match a Wikidata given name, and the Wikidata given names marked Portuguese.

TugaLexicon.get_given_name_gender("Isabel")   # 'f'
TugaLexicon.get_given_name_gender("Afonso")   # 'm'
TugaLexicon.get_given_name_gender("Darci")    # 'mf' (both genders)
TugaLexicon.get_given_name_gender("Raio")     # None

Datasets

TugaLex ships the following datasets. Together they contain over 100,000 entries sourced from the Portal da Língua Portuguesa.

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.

given_names.csv.gz lists given names with their gender. scripts/build_given_names.py regenerates it from Wikidata (CC0) and the IBGE 2010 census first names published by datasets-br/prenomes (ODC-PDDL-1.0). scripts/given_name_overrides.csv corrects the names whose Wikidata items mislead, each with its evidence.


Install

pip install -e .

TugaLex has no third-party runtime dependencies. All datasets ship inside the package under tugalex/data/.


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.2.0a1

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

Source distribution (sdist)

Source distribution for tugalex 2.2.0a1
File Size Uploaded Provenance Actions
tugalex-2.2.0a1.tar.gz 2.7 MB Without provenance Details for tugalex-2.2.0a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tugalex 2.2.0a1
File Interpreter ABI Platform Actions
tugalex-2.2.0a1-py3-none-any.whl Python 3 none any Details for tugalex-2.2.0a1-py3-none-any.whl

Total release size: 5.5 MB

Release files / tugalex-2.2.0a1.tar.gz

Download URL tugalex-2.2.0a1.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
9d0bb2d373e8e4c2a7658f23d6a087b7b44b478accb7d677816d6d510f5c4de5
BLAKE2b-256 checksum
How to use checksums
682f19cfc90787287d409584a81dc1b6152aa888794646e6b30b92afcaeeaa8a
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.2.0a1-py3-none-any.whl

Download URL tugalex-2.2.0a1-py3-none-any.whl
Size 2.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
efb20e37f52322c406bf6aa66e7af50b1a6f203fcb6c4fa27e22f792a712fc14
BLAKE2b-256 checksum
How to use checksums
bf8339500d7da3bbcee164918f261a43db3df664746a3f2bdc92577f7fbd24c1
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.2.0a1

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.

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