To extract essential information from the textual data for various downstream tasks, it is often necessary to structuralize the data. This process is called “parsing”. Although various state-of-the-art parsers have been developed, they are all specialized in processing texts presented in one dimensional sequence format. However, in the era of smartphone, useful textual information is often visually embedded in images calling for a new type of parser. Here, we present POST OCR TAGGING BASED PARSER (POT), a simple yet robust post-OCR parser that can structuralize textual information presented in images by BIO-tagging text segments extracted from OCR task.

To extract visually embedded texts from an image, we used our in-house OCR system consisting of CRAFT text detector and Comb.best text recognizer.
The OCR models are finetuned on each parsing dataset. Resulting text segments and their spatial information on image were delivered to the serializer.
To maximally recover contextual information, extracted text segments are serialized according to their coordinate information. The algorithm first uses lexical sort to rearrange the text segments according to their coordinates from top to down and left to right direction using y axis as a primary order. Next, to group the text segments placed on the same line in the image, two segments whose the height difference is smaller than certain threshold are labeled as the same line and the segments are rearranged accordingly.
The serialized text segments are BIO-tagged using a neural network in following order. First, the text segments are tokenized and mapped to input vectors by adding token-, segment-, (sequential) position-, coordinate-, and line group-embeddings. The first three embeddings are prepared in identical way as BERT. The segment id is set to 1 for tokens from text segments and to 0 for BERT special tokens like [CLS]. The coordinate embedding represents the spatial information of visually embedded text segments. Before embedding, coordinates are normalized by using image width and height and mapped to integers between 0 to 30. The line group embedding is prepared by embedding line number found in the serialization process.
To tag each token, the first N_{tag} scalars of each BERT-encoded token vector are interpreted as logits where N_{tag} stands for the number of possible tags.
The output of the tagging model consists of mixed BIO tags of tokens which can be decoded sequentially into raw parses by noticing that for each target field, B and I of other fields can be considered as O-tag.
In receipt parsing task, there is an additional group tag (not to be confused with line group) to reflect the hierarchical structure of parses (for example fields such as name, count, and price are grouped together based on the item they represent). The group BIO-tags are also decoded sequentially.
Final parses are generated by refining raw parses. The refinement process involves database match and string conversion using a regular expression.
In receipt parsing task,
(1) various special symbols in cnt and price values, and
(2) the thousands separator in price are refined to have unified representation.