Reading Handwritten Part Numbers and Codes: Correct Them with a Code List and Format Hints
Handwritten part numbers and ID codes are easy for OCR to get wrong because of look-alike characters such as 0 and O or 1 and I. This guide covers the Korean line recognition and English handwriting engines, matching against a code list, rereading with format hints, checking and turning off corrections, and the limits.
- Published
- Updated
Sometimes you have to move handwritten part numbers into a spreadsheet: a warehouse receiving sheet, equipment asset tags, labels on test samples. OCR handles printed text quite well, but handwritten codes are a different story, because a single wrong character turns a code into a completely different one. This guide explains how to read handwritten codes in Mandumon OCR and how to correct the result using a code list and format hints you already have. We will cover which engine to choose, which characters get confused, how the correction rules work, and where you should not trust the output.
Why handwritten codes are hard to read
In ordinary sentences, the surrounding words act as hints. If one letter is smudged, context lets you guess it. A code like WAJ3PT301ABC has no context at all. Even deciding whether a position holds a letter or a digit has to come from the shape alone. Handwritten 0 and O, 1 and I, 5 and S look almost identical, and depending on the writer a hyphen can look like a zero.
Line splitting is another problem. Handwriting has uneven gaps, so one code may be broken into two pieces or pick up a stray dot in the middle. In one scanned PDF, the handwritten code WAJ3PT301ABC was read as WAJ 3PT3·1ABC: a space appeared in the middle and a 0 turned into a centered dot. A person can see the right answer, but you cannot copy that text and use it.
Korean line recognition or English handwriting: which engine?
Besides the printed-text engine, the OCR app has two experimental models for handwriting. Both are labeled as experimental, and both read one line at a time.
- Korean line recognition (handwritten & printed, experimental): reads single lines of Korean text, including handwriting-style fonts. The model is about 57 MB and downloads only the first time you choose this engine. It is not fetched on the first screen, and once downloaded it is stored in your browser. The runtime and the Korean data used to find lines are separate downloads.
- English handwriting (experimental): built for English handwriting only. The model downloads directly from Hugging Face and the total with configuration and runtime is about 63.6 MB. Each line is recognized separately, so it takes time.
- Both experimental engines read your original image as is. Preprocessing settings apply only to the printed text engine.
Codes mix letters and digits, so the English handwriting engine looks like the natural choice, but Korean line recognition also reads Latin letters and numbers. The Reread with hints feature described below works with Korean line recognition. The best approach is to try both engines on the same photo and see which one suits your handwriting. You choose and manage engines under Change settings and Engine and model details, where you can also download or delete a model.
Know the look-alike character groups
The first thing code correction considers is characters that look alike and are easily swapped. The app treats a swap within these groups as cheaper than other mistakes.
- 0, O, D and Q
- 1, I, L and 7
- 5 and S
- 8 and B
- 2 and Z
- 6 and G
- A hyphen and 0
Symbols such as a dot, period, slash, backslash, vertical bar or comma that appear where a 0, 1, I or L should be are treated as similarly cheap. The centered dot standing in for the 0 in the earlier example is this case. On the other hand, replacing a character with one that looks nothing like it, or inserting and deleting characters, costs more. The result is that errors caused by look-alike characters are easy to undo, while an unrelated character is hard to overwrite by accident.
Correct with a code list
If you already know the possible answers, this is the most reliable method. Give the app the codes from your inventory or asset register, and it replaces each code in the result with the closest entry in that list. Here is the process.
- Run Extract text, then open the collapsible Corrections panel in the results area.
- Paste your codes into Code list (lines or commas), or use Load .txt/.csv. Lines and commas both work. Quotation marks, Windows line endings and a leading BOM are handled, and duplicates are merged into one.
- Check Ignore spaces when comparing and Ignore hyphens when comparing. Ignoring spaces is on by default and ignoring hyphens is off.
- With Apply corrections on, the corrections show up in your text and the panel displays a count such as 2 corrections.
The comparison uses a weighted edit distance. Inserting, deleting or generally replacing a character costs 1, while swapping within the look-alike groups above costs 0.4. Only tokens that are mostly letters and digits and at least four characters long are compared, after converting to uppercase. A correction is applied only when the distance is within 20 percent of the code length (at least 1) and exactly one list entry is the closest. If two or more candidates tie, the app cannot tell which one is right, so it deliberately leaves the text alone.
Codes split by spaces are handled too. The app builds candidates by joining neighboring pieces on the same line, and merges them only if the joined version is closer to a list entry than the separate pieces and fits the length of a listed code. It never joins across a line break or other punctuation.
On privacy: only the raw text of the code list is saved, in this browser's localStorage, and nothing goes to a server. Format examples, recognition results and files are not sent to a server either. Choosing Clear list deletes the saved list. If browser storage is blocked, the list is used in the current tab only and the app tells you about the error.
Format hints: judging each position without a list
When there are too many codes, or new numbers appear every time, you cannot build a list. Use format hints instead. Enter one or more codes that follow the same rule in Example codes. The app extracts a position-by-position pattern from them: letter positions stay letters, digit positions stay digits, and symbols such as hyphens stay as they are.
For instance, with the example WAJ3PT301ABC, the pattern is three letters, one digit, two letters, three digits, three letters. In a code of the same length, if a digit position holds O, I, L, S, B, Z, G or a hyphen, it is changed to 0, 1, 1, 5, 8, 2, 6 or 0 respectively. If a letter position holds 0, 1, 5 or 8, it becomes O, I, S or B. When you give several examples and their patterns produce different results, the app cannot know which is right, so it keeps the original text. Removing a hyphen first would erase the information that a position was a 0, so format correction tries the digit replacements first.
With Korean line recognition, hints help in one more way. If a list or format example exists, only lines that contain a code are read again, using a beam width of 4 and up to 4 candidates. Candidates that exactly match the list are preferred, then candidates that match the pattern, then candidates that can be corrected, and the model's score breaks ties. For results you already have, the Reread with hints button recognizes only the code lines again. Text you edited by hand is kept, and in a mixed PDF only lines read by Korean OCR are reread.
Two corrections from real testing
These are cases confirmed during development. First, the handwritten code WAJ3PT301ABC was read as WAJ 3PT3·1ABC. With WAJ3PT301ABC in the list, the space is removed, the dot is counted as a cheap look-alike for the 0, and WAJ3PT301ABC is chosen as the closest entry. Entering just WAJ3PT301ABC as a format example, with no list, gives the same result.
Second, W UC-20 is corrected to WMC-20 from the list. W and UC-20 were read separately, but joined they become WUC-20, which is one character away from WMC-20. When the text reads W WMC-20, however, the leading W stays a separate token and only WMC-20 is kept as is, because joining would not get any closer.
The same handwriting could also read differently depending on preprocessing. In one scan, turning preprocessing off gave WAJ 3PT3·1ABC while automatic preprocessing gave something quite different, WAT3P3D/ABC. That is why the two experimental engines now read the original image directly. Still, none of this means the model itself became more accurate. Correction is post-processing applied after recognition.
Checking corrections and turning them off
Correction assumes that a person checks the result. In the preview, corrected parts are underlined, and hovering shows the original reading in a tooltip. Compare with the source image to make sure each fix is right. You can also edit directly in the text field below.
- Copy, TXT download, the word tools and position selection all use the same corrected version, so they never disagree.
- Turning off Apply corrections returns the original reading. The OCR result itself is not changed by correction and stays stored.
- Parts you edited by hand stay as you wrote them even if you switch corrections off. A code you typed yourself is not an originally recognized token, so it is not corrected again.
- If joining codes changes word boundaries, the app selects words using approximate positions from the line boxes.
Limits and practical advice
The most important point is that list and format correction does not raise the model's actual accuracy or confidence. It only tidies a result that was already read wrongly. Korean line recognition and English handwriting are experimental, and real handwriting can produce low accuracy. Vertical text and tables are not supported, and printed OCR sometimes fails to find the lines.
- A new code that is not in the list will not be corrected. It might even be changed into a similar but wrong code, so if you have many new numbers, turn list correction off and check carefully.
- If your list has many codes that differ by one character, candidates may tie or the wrong one may win. The text is then left alone or changed unexpectedly, so always compare with the source.
- Format hints apply only to codes of the same length. If your code length varies a lot, they help less.
- For important numbers such as shipping, safety or legal documents, do not trust the corrected output blindly. Have a person check it last.
To sum up: read the handwriting with an engine, match it to the right answers with a code list, and when you have no list, fix letter and digit positions with a format example. Finally, check by eye using the underlines and original values. Open the OCR app with the button below and try it yourself. Images and results are never sent to a server and are processed only in your browser.
