Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Silabificador

Silabificador splits a Portuguese word into syllables. It uses hand-crafted rules based on Portuguese phonotactics. It has no runtime dependencies and loads no model.

Features

  • Syllabification for Portuguese, derived from the licit onset inventory and the diphthong/hiatus rules. A short list, silabificador/data/stems.csv, holds only the stems and words no rule reaches, each with its source.
  • Stress, primary and secondary, read from the orthography that encodes it.
  • Syllable structure, not just strings: onset, glide, nucleus, coda.
  • The output always reconstructs the input. Hyphens, spaces, and apostrophes stay in place and are never dropped.
  • No dependencies.

Installation

uv pip install --prerelease=allow silabificador

Silabificador needs Python 3.11 or later. The project publishes alpha releases, so the install needs --prerelease=allow.

Usage

from silabificador import syllabify

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

Use analyze for the constituents, or stressed_index for the stress. The stress of transportar falls on the last syllable (trans.por.TAR), and the stress of sílaba on the first (SÍ.la.ba):

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

print(stressed_index("sílaba"))   # 0

A compound keeps a stress on every element. The last element takes the primary stress:

from silabificador import analyze

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

Documentation

docs/index.md lists every page in reading order:

Accuracy

Silabificador is measured against five sources of syllabification:

  • Infopédia (Porto Editora), from the Portuguese Unified Pronunciation Lexicon.
  • Michaelis (Melhoramentos), from the same lexicon.
  • en.wiktionary, from the Kaikki extract of its {{hyph|pt}} templates.
  • pt.wiktionary, from the stress templates ({{paroxítona|ex|cer|to}}) in the Wikimedia dump.
  • The Portal da Língua Portuguesa, from the same lexicon.

The first four are edited by people. The Portal is not. Its Dicionário de divisão silábica says that "as regras de divisão silábica para a criação deste dicionário foram baseadas" on Base XX of the 1990 Orthographic Agreement. Its data agree with that: on every letter shape with two accepted splits, the Portal gives one answer to all of the words. The Portal is therefore scored as its own generated tier and is never gold.

A word can have more than one correct split. Cunha & Cintra accept both a-pto and ap-to; en.wiktionary lists both sub.li.nhar and su.bli.nhar. Each gold entry is a set of accepted splits, and a prediction is correct when it is one of them.

A source sometimes prints a headword with no division: Michaelis gives bacon and arroz-doce whole, and pt.wiktionary gives metodismo. That is no claim about the syllables, so a split is dropped when a piece between two separators holds more than one run of vowels. The rule also drops a few English loans whose syllable holds a silent ⟨e⟩ (soft.ware), and it misses an undivided word whose vowels form one run (voyeur).

tier what it holds accepted match
edge cases cited splits from grammars and dictionaries, tests/edge_cases.json 100.00% 148 / 148
agreement, 4 sources all four human sources give the split 99.97% 10,785 / 10,788
agreement, 3 sources three human sources give the split 99.90% 13,340 / 13,354
agreement, 2 sources two human sources give the split 99.70% 26,180 / 26,260
agreement (gold) the three rows above 99.81% 50,305 / 50,402
Infopédia only one human source 99.30% 59,033 / 59,447
Michaelis only one human source 93.37% 577 / 618
Wiktionary only one human source 98.16% 65,340 / 66,568
conflict human sources share no split; any of them is accepted 99.30% 707 / 712
generated: Portal not gold 99.69% 51,830 / 51,990

All 184,796 scoreable words reconstruct exactly.

Michaelis writes a final unstressed vowel pair such as ⟨ia⟩, ⟨ie⟩ or ⟨ea⟩ as one syllable (gló.ria, sé.rie, náu.sea). Infopédia and the engine write a hiatus (gló.ri.a, sé.ri.e). Cunha & Cintra (p. 63) accept both: final ⟨-ia -ie -io⟩ "são normalmente ditongos crescentes" but "podem, no entanto, ser emitidos com separação dos dois elementos". The edge case glória accepts both splits. A word that only Michaelis holds has only the Michaelis split, so 34 of the 41 Michaelis-only misses come from this difference.

The rules were first tuned on the words where Infopédia and the Portal agree, so the Portal score shows how close the engine is to one rule system, not how correct it is. Where a cited rule and the Portal disagree, the rule wins: the Portal joins the unstressed iu of miu.de.za and ciu.men.to, and the engine follows the human sources (mi.u.de.za).

The edge cases cover the classes where the sources disagree: medial clusters (ap.to and a.pto), prefix seams (sub.li.nhar, a.brup.to and ab.rup.to), hiatus and diphthong (gló.ri.a and gló.ria), the productive prefixes, the hyphenated prefixes of the Agreement (ab-rogar, sub-reino), the hiatus that depends on stress (flu.iu, ci.u.men.to), and words where one source is wrong. Every accepted split names its source.

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.85% 43,772 / 43,839
gold self-check 99.79% 4,709 / 4,719

The self-check gives a 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 must agree with it, and it does.

To reproduce the numbers and see every remaining failure bucketed by cause, run the commands below. The first run downloads the two Wiktionary dumps (about 130 MB) into ~/.cache/silabificador.

uv pip install --prerelease=allow -e ".[benchmark]"
python -m benchmark.report

Silabificador is part of the TigreGotico Portuguese phonetics toolchain, alongside:

  • orthography2ipa: its portuguese extra installs silabificador for SilabificadorSyllabifier, a syllabifier plugin that a caller passes to one engine.
  • tugaphone: depends on silabificador for its deprecated token tree.
  • bifonia

Development

uv pip install --prerelease=allow -e ".[test]"
python -m pytest tests

The suite runs offline. tests/test_accuracy_regression.py scores a fixed sample of the gold in tests/gold_sample.json, and the full scoreboard comes from python -m benchmark.report. Do not edit docs/accuracy.md by hand.

License

MIT License

Metadata

Release files for silabificador 2.1.15a3

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.15a3
File Size Uploaded Provenance Actions
silabificador-2.1.15a3.tar.gz 50.0 kB Without provenance Details for silabificador-2.1.15a3.tar.gz

Built distribution (wheel)

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

Total release size: 84.9 kB

Release files / silabificador-2.1.15a3.tar.gz

Download URL silabificador-2.1.15a3.tar.gz
Size 50.0 kB
Tags Source
SHA-256 checksum
How to use checksums
35825b7886006d615ed438c4db9d25cba7334fa255c8948a2efa11f204bf5c75
BLAKE2b-256 checksum
How to use checksums
b2123410d4f57cfb60a784cb50ad22e771cea4bd233185258a518819fd4eda1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / silabificador-2.1.15a3-py3-none-any.whl

Download URL silabificador-2.1.15a3-py3-none-any.whl
Size 34.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf2d3be8d1bbc57bedb358fea0e782ec21e12b3697bea8b004e651e826255ef3
BLAKE2b-256 checksum
How to use checksums
62cdddfe0318d577e10afec8ca16399ecb65643b8f2d86c8a36370f8cc9fea3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for silabificador 2.1.15a3

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.

Release history Release notifications | RSS feed

This release
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