belarusian-verse
Belarusian stress, rhyme, rhythm, agreement and spelling — the checks you need to write or judge a line of Belarusian verse, as a small Python library.
The tables behind it — about 2 million word forms — are published separately as 🤗 YauhenBichel/belarusian-verse and downloaded on first use.
from belarusian_verse import mark_stress, rhyme, check_agreement, check_spelling
mark_stress("Побач ты, і добра мне") # 'По́бач ты, і до́бра мне'
rhyme("вадзе", "ідзе") # ('rich', 1.0)
rhyme("ідзе", "знайдзе") # ('none', 0.0) — зна́йдзе is stressed at the start
check_agreement("тваіх вачам")["errors"] # 1 — no shared case
check_agreement("тваім вачам")["errors"] # 0
Why
Belarusian has good dictionaries and good speech models, and little in between:
- no rhyme dictionary in software — only Minkin's printed one;
- LanguageTool's Belarusian module has ~66 rules and almost no morphology, so it cannot see that «тваіх вачам» is ungrammatical;
- a spell checker accepts every real word, so «ідзе́ / зна́йдзе» passes as a rhyme even though the two words are stressed on different syllables.
Everything needed was already inside the Belarusian Grammar Database: stress marks and full morphological tags for millions of forms. This library is those tables plus the rules that make them answer musical questions.
Install
pip install belarusian-verse # tables download on first use, then cached
pip install "belarusian-verse[spelling]" # adds the spell checker (spylls)
Set BELARUSIAN_VERSE_DATA to a folder holding the tables to work offline.
What it does
| Function | Question it answers |
|---|---|
mark_stress(text) |
Where does the stress fall? (по́бач, not паба́ч) |
rhyme(a, b) |
Do these rhyme, and how well: rich / exact / near / none |
analyse_verse(text, "AABB") |
Rhyme and rhythm scores for a whole verse, line by line |
check_agreement(text) |
Does each adjective match its noun in gender, case and number? |
check_spelling(text, dictionary=…) |
Real Belarusian words, correct orthography, syllable counts |
respell(text, "uk"|"ru") |
Rewrite Belarusian so a Ukrainian- or Russian-trained model pronounces it, syllable count unchanged |
Each is also a command: be-stress, be-poetry, be-grammar, be-spelling, be-respell.
$ be-poetry verse.txt --rhyme AABB
1 100111001 rhythm 1.00 Белы туман па лесе плыве,
2 101000101 rhythm 0.44 Свежасць ранішняя тут жыве.
rhyme 1-2: rich (1.0)
rhyme 0.95 rhythm 0.78
How rhyme is judged
A Belarusian rhyme matches from the last stressed vowel to the end of the line, so the stress
table does the real work. маёй and спакой rhyme (iotated vowels are folded: ёй = ой);
ідзе́ and зна́йдзе do not, because the stress sits elsewhere. Final consonants are devoiced
before comparison, as they are when sung.
Two Belarusian rules this encodes
ёis always stressed, so a word containing it needs no lookup.- A word starting with
ўis the same word as the one starting withу(ўдваіх=удваіх), butўis not a vowel, so every stress index shifts by one. Getting this wrong moves the stress a syllable — it is the kind of bug that only shows up when a singer sings it.
Limits
- Homographs are not disambiguated by context: 20,754 forms carry more than one stress. Pass your
own overrides file, or
pick_first=Trueto accept the first reading. - Agreement checking looks at adjacent adjective/pronoun and noun pairs on either side, not at full syntax; it finds the common errors, not every possible one.
- Meaning is not checked at all. A line can pass every check here and still say nothing.
Data and licence
The code is Apache-2.0. The tables it downloads are CC BY-SA 4.0, derived from the Belarusian Grammar Database by Aleś Bułojčyk and Uładzimir Koščanka — if you redistribute the data or a derivative of it, keep that licence and the attribution: https://huggingface.co/datasets/YauhenBichel/belarusian-verse
Tests
pip install -e ".[spelling]" && python -m unittest discover tests
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file belarusian_verse-0.1.0.tar.gz.
File metadata
- Download URL: belarusian_verse-0.1.0.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d80d409a1ee0476085becbcca9aed2beeccd37dac39866078aea4c5b4a379411
|
|
| MD5 |
714ef4f772b8df0a23eb2728f0df32be
|
|
| BLAKE2b-256 |
1a19fc1db058b173e9f22c3afdda4a9a9ad0b76f939f1d688d133206fae5a796
|
Provenance
The following attestation bundles were made for belarusian_verse-0.1.0.tar.gz:
Publisher:
release.yml on YauhenBichel/belarusian-verse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
belarusian_verse-0.1.0.tar.gz -
Subject digest:
d80d409a1ee0476085becbcca9aed2beeccd37dac39866078aea4c5b4a379411 - Sigstore transparency entry: 2810999684
- Sigstore integration time:
-
Permalink:
YauhenBichel/belarusian-verse@8c24245a9c77a535a8da20944f4f4c834f3a1afd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/YauhenBichel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8c24245a9c77a535a8da20944f4f4c834f3a1afd -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file belarusian_verse-0.1.0-py3-none-any.whl.
File metadata
- Download URL: belarusian_verse-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0302b0d53d49e5bced48bc2da8bf73f3b23b0e54d0da9b6c52be09b78a953bdb
|
|
| MD5 |
a81e109b89f1df70a0e1559254a4bd38
|
|
| BLAKE2b-256 |
2188829b4955ddf9933d6c469df40c5106cba73fa77bc42735c6937d80431dfa
|
Provenance
The following attestation bundles were made for belarusian_verse-0.1.0-py3-none-any.whl:
Publisher:
release.yml on YauhenBichel/belarusian-verse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
belarusian_verse-0.1.0-py3-none-any.whl -
Subject digest:
0302b0d53d49e5bced48bc2da8bf73f3b23b0e54d0da9b6c52be09b78a953bdb - Sigstore transparency entry: 2810999702
- Sigstore integration time:
-
Permalink:
YauhenBichel/belarusian-verse@8c24245a9c77a535a8da20944f4f4c834f3a1afd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/YauhenBichel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8c24245a9c77a535a8da20944f4f4c834f3a1afd -
Trigger Event:
workflow_dispatch
-
Statement type: