Skip to main content
QUICK REVIEW

[Paper Review] Recognizing Handwritten Source Code

Qiyu Zhi, Ronald Metoyer|arXiv (Cornell University)|Jan 1, 2017
Software Engineering ResearchComputer Science38 references2 citations
TL;DR

This paper proposes enhancing a commercial handwriting recognizer with programming language grammar rules to improve recognition of handwritten Python source code. By post-processing MyScript's output using syntactic constraints and token-level corrections, the system achieves an 8.6% word error rate and 3.6% character error rate—outperforming standard recognition and matching typing performance on virtual keyboards.

ABSTRACT

Supporting programming on touchscreen devices requires effective text input and editing methods. Unfortunately, the virtual keyboard can be inefficient and uses valuable screen space on already small devices. Recent advances in stylus input make handwriting a potentially viable text input solution for programming on touchscreen devices. The primary barrier, however, is that handwriting recognition systems are built to take advantage of the rules of natural language, not those of a programming language. In this paper, we explore this particular problem of handwriting recognition for source code. We collect and make publicly available a dataset of handwritten Python code samples from 15 participants and we characterize the typical recognition errors for this handwritten Python source code when using a state-of-the-art handwriting recognition tool. We present an approach to improve the recognition accuracy by augmenting a handwriting recognizer with the programming language grammar rules. Our experiment on the collected dataset shows an 8.6% word error rate and a 3.6% character error rate which outperforms standard handwriting recognition systems and compares favorably to typing source code on virtual keyboards.

Motivation & Objective

  • Address the challenge of accurately recognizing handwritten source code on touchscreen devices, where traditional handwriting recognition systems fail due to lack of support for programming language syntax.
  • Overcome the limitations of general-purpose handwriting recognition engines, which are optimized for natural language and struggle with camelCase, underscores, and non-space-delimited identifiers common in code.
  • Develop a practical, grammar-augmented post-processing framework to improve recognition accuracy without retraining the base recognizer.
  • Provide a publicly available dataset of 555 lines of handwritten Python code from 15 participants to support future research in handwritten code recognition.
  • Demonstrate that grammar-aware correction can significantly reduce error rates in handwritten source code recognition, making stylus-based programming a viable alternative to virtual keyboards.

Proposed method

  • Collected a dataset of 555 lines of handwritten Python code from 15 participants using a tablet and stylus, including both shared code samples and unique, participant-specific functions.
  • Used the MyScript handwriting recognition engine as a baseline, processing all handwritten input through its commercial API.
  • Implemented a post-processing pipeline that leverages Python’s grammar rules to validate and correct recognition output, including tokenization, syntax checking, and context-aware word replacement.
  • Applied regular expressions and grammar productions to identify and correct common errors such as misrecognized identifiers, missing or incorrect operators, and incorrect spacing.
  • Used a rule-based approach to merge or split tokens based on syntactic context, such as correcting 'ifthen' as 'if then' or 'variableName' as 'variable name' when contextually appropriate.
  • Evaluated the system by comparing recognition results against ground-truth code, measuring word error rate (WER) and character error rate (CER) on the full dataset.

Experimental results

Research questions

  • RQ1Can a grammar-augmented post-processing approach significantly reduce error rates in handwritten source code recognition compared to using a standard handwriting recognizer alone?
  • RQ2How do common handwriting recognition errors in Python code—such as misrecognized identifiers or incorrect spacing—manifest when using a general-purpose engine like MyScript?
  • RQ3To what extent can existing commercial handwriting recognition systems be improved for source code recognition through language-specific post-processing?
  • RQ4How does the performance of handwriting-based code input compare to virtual keyboard input in terms of error rates and usability for programming tasks?
  • RQ5What are the key error patterns in handwritten Python code that can be systematically corrected using syntactic and lexical constraints?

Key findings

  • The grammar-augmented post-processing approach reduced the word error rate (WER) to 8.6% and character error rate (CER) to 3.6% on the collected dataset, significantly outperforming the baseline MyScript recognizer.
  • The system’s performance is comparable to typing on a virtual keyboard, which has a reported 7.81% total error rate (TER), suggesting handwriting input can be a viable alternative for mobile programming.
  • Common errors in MyScript’s output included misrecognition of camelCase identifiers (e.g., 'myVariable' as 'my variable' or 'myvariable'), incorrect spacing around operators, and failure to recognize keywords like 'def' or 'return'.
  • The use of language grammar rules enabled effective correction of multi-token errors and improved recognition of compound identifiers, especially in cases where word boundaries were ambiguous.
  • The dataset of 555 lines of handwritten Python code from 15 participants is publicly available, providing a valuable benchmark for future research in handwritten source code recognition.
  • The results suggest that handwriting input, when enhanced with grammar-aware correction, can be a practical and accurate input method for programming on mobile and touchscreen devices, particularly for code editing rather than full-code creation.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.