Text error correction method, control device, storage medium and equipment
By constructing confusion-prone recognition maps and matrices, combined with graph convolutional neural networks, and training text error correction models, the problem of poor error correction effects of domain-specific vocabulary in the existing technology has been solved, and the accuracy and accuracy of text error correction after OCR have been improved. Recall rate.
Patent Information
- Application Number
- CN202310198735.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-01
- Publication Date
- 2024-09-03
AI Technical Summary
Existing text error correction models are not effective in text processing of domain-specific vocabulary, mainly due to the small sample size, which makes it difficult to effectively correct glyph recognition errors after OCR processing.
By constructing confusion-prone recognition maps and matrices, Chinese character embedding processing is performed, and a text error correction model is constructed using a graph convolutional neural network, and the error correction model is trained to correct the text after OCR recognition.
It improves the accuracy and recall rate of text error correction after OCR in the domain, and solves the problem of poor error correction of domain-specific vocabulary.
Smart Images

Figure CN118587716A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text recognition, and in particular to a text error correction method, a control device, a storage medium and equipment. Background Art
[0002] After the image or image-formatted document is processed by Optical Character Recognition (OCR), there will be some errors. These errors are mainly character recognition errors, and pinyin errors are relatively rare.
[0003] Currently, the solution to glyph recognition errors after OCR processing is to use a trained text correction model to correct text errors. However, the current text correction model is a model trained with samples consisting of general domain data. In some vertical fields where the vocabulary is domain-specific, the sample size is small, so the effect of using a general domain model to process such text correction is not good. Summary of the invention
[0004] The purpose of the embodiment of the present invention is to provide a text error correction method, which can solve the problem of character recognition errors after OCR processing.
[0005] In order to achieve the above-mentioned purpose, an embodiment of the present invention provides a text error correction method, which includes: constructing a confusing recognition map through original Chinese characters, Chinese characters with glyph errors corresponding to the original Chinese characters after OCR recognition, and the number of errors corresponding to the glyph errors; converting the confusing recognition map into a confusing recognition matrix; embedding the Chinese characters in the confusing recognition map to obtain an embedding matrix; using the confusing recognition matrix and the embedding matrix to train a text error correction model constructed by a graph convolutional neural network; and correcting the text after OCR recognition by using the text error correction model obtained after training.
[0006] Optionally, the easily confused identification map includes the relationship between nodes, the nodes are the original Chinese characters and the corresponding Chinese characters with glyph errors after OCR recognition, and the relationship between the nodes is the number of errors that occur after the two Chinese characters corresponding to the two nodes are recognized by OCR.
[0007] Optionally, the easily confused identification matrix is a second-order matrix, and converting the easily confused identification map into the easily confused identification matrix includes: converting the relationship between the nodes into a similarity coefficient obtained by normalizing the number of errors.
[0008] Optionally, the embedding matrix includes a basic embedding matrix and a radical embedding matrix.
[0009] Optionally, the embedding processing of the Chinese characters in the easily confused identification map includes: decomposing the Chinese characters in the easily confused identification map by radicals; embedding the Chinese characters and their radicals after the decomposition processing through one or more layers of recurrent neural network models to obtain the radical embedding matrix.
[0010] Optionally, the embedding processing of the Chinese characters in the easily confused identification map includes: embedding the Chinese characters in the easily confused identification map through a BERT model to obtain the basic embedding matrix.
[0011] Optionally, the text error correction model includes: each layer training of the text error correction model is expressed by the following formula:
[0012] f(A,H l )=A(H+E) l W l
[0013] Among them, A represents the confusing identification matrix, H represents the basic embedding matrix, E represents the radical embedding matrix, W represents the weight between each layer of the text correction model, l represents the lth layer of the text correction model, the activation function of the text correction model is ReLU, and the convergence function of the text correction model is softmax.
[0014] The embodiment of the present invention also provides a control device for text error correction, which includes: a graph construction module, which is used to construct an easily confused recognition graph through original Chinese characters, Chinese characters with glyph errors corresponding to the original Chinese characters after OCR recognition, and the number of errors corresponding to the glyph errors; a conversion matrix module, which is used to convert the easily confused recognition graph into an easily confused recognition matrix; an embedding module, which is used to embed the Chinese characters in the easily confused recognition graph to obtain an embedding matrix; a neural network training module, which is used to use the easily confused recognition matrix and the embedding matrix to train a text error correction model constructed by a graph convolutional neural network; and an error correction module, which is used to correct the text after OCR recognition by using the text error correction model obtained after training.
[0015] An embodiment of the present invention also provides a text correction device, which includes at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the above-mentioned text correction method.
[0016] Through the above technical scheme, by constructing an easily confused recognition map and a corresponding easily confused recognition matrix, and embedding the Chinese characters in the easily confused recognition map to obtain an embedding matrix, the easily confused recognition matrix and the embedding matrix are used to train a text error correction model; the text error correction model obtained after training is used to correct the text after character recognition in the text, which can solve the problem of post-OCR text error correction in the field.
[0017] Other features and advantages of the embodiments of the present invention will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention. In the accompanying drawings:
[0019] Figure 1 It is a flowchart of a text error correction method provided by an embodiment of the present invention;
[0020] Figure 2 is a schematic diagram of an example confusable identification map;
[0021] Figure 3 is a schematic diagram of an example confusable identification matrix;
[0022] Figure 4 is a schematic diagram of an example radical embedding matrix;
[0023] Figure 5 is a schematic diagram of an example embedding matrix;
[0024] Figure 6 is a schematic diagram of an example text error correction model and its training;
[0025] Figure 7 is a schematic diagram of the structure of a control device for text error correction provided by an embodiment of the present invention; and
[0026] Figure 8 It is a schematic diagram of the structure of a device provided in an embodiment of the present invention.
[0027] Description of Reference Numerals
[0028] 701 Construction of graph module 702 Transformation matrix module
[0029] 703 embedding module 704 neural network training module
[0030] 705 Error Correction Module 80 Device
[0031] 801 processor 802 memory
[0032] 803 Bus Detailed Implementation Manner
[0033] The following will describe in detail the specific implementation manners of the embodiments of the present invention with reference to the accompanying drawings. It should be understood that the specific implementation manners described herein are only for explaining and illustrating the embodiments of the present invention, and are not used to limit the embodiments of the present invention.
[0034] Figure 1 is a schematic flowchart of the text error correction method provided by the embodiments of the present invention. Please refer to Figure 1 , and the text error correction method may include the following steps:
[0035] Step S110: Construct a confusion recognition map through the original Chinese characters, the Chinese characters with glyph errors corresponding to the original Chinese characters after OCR recognition, and the number of times of corresponding glyph errors.
[0036] After a picture or a document in picture format undergoes optical character recognition (OCR) processing, there will be some errors. The embodiments of the present invention process the text with glyph errors after OCR recognition to generate a glyph similarity map, that is, a confusion recognition map.
[0037] Preferably, the confusion recognition map in the embodiments of the present invention includes nodes and the relationships between the nodes. The nodes are the original Chinese characters and the Chinese characters with glyph errors corresponding to them after OCR recognition, and the relationship between the nodes is the number of errors that occur when the two Chinese characters corresponding to the two nodes are recognized by OCR.
[0038] Please refer to Figure 2 For example, the nodes in the confusion recognition map are Chinese characters (the original Chinese characters and the corresponding incorrect Chinese characters), and the relationship between the nodes is the number of times the two Chinese characters are recognized incorrectly. For example, the character "磨" in the text has had incorrect characters "摩" and "麽" after OCR, or the character "摩" in the document has had an incorrect character "磨" after OCR. These Chinese characters with similar glyphs are combined into a confusion recognition map.
[0039] Step S120: Convert the confusion recognition map into a confusion recognition matrix.
[0040] Preferably, the confusion recognition matrix in the embodiments of the present invention is a second-order matrix. The conversion of the confusion recognition map into a confusion recognition matrix includes: converting the relationship between the nodes into a similarity coefficient obtained by normalizing the number of errors.
[0041] Illustrated by an example, after constructing as Figure 2After the shown confusion recognition graph is generated, a corresponding confusion recognition matrix A is generated, as Figure 3 shown. For example, if the confusion recognition graph has N nodes, the corresponding confusion recognition matrix is an N*N adjacency matrix (i.e., a matrix of the adjacent relationships between nodes). If there is a relationship between two nodes in the confusion recognition graph, it is recorded as 1 in the adjacency matrix ("1" indicates complete correlation, i.e., the same Chinese character), and normalization processing is performed. For example, after the character "人" in the text is OCRed multiple times (e.g., m times), the number of times the incorrect character "入" appears is, for example, n times. Since there is a relationship between "人" and "入", after normalization processing, the similarity coefficient is obtained as n / m (as Figure 3 shown, the similarity coefficient is 0.76).
[0042] Step S130: Perform embedding processing on the Chinese characters in the confusion recognition graph to obtain an embedding matrix.
[0043] Preferably, the embedding matrix in the embodiment of the present invention includes a basic embedding matrix and a radical embedding matrix.
[0044] Preferably, the performing embedding processing on the Chinese characters in the confusion recognition graph may include: performing radical character splitting processing on the Chinese characters in the confusion recognition graph; performing embedding processing on the characters and their radicals after the splitting processing through one or more recurrent neural network models to obtain the radical embedding matrix.
[0045] Illustrated by an example, for the N Chinese characters (also known as characters) in the confusion recognition graph in step S110, radical character splitting is performed and vectorization is carried out to obtain a radical embedding matrix E. As Figure 4 in the example, splitting the character "磨" into radicals can obtain "广", "林", and "石". After splitting all the characters as Figure 2 shown into radicals, for example, 1 layer of recurrent neural network (preferably GRU) is used for embedding. Figure 2Each character in the easily confused identification map can be broken down into radicals. Different characters have different numbers of radicals, so different characters can take the same number of radicals, for example, 6 radicals, that is, each Chinese character is broken down into 6 radicals. If there are less than 6, they are padded to the specified length, such as 0. If there are more than 6, they can be truncated. In this way, each character can be broken down into radicals of the same length and converted into a vector representation after embedding. For example, 768 dimensions (each character is represented by a vector of length 768). Since the character vectorization is determined by BERT embedding (please refer to the following), the number of neurons in the hidden layer of BERT is 768, so the vector obtained by BERT is also 768-dimensional, that is, each word in the basic embedding matrix H is represented by a 768-dimensional vector.
[0046] Among them, GRU (Gate Recurrent Unit) is a type of Recurrent Neural Network (RNN). Similar to the Long-Short Term Memory (LSTM), it is also used to solve problems such as long-term memory and gradients in back propagation. The task of deep learning is to map high-dimensional raw data (for example, images and sentences, etc.) to low-dimensional manifolds, so that the high-dimensional raw data becomes separable after being mapped to the low-dimensional manifold, and this mapping is called embedding. The embodiment of the present invention preferably maps the Chinese characters and their radicals after the decomposition process to a representation vector, that is, the radical embedding matrix E, wherein the output dimension of each character is, for example, 768 dimensions.
[0047] Preferably, the embedding process of the Chinese characters in the easily confused identification map may also include: embedding the Chinese characters in the easily confused identification map through a BERT model to obtain the basic embedding matrix.
[0048] The basic embedding matrix preferably in the embodiment of the present invention is the output result of the 12th hidden layer of the BERT model.
[0049] By way of example, the N Chinese characters (also called characters) in the easily confused recognition graph in step S110 are directly vectorized to obtain the basic embedding matrix H. The BERT model can be used, and the output result of the 12th hidden layer is used as the character embedding result, and the output dimension of each character is, for example, 768 dimensions (consistent with the output result of the radical embedding matrix E).
[0050] Among them, the BERT (Bidirectional Encoder Representation from Transformers) model is a pre-trained language representation model. BERT emphasizes that it no longer uses the traditional unidirectional language model or the shallow concatenation of two unidirectional language models for pre-training as in the past, but instead uses the new MLM (Masked Language Model) to generate deep bidirectional language representation.
[0051] Please refer to Figure 5 In the embodiment of the present invention, the embedding results obtained by the above two methods are preferably summed as the initial embedding of the character, that is, the embedding matrix B (also denoted as H+E).
[0052] Optionally, the method of obtaining radical embedding and the method of character embedding can be replaced by other methods, but the output dimensions of the two parts must be the same.
[0053] Step S140: Use the confusing identification matrix A and the embedding matrix B to train a text error correction model constructed by a graph convolutional neural network.
[0054] Among them, Graph Convolutional Networks (GCN) are convolutional neural networks (CNN) for graph data structures. GCN actually has the same function as CNN, which is a feature extractor, except that its object is graph data. GCN has cleverly designed a method to extract features from graph data, so that these features can be used to perform node classification, graph classification, link prediction, and graph embedding.
[0055] The text error correction model preferably in the embodiment of the present invention may include: each layer training of the text error correction model is expressed by the following formula:
[0056] f(A,H l )=A(H+E) l W l (1)
[0057] Among them, A represents the confusing identification matrix, H represents the basic embedding matrix, E represents the radical embedding matrix, W represents the weight between each layer of the text correction model, and l represents the lth layer of the text correction model.
[0058] Among them, the activation function of the text error correction model is ReLU, and the convergence function of the text error correction model is softmax, that is, the final conditional probability is obtained through the softmax function.
[0059] Please refer to Figure 5 The embodiment of the present invention uses the easily confused identification matrix A and the embedding matrix B (basic embedding matrix H and radical embedding matrix E) to train the text error correction model constructed by the graph convolutional neural network, and a trained text error correction model can be obtained.
[0060] Step S150: Correct the text recognized by OCR by using the text error correction model obtained after training.
[0061] Accordingly, the text error correction method provided by the embodiment of the present invention constructs an easily confused recognition map and a corresponding easily confused recognition matrix, and embeds the Chinese characters in the easily confused recognition map to obtain an embedding matrix B. The easily confused recognition matrix and the embedding matrix are used to train a text error correction model. The text error correction model obtained after training is used to correct the text after character recognition in the text, thereby solving the problem of post-OCR text error correction in the field.
[0062] Furthermore, we use the Chinese character decomposition dictionary (i.e., the radical embedding matrix) and the basic embedding obtained by Bert (i.e., the basic embedding matrix) to obtain more features of Chinese character shapes, and combine them with GCN to obtain the final error correction probability. Optimizing the quantization of Chinese character shape features further highlights the focus of the text error correction model on the features of character shapes and radicals, and improves the accuracy and recall of text error correction after OCR.
[0063] Figure 7 is a schematic diagram of the structure of a control device for text error correction provided by an embodiment of the present invention, please refer to Figure 7The embodiment of the present invention also provides a control device for text error correction, the control device comprising: a graph construction module 701, used to construct a confusing recognition graph through original Chinese characters, Chinese characters with glyph errors corresponding to the original Chinese characters after OCR recognition, and the number of errors corresponding to glyph errors; a conversion matrix module 702, used to convert the confusing recognition graph into a confusing recognition matrix; an embedding module 703, used to embed the Chinese characters in the confusing recognition graph to obtain an embedding matrix; a neural network training module 704, used to use the confusing recognition matrix and the embedding matrix to train a text error correction model constructed by a graph convolutional neural network; and an error correction module 705, used to correct the text after OCR recognition by using the text error correction model obtained after training.
[0064] The control device provided in the embodiment of the present invention has similar technical contents and advantages to the above-mentioned text error correction method in the embodiment of the present invention. Please refer to the detailed contents of steps S110-S150, which will not be repeated here.
[0065] An embodiment of the present invention further provides a machine-readable storage medium, on which instructions are stored, and the instructions enable a machine to execute the text error correction method described in steps S110-S150.
[0066] Please refer to Figure 8 The embodiment of the present invention provides a text error correction device 80, which includes at least one processor 801, at least one memory 802 and a bus 803 connected to the processor 801; wherein the processor 801 and the memory 802 communicate with each other through the bus 803; the processor 801 is used to call the program instructions in the memory 802 to execute the text error correction method described in steps S110-S150. The device 80 in this article can be a server, a PC, a PAD, a mobile phone, etc.
[0067] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0068] In a typical configuration, the device includes one or more processors (CPU), memory and bus. The device may also include input / output interface, network interface and the like.
[0069] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
[0070] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0071] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0072] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0073] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A text error correction method, characterized in that: The text error correction method comprises: Constructing a confusing recognition map through the original Chinese characters, the Chinese characters with glyph errors corresponding to the original Chinese characters after OCR recognition, and the number of errors corresponding to the glyph errors; Converting the confusable identification map into a confusable identification matrix; Embedding the Chinese characters in the easily confused identification graph to obtain an embedding matrix; Using the confusing identification matrix and the embedding matrix, training a text error correction model constructed by a graph convolutional neural network; and The text error correction model obtained after training is used to correct the text after OCR recognition.
2. The text error correction method according to claim 1, characterized in that: The confusing identification graph includes nodes and relationships between nodes. The nodes are the original Chinese characters and the corresponding Chinese characters with glyph errors after OCR recognition. The relationship between the nodes is the number of errors that occur after two Chinese characters corresponding to the two nodes are recognized by OCR.
3. The text error correction method according to claim 2, characterized in that: The easily confused identification matrix is a second-order matrix, and the converting of the easily confused identification map into the easily confused identification matrix includes: The relationship between the nodes is converted into a similarity coefficient obtained by normalizing the number of errors.
4. The text error correction method according to claim 1, characterized in that: The embedding matrix includes a basic embedding matrix and a radical embedding matrix.
5. The text error correction method according to claim 4, characterized in that: The embedding process of the Chinese characters in the easily confused identification graph includes: For the Chinese characters in the easily confused identification graph, performing character decomposition processing based on radicals; The Chinese characters and their radicals after the decomposition process are embedded through one or more layers of recurrent neural network models to obtain the radical embedding matrix.
6. The text error correction method according to claim 4, characterized in that: The embedding process of the Chinese characters in the easily confused identification graph includes: The Chinese characters in the easily confused recognition graph are embedded through the BERT model to obtain the basic embedding matrix.
7. The text error correction method according to claim 4, characterized in that: The text error correction model includes: The training of each layer of the text error correction model is expressed by the following formula: f(A,H l )=A(H+E) l W l Among them, A represents the easy-to-confuse identification matrix, H represents the basic embedding matrix, E represents the radical embedding matrix, W represents the weight between each layer of the text correction model, l represents the lth layer of the text correction model, The activation function of the text error correction model is ReLU, The convergence function of the text error correction model is softmax.
8. A control device for text error correction, characterized in that: The control device comprises: A graph construction module is used to construct a confusing identification graph through the original Chinese characters, the Chinese characters with glyph errors corresponding to the original Chinese characters after OCR recognition, and the number of errors corresponding to the glyph errors; A conversion matrix module, used for converting the confusable identification map into a confusable identification matrix; An embedding module, used for embedding Chinese characters in the easily confused identification map to obtain an embedding matrix; A neural network training module, used to train a text error correction model constructed by a graph convolutional neural network using the confusable identification matrix and the embedding matrix; and The error correction module is used to correct the text recognized by OCR by using the text error correction model obtained after training.
9. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores instructions, which enable the machine to execute the text error correction method according to any one of claims 1-7.
10. A text error correction device, characterized in that: The text error correction device includes at least one processor, and at least one memory and a bus connected to the processor; Among them, the processor and memory communicate with each other through the bus; The processor is used to call the program instructions in the memory to execute the text error correction method described in any one of claims 1-7.
