Skip to content

Autocorrect and tone marks (beta)

Fixes typos and real-word errors, and puts back missing tone marks and accents, in 307 languages, with one model.

r = ym.mend("Mo fe lo si oja lati ra eja", "yor_Latn")
print(r.suggestion)   # the corrected text
print(r.text)         # what to show: the correction in "auto" languages, the input otherwise
print(r.mode)         # "auto", "suggest" or "off"

ym.flag("Ich freue mich sehr, Sie heute zu sehn", "deu_Latn")   # spell-check view: [(word, flagged), ...]
const r = await ym.mend("Toi muon di cho mua ca", "vie_Latn");

Modes

Each language has a calibrated mode:

  • auto: reliable enough to apply automatically.
  • suggest: offer the change (for example, underline the word) and let the user accept it.
  • off: not reliable enough for this language yet; suggestion is still returned for reference.

More or fewer corrections

eagerness is one knob from 0 to 1. At 0.5 each language uses its calibrated settings; higher fixes and restores more, lower changes less. Above 0.75 it also stops protecting words that are common as typed, so tone marks go back on common unmarked words ("Mo fe lo si oja" → "Mo fẹ lọ sí ọjà"), at the cost of more mistakes.

ym.mend("Mo fe lo si oja lati ra eja", "yor_Latn", eagerness=0.9)
await ym.mend("Toi muon di cho mua ca", "vie_Latn", { eagerness: 0.9 });

Your own settings

Every calibrated setting can also be overridden per call (these win over eagerness):

ym.mend(text, "yor_Latn", mode="auto", threshold=0.4, margin=0.5, restore_confidence=0.6)
ym.flag(text, "deu_Latn", threshold=0.4)
await ym.mend(text, "yor_Latn", { mode: "auto", threshold: 0.4, margin: 0.5, restoreConfidence: 0.6 });
Setting What it does
mode "auto", "suggest" or "off": whether text shows the correction
threshold how sure the model must be that a word is wrong before trying to fix it, 0–1
margin how much better a fix must score than the typed word: higher means fewer, safer changes
restore_confidence / restoreConfidence how sure the model must be before adding a tone mark or accent, 0–1

How it works

The model flags words that look wrong, scores nearby words from the language's word list (edit distance up to 2), and changes a word only when the best candidate clearly beats what was typed. Words that are a common spelling as typed are protected. A second pass puts back tone marks and accents where the model is confident, keeping any marks the person typed.

Beta

Mend is calibrated to break very few correct words, so it fixes fewer than a heavier spell checker would. Results per language are in the model card: olaverse/YellowMIST-Mend-1.0. A later release rebuilds it as one model per region, like next-word suggestions; the API stays the same.

The first call downloads about 12 MB (8-bit model and candidate scorer) plus that language's word list, about 1 MB.