Text error correction method, device, electronic device and storage medium
By automatically identifying and replacing erroneous characters in OCR, combined with feature matching and rollback mechanisms, it solves the problem of low error correction efficiency caused by OCR recognition errors, achieves efficient automatic error correction, reduces human resource consumption and improves accuracy. .
Patent Information
- Application Number
- CN202110598406.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-28
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-05-28
AI Technical Summary
OCR technology has fixed errors in the character recognition process, resulting in low error correction efficiency and requiring a large amount of manpower for repetitive modifications.
By automatically identifying erroneous characters, obtaining their characteristics, matching and replacing erroneous characters, automatic error correction is achieved, and rollback is performed during the replacement process, reducing manpower consumption and improving error correction efficiency.
Automatic error correction of recognized text is realized, reducing the consumption of human resources, improving error correction efficiency, and ensuring the accuracy of automatic error correction.
Smart Images

Figure CN113283233B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular, to a text error correction method, device, electronic device, and storage medium. Background Art
[0002] Optical Character Recognition (OCR) is a process of electronically scanning an input image and extracting text therefrom. Compared with manually typing text, it has a faster input speed, can save a large amount of human resources, and can also be used for automated recognition in various fields such as license plate recognition, ID card recognition, bank card recognition, etc.
[0003] However, OCR will have fixed errors in the recognition of certain characters. Therefore, manual error correction is required for the text after OCR. For example, taking the OCR recognition in the process of converting a PDF file to a Word file by Adobe Acrobat DC as an example, in the OCR recognition process, "基于" is always recognized as "晶千", "由此" as "山此", and "基础" as "辈础". Therefore, in the process of converting a large number of files, proofreaders need to repeatedly modify such errors, which requires a large amount of manpower and has a low error correction efficiency. Summary of the Invention
[0004] In order to solve the above problems existing in the prior art, the embodiments of the present application provide a text error correction method, device, electronic device, and storage medium, which can automatically identify error characters and replace them, and automatically roll back the replaced error places, reducing the consumption of manpower while improving the error correction efficiency.
[0005] In a first aspect, an embodiment of the present application provides a text error correction method, including:
[0006] Replacing a first character in the recognized text with a second character;
[0007] Adding an identifier to the second character obtained by replacing the first character in the recognized text;
[0008] Determining a second character to be error-corrected among the second characters with identifiers in the recognized text according to adjacent characters of the second characters with identifiers in the recognized text;
[0009] Obtaining features of the second character to be error-corrected;
[0010] Replacing the second character in the recognized text with the identifier that matches the features of the second character to be error-corrected with the first character to obtain the error-corrected recognized text.
[0011] In a second aspect, an embodiment of the present application provides a text error correction device, comprising:
[0012] A character replacement module, used to replace a first character in the recognized text with a second character;
[0013] A character identification module, used to add an identification to a second character obtained by replacing the first character in the recognized text;
[0014] A character determination module, used for determining a second character to be corrected in the second character with the mark in the recognized text according to adjacent characters of the second character with the mark in the recognized text;
[0015] A feature determination module, used for obtaining a feature of a second character to be corrected;
[0016] The character replacement module is also used to replace the second character with the mark in the recognized text that matches the feature of the second character to be corrected with the first character to obtain the recognized text after correction.
[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, the processor is connected to a memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device performs the method of the first aspect.
[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program enables a computer to execute the method of the first aspect.
[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and is computer-operable to cause the computer to execute the method of the first aspect.
[0020] The implementation of the present application has the following beneficial effects:
[0021] In the implementation mode of the present application, the first character to be modified is automatically identified, and the second character after modification is automatically determined, thereby modifying the first character in the recognized text to the second character. Then, by adding a mark to the second character obtained by replacing the first character in the recognized text, it is determined that in the replacement process, the replacement error is automatically rolled back, that is, the second character with modification error is replaced back to the first character. In this way, automatic error correction of recognition errors in the recognized text can be achieved without manual error correction, which greatly reduces the consumption of human resources, improves the error correction efficiency, and ensures the accuracy of automatic error correction. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the implementation modes of the present application, the drawings required for use in the description of the implementation modes will be briefly introduced below. Obviously, the drawings described below are some implementation modes of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0023] Figure 1 A schematic diagram of the hardware structure of a text error correction device provided in an embodiment of the present application;
[0024] Figure 2 A flowchart of a text error correction method provided for an embodiment of the present application;
[0025] Figure 3 A flowchart of a method for determining a second character from a plurality of candidate characters based on adjacent characters of a first character provided in an embodiment of the present application;
[0026] Figure 4 A flowchart of a method for matching each first word vector in a plurality of first word vectors with word vectors of a plurality of template words in a preset word library, obtaining a plurality of first matching results corresponding to the plurality of template words, and determining a second character according to the plurality of first matching results, provided in an embodiment of the present application;
[0027] Figure 5 A schematic flow chart of a method for determining a fourth word from at least one third word provided in an embodiment of the present application;
[0028] Figure 6 A flow chart of a method for determining a second character to be corrected in a second character with a mark in a recognized text according to adjacent characters of the second character with a mark in the recognized text provided for an embodiment of the present application;
[0029] Figure 7 A flowchart of a method for obtaining a feature of a second character to be corrected provided in an embodiment of the present application;
[0030] Figure 8 A functional module composition block diagram of a text error correction device provided in an embodiment of the present application;
[0031] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0033] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0034] Reference to "embodiment" herein means that a particular feature, result, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0035] See also Figure 1 , Figure 1 The hardware structure diagram of a text error correction device provided in the embodiment of the present application is as follows: The text error correction device 100 includes at least one processor 101 , a communication line 102 , a memory 103 and at least one communication interface 104 .
[0036] In this embodiment, the processor 101 can be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.
[0037] The communication link 102 may include a path to transmit information between the above components.
[0038] The communication interface 104 may be any transceiver-like device (eg, antenna, etc.) for communicating with other devices or communication networks, such as Ethernet, RAN, wireless local area networks (WLAN), etc.
[0039] The memory 103 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.
[0040] In this embodiment, the memory 103 can exist independently and be connected to the processor 101 via the communication line 102. The memory 103 can also be integrated with the processor 101. The memory 103 provided in the embodiment of the present application can generally be non-volatile. Among them, the memory 103 is used to store computer-executable instructions for executing the scheme of the present application, and the execution is controlled by the processor 101. The processor 101 is used to execute the computer-executable instructions stored in the memory 103, so as to implement the method provided in the following embodiment of the present application.
[0041] In an optional implementation, the computer-executable instructions may also be referred to as application code, which is not specifically limited in this application.
[0042] In an optional embodiment, the processor 101 may include one or more CPUs, such as Figure 1 CPU0 and CPU1 in.
[0043] In an optional embodiment, the text correction device 100 may include multiple processors, such as Figure 1The processors 101 and 107 therein. Each of these processors can be a single-CPU processor or a multi-CPU processor. The processors here can refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).
[0044] In an alternative embodiment, if the text error correction device 100 is a server, the text error correction device 100 may further include an output device 105 and an input device 106. The output device 105 communicates with the processor 101 and can display information in various ways. For example, the output device 105 can be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector, etc. The input device 106 communicates with the processor 101 and can receive user input in various ways. For example, the input device 106 can be a mouse, a keyboard, a touch screen device, or a sensing device, etc.
[0045] The above-mentioned text error correction device 100 can be a general-purpose device or a special-purpose device. The embodiments of the present application do not limit the type of the text error correction device 100.
[0046] Refer to Figure 2 , Figure 2 FIG. is a schematic flowchart of a text error correction method provided by an embodiment of the present application. The text error correction method includes the following steps:
[0047] 201: Replace the first character in the recognized text with the second character.
[0048] In this embodiment, the first character refers to an incorrect character generated due to recognition error during the OCR recognition process, and the second character refers to the original correct character corresponding to the incorrect character generated due to recognition error. For example, during the OCR recognition process, if the original "基础" is recognized as "辈础", then "辈" is the first character, and the originally correct "基" is the second character.
[0049] In this embodiment, before performing step 201, it is also necessary to determine the first character in the recognized text and determine the second character according to the first character. Exemplarily, this embodiment provides a method for determining the first character in the recognized text, which is specifically as follows:
[0050] Determine the first character to be modified in the recognized text according to a preset error table. The error table is a record of characters with an OCR recognition error rate greater than a first threshold. For example, in OCR recognition, "基于" is often recognized as "晶千", "由此" as "山此", and "基础" as "辈础". Therefore, characters such as "基", "于", "由", etc. are common recognition error characters and are recorded in the error table.
[0051] Based on this, this embodiment also provides a method for determining a second character according to the first character, which is as follows:
[0052] First, determine the character group corresponding to the first character according to the error table.
[0053] Since in OCR recognition, misrecognition is usually fixed, in this embodiment, in addition to recording characters with an OCR recognition error rate greater than the first threshold in the error table, the character group corresponding to the character is also recorded. The character group includes multiple candidate characters corresponding to the character, and the probability of the multiple candidate characters being recognized as the character is greater than a second threshold during the OCR recognition process.
[0054] Exemplarily, for the misrecognized character "晶" generated by recognition, in OCR recognition, it is often caused by misrecognizing characters such as "基", "甚", "其", "塞", etc. Therefore, the character group corresponding to the misrecognized character "晶" is ["基", "甚", "其", "塞"].
[0055] Then, determine the second character from the multiple candidate characters according to the adjacent characters of the first character.
[0056] Exemplarily, a method for determining the second character from the multiple candidate characters according to the adjacent characters of the first character is provided, as Figure 3 shown, this method includes:
[0057] 301: Obtain a third character.
[0058] Exemplarily, the third character is the character adjacent to the first character in the recognized text. For example, it can be determined which character in the character group (i.e., the second character) the misrecognized character (i.e., the first character) should be modified to through the context of the misrecognized character. Specifically, for a certain sentence "下水道管网是一个城市的晶础设施" in the recognition result, after comparison with the error table, the first character can be obtained as "晶", and the previous character (the character adjacent to the first character on the left) "的" and the next character (the character adjacent to the first character on the right) "础" of "晶" are respectively obtained as the third character.
[0059] 302: Combine the third character and the first character in the order in the recognized text to obtain the first word.
[0060] Exemplarily, continuing with the above example of "The sewer network is the crystal infrastructure of a city", it is determined that the first character is "晶" (crystal), and the third characters are the character before "晶" (的, de) and the character after "晶" (础, chu). Therefore, by combining the third character and the first character in the order in the recognized text, the first words "的晶" (de crystal) and "晶础" (crystal chu) can be obtained.
[0061] 303: Replace the first character in the first word with each of the multiple candidate characters respectively to obtain multiple second words corresponding one by one to the multiple candidate characters.
[0062] Exemplarily, continuing with the above example of "The sewer network is the crystal infrastructure of a city", by querying the error table, the character group corresponding to the character "晶" (crystal) can be obtained as ["基" (base), "甚" (very), "其" (its), "塞" (plug)]. Using the characters in the character group to replace the character "晶" in the first word respectively, the second words can be obtained: "的基" (de base), "的甚" (de very), "的其" (de its), "的塞" (de plug), "基础" (base), "甚础" (very chu), "其础" (its chu), and "塞础" (plug chu).
[0063] 304: Perform word embedding processing on each of the multiple second words respectively to obtain multiple first word vectors corresponding one by one to the multiple second words.
[0064] In an alternative embodiment, a method for determining the first word vector of a second word is provided as follows: First, determine the character vectors of each character in the composed second word, and then, according to the positions of each character in the composed second word, splice the character vectors of each character. Specifically, for the composed second word "基础" (base), first, determine the character vector A of the character "基" (base) and the character vector B of the character "础" (chu), and then, determine the positional relationship between the character "基" (base) and the character "础" (chu). Since the character "基" (base) is located on the left of the character "础" (chu), the splicing result is C = [A, B]. Finally, use this splicing result as the first word vector of this second word.
[0065] 305: For each of the multiple first word vectors, respectively match each word vector with the word vectors of multiple template words in the preset word library to obtain multiple first matching results corresponding one by one to the multiple template words, and determine the second character according to the multiple first matching results.
[0066] In this embodiment, a method for determining a second character is provided. For each of a plurality of first word vectors, each first word vector is respectively matched with word vectors of a plurality of template words in a preset word library to obtain a plurality of first matching results corresponding one by one to the plurality of template words, and the second character is determined according to the plurality of first matching results, as Figure 4 shown. The method includes:
[0067] 401: Calculate the first similarity between each first word vector and the word vector of each template word in the preset word library respectively, to obtain a plurality of first similarities corresponding one by one to the plurality of common words.
[0068] In this embodiment, the similarity is used as the matching result between each first word vector and the word vector of each template word in the preset word library. The preset word library stores a plurality of common template words with actual semantics. Thus, by calculating the similarity between each first word vector and the word vector of each template word in the preset word library, it can be quickly determined whether each first word vector corresponds to a word with actual semantics.
[0069] Exemplarily, the cosine value of the angle between each first word vector and the word vector of each template word can be calculated, and this cosine value is used as the similarity between each first word vector and the word vector of each template word.
[0070] Specifically, each first word vector A = [a1, a2,..., ai,..., an], and the word vector B of each template word = [b1, b2,..., bi,..., bn], where i = 1, 2,..., n.
[0071] Based on this, the cosine value of the angle can be expressed by formula ②:
[0072]
[0073] Among them, A·B represents the inner product of each first word vector A and the word vector B of each template word, || is the modulus symbol, |A| represents the modulus of each first word vector A, and |B| represents the modulus of the word vector B of each template word.
[0074] Further, the inner product of each first word vector A and the word vector B of each template word can be expressed by formula ③:
[0075]
[0076] Further, the modulus of each first word vector A can be expressed by formula ④:
[0077]
[0078] Finally, the cosine value of the angle is used as the similarity between each first word vector and the word vector of each template word. Exemplarily, the similarity between each first word vector and the word vector of each template word can be expressed by formula ⑤:
[0079] d=cosθ…………⑤
[0080] Since the range of cosine values is [-1, 1], the cosine value still has the property of being 1 when the two vectors are the same, 0 when they are orthogonal, and -1 when they are opposite in high dimensions. That is, the closer the cosine value is to 1, the closer the directions of the two vectors are; the closer it is to -1, the more opposite their directions are; and the closer it is to 0, the two vectors are nearly orthogonal, which can reflect the relative difference in the directions of the two vectors. Therefore, using the cosine value as the similarity between each first word vector and the word vector of each template word can accurately represent the similarity between each first word vector and the word vector of each template word.
[0081] 402: Using the largest first similarity among the multiple first similarities as the first score of each first word vector, to obtain multiple first scores corresponding to the multiple first word vectors one by one.
[0082] 403: Among the multiple first scores, the second word corresponding to the first word vector corresponding to the first score greater than the third threshold is taken as the third word to obtain at least one third word.
[0083] In this way, the words with actual semantics can be screened out from the second words.
[0084] 404: Determine a fourth word in the at least one third word, and use a character in the fourth word that is in the same position as the first character as the second character.
[0085] In this embodiment, if only one third word is obtained after screening in step 503, the third word can be directly determined as the fourth word. If multiple third words are obtained, the matching degree between each third word and the text to be recognized can be determined, and the third word with the highest matching degree is selected as the fourth word.
[0086] Exemplarily, in this embodiment, a method for determining a fourth word in at least one third word is provided, such as Figure 5 As shown, the method includes:
[0087] 501: In the recognized text, obtain the sentence where the first word is located to obtain the first sentence.
[0088] 502: For each third word in the at least one third word, replace the first word in the first sentence with each third word to obtain a plurality of second sentences corresponding to the plurality of third words one by one.
[0089] 503: Calculate the perplexity of each of the multiple second sentences separately to obtain multiple perplexities corresponding one-to-one to the multiple second sentences.
[0090] In this embodiment, the perplexity is used to describe the quality of a sentence. Generally speaking, the better a sentence is, the smaller the probability of confusion when people understand this sentence. On the contrary, the smaller the perplexity of a sentence, the smoother the grammar and the more coherent the semantics of this sentence, which belongs to a good sentence.
[0091] 504: Use the third word corresponding to the second sentence with the smallest perplexity among the multiple perplexities as the fourth word.
[0092] Thus, the optimal second character can be obtained, making the replaced recognized text have good grammar fluency and semantic coherence.
[0093] 202: Add an identifier to the second character obtained by replacing the first character in the recognized text.
[0094] In this embodiment, the operation of replacing all the first characters in the recognized text with this second character may modify the originally correct first characters into second characters, introducing new errors. Exemplarily, continuing with the above example of "The sewer network is the crystal infrastructure of a city", after the processing of step 201, all the characters '晶' in the recognized text are replaced with the character '基'. At this time, if there is a word '晶莹' in the text to be recognized, then through the above modification, this word will become '基莹', thus introducing new errors.
[0095] Therefore, in this embodiment, it is also necessary to add an identifier to the second character obtained by replacing the first character in the recognized text. Exemplarily, it can be identified by means of highlighting, so as to distinguish the second character obtained by replacing the first character from the original second characters in the recognized text.
[0096] 203: Determine the second character to be corrected among the second characters with identifiers in the recognized text according to the adjacent characters of the second characters with identifiers in the recognized text.
[0097] Exemplarily, the present application provides a method for determining the second character to be corrected among the second characters with identifiers in the recognized text according to the adjacent characters of the second characters with identifiers in the recognized text. As Figure 6 shown, this method includes:
[0098] 601: Obtain the fourth character.
[0099] Exemplarily, the fourth character is an adjacent character of the second character with an identifier in the recognition text, and the second character to be corrected in the second character with an identifier can be determined through the context of the second character with an identifier. Specifically, for a sentence "On the petals, there are dewdrops condensing on Jiying" in the text after the first error correction, the character "Ji" is the second character replaced during the first error correction and is highlighted. The previous character (the character adjacent to the left of the second character replaced during the first error correction) "zhe" and the next character (the character adjacent to the right of the second character replaced during the first error correction) "ying" are obtained as the fourth characters.
[0100] 602: Combine the fourth character and the second character with an identifier in the recognition text in the order in the recognition text to obtain a fifth word.
[0101] Exemplarily, following the above example of "On the petals, there are dewdrops condensing on Jiying", it is determined that the second character with an identifier is "Ji", and the fourth characters are the previous character "zhe" and the next character "ying" of "Ji". Therefore, by combining the fourth character and the second character with an identifier in the order in the recognition text, the fifth words "zheJi" and "JiYing" can be obtained.
[0102] 603: Perform word embedding processing on the fifth word to obtain a second word vector.
[0103] In this embodiment, the method for obtaining the second word vector is similar to the method for obtaining the first word vector in step 404 and will not be elaborated here.
[0104] 604: Calculate the second similarity between the second word vector and the word vectors of each of the multiple template words in the preset word library respectively to obtain multiple second similarities corresponding one by one to the multiple template words.
[0105] 605: Take the largest second similarity among the multiple second similarities as the second score of the second word vector.
[0106] In this embodiment, the method for obtaining the second similarity is similar to the method for obtaining the first similarity in step 401 and will not be elaborated here.
[0107] 606: When the second score is less than the fourth threshold, determine that the second character in the fifth word corresponding to the second word vector corresponding to the second score is the second character to be corrected.
[0108] In this embodiment, since the second score is less than the fourth threshold, it indicates that the fifth word corresponding to the second word vector is a word without actual semantics. Generally speaking, that is, the fifth word does not belong to the words defined in regular writing. Therefore, it can be determined that the second character in the fifth word corresponding to the second word vector corresponding to the second score is the second character to be corrected.
[0109] 204: Obtain the feature of the second character to be corrected.
[0110] In this embodiment, after determining the second character to be corrected, the feature of the second character to be corrected can be determined by determining the adjacent characters of the second character to be corrected. Exemplarily, the present application provides a method for obtaining the feature of the second character to be corrected, as Figure 7 shown, the method includes:
[0111] 701: Obtain the fifth character.
[0112] Exemplarily, the fifth character is the character adjacent to the second character to be corrected in the recognition text. For example, the feature of the second character to be corrected can be determined through the context of the second character to be corrected. Specifically, for a sentence "The sewer network is a city's crystal infrastructure" in the recognition result, after determination by the above method, the second character to be corrected is "晶", then the previous character (the character adjacent to the first character on the left) "的" and the next character (the character adjacent to the first character on the right) "础" of the character "晶" are respectively obtained as the fifth character.
[0113] 702: Obtain the word vector of the fifth character and the word vector of the second character to be corrected.
[0114] 703: Concatenate the word vector of the fifth character and the word vector of the second character to be corrected in the order of the fifth character and the second character to be corrected in the recognition text to obtain a fusion vector.
[0115] Exemplarily, continuing with the above example of "The sewer network is a city's crystal infrastructure", where the word vector of the second character to be corrected "晶" is [1, 2], the word vector of the fifth character "的" is [3, 4], and the word vector of the fifth character "础" is [5, 6]. Then, according to the order "的晶础" of the second character to be corrected and the fifth character in the original text, the obtained word vectors are horizontally concatenated to obtain the fusion vector [3, 4, 1, 2, 5, 6].
[0116] 704: Use the fusion vector as the feature of the second character to be corrected.
[0117] 205: Replace the second character in the second character with a mark in the recognition text that matches the feature of the second character to be corrected with the first character to obtain the corrected recognition text.
[0118] In this embodiment, after determining the characteristics of the second character to be corrected, the characteristics of each identified second character can be obtained, and the similarity between the characteristics of the second character to be corrected and the characteristics of each identified second character can be calculated, and the identified second character with a similarity greater than a fifth threshold can be identified as a second character that matches the characteristics of the second character to be corrected.
[0119] Among them, the method for obtaining the features of each identified second character is similar to the method for obtaining the features of the second character to be corrected in step 204, and the method for calculating the similarity between the features of the second character to be corrected and the features of each identified second character is similar to the method for calculating the first similarity between each first word vector and the word vector of each template word in the multiple template words in the preset vocabulary in step 401, which will not be repeated here.
[0120] In summary, the text error correction method provided by the present invention realizes automatic error correction of the recognized text by automatically identifying the first character to be modified and automatically determining the second character after the modification, thereby modifying the first character in the recognized text to the second character. Then, by adding a mark to the second character obtained by replacing the first character in the recognized text, it is determined that the replacement error is automatically rolled back during the replacement process, thereby, at most two modifications are made to realize the error correction of the vast majority of recognition errors in the recognized text, which greatly reduces the consumption of human resources, improves the error correction efficiency, and ensures the accuracy of automatic error correction.
[0121] See also Figure 8 , Figure 8 This is a functional module block diagram of a text error correction device provided in the embodiment of the present application. Figure 8 As shown, the text error correction device 800 includes:
[0122] A character replacement module 801, used to replace a first character in a recognized text with a second character;
[0123] A character identification module 802, used to add an identification to a second character obtained by replacing the first character in the recognized text;
[0124] A character determination module 803, configured to determine a second character to be corrected in the second character with the mark in the recognized text according to adjacent characters of the second character with the mark in the recognized text;
[0125] A feature determination module 804 is used to obtain a feature of a second character to be corrected;
[0126] The character replacement module 801 is further used to replace the second character with the mark in the recognized text that matches the feature of the second character to be corrected with the first character to obtain the recognized text after correction.
[0127] In an embodiment of the present invention, before replacing the first character in the recognized text with the second character, the character determination module 803 is further configured to:
[0128] Determining a character group corresponding to the first character according to the error table, wherein the error table records characters whose recognition error rate during the OCR recognition process is greater than a first threshold and character groups corresponding to the characters, the character group includes multiple candidate characters corresponding to the characters, and during the OCR recognition process, probabilities that the multiple candidate characters are recognized as characters are greater than a second threshold;
[0129] A second character is determined from a plurality of candidate characters according to adjacent characters of the first character.
[0130] In an embodiment of the present invention, in determining the second character from a plurality of candidate characters according to adjacent characters of the first character, the character determination module 803 is specifically configured to:
[0131] Get a third character, where the third character is a character adjacent to the first character in the recognized text;
[0132] combining the third character and the first character according to the order in the recognized text to obtain a first word;
[0133] Replacing the first character in the first word with each candidate character in the plurality of candidate characters to obtain a plurality of second words, wherein the plurality of second words correspond to the plurality of candidate characters one by one;
[0134] Performing word embedding processing on each of the plurality of second words respectively to obtain a plurality of first word vectors, wherein the plurality of first word vectors correspond one-to-one to the plurality of second words;
[0135] For each first word vector among the multiple first word vectors, each first word vector is matched with the word vectors of multiple template words in a preset vocabulary to obtain multiple first matching results, and the second character is determined based on the multiple first matching results, wherein the multiple first matching results correspond one-to-one to the multiple template words.
[0136] In an embodiment of the present invention, for each first word vector in a plurality of first word vectors, each first word vector is matched with a word vector of a plurality of template words in a preset word library to obtain a plurality of matching results, and a second character is determined according to the plurality of matching results, the character determination module 803 is specifically used to:
[0137] Calculating first similarities between each first word vector and each word vector of a plurality of template words in a preset word library respectively, to obtain a plurality of first similarities, wherein the plurality of first similarities correspond one-to-one to the plurality of common words;
[0138] Taking the largest first similarity among the multiple first similarities as the first score of each first word vector to obtain multiple first scores, wherein the multiple first scores correspond to the multiple first word vectors one by one;
[0139] Taking, among the multiple first scores, a second word corresponding to the first word vector corresponding to the first score greater than the third threshold as the third word, to obtain at least one third word;
[0140] A fourth word is determined in at least one third word, and a character in the fourth word that is in the same position as the first character is used as a second character, wherein the fourth word is the word in the at least one third word that has the highest matching degree with the recognized text.
[0141] In an embodiment of the present invention, in determining the fourth word in at least one third word, the character determination module 803 is specifically configured to:
[0142] In the recognized text, a sentence containing the first word is obtained to obtain a first sentence;
[0143] For each third word in the at least one third word, replace the first word in the first sentence with each third word to obtain a plurality of second sentences, wherein the plurality of second sentences correspond one to one to the plurality of third words;
[0144] Calculate the perplexity of each of the plurality of second sentences respectively to obtain a plurality of perplexities, wherein the plurality of perplexities correspond one-to-one to the plurality of second sentences;
[0145] The third word corresponding to the second sentence corresponding to the smallest perplexity among multiple perplexities is taken as the fourth word.
[0146] In an embodiment of the present invention, in determining the second character to be corrected in the second character with a mark in the recognized text according to the adjacent characters of the second character with a mark in the recognized text, the character determination module 803 is specifically used to:
[0147] Obtain a fourth character, where the fourth character is an adjacent character of the second character with the identifier in the recognized text;
[0148] combining the fourth character and the second character with the identifier in the recognized text according to the order in the recognized text to obtain a fifth word;
[0149] Perform word embedding processing on the fifth word to obtain the second word vector;
[0150] Respectively calculating a second similarity between the second word vector and the word vector of each template word in a plurality of template words in a preset word library to obtain a plurality of second similarities, wherein the plurality of second similarities correspond one-to-one to the plurality of template words;
[0151] The largest second similarity among the multiple second similarities is used as the second score of the second word vector;
[0152] When the second score is less than the fourth threshold, it is determined that the second character in the fifth word corresponding to the second word vector corresponding to the second score is the second character to be corrected.
[0153] In the embodiment of the present invention, in terms of obtaining the feature of the second character to be corrected, the feature determination module 804 is specifically used to:
[0154] Obtain a fifth character, where the fifth character is an adjacent character of the second character to be corrected;
[0155] Obtain a word vector of the fifth character, and obtain a word vector of the second character to be corrected;
[0156] concatenate the word vector of the fifth character and the word vector of the second character to be corrected according to the order of the fifth character and the second character to be corrected in the recognized text to obtain a fused vector;
[0157] The fused vector is used as the feature of the second character to be corrected.
[0158] See also Fig. 9 , Fig. 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig. 9 As shown, the electronic device 900 includes a transceiver 901, a processor 902 and a memory 903. They are connected via a bus 904. The memory 903 is used to store computer programs and data, and can transmit the data stored in the memory 903 to the processor 902.
[0159] The processor 902 is used to read the computer program in the memory 903 and perform the following operations:
[0160] Replace the first character in the recognized text with the second character;
[0161] Adding a mark to a second character obtained by replacing the first character in the recognized text;
[0162] Determine, according to adjacent characters of the second character with the mark in the recognized text, a second character to be corrected in the second character with the mark in the recognized text;
[0163] Obtaining a feature of a second character to be corrected;
[0164] The second character with the identifier in the recognized text that matches the feature of the second character to be corrected is replaced with the first character to obtain the recognized text after correction.
[0165] In an embodiment of the present invention, before replacing the first character in the recognized text with the second character, the processor 902 is further configured to perform the following operations:
[0166] Determining a character group corresponding to the first character according to the error table, wherein the error table records characters whose recognition error rate during the OCR recognition process is greater than a first threshold and character groups corresponding to the characters, the character group includes multiple candidate characters corresponding to the characters, and during the OCR recognition process, probabilities that the multiple candidate characters are recognized as characters are greater than a second threshold;
[0167] A second character is determined from a plurality of candidate characters according to adjacent characters of the first character.
[0168] In an embodiment of the present invention, in determining the second character from a plurality of candidate characters according to adjacent characters of the first character, the processor 902 is specifically configured to perform the following operations:
[0169] Get a third character, where the third character is a character adjacent to the first character in the recognized text;
[0170] combining the third character and the first character according to the order in the recognized text to obtain a first word;
[0171] Replacing the first character in the first word with each candidate character in the plurality of candidate characters to obtain a plurality of second words, wherein the plurality of second words correspond to the plurality of candidate characters one by one;
[0172] Performing word embedding processing on each of the plurality of second words respectively to obtain a plurality of first word vectors, wherein the plurality of first word vectors correspond one-to-one to the plurality of second words;
[0173] For each first word vector among the multiple first word vectors, each first word vector is matched with the word vectors of multiple template words in a preset vocabulary to obtain multiple first matching results, and the second character is determined based on the multiple first matching results, wherein the multiple first matching results correspond one-to-one to the multiple template words.
[0174] In an embodiment of the present invention, for each first word vector in a plurality of first word vectors, each word vector is matched with the word vectors of a plurality of template words in a preset word library to obtain a plurality of matching results, and the second character is determined according to the plurality of matching results, the processor 902 is specifically configured to perform the following operations:
[0175] Calculating first similarities between each first word vector and each word vector of a plurality of template words in a preset word library respectively, to obtain a plurality of first similarities, wherein the plurality of first similarities correspond one-to-one to the plurality of common words;
[0176] Taking the largest first similarity among the multiple first similarities as the first score of each first word vector to obtain multiple first scores, wherein the multiple first scores correspond to the multiple first word vectors one by one;
[0177] Taking, among the multiple first scores, a second word corresponding to the first word vector corresponding to the first score greater than the third threshold as the third word, to obtain at least one third word;
[0178] A fourth word is determined in at least one third word, and a character in the fourth word that is in the same position as the first character is used as a second character, wherein the fourth word is the word in the at least one third word that has the highest matching degree with the recognized text.
[0179] In an embodiment of the present invention, in terms of determining a fourth word from at least one third word, the processor 902 is specifically configured to perform the following operations:
[0180] In the recognized text, a sentence containing the first word is obtained to obtain a first sentence;
[0181] For each third word in the at least one third word, replace the first word in the first sentence with each third word to obtain a plurality of second sentences, wherein the plurality of second sentences correspond one to one to the plurality of third words;
[0182] Calculate the perplexity of each of the plurality of second sentences respectively to obtain a plurality of perplexities, wherein the plurality of perplexities correspond one-to-one to the plurality of second sentences;
[0183] The third word corresponding to the second sentence corresponding to the smallest perplexity among multiple perplexities is taken as the fourth word.
[0184] In an embodiment of the present invention, in determining the second character to be corrected in the second character with a mark in the recognized text according to the adjacent characters of the second character with a mark in the recognized text, the processor 902 is specifically configured to perform the following operations:
[0185] Acquire a fourth character, where the fourth character is an adjacent character of the second character with the identifier in the recognized text; combine the fourth character and the second character with the identifier in the recognized text according to the order in the recognized text to obtain a fifth word;
[0186] Perform word embedding processing on the fifth word to obtain the second word vector;
[0187] Respectively calculating a second similarity between the second word vector and the word vector of each template word in a plurality of template words in a preset word library to obtain a plurality of second similarities, wherein the plurality of second similarities correspond one-to-one to the plurality of template words;
[0188] The largest second similarity among the multiple second similarities is used as the second score of the second word vector;
[0189] When the second score is less than the fourth threshold, it is determined that the second character in the fifth word corresponding to the second word vector corresponding to the second score is the second character to be corrected.
[0190] In the embodiment of the present invention, in terms of obtaining the feature of the second character to be corrected, the processor 902 is specifically configured to perform the following operations:
[0191] Obtain a fifth character, where the fifth character is an adjacent character of the second character to be corrected;
[0192] Obtain a word vector of the fifth character, and obtain a word vector of the second character to be corrected;
[0193] concatenate the word vector of the fifth character and the word vector of the second character to be corrected according to the order of the fifth character and the second character to be corrected in the recognized text to obtain a fused vector;
[0194] The fused vector is used as the feature of the second character to be corrected.
[0195] It should be understood that the text correction device in the present application may include a smart phone (such as an Android phone, an iOS phone, a Windows Phone phone, etc.), a tablet computer, a PDA, a laptop computer, a mobile Internet device MID (Mobile Internet Devices, referred to as: MID), a robot or a wearable device, etc. The above-mentioned text correction device is only an example, not an exhaustive list, including but not limited to the above-mentioned text correction device. In practical applications, the above-mentioned text correction device may also include: a smart vehicle terminal, a computer device, etc.
[0196] Through the description of the above implementation modes, those skilled in the art can clearly understand that the present invention can be implemented by combining software with a hardware platform. Based on such an understanding, all or part of the contribution of the technical solution of the present invention to the background technology can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various implementation modes of the present invention or some parts of the implementation modes.
[0197] Therefore, the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement some or all of the steps of any text error correction method described in the above method implementation. For example, the storage medium may include a hard disk, a floppy disk, an optical disk, a tape, a disk, a USB flash drive, a flash memory, etc.
[0198] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps of any text correction method recorded in the above method embodiment.
[0199] It should be noted that, for the sake of simplicity, the aforementioned method implementations are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the implementations described in the specification are all optional implementations, and the actions and modules involved are not necessarily required by the present application.
[0200] In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0201] In the several embodiments provided in this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device implementation described above is only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be electrical or other forms.
[0202] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0203] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software program module.
[0204] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0205] A person skilled in the art may understand that all or part of the steps in the various methods of the above-mentioned embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable memory, and the memory may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0206] The above is a detailed introduction to the implementation methods of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above implementation methods is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A text error correction method, characterized in that: The error correction method comprises: Determining a character group corresponding to the first character according to an error table, wherein the error table records characters whose recognition error rate is greater than a first threshold during an OCR recognition process and character groups corresponding to the characters, the character group includes a plurality of candidate characters corresponding to the characters, and in the OCR recognition process, probabilities that the plurality of candidate characters are recognized as the characters are greater than a second threshold; Determining a second character from the plurality of candidate characters according to adjacent characters of the first character, including: obtaining a third character, the third character being a character adjacent to the first character in the recognized text; combining the third character and the first character in the order in the recognized text to obtain a first word; replacing the first character in the first word with each candidate character in the plurality of candidate characters to obtain a plurality of second words, wherein the plurality of second words correspond one-to-one to the plurality of candidate characters; performing word embedding processing on each second word in the plurality of second words to obtain a plurality of first word vectors, wherein the plurality of first word vectors correspond one-to-one to the plurality of second words; for each first word vector in the plurality of first word vectors, matching each first word vector with a word vector of a plurality of template words in a preset word library to obtain a plurality of first matching results, and determining the second character according to the plurality of first matching results, wherein the plurality of first matching results correspond one-to-one to the plurality of template words; Replace the first character in the recognized text with the second character; adding a mark to a second character obtained by replacing the first character in the recognized text; Determine, according to adjacent characters of the second character with the mark in the recognized text, a second character to be corrected in the second character with the mark in the recognized text; Acquire the feature of the second character to be corrected; Replacing the second character with the identifier in the recognized text and matching the feature of the second character to be corrected with the first character to obtain a recognized text after correction; The step of matching each first word vector in the plurality of first word vectors with word vectors of a plurality of template words in a preset word library to obtain a plurality of matching results, and determining the second character according to the plurality of matching results includes: Respectively calculating a first similarity between each of the first word vectors and a word vector of each of the multiple template words in the preset word library to obtain multiple first similarities, wherein the multiple first similarities correspond one-to-one to the multiple common words; Taking the largest first similarity among the multiple first similarities as the first score of each of the first word vectors to obtain multiple first scores, wherein the multiple first scores correspond to the multiple first word vectors one by one; Taking, among the multiple first scores, a second word corresponding to the first word vector corresponding to a first score greater than a third threshold as a third word, to obtain at least one third word; A fourth word is determined in the at least one third word, and a character in the fourth word that is in the same position as the first character is used as the second character, wherein the fourth word is the word in the at least one third word that has the highest matching degree with the recognized text.
2. The error correction method according to claim 1, characterized in that: The step of determining a fourth word from the at least one third word comprises: In the recognized text, obtaining the sentence where the first word is located to obtain a first sentence; For each third word in the at least one third word, replace the first word in the first sentence with each third word to obtain a plurality of second sentences, wherein the plurality of second sentences correspond one to one to the plurality of third words; Calculating the perplexity of each of the plurality of second sentences respectively to obtain a plurality of perplexities, wherein the plurality of perplexities correspond one-to-one to the plurality of second sentences; The third word corresponding to the second sentence corresponding to the smallest perplexity among the multiple perplexities is used as the fourth word.
3. The error correction method according to claim 2, characterized in that: The step of determining the second character to be corrected in the second character with the mark in the recognized text according to the adjacent characters of the second character with the mark in the recognized text comprises: Acquire a fourth character, where the fourth character is an adjacent character of the second character with the mark in the recognized text; Combining the fourth character and the second character with the identifier in the recognized text according to the order in the recognized text to obtain a fifth word; Performing word embedding processing on the fifth word to obtain a second word vector; Respectively calculating a second similarity between the second word vector and a word vector of each template word in a plurality of template words in a preset word library to obtain a plurality of second similarities, wherein the plurality of second similarities correspond one-to-one to the plurality of template words; Using the largest second similarity among the multiple second similarities as the second score of the second word vector; When the second score is less than a fourth threshold, it is determined that the second character in the fifth word corresponding to the second word vector corresponding to the second score is the second character to be corrected.
4. The error correction method according to any one of claims 1 to 3, characterized in that: The step of obtaining the feature of the second character to be corrected includes: Obtain a fifth character, where the fifth character is an adjacent character of the second character to be corrected; Obtaining a word vector of the fifth character, and obtaining a word vector of the second character to be corrected; concatenating the word vector of the fifth character and the word vector of the second character to be corrected according to the order of the fifth character and the second character to be corrected in the recognized text to obtain a fusion vector; The fused vector is used as a feature of the second character to be corrected.
5. A text error correction device, the device being used to execute the method according to any one of claims 1 to 4, characterized in that: The error correction device comprises: A character replacement module, used to replace a first character in the recognized text with a second character; A character identification module, used for adding an identification to a second character obtained by replacing the first character in the recognized text; A character determination module, used for determining a second character to be corrected in the second character with the mark in the recognized text according to adjacent characters of the second character with the mark in the recognized text; A feature determination module, used for obtaining the feature of the second character to be corrected; The character replacement module is further used to replace the second character with the mark in the recognized text that matches the feature of the second character to be corrected with the first character to obtain the recognized text after correction.
6. An electronic device, characterized in that: The method comprises a processor, a memory, a communication interface and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the one or more programs include instructions for executing the steps in any one of the methods of claims 1 to 4.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 4.
