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, not from a table of special cases.
  • 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

pip install silabificador

Silabificador needs Python 3.11 or later. The --pre flag of pip installs the latest alpha.

Usage

from silabificador import syllabify

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

Use analyze for the constituents, or stressed_index for 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 element takes the primary stress:

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

Documentation

Accuracy

Silabificador is measured against four sources of syllabification:

  • Infopédia (Porto Editora), from the Portuguese Unified Pronunciation 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 three 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.

tier what it holds accepted match
edge cases cited splits from grammars and dictionaries, tests/edge_cases.json 97.37% 74 / 76
agreement, 3 sources all three human sources give the split 99.86% 18,265 / 18,290
agreement, 2 sources two human sources give the split 99.60% 29,904 / 30,025
agreement (gold) the two rows above 99.70% 48,169 / 48,315
Infopédia only one human source 99.12% 59,792 / 60,325
Wiktionary only one human source 97.83% 66,376 / 67,850
conflict human sources share no split; any of them is accepted 98.80% 740 / 749
generated: Portal not gold 99.78% 51,880 / 51,996

All 184,501 scoreable words reconstruct exactly.

The engine scores highest on the Portal. The rules were first tuned on the words where Infopédia and the Portal agree, so this number shows how close the engine is to one rule system, not how correct it is.

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), and words where one source is wrong. Every accepted split names its source. Two cases are known failures: flu.i.dez and flu.iu.

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,818 / 43,892
gold self-check 99.75% 4,712 / 4,724

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.

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

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

  • orthography2ipa: its portuguese extra installs silabificador and registers it as the Portuguese plugin in the orthography2ipa.syllabify entry-point group.
  • tugaphone: depends on silabificador and syllabifies through that orthography2ipa plugin.
  • bifonia
  • g2p_barranquenho

Development

pip install -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.2a1

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.2a1
File Size Uploaded Provenance Actions
silabificador-2.1.2a1.tar.gz 34.2 kB Without provenance Details for silabificador-2.1.2a1.tar.gz

Built distribution (wheel)

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

Total release size: 59.7 kB

Release files / silabificador-2.1.2a1.tar.gz

Download URL silabificador-2.1.2a1.tar.gz
Size 34.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9815bb9472b63f1c7d347f268902879d1df6f8e010b4c1d831af3d033a121b4b
BLAKE2b-256 checksum
How to use checksums
0edbe1b6e1d5eec57a442e94ec662ee8fd8e3acc84d5c116d54b63b9287b1c4b
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.2a1-py3-none-any.whl

Download URL silabificador-2.1.2a1-py3-none-any.whl
Size 25.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
962373e371cf92bf44d5b2e6019b2fead01bdfd149a026992ae699b6a0247f97
BLAKE2b-256 checksum
How to use checksums
ea4135f2754012af3e382d6577561504bd5ef433e989acb938c8291bb56ca368
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.2a1

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