Back to projects

Published on pub.dev (Aug 2026)

Unicode Typing Grader

A Dart package for developers of typing-practice apps who need to grade Korean, Japanese, and emoji input by visible character.

I extracted the grading logic of my personal Korean typing-practice app into a Dart package and published it on pub.dev. It compares input with the reference by visible character, and fixes the comparison steps and score calculation so that an app and a server produce the same score.

ResultThe original Korean typing app now grades with this package.

Period
2026.08 - Present
Format
Solo project, open source
Team
Solo project
Role
Designed and implemented the comparison steps and scoring, added conformance cases that let an implementation in another language confirm the same results, and published on pub.dev.
Tech stack
Dart, characters, unorm_dart

A visible character is not a string length

I was writing the code that compares input with the reference in a personal app where Japanese speakers practice typing short Korean phrases. This package is that logic, extracted in August 2026.

The problem was counting characters. Dart's String.length counts UTF-16 code units, and runes counts code points. Neither matches what a person sees as one character. The emoji 👩🏽‍💻, with a skin tone and a zero-width joiner, looks like one character but is several code points. 가 can be written either as one precomposed syllable or as the consonant ᄀ followed by the vowel ᅡ.

Before comparing, the package normalizes both strings to NFC and splits them into extended grapheme clusters, the units people see as characters. Segmentation uses the Dart team's characters package, and normalization uses unorm_dart.

Fixing even the order of normalization, whitespace, and punctuation

Grading runs in this order: NFC normalization, whitespace handling, terminal punctuation, grapheme segmentation, then edit distance. The order never changes. For example, comparing "안녕. " with trimmed whitespace and ignored terminal punctuation removes the trailing space first, then the period.

I chose NFC over NFKC. NFKC folds compatibility forms, such as full-width and half-width letters, half-width kana, or ① and 1, into one character. That would accept characters typed with different keystrokes as correct, which is wrong for grading.

The set of whitespace characters is a fixed list of code points instead of whatever the runtime's trim does, so the result does not change between languages with different whitespace definitions. When terminal punctuation is ignored, only one trailing ., !, ?, 。, !, or ? is removed. For 정말?!, only the last ! goes, so the writer's ?! is not ignored as a whole.

Grading

final result = gradeTyping(
  reference: 'Practice makes progress',
  input: 'Practice makes progres',
  policy: TypingGradingPolicy.exact,
  activeElapsed: const Duration(seconds: 30),
);

result.accuracyPercent;               // 95.6
result.charactersPerMinute;           // 44.0
result.comparison.deletionCount;      // 1

Equal after NFC

// precomposed 가 vs. ᄀ + ᅡ
final comparison = compareNormalizedGraphemes(
  reference: '\uAC00',
  input: '\u1100\u1161',
);

comparison.editDistance;              // 0
Usage taken from the README and tests. gradeTyping takes the app's reference, the input, a grading policy, and the active typing time, and returns accuracy and characters per minute. The same character written in a different form has an edit distance of 0.

The same score in the app and on the server

In the original app, the score computed in the Flutter UI is recalculated on a Go server to check it. If the two implementations disagree, there is no way to say which one is right.

Rather than keeping the scoring inside the package, I defined it as a contract that another language can reproduce exactly.

The original app uses this package (0.1.2) for grading on the Flutter side, and checks its results against the Go re-check with the app's shared fixtures.

Implementation details
  • Accuracy and characters per minute (CPM) are stored as integers, not floating point: accuracy times 1000 and CPM times 1000. Display decimals are derived from those.
  • Even with the same minimum number of edits, there can be several paths that differ in which positions count as errors. So the backtracking direction, from end to start, and the priority of substitution, deletion, and insertion are fixed as part of the contract.
  • This behavior is written out as 16 JSON conformance cases, covering NFC equivalence for Hangul and kana, ZWJ emoji, Latin combining marks, 가 with a Middle Korean tone mark (U+302E) counted as one character, and ambiguous edit paths. Another implementation, in Go or anything else, can run the same cases to confirm it agrees.
  • When a stored grading policy is read, unknown or missing fields are rejected, so separate implementations cannot silently read the same policy in different ways.
  • Because the edit path is kept, time and memory grow with the product of reference and input grapheme counts. The package targets short practice sentences, and the README says apps must cap input length before grading long documents.

Why the first release was stable 0.1.0

It was first prepared as a hidden prerelease. But pub.dev leaves prereleases out of search and analysis scores, and does not use them for the main README and docs. A stable 0.x release can still take breaking changes in 0.2.0 while being found and installed normally. For that reason, 0.1.0 went out as stable.

Just before release, I changed a negative active duration to raise an error instead of silently reporting zero CPM. Before publishing, the package passed 39 tests, documentation generation with link validation, and scored the full 160/160 on pub.dev's quality check (pana). CI runs the tests on both the minimum supported Dart 3.8.0 and the latest stable SDK.

Usage is documented in English, Korean, and Japanese READMEs, with a browser demo that calls the same gradeTyping. In 0.1.1, the demo GIFs did not render on pub.dev; I fixed it by switching to absolute image URLs.