Text error correction processing method and device, equipment and storage medium
By extracting features using a text correction model and performing stroke matching using a dictionary of similar-looking characters, the low accuracy problem caused by the underutilization of character stroke information in existing technologies is solved, thus improving the accuracy of text correction in the insurance field.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA PING AN LIFE INSURANCE CO LTD
- Filing Date
- 2023-07-19
- Publication Date
- 2026-05-29
AI Technical Summary
Existing OCR error correction technologies used by financial institutions do not fully utilize the stroke information of characters, resulting in low accuracy in text correction.
The text correction model extracts location features, image features, and character shape features, and combines them with a pre-set dictionary of similar-looking characters to perform stroke matching of characters, and then selects target characters for replacement.
It improved the accuracy of text correction during the information entry process in the insurance sector, ensuring the accuracy of information entry.
Smart Images

Figure CN117058679B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing, and in particular to a text error correction processing method, apparatus, device, and storage medium. Background Technology
[0002] Optical Character Recognition (OCR) technology is a crucial component of text processing systems. Its purpose is to acquire text information from paper documents through optical input methods such as sampling and photography, and then convert it into computer-readable text using various recognition algorithms. For example, in insurance claims scenarios, OCR is used to recognize the text in supporting documents uploaded by customers and to determine whether to grant a claim based on the text.
[0003] In existing technologies, OCR technology based on deep neural networks has achieved relatively significant accuracy. However, when applied to real-world scenarios, such as in the financial sector, numerous problems arise, including the loss of important data in images, overall information bias caused by image tilt, and noise issues due to poor image quality. These issues prevent OCR systems based solely on deep neural networks from functioning correctly. Therefore, many OCR post-processing error correction technologies have emerged. However, most financial institutions currently only perform OCR error correction on data composed primarily of characters. Existing language models in financial institutions only consider the interrelationships between characters, neglecting stroke information, resulting in low accuracy in text correction. Summary of the Invention
[0004] This invention provides a text correction processing method, apparatus, device, and storage medium to improve the problem of low text correction accuracy caused by insufficient utilization of character information in the prior art.
[0005] A text correction processing method includes:
[0006] Obtain the text to be corrected; the text to be corrected refers to the scanned image.
[0007] A text correction model is obtained, and the text to be corrected is extracted through the feature layer of the text correction model to obtain position features, image features and glyph features.
[0008] Through the annotation layer of the text correction model, errors are marked on the text characters in the text to be corrected based on the position features, the image features and the glyph features, to obtain at least one erroneous character corresponding to the text to be corrected;
[0009] Each of the aforementioned erroneous characters is broken down into its strokes to obtain the corresponding character strokes;
[0010] By matching the strokes of each erroneous character with a pre-set dictionary of similar-looking characters, candidate characters corresponding to each erroneous character are obtained.
[0011] The target text is selected from all the candidate texts corresponding to each of the erroneous texts, and the erroneous texts are replaced according to the target texts to obtain the target text.
[0012] A text correction processing device, comprising:
[0013] The text acquisition module is used to acquire the text to be corrected; the text to be corrected refers to the scanned image.
[0014] The feature extraction module is used to obtain a text correction model, and to extract features from the text to be corrected through the feature layer of the text correction model to obtain position features, image features and glyph features.
[0015] The error annotation module is used to annotate the text characters in the text to be corrected based on the location features, image features and glyph features through the annotation layer of the text correction model, so as to obtain at least one erroneous character corresponding to the text to be corrected;
[0016] The stroke decomposition module is used to decompose each of the erroneous characters into strokes to obtain the character strokes corresponding to each of the erroneous characters.
[0017] The text matching module is used to perform text matching on the strokes of each of the erroneous characters using a preset dictionary of similar-looking characters, and to obtain candidate characters corresponding to each of the erroneous characters;
[0018] The text replacement module is used to filter out target text from all candidate texts corresponding to each of the erroneous texts, and replace the erroneous texts with the target texts to obtain the target text.
[0019] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described text correction processing method.
[0020] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described text correction processing method.
[0021] This invention provides a text correction processing method, apparatus, device, and storage medium. The method extracts features from the scanned text to be corrected using the feature layer of a text correction model, achieving the extraction of positional features, image features, and character shape features. Through the annotation layer of the text correction model, errors are marked in the text to be corrected based on positional features, image features, and character shape features, thus achieving the annotation of erroneous characters and further enabling the decomposition of the strokes of the erroneous characters. A preset dictionary of similar-looking characters is used to match the strokes of each erroneous character, determining candidate characters and thus filtering the target character. The target character is then replaced with its corresponding text, achieving the acquisition of the target text and ensuring the accuracy of information entered in the insurance field. Furthermore, the preset dictionary of similar-looking characters is used to match the strokes of each erroneous character, achieving character matching based on stroke information, which improves the accuracy of text correction during information entry in the insurance field. Attached Figure Description
[0022] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a schematic diagram of the application environment of the text error correction processing method in one embodiment of the present invention;
[0024] Figure 2 This is a flowchart of a text correction processing method in one embodiment of the present invention;
[0025] Figure 3 This is a flowchart of step S20 of the text correction processing method in one embodiment of the present invention;
[0026] Figure 4 This is a flowchart of step S50 of the text correction processing method in one embodiment of the present invention;
[0027] Figure 5 This is a schematic block diagram of a text correction processing device in one embodiment of the present invention;
[0028] Figure 6 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0029] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0030] The text correction processing method provided in this embodiment of the invention can be applied to, for example... Figure 1 In the application environment shown. Specifically, this text correction processing method is applied in a text correction processing device, which includes, as shown in the example. Figure 1 The client and server shown communicate over a network to improve the low accuracy of text correction caused by the underutilization of character information in existing technologies. The server can be a standalone server or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The client, also known as the user terminal, refers to the program that provides categorized services to customers, corresponding to the server. The client can be installed on, but is not limited to, various computers, laptops, smartphones, tablets, and portable wearable devices.
[0031] In one embodiment, such as Figure 2 As shown, a text error correction processing method is provided, which is applied to... Figure 1 Taking the server in the example, the following steps are included:
[0032] S10, Obtain the text to be corrected; the text to be corrected refers to the scanned image.
[0033] Understandably, the text to be corrected is obtained by OCR recognition technology from paper documents. This text can be retrieved from different databases; that is, user-uploaded materials are categorized and stored in different databases, meaning it can be sent from the client to the server. For example, it could be obtained from an insurance company's claims system, where user-uploaded claim documentation is an image obtained by scanning a paper document using OCR recognition technology.
[0034] S20, Obtain the text correction model, and extract features from the text to be corrected through the feature layer of the text correction model to obtain position features, image features and character shape features.
[0035] Understandably, the text correction model's model structure is constructed and trained using a combination of the Chinese-BERT-base structure and the LayoutLM structure.
[0036] Specifically, the trained text correction model is retrieved, and the text to be corrected is input into the model. Then, the feature layer of the text correction model extracts features from the text. First, the bounding boxes of each word in the OCR recognition results are used to divide the text image into several parts, with each segment corresponding to a word. Next, the Faster R-CNN model is used to generate image region features as the image features for each text character. The layoutLM method is used to extract positional features from the text correction model, that is, by defining the coordinates of the top-left and bottom-right corners of the bounding box of each word, the positional features of each text character in the text to be corrected are obtained. Finally, the embedding layer embeds each text character in the text to be corrected, thereby obtaining the glyph features corresponding to each text character.
[0037] S30, through the annotation layer of the text correction model, the original text in the text to be corrected is annotated with errors according to the position features, the image features and the glyph features, to obtain at least one erroneous text corresponding to the text to be corrected.
[0038] Understandably, "error text" refers to the text marked as incorrectly identified. "Text text" refers to the text within the text to be corrected.
[0039] Specifically, after obtaining the positional features, image features, and glyph features, the positional features, image features, and glyph features corresponding to each text character are input into the annotation layer. The annotation layer of the text correction model performs error prediction based on the mask prediction function and the positional features, image features, and glyph features corresponding to each text character. That is, it predicts the text characters through the mask function and compares the predicted characters with the positional features, image features, and glyph features corresponding to each text character, thereby obtaining at least one erroneous character corresponding to the text to be corrected. For example, in an insurance scenario, the result of recognizing the uploaded supporting documents is used to mark errors through the annotation layer of the text correction model to obtain the erroneous characters in the supporting documents and their corresponding error locations.
[0040] S40, decompose each of the erroneous characters into strokes to obtain the character strokes corresponding to each of the erroneous characters.
[0041] S50, the strokes of each erroneous character are matched using a preset dictionary of similar-looking characters to obtain candidate characters corresponding to each erroneous character.
[0042] Specifically, each erroneous character is decomposed into its strokes using the iQiyi character stroke decomposition method. This involves treating each stroke of each character as a feature to obtain the corresponding character strokes. Next, a preset dictionary of similar-looking characters is retrieved, and the strokes of each erroneous character are matched against the similar-looking characters in the dictionary. A preset number of similar-looking characters with high similarity are then decomposed into their corresponding similar strokes. Next, the similar strokes of each similar-looking character are matched against the strokes of the erroneous character to obtain a similarity value. All similarity values are compared to a preset similarity threshold. When a similarity value is greater than or equal to the preset threshold, the similar-looking character corresponding to that value is identified as a candidate character corresponding to the erroneous character.
[0043] S60, select the target text from all the candidate texts corresponding to each of the erroneous texts, and replace the erroneous texts with the target texts to obtain the target text.
[0044] Furthermore, the probability value corresponding to each candidate text is obtained. This involves ranking all candidate texts based on their similarity to the erroneous text, and then sequentially substituting the candidate texts into the position of the erroneous text according to the ranking result for semantic prediction, thus obtaining the probability value. Based on all probability values, all candidate texts are filtered, and the candidate text with the highest probability value is determined as the target text. This yields the target text corresponding to the erroneous text.
[0045] This invention provides a text correction processing method that extracts features from the scanned text to be corrected using the feature layer of a text correction model, achieving the extraction of positional features, image features, and glyph features. Through the annotation layer of the text correction model, errors are marked in the text to be corrected based on positional features, image features, and glyph features, thus identifying erroneous characters and further breaking them down into their strokes. A pre-set dictionary of similar-looking characters is used to match the strokes of each erroneous character, determining candidate characters and filtering target characters. The target characters are then replaced with their corresponding characters, achieving the acquisition of the target text and ensuring the accuracy of information entered in the insurance field. Furthermore, the pre-set dictionary of similar-looking characters is used to match the strokes of each erroneous character, achieving character matching based on stroke information, which improves the accuracy of text correction during information entry in the insurance field.
[0046] In one embodiment, before step S50, that is, before matching the strokes of each of the erroneous characters using a preset dictionary of similar-looking characters, the following steps are included:
[0047] S701, the strokes of all preset characters in the preset character list are decomposed and annotated using the character stroke decomposition method to obtain annotated characters, and the annotated characters are recalled to obtain at least one first recalled character.
[0048] Understandably, the labeled text refers to the marked text, which can be manually labeled through a third-party platform. The first recalled text refers to similar text recalled through the first method. The preset character list is pre-set and includes a preset number of characters (e.g., 20,000).
[0049] Specifically, before obtaining the preset dictionary of similar-looking characters, a preset character list is retrieved from the database. This preset character list is then sent to a third-party platform. Staff retrieve the preset character list from the platform and use a stroke-based character decomposition method to annotate all the preset characters in the list. This involves first classifying the characters according to their radicals or clustering their image features. Then, similar-looking characters within each category are annotated using the stroke-based character decomposition method, resulting in annotated characters corresponding to each preset character. These annotated characters are then fed back to the server's database. The annotated characters are extracted from the database, and a character recall process is performed on all annotated characters. This involves recalling similar characters corresponding to each annotated character, thus obtaining at least one primary recalled character.
[0050] S702, obtain the output value of the image feature processing of similar characters by the preset classification model.
[0051] S703, when each of the output values is greater than or equal to a preset threshold, the similar text corresponding to the image features of each of the output values is determined as the second recall text.
[0052] S704, obtain a common error confusion set, and construct a preset dictionary of similar-looking characters based on all the first recalled characters, all the second recalled characters, and the common error confusion set.
[0053] Understandably, the second recalled text refers to similar text recalled through the second method. Commonly used error obfuscation sets are those frequently encountered in manually mined OCR systems.
[0054] Specifically, obtain the output value of the preset classification model for processing the image features of similar characters, that is, obtain the output value of the logit layer of the cnn classification model for classifying and predicting each similar character. Compare the output values of each preset character with a preset threshold. When the output value is less than the preset threshold, delete the similar character corresponding to the image feature of the output value. When the output value is greater than or equal to the preset threshold, determine the similar character corresponding to the image feature of the output value as the second recalled character. In this way, all the second recalled characters can be obtained. Further, obtain the commonly used error confusion set mined manually from the database. Then, remove the duplicates from all the first recalled characters, all the second recalled characters, and the characters in the commonly used error confusion set, that is, delete the duplicate characters in all the characters obtained by the three methods, and the preset dictionary of similar characters with similar shapes can be constructed. For example, if the first recalled character is the character "不" and the second recalled character is the character "还", there may be duplicate characters such as 下, 丕, 坏, 怀, 坯, etc. Therefore, it is necessary to remove the duplicates and then construct the preset dictionary of similar characters with similar shapes.
[0055] In the embodiment of the present invention, the stroke decomposition and annotation are performed on the glyphs by the glyph stroke decomposition method, and the determination of the annotated characters is realized. The first recalled characters are recalled by performing character recall on the annotated characters. By determining the similar characters corresponding to the image features of each output value as the second recalled characters, the recall of the second recalled characters is realized, and then the construction of the preset dictionary of similar characters with similar shapes is realized.
[0056] In one embodiment, as Figure 3 shown, before step S20, that is, before obtaining the text error correction model, it includes:
[0057] S201: Obtain at least one initial character, perform error annotation on all the initial characters through a preset training model, and determine the sample error character and its corresponding sample error position.
[0058] It can be understood that the initial characters are obtained by performing OCR recognition on a paper document. For example, in an insurance scenario, the initial characters can be an accident liability determination letter, or a hospitalization expense list and a hospitalization record, etc. The error characters are the initial characters with incorrect OCR recognition, such as similar characters with similar shapes like 止 and 上. The sample error position is obtained by referring to the layoutlm method, and the horizontal and vertical coordinates of the characters are respectively normalized to 0 - 1000. In this embodiment, it is the center point coordinates of the error characters.
[0059] Specifically, obtain the uploaded paper document and perform OCR recognition on the paper document. That is, first scan the paper document to obtain the corresponding image for each page, binarize the image, that is, separate the foreground and background of the image, and then denoise the image. Then, perform skew correction on the denoised image to obtain a corrected image. Analyze the corrected image. That is, this step is to determine the coordinates of each character. First, divide the document in the corrected image into paragraphs. That is, the two-dimensional position embedding first models the relative spatial positions in the document, and regards the document page as a coordinate system with the upper left corner as the origin. Therefore, a bounding box can be defined by (x0, y0, x1, y1), where (x0, y0) corresponds to the position of the upper left corner of the bounding box, and (x1, y1) represents the lower right corner position of the bounding box. Use 2 embedding tags for 4 position embedding layers. Embedding layers with the same dimension use embedding tags with the same dimension. The embedding tags can be viewed in the definitions in tensorflow or pytorch. For example, the 2 embedding tag names are X and Y. Find the position embeddings of x0 and x1 in X, and find the position embeddings of y0 and y1 in Y to determine the character coordinates of each character. Then, cut the characters of each paragraph through the bounding box. That is, divide each character into an independent rectangular box, and the image features can be obtained. Use the four-point coordinates of the character to cut out the sub-image within the corresponding rectangular box in the picture, and the initial character can be obtained. Vectorize the initial character through the Embedding layer to obtain the character vector. In this way, the character vector, image features and character coordinates can be obtained. Perform error annotation on all the initial characters through a preset training model. That is, perform error annotation on the initial characters, character vectors, image features and character coordinates. That is, use the masked prediction function in the Chinese bert-base model to perform error prediction, and the sample error characters and their corresponding sample error positions can be obtained. For example, in an insurance scenario, the result after recognizing the uploaded supporting documents is error-annotated through a preset training model, and the sample error characters and their corresponding sample error positions in the supporting documents can be obtained.
[0060] S202: Obtain a preset dictionary of similar characters, and perform character matching on each of the sample error characters through the preset dictionary of similar characters to obtain sample candidate characters corresponding to each of the sample error characters; one sample error character corresponds to at least one sample candidate character.
[0061] Understandably, the sample candidate characters are similar similar characters to each sample error character. For example, similar characters such as "不", "丕", "还", etc. Each sample error character corresponds to at least one sample candidate character. The preset dictionary of similar characters is obtained by performing character recall according to a preset character list.
[0062] Specifically, retrieve a preset dictionary of similar Chinese characters from the database, and perform character matching on each sample of incorrect characters through the preset dictionary of similar Chinese characters. That is, perform similarity matching on the strokes of each similar Chinese character in the preset dictionary of similar Chinese characters and the character strokes of each sample of incorrect characters, so as to obtain the sample character similarity value corresponding to each similar Chinese character. Compare all the sample character similarity values with the preset sample similarity threshold respectively. When the sample character similarity value is less than the preset sample similarity threshold, delete the similar Chinese character corresponding to the sample character similarity value. When the sample character similarity value is greater than or equal to the preset sample similarity threshold, determine the similar Chinese character corresponding to the sample character similarity value as the sample candidate character corresponding to the sample of incorrect characters. For example, in a financial scenario where it is necessary to identify a paper document, the sample candidate characters of the character "且" include "旦" with a similarity of 0.89, "早" with a similarity of 0.82, "日" with a similarity of 0.78, "曰" with a similarity of 0.78, and so on.
[0063] S203. Screen out sample target characters from all the sample candidate characters corresponding to each sample of incorrect characters; each sample of incorrect characters corresponds to one sample target character.
[0064] It can be understood that the sample target character is the character selected as the closest through a preset training model.
[0065] Specifically, screen out target characters from all the candidate characters corresponding to each incorrect character, that is, screen out a preset number of candidate characters through the similarity value between the candidate characters and the incorrect characters, and then calculate the probability value corresponding to each candidate character based on the association between the candidate characters and the context. Then, screen out target characters from all the candidate characters corresponding to each incorrect character based on the probability value, that is, determine the candidate character with the largest probability value as the sample target character. Each sample of incorrect characters corresponds to one sample target character. For example, in the insurance field, when the proof material is an accident liability recognition document, for the character "不" that does not bear responsibility, it is recognized as the character "丕". By screening out candidate characters and then according to the association between the similarity value and the context, the probability value of the character "不" is determined to be 99%, the probability value of the character "还" is 88%, the probability value of the character "怀" is 60%, the probability value of the character "坏" is 30%, and so on, and thus the target character can be determined to be the character "不".
[0066] S204: Determine the prediction loss value of the preset training model according to the preset replacement character, the sample target character, the sample incorrect position, and the preset replacement position.
[0067] It can be understood that the prediction loss value is generated during the process of character error correction. The preset replacement character and the preset replacement position can be determined manually or obtained through other error correction methods.
[0068] Specifically, after obtaining the target text, loss calculations are performed on the target text and the preset replacement text corresponding to the same erroneous text to obtain the text loss value of the erroneous text. Then, the text loss value of each erroneous text is calculated, and the text loss values of all erroneous texts are summed to obtain the first loss value. Next, loss calculations are performed on the error position and the preset replacement position corresponding to the same erroneous text to obtain the position loss value of the erroneous text. Then, the position loss value of each erroneous text is calculated, and the position loss values of all erroneous texts are summed to obtain the second loss value. Finally, a predicted loss value is calculated based on the first and second loss values. For example, in an insurance claims scenario, after OCR recognition of uploaded materials, loss values are calculated on the target text and the preset replacement text corresponding to all erroneous texts in the materials. For example, by calculating the similarity between the target text and the preset replacement text, the loss value of the erroneous text is determined, and the first loss value is obtained by weighted summing of all loss values. The loss value is calculated for the sample error position and the preset replacement position corresponding to each sample error text in the data. That is, it is determined whether all sample error positions are the same as the corresponding preset replacement positions, and then the second loss value can be calculated.
[0069] S205: When the predicted loss value reaches the preset convergence condition, the preset training model after convergence is recorded as a text error correction model.
[0070] Understandably, the convergence condition can be either the predicted loss value being less than a set threshold, or the predicted loss value being very small after 500 calculations and no longer decreasing, at which point training can stop.
[0071] Specifically, after obtaining the predicted loss value, if the predicted loss value does not reach the preset convergence condition, the initial parameters of the preset training model are adjusted based on the predicted loss value. All initial text, preset replacement text, and preset replacement positions are then re-input into the preset training model with adjusted initial parameters. Iterative training is then performed on the preset training model with adjusted initial parameters to obtain the predicted loss value corresponding to the adjusted preset training model. Then, if the predicted loss value does not reach the preset convergence condition, the initial parameters of the preset training model are adjusted again based on the predicted loss value, so that the predicted loss value of the preset training model with adjusted initial parameters reaches the preset convergence condition. In this way, the error correction result of the preset training model continuously approaches the correct result, resulting in increasingly higher accuracy, until the predicted loss value reaches the preset convergence condition. At this point, the converged preset training model is determined as the text correction model.
[0072] In one embodiment, step SS204, namely determining the prediction loss value of the preset training model based on the preset replacement text, the sample target text, the sample error position, and the preset replacement position, includes:
[0073] S2041, determine a first loss value based on the preset replacement position and the sample error position corresponding to the same sample error text.
[0074] Understandably, the first loss is generated during the process of predicting the sampled incorrect locations of the initial text.
[0075] Specifically, after obtaining the target text, all error positions corresponding to the same error text are arranged according to the order of the text coordinates of the error text. Then, the preset replacement position is compared with the error positions of the same sequence. That is, according to the sorting of the error text, the preset replacement position located first is compared with the error position located first, and the loss value between the preset replacement position and the error position is calculated by the loss function. Then, the preset replacement position located second is compared with the error position located second, until all preset replacement positions and all error positions have been compared. The position loss values of all error texts are added together to obtain the first loss value. For example, in an insurance scenario, the preset replacement positions are the center coordinates of the characters in the 5th row and 8th column, the 8th row and 11th column, the 13th row and 2nd column, the 18th row and 6th column, and the 23rd row and 25th column. The model predicts the error positions as the center coordinates of the characters in the 5th row and 8th column, the 9th row and 15th column, the 13th row and 2nd column, the 18th row and 6th column, and the 22nd row and 24th column. By calculating the difference between all preset replacement positions and all error positions, the first loss value can be calculated.
[0076] S2042, determine a second loss value based on the preset replacement text corresponding to the same sample error text and the sample target text.
[0077] Understandably, the second loss value is generated during the prediction of erroneous characters in the initial text sample.
[0078] Specifically, all the sample target texts corresponding to the same sample error text are arranged in the order of the text coordinates of the sample error text, and then the preset replacement text is compared with the sample target text with the same sequence; that is, according to the sorting of the sample error text, the first preset replacement text is compared with the first sample target text, and the loss value between the preset replacement text and the sample target text is calculated through the loss function; then the second preset replacement text is compared with the second sample target text until all the preset replacement texts and all the sample target texts are compared. By adding up the text loss values of all the sample error texts, the second loss value can be obtained. For example, in an insurance scenario, the preset replacement texts are "no", "and", "special", "and", and "world", and the target texts are "pi", "and", "special", "dawn", and "world". Thus, according to the gap between all the preset replacement texts and all the target texts, the second loss value can be calculated.
[0079] S2043. Based on the first loss value and the second loss value, determine the prediction loss value of the preset training model.
[0080] Specifically, based on the first loss value and the second loss value, determine the prediction loss value of the preset training model. That is, the prediction loss value can be calculated by directly adding the first loss value and the second loss value. Or, obtain the preset first weight and second weight, multiply the first loss value by the first weight, multiply the second loss value by the second weight, and add the two multiplication results to obtain the prediction loss value.
[0081] In the embodiment of the present invention, by calculating the loss value for all the preset replacement positions and sample error positions corresponding to the same sample error text, the determination of the first loss value is realized. By comparing all the preset replacement texts and sample target texts corresponding to the same sample error text, the determination of the second loss value is realized. Through the first loss value and the second loss value, the determination of the prediction loss value of the preset training model is realized.
[0082] In one embodiment, as Figure 4 shown, in step S50, that is, by using the preset similar-character dictionary to perform text matching on the text strokes of each of the error texts to obtain candidate texts corresponding to each of the error texts, including:
[0083] S501. Perform similarity matching on the strokes of each similar character in the preset similar-character dictionary and the text strokes of each of the error texts to obtain a text similarity value corresponding to each similar character.
[0084] S502. When the text similarity value is greater than or equal to the preset similarity threshold, determine the similar character corresponding to the text similarity value as the candidate text corresponding to the error text.
[0085] Specifically, after obtaining the character strokes, a preset dictionary of similar-looking characters is retrieved from the database. The strokes of each similar-looking character in the dictionary are then matched against the strokes of the incorrect characters. This involves first using character shape features and image features to match a preset number of similar-looking characters with high similarity to the incorrect characters. Then, the strokes of all matched similar-looking characters are matched against the strokes of each incorrect character. This involves calculating the similarity between all strokes of the two characters to obtain the character similarity value. A preset similarity threshold is obtained, and all character similarity values are compared to this threshold sequentially. If the character similarity value is less than the threshold, the matched similar-looking characters are deleted. If the character similarity value is greater than or equal to the threshold, the matched similar-looking characters are retained, and these are identified as candidate characters corresponding to the incorrect characters. This process selects at least one candidate character from all matched similar-looking characters that corresponds to each incorrect character.
[0086] In this embodiment of the invention, similarity matching is performed on the strokes of each similar-looking character in a preset dictionary of similar-looking characters and the strokes of each incorrect character to calculate the similarity value of the character corresponding to each similar-looking character. By comparing the character similarity value with a preset similarity threshold, candidate characters are determined.
[0087] In one embodiment, step S60, namely, selecting the target text from all the candidate texts corresponding to each of the erroneous texts, includes:
[0088] S601, Obtain the probability value corresponding to each of the candidate characters.
[0089] S602, based on all the probability values, all the candidate characters are filtered to obtain the target character corresponding to the erroneous character.
[0090] Understandably, the probability value is obtained by matching similar-looking characters.
[0091] Specifically, after obtaining the candidate characters, the similarity values corresponding to each candidate character are obtained, and all candidate characters are sorted according to the magnitude of the similarity values. The first preset number of candidate characters with higher similarity are selected, and each selected candidate character is brought into the context of the position corresponding to the incorrect character for probability prediction. In this way, the probability values corresponding to each candidate character can be obtained. Then, all the candidate characters are screened based on all the probability values, that is, all the probability values are compared in size, sorted in descending order, and the candidate characters corresponding to each probability value are sorted according to the size of the probability value. The candidate character with the largest probability value is selected as the target character corresponding to the incorrect character. In this way, all the target characters are determined in turn through the above method. For example, in the insurance claim settlement scenario, for the correction of the identification result of the supporting materials, the candidate characters corresponding to the incorrect character "丕" are "不", "怀", "坏", "还", etc. Through context probability prediction, the probability value of "不" is 0.95, the probability value of "怀" is 0.83, the probability value of "坏" is 0.76, and the probability value of "还" is 0.68. In this way, the candidate sorting result can be obtained, and "不" is selected as the target character from the candidate sorting result.
[0092] In the embodiment of the present invention, based on the probability values corresponding to each candidate character, the target character corresponding to the incorrect position is screened out from all the candidate characters corresponding to each incorrect character, thereby improving the accuracy of the target character.
[0093] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0094] In one embodiment, a text error correction processing device is provided, and the text error correction processing device corresponds to the text error correction method in the above embodiment one by one. As Figure 5 shown, the text error correction processing device includes a text acquisition module 10, a feature extraction module 20, an error annotation module 30, a stroke decomposition module 40, a character matching module 50, and a character replacement module 60. The detailed description of each functional module is as follows:
[0095] The text acquisition module 10 is used to acquire the text to be error-corrected; the text to be error-corrected refers to the scanned image;
[0096] The feature extraction module 20 is used to acquire a text error correction model, and perform feature extraction on the text to be error-corrected through the feature layer of the text error correction model to obtain position features, image features, and glyph features;
[0097] Error annotation module 30 is used to annotate the text characters in the text to be corrected according to the position features, the image features and the glyph features through the annotation layer of the text correction model, so as to obtain at least one erroneous character corresponding to the text to be corrected;
[0098] The stroke decomposition module 40 is used to decompose each of the erroneous characters into strokes to obtain the character strokes corresponding to each of the erroneous characters.
[0099] The text matching module 50 is used to perform text matching on the strokes of each of the erroneous characters using a preset dictionary of similar-looking characters, so as to obtain candidate characters corresponding to each of the erroneous characters.
[0100] The text replacement module 60 is used to filter out target text from all candidate texts corresponding to each of the erroneous texts, and replace the erroneous texts with the target texts to obtain target text.
[0101] In one embodiment, the feature extraction module 20 includes:
[0102] An error labeling unit is used to acquire at least one initial text, label all the initial texts with errors using a preset training model, and determine the sample error text and its corresponding sample error location.
[0103] The text matching unit is used to obtain a preset dictionary of similar-looking characters, and to perform text matching on each of the sample error characters through the preset dictionary of similar-looking characters to obtain sample candidate characters corresponding to each of the sample error characters; one sample error character corresponds to at least one sample candidate character.
[0104] A text filtering unit is used to filter out target text from all candidate texts corresponding to each of the sample error texts; each sample error text corresponds to one target text.
[0105] The loss prediction unit is used to determine the predicted loss value of the preset training model based on the preset replacement text, the target text of the sample, the error position of the sample, and the preset replacement position.
[0106] The model convergence unit is used to record the converged preset training model as a text correction model when the predicted loss value reaches the preset convergence condition.
[0107] In one embodiment, the loss prediction unit further includes:
[0108] The first loss unit is used to determine a first loss value based on the preset replacement position and the sample error position corresponding to the same sample error text;
[0109] The second loss unit is used to determine a second loss value based on the preset replacement text and the target text of the sample corresponding to the same sample error text;
[0110] The loss prediction unit is used to determine the predicted loss value of the preset training model based on the first loss value and the second loss value.
[0111] In one embodiment, the text replacement module 60 includes:
[0112] A probability value unit is used to obtain the probability value corresponding to each of the candidate characters;
[0113] The text filtering unit is used to filter all the candidate texts based on all the probability values to obtain the target text corresponding to the erroneous text.
[0114] In one embodiment, the text matching module 50 includes:
[0115] The first recall unit is used to decompose and annotate all the preset characters in the preset character list by stroke decomposition method to obtain annotated characters, and to recall the annotated characters to obtain at least one first recalled character.
[0116] The output value unit is used to obtain the output value of the image feature processing of similar characters by the preset classification model;
[0117] The second recall unit is used to determine the similar text corresponding to the image features of each output value as the second recall text when each output value is greater than or equal to a preset threshold.
[0118] The dictionary construction unit is used to obtain a common error confusion set and construct a preset dictionary of similar-looking characters based on all the first recalled characters, all the second recalled characters and the common error confusion set.
[0119] In one embodiment, the text matching module 50 further includes:
[0120] The similarity matching unit is used to perform similarity matching on the strokes of each similar character in the preset similar character dictionary and the strokes of each incorrect character to obtain the character similarity value corresponding to each similar character;
[0121] The candidate character unit is used to determine the similar-looking characters corresponding to the character similarity value as candidate characters corresponding to the erroneous character when the character similarity value is greater than or equal to a preset similarity threshold.
[0122] Specific limitations regarding the text correction processing device can be found in the limitations of the text correction processing method described above, and will not be repeated here. Each module in the aforementioned text correction processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0123] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system, computer programs, and the database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores data used in the text correction processing method described in the above embodiments. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a text correction processing method.
[0124] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described text correction processing method.
[0125] In one embodiment, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described text correction processing method.
[0126] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0127] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0128] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A text error correction processing method, characterized in that, include: Obtain the text to be corrected; the text to be corrected refers to the scanned image. A text correction model is obtained, and features are extracted from the text to be corrected through the feature layer of the text correction model to obtain positional features, image features, and glyph features; wherein, the positional features refer to the coordinate positions of the upper left and lower right corners of the bounding box of each word; Through the annotation layer of the text correction model, errors are marked on the text characters in the text to be corrected based on the position features, the image features and the glyph features, to obtain at least one erroneous character corresponding to the text to be corrected; Each of the aforementioned erroneous characters is broken down into its strokes to obtain the corresponding character strokes; By matching the strokes of each erroneous character with a pre-set dictionary of similar-looking characters, candidate characters corresponding to each erroneous character are obtained. Target text is selected from all candidate texts corresponding to each of the erroneous texts, and the erroneous texts are replaced according to the target texts to obtain the target text; Before performing character matching on the strokes of each erroneous character using a preset dictionary of similar-looking characters, the process includes: The stroke decomposition method is used to decompose and annotate all the preset characters in the preset character list to obtain annotated characters. Then, the annotated characters are recalled to obtain at least one first recalled character. Obtain the output values of the image feature processing of similar characters by the preset classification model; When each of the output values is greater than or equal to a preset threshold, the similar text corresponding to the image features of each of the output values is determined as the second recall text; Obtain a set of commonly used error obfuscations, and construct a preset dictionary of similar-looking characters based on all the first recalled characters, all the second recalled characters, and the set of commonly used error obfuscations.
2. The text correction processing method as described in claim 1, characterized in that, The step of matching the strokes of each erroneous character with a preset dictionary of similar-looking characters to obtain candidate characters corresponding to each erroneous character includes: The strokes of each similar character in the preset similar character dictionary and the strokes of each incorrect character are matched to obtain the character similarity value corresponding to each similar character; When the text similarity value is greater than or equal to a preset similarity threshold, the similar-looking characters corresponding to the text similarity value are determined as candidate characters corresponding to the erroneous characters.
3. The text correction processing method as described in claim 1, characterized in that, The step of filtering the target text from all the candidate texts corresponding to each of the erroneous texts includes: Obtain the probability value corresponding to each of the candidate characters; Based on all the probability values, all the candidate characters are filtered to obtain the target characters corresponding to the erroneous characters.
4. The text correction processing method as described in claim 1, characterized in that, Before obtaining the text correction model, the following steps are also included: Obtain at least one initial text, and use a preset training model to label all the initial text with errors, thereby determining the sample error text and its corresponding sample error location; A preset dictionary of similar-looking characters is obtained, and the sample error characters are matched with the preset dictionary of similar-looking characters to obtain sample candidate characters corresponding to each sample error character; one sample error character corresponds to at least one sample candidate character. Select target text from all candidate texts corresponding to each of the aforementioned erroneous texts; each erroneous text corresponds to one target text. The prediction loss value of the preset training model is determined based on the preset replacement text, the target text of the sample, the error position of the sample, and the preset replacement position. When the predicted loss value reaches the preset convergence condition, the preset training model after convergence is recorded as a text correction model.
5. The text correction processing method as described in claim 4, characterized in that, The step of determining the prediction loss value of the preset training model based on the preset replacement text, the sample target text, the sample error position, and the preset replacement position includes: A first loss value is determined based on the preset replacement position and the sample error position corresponding to the same sample error text; A second loss value is determined based on the preset replacement text and the target text of the sample corresponding to the same erroneous text in the sample. Based on the first loss value and the second loss value, the predicted loss value of the preset training model is determined.
6. A text correction processing device, characterized in that, include: The text acquisition module is used to acquire the text to be corrected; the text to be corrected refers to the scanned image. The feature extraction module is used to obtain a text correction model, and to extract features from the text to be corrected through the feature layer of the text correction model to obtain position features, image features and glyph features. The error annotation module is used to annotate the text characters in the text to be corrected based on the location features, image features and glyph features through the annotation layer of the text correction model, so as to obtain at least one erroneous character corresponding to the text to be corrected; The stroke decomposition module is used to decompose each of the erroneous characters into strokes to obtain the character strokes corresponding to each of the erroneous characters. The text matching module is used to perform text matching on the strokes of each of the erroneous characters using a preset dictionary of similar-looking characters, and to obtain candidate characters corresponding to each of the erroneous characters; The text replacement module is used to filter out target text from all candidate texts corresponding to each of the erroneous texts, and replace the erroneous texts with the target texts to obtain the target text; The text matching module includes: The first recall unit is used to decompose and annotate all the preset characters in the preset character list by stroke decomposition method to obtain annotated characters, and to recall the annotated characters to obtain at least one first recalled character. The output value unit is used to obtain the output value of the image feature processing of similar characters by the preset classification model; The second recall unit is used to determine the similar text corresponding to the image features of each output value as the second recall text when each output value is greater than or equal to a preset threshold. The dictionary construction unit is used to obtain a common error confusion set and construct a preset dictionary of similar-looking characters based on all the first recalled characters, all the second recalled characters and the common error confusion set.
7. The text correction processing apparatus as described in claim 6, characterized in that, The feature extraction module further includes: An error labeling unit is used to acquire at least one initial text, label all the initial texts with errors using a preset training model, and determine the sample error text and its corresponding sample error location. The text matching unit is used to obtain a preset dictionary of similar-looking characters, and to perform text matching on each of the sample error characters through the preset dictionary of similar-looking characters to obtain sample candidate characters corresponding to each of the sample error characters; one sample error character corresponds to at least one sample candidate character. A text filtering unit is used to filter out target text from all candidate texts corresponding to each of the sample error texts; each sample error text corresponds to one target text. The loss prediction unit is used to determine the predicted loss value of the preset training model based on the preset replacement text, the target text of the sample, the error position of the sample, and the preset replacement position. The model convergence unit is used to record the converged preset training model as a text correction model when the predicted loss value reaches the preset convergence condition.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the text correction processing method as described in any one of claims 1 to 5.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the text correction processing method as described in any one of claims 1 to 5.