The problem
No tool corrects Vietnamese spelling across applications. Word checks only inside Word, browser extensions only inside the browser, LanguageTool doesn’t support Vietnamese, and Grammarly doesn’t know it. The most common Vietnamese mistake, confusing the hỏi and ngã tones, is one almost nothing handles well.
A real-time checker has a harsher constraint than accuracy: a tool that underlines correct text gets switched off within five minutes. False positives are treated as an existential risk, and most of the design follows from that.
Architecture
A Rust workspace in a Tauri 2 shell. The engine, writa-core, is portable and has no network access. Everything
Windows-specific lives in writa-win. The optional AI layer is the only crate allowed to touch the network, and it is off by default.
Key decisions
Build on the closed syllable set
Vietnamese syllables form a closed, generatable set: initial × rhyme × tone gives about 18,000. A syllable outside the set is definitely wrong, so detecting non-word errors is a single lookup with perfect precision. Generating the set from a phonology table also avoided hunspell-vi, which is GPLv3. Longer note →
Confusion rules, not blind edit distance
Candidates come from structured rules for the confusions people actually make: hỏi/ngã, s/x, ch/tr, r/d/gi. Candidates that need two edits must clear an extra score margin.
One decoder, two features
Real-word correction and adding diacritics are the same problem: generate candidates, then pick the best sequence with Viterbi over an n-gram model. Only the candidate generator differs, which is why diacritics made it into the first release.
Two-way association strength
A pair is scored by min(P(b|a), P(a|b)). This separates fixed compounds from free combinations; a one-way measure let function words slip through.
Windows only, hotkey first
Tauri 2 and Rust, Windows only for v1. The hotkey-on-selection mode shipped before the real-time hook, because it can’t produce an unwanted underline.
Measurements
Trained on all of Vietnamese Wikipedia (1.6M articles, 231.7M tokens) and measured on 50,000 held-out sentences. The detection threshold was picked from a sweep over 35,000 injected errors.
The combined diacritic figure misses its 95% target, mostly on proper names; that’s the first item for v0.2. An earlier memory figure of 79.6 MB left out WebView2 and was corrected.
Spikes that changed the plan
- Coexisting with UniKey. The first model, “trust only injected keystrokes”, was wrong. Measured on 163 real key events, subtracting the swallowed key within a 20 ms window gives an exact match, and any window from 1 to 60 ms gives the same result.
- Code signing. Azure Trusted Signing isn’t available to developers in Vietnam, and EV certificates no longer grant instant SmartScreen reputation. The plan is OV signing and possibly the Microsoft Store.
- Password fields. Checking whether the focused field is a password through UI Automation cost up to 200 ms at p99, so that check was removed from the hot path.
- Data pipeline. Corpus checks found five data bugs, including a regex that dropped the first letter of every capitalised word.
Status & roadmap
v0.1.3 ships the selection hotkeys (check spelling, add diacritics), inline suggestions behind a setting, signed builds and auto-update. Verified by hand in Zalo, VS Code and Google Chat. Nine of thirteen apps in the compatibility matrix are still untested.
- v0.2: better diacritics for proper names, Kneser-Ney smoothing, joint decoding of adjacent errors, and a held-out set that makes false-positive rate and recall CI gates.
- v0.3: a chat and forum corpus beyond Wikipedia, and a personal dictionary that learns.