Skip to main content

🧩 Silabificador

A Portuguese syllabifier built from Portuguese phonotactics. Rule-based, dependency-free, no model to load.


📦 Features

  • Syllabification for Portuguese, derived from the licit onset inventory and the diphthong/hiatus rules rather than from a table of special cases.
  • Stress, primary and secondary, read out of the orthography that encodes it.
  • Syllable structure, not just strings: onset, glide, nucleus, coda.
  • The output always reconstructs the input — hyphens, spaces and apostrophes are kept, never dropped.
  • No dependencies.

🚀 Installation

pip install git+https://github.com/TigreGotico/silabificador

🧠 Usage

from silabificador import syllabify

syllabify("computador")     # ['com', 'pu', 'ta', 'dor']
syllabify("guarda-chuva")   # ['guar', 'da-', 'chu', 'va']

Need the constituents, or the stress?

from silabificador import analyze, stressed_index

for s in analyze("transportar"):
    print(s.onset, s.nucleus, s.coda, s.stressed)
# tr a ns False
# p  o r  False
# t  a r  True      -> trans.por.TAR

stressed_index("sílaba")   # 0   SÍ.la.ba

A compound keeps a stress on every element — the last one takes the primary:

[str(s) for s in analyze("guarda-chuva") if s.secondary]   # ['guar']
[str(s) for s in analyze("guarda-chuva") if s.stressed]    # ['chu']

See docs/api.md for the full surface and docs/advanced.md for the rules and the known limits.


📊 Accuracy

Measured against the Portuguese Unified Pronunciation Lexicon, which carries syllabifications from two independent authorities — Infopédia (Porto Editora) and the Portal da Língua Portuguesa.

The gold is the set of words the two sources independently agree on (35,181), after discarding any entry whose syllables do not reconstruct its headword. Every word is scored — no sampling, no caps.

set exact match
agreement (gold) 99.87% 35,137 / 35,181
Infopédia 99.34% 99,619 / 100,279
Portal 99.81% 51,763 / 51,861

Every one of the 116,959 scoreable words reconstructs exactly.

Where the two authorities disagree (135 words — on morpheme boundaries, and on etymological hiatus) neither answer is scored against, because there is no fact of the matter to be right about.

Stress is measured against a gold the engine cannot see: the lexicon's IPA transcriptions, which mark stress with ˈ. Nothing in the engine reads IPA.

stress accuracy 99.83% 43,819 / 43,893
gold self-check 99.75% 4,712 / 4,724

The self-check is the reason to trust the gold: on a simple word, a written accent is the stress, by definition of the spelling rules — so the IPA-derived answer had better agree with it, and it does.

Reproduce it, and see every remaining failure bucketed by cause:

pip install -e ".[benchmark]"
python -m benchmark.report

📄 License

MIT License

Metadata

Release files for silabificador 2.1.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 silabificador 2.1.0
File Size Uploaded
silabificador-2.1.0.tar.gz 28.8 kB Details

Built distribution (wheel)

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

Total release size: 52.3 kB

Release files / silabificador-2.1.0.tar.gz

Download URL silabificador-2.1.0.tar.gz
Size 28.8 kB
Tags Source
SHA-256 checksum
How to use checksums
757fe6c61145c8cd8c8cb513b2428584423d7b4d0341c745fb47356c1be493dc
BLAKE2b-256 checksum
How to use checksums
ebafb78c241ee1bcda13103c013d129711c48acb23e17f0b16192cc7ac97078b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / silabificador-2.1.0-py3-none-any.whl

Download URL silabificador-2.1.0-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac3ed085cdb4c385092c2532b4c57092e5ca9e51f156906aa7ac4370ddd70d5a
BLAKE2b-256 checksum
How to use checksums
cea8e1766571d5a12937fa86e264ac72bb0e2ab52779d777716baaa742bc2e5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12
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