A Novel Machine Learning Based Approach for Post- OCR Error Detection (2021)

Abstract: Post processing is the most conventional approach for correcting errors that are caused by Optical Character Recognition(OCR) systems. Two steps are usually taken to correct OCR errors: detection and corrections. For the first task, supervised machine learning methods have shown state-of-the-art performances. Previously proposed approaches have focused most prominently on combining lexical, contextual and statistical features for detecting errors. In this study, we report a novel system to error detection which is based merely on the n-gram counts of a candidate token. In addition to being simple and computationally less expensive, our proposed system beats previous systems reported in the ICDAR2019 competition on OCR-error detection with notable margins. We achieved state-of-the-art F1-scores for eight out of the ten involved European languages. The maximum improvement is for Spanish which improved from 0.69 to 0.90, and the minimum for Polish from 0.82 to 0.84.

## introduction post processing is the most conventional approach for correcting errors that are caused by optical character recognition (ocr) systems. traditionally, the task is divided into two subtasks: (1) error detection to classify words foot_0 as either erroneous or valid, and (2) error correction to find suitable candidates to correct the erroneous words @xcite @xcite . a large body of work has proven the success of statistical and supervised machine learning methods for both subtasks @xcite @xcite @xcite . machine learning methods largely rely on feature engineering for their performances, particularly in supervised settings. feature engineering involves exploring various features and feature combinations that best characterise the data. however, for post-ocr error detection, finding a suitable set of features is challenging because of the diversity of ocr errors @xcite . this has been demonstrated in previous work and more recently in the icdar competitions @xcite where various features have been explored with varying success rates (more details in section 2). to address this challenge we propose a novel approach to the error detection task. instead of examining more features we focus merely on a single feature, namely the n-gram counts of the candidate token. our approach is inspired by dictionary lookup approaches, which are known for their simplicity and efficiency but are restricted to the dictionary size. since building large-scale dictionaries is a challenging task in itself, we propose to generate n-grams of a given candidate token, and then use their counts as the only feature to train machine learning models (more details in section 3). we evaluate our method on the icdar2019 dataset @xcite and compare the results to a number of approaches reported in the competition (section 4). our system achieves state-of-the-art results for eight out of the ten involved languages by beating the previous results with fair margins and comparable scores for the remaining two languages. our approach is very simple and is computationally less expensive as it does not require any other feature computation apart from the n-gram counts. simple dictionary based approaches has performed reasonably well for various natural language processing tasks (e.g. @xcite ; @xcite ). it is therefore not surprising the approach has been applied to detecting ocr errors before @xcite . taking this approach, dictionaries and large word lists are usually compiled from corpora and other sources. each token in the data is then compared with the word in the dictionary to determine whether it is an error word or not. this approach has been explored by the csiitj team who was among the six successful teams participating in the icdar 2019 competition @xcite . the team complied a dictionary of over 370 thousand english and french words and checked each word in the dataset against it. dictionary lookup methods for post-ocr are challenging because they usually suffer from outof-vocabulary problem. another limitation is in detecting real-word errors, i.e. the word appears in the dictionary but is wrong in its context. therefore alternative methods to ocr error detection have been proposed (see a comprehensive survey of existing methods by @xcite al. (2021) other approaches to post-ocr error detection combined character-, word-n-grams and context based features to train a machine learning model @xcite @xcite . @xcite trained a regression model on 6 features containing n-gram and context information. @xcite trained a support vector machine (svm) model with 3 features: presence of non-4.0 licence at https://github.com/spraakbanken/ novelocrerrorcorrection . as many authors point out the choice of the features is essential for the performance of the machine learning model. the advantage of these methods is that they are trained to detect both real-word and non-word errors. the drawback is they require laborious feature engineering. laborious feature engineering is a bottleneck not only for machine learning but also for other statistical approaches that rely on pre-defined features extracted from data, such as noisy channel approaches @xcite @xcite . ## conclusion and future work training supervised machine learning models with large number of features is a computationally expensive task. this has been demonstrated in previous work where handcrafted features were considered at the expense of high computational costs. in this study we have taken a different approach and have proposed to use n-gram counts as the only feature to train svm models. n-gram counts have previously been used for post-ocr detection, but not in the sense that we have proposed in this study. instead of computing the n-gram counts over the entire training data we have proposed to compute them within a given token and use them as the only feature to train and test our models. to find the best 'n' for the n-grams, we experimented with uni-grams, bi-grams, and tri-grams. we tested the approach on the icdar 2019 dataset. as the experiment results show, with uni-grams our model outperforms the best system reported in the icdar2019 competition for six out of the 10 european languages included in the competition with default class distribution, and two more languages with balanced class distribution. with bi-grams, our model outperforms the previous system for 7 languages with comparable results for the remaining three languages. with tri-grams the results start deteriorating for most of the languages meaning that bi-grams are the best choice. overall, with this approach we were able to beat 8 out of the 10 languages achieving state-of-the-art results for those languages. the proposed approach is interesting because it eliminates the need for feature engineering; a task which is laborious and computationally expensive. the results show simple n-gram counts, which are fairly easy to compute, are enough for the task at hand. the approach is also gainful because it does not require large amounts of data. given the relatively small datasets we experimented with we were able to show our method is performing better for the majority of languages compared to deep learning systems such as the ones explored by the ccc and uva teams. as previously said, we have used an svm classifier with default parameters. in the future, we plan to apply parameter optimization, e.g. scaling, class distribution, grid-search, etc. to try and improve the results further. for example to detect real word errors when the word with an error is still a good word but inappropriate in the context. another possible way to improve the results is to use the back-off approach in the n-gram setting. taking a back-off approach we will use a bi-gram if a tri-gram is not in the vocabulary in a tri-gram setting, and likewise a uni-gram if a bi-gram is not in the vocabulary. with these reported state-of-the-art results on post-ocr error detection, it will be interesting to experiment how these results will contribute to the improvement of the overall task of post-ocr error correction. we leave this to be another possible direction to explore further.