Question Details

No question body available.

Tags

python python-chess

Answers (1)

May 21, 2026 Score: 2 Rep: 114,535 Quality: Medium Completeness: 60%

For one thing, Levenshtein similarity won't help you there. At all. Becuase it compares string distance, and doesn't take into account any character possibilities. Chess notation all being 2-3 characters long, will yield L. similarity as tied at "difference 1" for almost all valid moves. There will be some 2, but even two tied at "1", just means it can't make any decision there. You need to go back to the OCR layer, and check the probability of matching each SAN valid move to the acturall image data, instead of letting it deliver you just the "most probable" notation. That works for big text, where you can later parse words for L. similarity, and even another model to check overall context.

Also, being able to annotate possible matches (from the OCR layer), and backtrack when attempting further moves in case of any incosnsitense, is the only thing that can ensure some success there.

You don't show the part of your code where you get the OCR text back as text, instead of images - but there are a lot of changes in that layer. Specially: you can't just try to get all the moves at once, in a single OCR pass - instead, you have to break it, to pick the rectangles where each move is written, and then OCR move by move (and join the layers so that when doing this you check the probabilities the OCR engine gives you against the SAN valid moves, and not pick any string without doing that).

Just to emphasize I am wording this again: just drop Levenshtein distance: it can't help in this scenario at all.

Can't help with any code, since the OCR part is not contained your example. It has to go before the ocr_move argument showing there is assumed to be right.