This release is a pre-release and may not be stable for production use.
pt2mirandese
pt2mirandese translates European Portuguese text into Mirandese with hand-written rules and word lists. It is a baseline for a language with few resources: it needs no model and no network.
Try it in the browser: TigreGotico/pt2mirandese on Hugging Face. The page runs this package with Pyodide; space/ holds its source.
Mirandese (lhéngua mirandesa, ISO 639-3 mwl) is an Astur-Leonese language of the Terra de Miranda in north-east Portugal. It has fewer than 4,000 speakers and is co-official with Portuguese in its region. Its spelling follows the Convenção Ortográfica da Língua Mirandesa (1999).
Install and use
uv pip install -e .
echo "O livro do meu pai está na mesa." | pt2mirandese
# L lhibro de l miu pai stá na mesa.
from pt2mirandese import translate, word
translate("Ela foi com o irmão para a escola e começou a escrever um poema.")
# 'Eilha fui cul armano pa la scola i ampeçou a screbir un poema.'
word("história") # 'stória'
translate takes one sentence or line and keeps template slots such as {name}. word converts one lowercase word with no context.
How it works
The translator works in three layers. A word goes to the first layer that has it.
Before the layers, data/native.tsv holds the corrections of a native speaker. They win over every other source. Some are false friends: Portuguese brincar is Mirandese gaiar, because Mirandese brincar means saltar. Portuguese bolo is bolho, because Mirandese bolo is voo. A verb row covers every form of the verb (brincavam > gaiában, quebrou > scachou).
- Closed classes come from the tables of the Convenção: articles (l, la, ls, las), contractions (de l, al, cul, pa l), pronouns, possessives, demonstratives, prepositions, adverbs and the present tense of the irregular verbs. Each group names its PDF page in the code.
- Word lists.
data/convencao.tsvcomes first: it holds 1,699 words that the Convenção prints, such as scola, dixo and irie, and its form wins over the corpus. Claude Opus 5.5 glossed each Mirandese word on each page into Portuguese, and a second pass checked each gloss against its page. A gloss stays only when the word is Mirandese, the gloss is right, and the Portuguese word has no other common sense that Mirandese writes differently: verão is summer as well as beran, they will see.scripts/build_convencao.pybuilds the list.data/lexicon.tsvholds 10,098 words whose Mirandese form the rules do not give, such as tierra, muorte and anho.scripts/learn_lexicon.pylearns them from every parallel pair ingold/: 113,253 rows, of which 109,672 are different pairs. Where the writers disagree (lhéngua and léngua), the most frequent form wins.data/lhenguabase.tsvadds 296 words from the Lhenguabase that the parallel data does not check, such as gabilanes and majaricones. The Lhenguabase glosses a lemma, so Claude Opus 5.5 gave each Mirandese form the Portuguese word in the same gender and number.data/wiktionary.tsvadds 176 more from the Portuguese Wiktionary. A verb that a word list spells with another stem gives that stem to its other forms: ficar > quedar, so ficaram > quedórun.data/verbs.tsvkeeps only the verbs whose forms the parallel data writes that way, because a vowel that changes only under stress does not carry (buoltar, but boltou).scripts/build_verbs.pybuilds it after each relearn. - Spelling rules convert the rest. Among them: v > b, -ção > -çon, final -z > -ç, initial es- > s-, en-/in- > an-, pretonic con- > cun-, stressed final -ia > -ie, -mento > -miento, and the verb endings of the Convenção tables (cantórun, cantában, comie, cantarie, canteste, cantáren, comisse, comíssen). Where the parallel data writes an ending another way, the rules keep the Portuguese ending until a native speaker decides: cantassen or cantássen, cantaríamos or cantariemos.
Some rules need the words around a word. muito is mui before an adjective or an adverb (mui grande) and muito before a noun, a preposition or a pause (gusto muito de ti, hai muito tiempo), as a native speaker reports. não is nun before a verb and nó before a pause, Convenção p. 30: el dixo que nó. a is the article la except before an infinitive, a numeral or a pronoun. la, l, de and que elide before a vowel (l'alma, d'outro, qu'el). nos before the verb is the pronoun mos. A personal name takes no article: falei com o Virgílio > falei cun Virgílio, a casa da Maria > la casa de Marie. data/names.txt lists the given names from Wikidata. A name that the Portuguese side of the gold files writes after an article more often than after a bare preposition is a place, which keeps its article (de la Ouropa), and is left out. scripts/build_names.py builds the list. A given name in the list also keeps its spelling. Roman numerals, acronyms (TV), one-letter abbreviations (a.C.), web and e-mail addresses and template slots stay as they are.
The spelling follows the 2000 Adenda to the Convenção, which writes ie, uo and ye without the circumflex.
Evaluation
| Set | Rows | Copy the Portuguese: chrF2 | Rules alone: exact | Rules alone: chrF2 | pt2mirandese: exact | pt2mirandese: chrF2 |
|---|---|---|---|---|---|---|
wikimedia_test.tsv |
1,489 | 62.4 | 0.076 | 87.2 | 0.377 | 94.8 |
wikimedia_dev.tsv |
493 | 62.0 | 0.093 | 86.7 | 0.379 | 94.3 |
wikipedia_mined.tsv |
54,360 | 58.0 | 0.035 | 82.7 | 0.250 | 91.2 |
tatoeba.tsv |
35 | 35.1 | 0.229 | 49.9 | 0.486 | 63.5 |
convencao.tsv |
76 | 36.5 | 0.711 | 74.1 | 0.987 | 96.1 |
"Exact" accepts the reference or an alternative after lowercasing. chrF2 is corpus chrF from sacrebleu. "Rules alone" switches all the word lists off.
uv run --with sacrebleu --with-editable . python scripts/evaluate.py gold/wikimedia_test.tsv --no-lexicon --errors 20
Rules alone is the score on unseen text. The word lists learn from every file in gold/, the test files included, so the full pt2mirandese columns show how well the lists fit the data they come from. They are not a held-out score. Mirandese text is scarce, and the translator is meant to make synthetic training data for a later translation model, so it uses all the parallel text there is. The rules were tuned on wikimedia_dev.tsv, and the test split was read only after each round of tuning, so the rules-alone score on wikimedia_test.tsv is held out.
Machine drafts are left out. Content Translation offers MinT drafts for Portuguese to Mirandese since 2023. Of the 440 published translations, 414 date from 2017, before MinT. scripts/fetch_cx.py lists the 17 translations published since 2023 (gold/cx_mint_era.tsv), which Content Translation records as 34% to 59% machine text, and scripts/make_gold.py drops the 481 pairs that come from them. The older text still shows a mechanical habit of some translators: Roman VI written BI and TV written TB in 23 rows.
One Portuguese side is machine translation. gold/wikipedia_backtranslated.tsv pairs 51,045 Mirandese Wikipedia sentences with Portuguese from Claude Haiku 5.5. Its Mirandese side gives the word list real forms, but its Portuguese side is not a reference, so the table does not score it.
Encyclopaedic text is most of the data. Tatoeba holds everyday sentences by other writers, and there the translator scores 63.5: it misses everyday words (teç for pele, Adius for Tchau) and idioms.
The corpus does not always follow the Convenção. Where the two differ, the translator follows the Convenção, and loses exact matches against references that follow the corpus. On wikimedia_dev.tsv the printed words, lh- and proper names cost 41 of 493 rows together: 227 rows pass with the corpus forms, 186 with the Convenção forms.
- A word the Convenção prints takes that form (
data/convencao.tsv): scola, where the corpus writes scuola 593 times. - The Convenção (p. 15) asks for lh- in traditional words (lhibro, lhéngua, lhuna) and l- in neologisms, loanwords and proper names. The corpus mixes the two in both kinds of word, so its counts cannot tell them apart.
data/lh.tsvlists the words that a curated source writes with lh-: the examples of the Convenção, the Portuguese Wiktionary and the Lhenguabase. The translator writes lh- for those words and their verb forms, and l- for the rest (lógica, laboratório).scripts/build_lh.pybuilds the list. - The corpus writes the object pronoun nos as ne ls. The translator writes mos, as the Convenção (p. 25) does, and so loses those rows.
- The Convenção (p. 17) lets proper names keep an official V (Virgílio). The corpus writes Birgílio. The translator keeps V and initial l- in a capitalised word inside a sentence, unless the word list has a Mirandese form for it (Lisboua) or the word is a common word in capitals (Universidade, Revolução).
data/common.txtlists the common words: the words with a v or an initial l that the Portuguese side of the gold files writes in lowercase three times or more.scripts/build_common.pybuilds the list.
Other systems
The one other Portuguese to Mirandese system is MADLAD-400 3B (Google, Apache-2.0), which MinT, the Wikimedia translation service, serves for this pair. Apertium has no Mirandese pair. scripts/baselines.py runs the CTranslate2 build santhosh/madlad400-3b-ct2 on the CPU in int8, with greedy decoding, and writes bench/madlad/.
| Set | MADLAD: exact | MADLAD: chrF2 | Rules alone: chrF2 | pt2mirandese: chrF2 |
|---|---|---|---|---|
wikimedia_test.tsv |
0.144 | 89.0 | 87.2 | 94.8 |
wikimedia_dev.tsv |
0.114 | 88.4 | 86.7 | 94.3 |
tatoeba.tsv |
0.029 | 48.0 | 49.9 | 63.5 |
convencao.tsv |
0.276 | 55.9 | 74.1 | 96.1 |
uv run --with sacrebleu --with-editable . python scripts/evaluate.py gold/wikimedia_test.tsv --hyps bench/madlad
MADLAD learned from web text, which most likely includes the Mirandese Wikipedia, so its wikimedia scores are not held out either. On the everyday Tatoeba sentences it often copies the Portuguese (Adeus, Vamos) or loses the sense: Olho por olho, dente por dente becomes L'ouro ye l dendro.
Sources
- Convenção Ortográfica da Língua Mirandesa (1999). Câmara Municipal de Miranda do Douro and Centro de Linguística da Universidade de Lisboa.
- Ferreira, M. B. (2003). "Resposta a uma recensão crítica da Convenção Ortográfica da Língua Mirandesa". Revista de Filoloxía Asturiana 3-4, 327-343. It states what the 2000 Adenda changed.
- OPUS wikimedia mwl-pt, release v20260327 (CC-BY-SA 4.0). J. Tiedemann (2012), "Parallel Data, Tools and Interfaces in OPUS", LREC.
- Portuguese and Mirandese Wikipedia (CC-BY-SA 4.0), for the mined and back-translated pairs.
- Wiktionary, Portuguese edition, Mirandese entries (CC-BY-SA 4.0).
- Lhenguabase, the Mirandese lexical database on Wikibase Cloud (CC-BY-SA 4.0).
scripts/fetch_lhenguabase.pydownloads it. - Tatoeba (CC-BY 2.0 FR).
- Wikidata (CC0), for the given names.
Licence
The code is Apache-2.0. The word lists in pt2mirandese/data/ and the Wikipedia gold files are derived from CC-BY-SA 4.0 sources and are CC-BY-SA 4.0. gold/tatoeba.tsv is CC-BY 2.0 FR.
Metadata
Release files for pt2mirandese 0.0.1a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pt2mirandese-0.0.1a2.tar.gz | 379.8 kB | Without provenance | Details for pt2mirandese-0.0.1a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pt2mirandese-0.0.1a2-py3-none-any.whl | Python 3 | none | any | Details for pt2mirandese-0.0.1a2-py3-none-any.whl |
Total release size: 747.4 kB
Release files / pt2mirandese-0.0.1a2.tar.gz
| Download URL | pt2mirandese-0.0.1a2.tar.gz |
|---|---|
| Size | 379.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69bbff4d2247a3c46d982ec1d3e3d98f43b8b76312402f401bc3a9f1f0aa0a91
|
|
BLAKE2b-256 checksum How to use checksums |
9c0ec81b88e1c9d8d087cfa4e05c49ee774d334cfbcaefdf99cde47054b3fa08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pt2mirandese-0.0.1a2-py3-none-any.whl
| Download URL | pt2mirandese-0.0.1a2-py3-none-any.whl |
|---|---|
| Size | 367.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a68e6680ffdf640033c7cc63c71335970b1ad5b567700927c7a9d6d6ce37c3a6
|
|
BLAKE2b-256 checksum How to use checksums |
ed83b31688cebc9fa9c4e1ac7e1a07c3f6ce2b0aec37d813900b726a13268f02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for pt2mirandese 0.0.1a2
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.