Text error correction method and device, electronic device, and storage medium

By using inverted indexes to search and filter one by one in text error correction method, the problem of excessively large suspected error candidate sets in the prior art is solved, and a more efficient text error correction process is achieved.

CN114021560BActive Publication Date: 2025-02-14ZHUJIAN INTELLIGENT TECHNOLOGY (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111324451.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-10
Publication Date
2025-02-14
Estimated Expiration
2041-11-10

AI Technical Summary

Technical Problem

The existing text error correction method obtains too large a set of suspected error candidates in the error detection stage, resulting in a large amount of calculation and inefficient efficiency in the subsequent error correction stage.

Method used

By retrieving each Chinese character in the error correction text one by one in the inverted index of the target dictionary, the candidate word-to-corrected word pairs are selected, and the wrong words that need to be corrected and the corresponding corrected words are determined through further screening.

Benefits of technology

It significantly narrows the search range of subsequent wrong words, saves the construction events of candidate words, and improves the efficiency of text error correction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114021560B_ABST
    Figure CN114021560B_ABST
Patent Text Reader

Abstract

The present application provides a text error correction method and device, an electronic device, and a computer-readable storage medium. The method includes: for each Chinese character in the error correction text, according to a preset search strategy, searching one by one in the inverted index corresponding to the target dictionary, and obtaining multiple candidate word-to-be-corrected word pairs; wherein the candidate word is a suspected erroneous word in the text to be corrected, and the to-be-corrected word is an entry in the target dictionary; for each candidate word, from a number of candidate word-to-be-corrected word pairs containing the candidate word, a unique designated candidate word-to-be-corrected word pair is determined; for each designated candidate word-to-be-corrected word pair, judging whether the to-be-corrected word therein is the corrected word of the candidate word; based on the judgment results of all designated candidate word-to-be-corrected word pairs, obtaining the error correction result of the text to be corrected. The present application scheme greatly narrows the search scope of erroneous words, saves the time of constructing candidate words, and thus improves the efficiency of text error correction as a whole.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing technology, and in particular to a text error correction method and device, an electronic device, and a computer-readable storage medium. Background Art

[0002] Text error correction is usually divided into two stages: error detection and error correction. In the error detection stage, it is necessary to identify the erroneous words that may exist in the text to be corrected. Generally, the text to be corrected can be segmented to obtain multiple segmentation units, and then the segmentation units can be error detected at both the character granularity and the word granularity to obtain the detection results as a suspected error candidate set. The suspected error candidate set may include multiple suspected erroneous words and words in the text to be corrected. In the error correction stage, the word dictionary can be used to correct the suspected erroneous words or words to obtain the corrected text.

[0003] In the related art, 2-gram and 3-gram calculations can be performed on the text to be corrected at the word or phrase level to obtain a suspected error candidate set. However, the suspected error candidate set obtained in this way contains a huge number of words and vocabulary, which makes the subsequent error correction stage involve a lot of calculations, resulting in low efficiency of text error correction. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a text correction method and device, an electronic device, and a computer-readable storage medium for correcting erroneous words in a text.

[0005] On the one hand, the present application provides a text error correction method, comprising:

[0006] For each Chinese character in the error correction text, according to the preset search strategy, search one by one in the inverted index corresponding to the target dictionary to obtain multiple candidate word-to-be-corrected word pairs; wherein the candidate word is a suspected erroneous word in the error correction text, and the to-be-corrected word is an entry in the target dictionary;

[0007] For each candidate word, determine a unique designated candidate word-to-be-corrected word pair from a plurality of candidate word-to-be-corrected word pairs that include the candidate word;

[0008] For each designated candidate word-to-be-corrected word pair, determining whether the to-be-corrected word is a corrected word of the candidate word;

[0009] Based on the judgment results of all designated candidate word-to-be-corrected word pairs, the error correction result of the text to be corrected is obtained.

[0010] In one embodiment, before searching the inverted indexes corresponding to the target dictionary one by one to obtain a plurality of candidate word-to-be-corrected word pairs, the method further includes:

[0011] Obtaining the target dictionary, and parsing a plurality of entries from the target dictionary;

[0012] The inverted index is constructed based on each Chinese character in the multiple entries as a key; wherein the inverted index includes mapping relationships between multiple Chinese characters and entries containing the Chinese characters.

[0013] In one embodiment, the method of searching the inverted index corresponding to the target dictionary one by one according to the preset search strategy to obtain multiple candidate word-to-be-corrected word pairs includes:

[0014] Taking each Chinese character in the text to be corrected as a target Chinese character one by one, searching for an entry corresponding to the target Chinese character in the inverted index as the target entry;

[0015] Determine the word to be checked corresponding to the target entry according to the position of the target Chinese character in the target entry and the position of the target Chinese character in the text to be corrected;

[0016] For each word to be checked corresponding to the target entry, determining whether the matching degree of the word to be checked with the target entry is within a preset matching range;

[0017] If so, the word to be checked is taken as a candidate word, and the target entry corresponding to the word to be checked is taken as a proposed correction word, to construct the candidate word-proposed correction word pair.

[0018] In one embodiment, before constructing the candidate word-to-be-corrected word pair, the method further includes:

[0019] Determine whether the word to be checked is in a preset stop word list;

[0020] If yes, filter the words to be checked;

[0021] If not, continue to execute the step of constructing the candidate word-to-be-corrected word pair.

[0022] In one embodiment, before constructing the candidate word-to-be-corrected word pair, the method further includes:

[0023] Determine whether the last character of the word to be checked and the first character after the word to be checked in the text to be corrected are both designated characters;

[0024] If yes, filter the word to be checked;

[0025] If not, continue to execute the step of constructing the candidate word-to-be-corrected word pair.

[0026] In one embodiment, before constructing the candidate word-to-be-corrected word pair, the method further includes:

[0027] Determining whether the word to be checked and the target entry have constructed a candidate word-to-be-corrected word pair;

[0028] If yes, filter the words to be checked;

[0029] If not, continue to execute the step of constructing the candidate word-to-be-corrected word pair.

[0030] In one embodiment, for each candidate word, determining a unique designated candidate word-to-be-corrected word pair from a plurality of candidate word-to-be-corrected word pairs including the candidate word includes:

[0031] For each candidate word, determining the similarity between the candidate word and the proposed correction word in each candidate word-proposed correction word pair containing the candidate word;

[0032] For each candidate word, the candidate word-to-be-corrected word pair with the highest similarity is used as the designated candidate word-to-be-corrected word pair of the candidate word.

[0033] On the other hand, the present application also provides a text error correction device, comprising:

[0034] A search module is used to search for each Chinese character in the error correction text one by one in the inverted index corresponding to the target dictionary according to a preset search strategy, and obtain multiple candidate word-to-be-corrected word pairs; wherein the candidate word is a suspected erroneous word in the error correction text, and the to-be-corrected word is an entry in the target dictionary;

[0035] A determination module, for determining, for each candidate word, a unique designated candidate word-to-be-corrected word pair from a plurality of candidate word-to-be-corrected word pairs including the candidate word;

[0036] A judgment module, for judging, for each designated candidate word-to-be-corrected word pair, whether the to-be-corrected word therein is a corrected word of the candidate word;

[0037] A generation module is used to obtain the error correction result of the text to be corrected based on the judgment results of all designated candidate word-to-be-corrected word pairs.

[0038] Furthermore, the present application also provides an electronic device, the electronic device comprising:

[0039] processor;

[0040] a memory for storing processor-executable instructions;

[0041] Wherein, the processor is configured to execute the above-mentioned text error correction method.

[0042] In addition, the present application also provides a computer-readable storage medium, which stores a computer program, and the computer program can be executed by a processor to complete the above-mentioned text error correction method.

[0043] The present application scheme searches for each Chinese character in the text to be corrected one by one in the inverted index corresponding to the target word pair according to the retrieval strategy, thereby screening out multiple candidate word-to-be-corrected word pairs. By further screening the candidate word-to-be-corrected word pairs, the erroneous words that need to be corrected and the corresponding corrected words can be determined. Compared with the scheme of determining the suspected error candidate set by n-gram, the search scope of subsequent erroneous words can be greatly narrowed, saving the event of constructing candidate words, thereby improving the efficiency of text correction as a whole. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solution of the embodiments of the present application, the drawings required for use in the embodiments of the present application are briefly introduced below.

[0045] Figure 1 A schematic diagram of an application scenario of a text error correction method provided in an embodiment of the present application;

[0046] Figure 2 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application;

[0047] Figure 3 A flowchart of a text error correction method provided in one embodiment of the present application;

[0048] Figure 4 A schematic diagram of a flow chart of a method for constructing an inverted index provided in an embodiment of the present application;

[0049] Figure 5 A flowchart of a word pair search method provided in one embodiment of the present application;

[0050] Figure 6 A schematic diagram of a text error correction method provided by an embodiment of the present application;

[0051] Figure 7 A block diagram of a text error correction device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0052] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0053] Similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0054] Figure 1 Schematic diagram of application scenarios of the text error correction method provided in the embodiment of the present application. Figure 1 As shown, the application scenario includes a client 20 and a server 30; the client 20 can be a user terminal such as a host, a mobile phone, a tablet computer, etc., which is used to send the text to be corrected to the server 30; the server 30 can be a server, a server cluster or a cloud computing center, which can process the text to be corrected, obtain the correction result, and return it to the client 20.

[0055] like Figure 2 As shown, this embodiment provides an electronic device 1, including: at least one processor 11 and a memory 12, Figure 2 A processor 11 is taken as an example. The processor 11 and the memory 12 are connected via a bus 10. The memory 12 stores instructions that can be executed by the processor 11. The instructions are executed by the processor 11 so that the electronic device 1 can execute all or part of the process of the method in the following embodiment. In one embodiment, the electronic device 1 can be the above-mentioned server 30, which is used to execute the text error correction method.

[0056] The memory 12 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable red-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, disk or optical disk.

[0057] The present application also provides a computer-readable storage medium, which stores a computer program. The computer program can be executed by the processor 11 to complete the text error correction method provided by the present application.

[0058] See also Figure 3, is a flow chart of a text error correction method provided by an embodiment of the present application, such as Figure 3 As shown, the method may include the following steps 310 to 340.

[0059] Step 310: for each Chinese character in the text to be corrected, according to a preset search strategy, search one by one in the inverted index corresponding to the target dictionary to obtain multiple candidate word-to-be-corrected word pairs; wherein the candidate word is a suspected erroneous word in the text to be corrected, and the to-be-corrected word is an entry in the target dictionary.

[0060] The text to be corrected can be a sentence or an article.

[0061] The target dictionary is the dictionary of the field to which the text to be corrected belongs, and can be configured according to the application scenario. For example, in a general scenario, the target dictionary can be a dictionary of homophones, a dictionary of homographs, a dictionary of confusing words, a dictionary of personal names, a dictionary of place names, etc. In a special scenario, there are corresponding professional dictionaries in various industries such as finance, medical care, academic research, and finance, which serve as target dictionaries.

[0062] After obtaining the text to be corrected, the server can search the corresponding inverted index of the target dictionary one by one for each Chinese character in the text to be corrected according to the retrieval strategy. For any Chinese character in the text to be corrected, the server can search for the entry corresponding to the Chinese character in the inverted index, and determine the candidate word from the text to be corrected based on the found entry and the retrieval strategy. The candidate word is a suspected erroneous word. In other words, the candidate word may be wrong or correct. The server can use the entry corresponding to the Chinese character as a proposed correction word, and construct a candidate word-proposed correction word pair with the proposed correction word and the candidate word. The proposed correction word represents a word that may be used to correct the candidate word. For any Chinese character, one or more candidate word-proposed correction word pairs may be constructed.

[0063] After searching each Chinese character in the text to be corrected, multiple candidate word-to-be-corrected word pairs can be obtained.

[0064] Step 320: For each candidate word, determine a unique designated candidate word-to-be-corrected word pair from a plurality of candidate word-to-be-corrected word pairs that include the candidate word.

[0065] The proposed corrective word in the designated candidate word-proposed corrective word pair is the word most likely to be used to correct the candidate word among all the proposed corrective words corresponding to the candidate word in the word pair.

[0066] After obtaining multiple candidate word-to-be-corrected word pairs, the server can determine multiple candidate words that may be wrong. For each candidate word, there are one or more to-be-corrected words. For each candidate word, the server can filter out all candidate word-to-be-corrected word pairs that contain the candidate word. In one case, if the candidate word corresponds to a unique candidate word-to-be-corrected word pair, the candidate word-to-be-corrected word pair can be used as the designated candidate word-to-be-corrected word pair for the candidate word. In another case, if the candidate word corresponds to at least two candidate word-to-be-corrected word pairs, the server can compare different to-be-corrected words, determine the to-be-corrected word that is most likely to replace the candidate word, and use the candidate word-to-be-corrected word pair containing the to-be-corrected word as the designated candidate word-to-be-corrected word pair.

[0067] Step 330: For each designated candidate word-to-be-corrected word pair, determine whether the to-be-corrected word therein is a correction word of the candidate word.

[0068] After obtaining a number of designated candidate word-to-be-corrected word pairs, the server can determine whether the similarity between the candidate word and the to-be-corrected word in each designated candidate word-to-be-corrected word pair reaches a preset similarity threshold. Here, the similarity threshold is used to screen the to-be-corrected word that is sufficiently similar to the candidate word. The similarity between the candidate word and the to-be-corrected word can be determined by a similarity algorithm, and here, the similarity algorithm can be a combination of one or more algorithms such as Euclidean distance, edit distance, Jaccard similarity, and cosine similarity.

[0069] On the one hand, if the similarity between the word to be corrected and the candidate word reaches the similarity threshold, then it can be determined that the word to be corrected is the correction word of the candidate word, and the candidate word is a determined wrong word. The correction word is a word determined to be used to correct the candidate word. On the other hand, if the similarity between the candidate words to be corrected does not reach the similarity threshold, then it can be determined that the word to be corrected is not the correction word of the candidate word.

[0070] Step 340: Based on the judgment results of all designated candidate word-to-be-corrected word pairs, obtain the correction result of the text to be corrected.

[0071] After judging all designated candidate words and proposed correction words, all incorrect words with correction words can be determined. The server can form an error correction result based on the candidate words and their corresponding incorrect words. The error correction result includes all the correction words and the incorrect words corrected by the correction words.

[0072] If the text to be corrected is sent by the client to the server for processing, the server can return the correction result to the client after obtaining the correction result.

[0073] In one embodiment, before searching in the inverted index to determine the candidate word-to-be-corrected word, the server may construct an inverted index corresponding to the target dictionary. Figure 4, is a schematic flowchart of a method for constructing an inverted index provided by an embodiment of the present application. As Figure 4 shown, the method may include the following steps 301-step 302.

[0074] Step 301: Obtain a target dictionary and parse out multiple entries from the target dictionary.

[0075] The server can obtain the target dictionary according to the application scenario and parse out multiple entries from the target dictionary. Each entry is a word in the target dictionary.

[0076] Step 302: Construct an inverted index with each Chinese character in the multiple entries as a key; wherein, the inverted index includes the mapping relationship between multiple Chinese characters and the entries containing the Chinese characters.

[0077] For each entry, the mapping relationship between the Chinese characters in the entry and the entry can be constructed respectively with each Chinese character in the entry as a key. After constructing several mapping relationships for each entry, the server can merge the same keys in the multiple mapping relationships, so as to construct an inverted index with the multiple mapping relationships.

[0078] Exemplarily, the target dictionary is a dictionary of common prescription terms, including entries: amoxicillin, azlocillin, clindamycin... For the entry "amoxicillin", the mapping relationships between the Chinese character "a" and "amoxicillin", the Chinese character "mo" and "amoxicillin", the Chinese character "xi" and "amoxicillin", and the Chinese character "lin" and "amoxicillin" can be constructed. After constructing multiple mapping relationships for each entry, an inverted index can be constructed. The structure of the inverted index is shown in Table 1 below:

[0079]

[0080]

[0081] Table 1

[0082] In one embodiment, refer to Figure 5 , is a schematic flowchart of a word pair retrieval method provided by an embodiment of the present application. As Figure 5 shown, the method may include steps 311-step 314.

[0083] Step 311: Take each Chinese character in the text to be corrected one by one as the target Chinese character, and look up the entry corresponding to the target Chinese character in the inverted index as the target entry.

[0084] The server can take each Chinese character in the text to be corrected one by one as the target Chinese character, and search for the entry corresponding to the target Chinese character in the inverted index. On the one hand, if there is no entry corresponding to the target Chinese character in the inverted index, the server can select the next Chinese character in the text to be corrected as the target Chinese character and search again in the inverted index. On the other hand, if there is at least one entry corresponding to the target Chinese character in the inverted index, the found entry can be used as the target entry. After any target Chinese character is searched in the inverted index, the server can continue to select the next Chinese character in the text to be corrected as the target Chinese character and search again in the inverted index.

[0085] Step 312: Determine the word to be inspected corresponding to the target entry according to the position of the target Chinese character in the target entry and the position of the target Chinese character in the text to be corrected.

[0086] Here, the word to be inspected is the word that needs to be further checked whether it belongs to the candidate word.

[0087] The position of the target Chinese character in the target entry can be represented by the sorting position of the target Chinese character in the target entry, the number of characters to the left of the target Chinese character in the target entry, and the number of characters to the right of the target Chinese character in the target entry. Exemplarily, Table 2 lists the position information of multiple target Chinese characters in the target entry:

[0088]

[0089]

[0090] Table 2

[0091] The position of the target Chinese character in the text to be corrected can be represented by the sorting position of the target Chinese character in the text to be corrected.

[0092] For any target Chinese character, after determining the target entry corresponding to the target Chinese character, the server can, based on the position of the target Chinese character in the text to be corrected, intercept a number of Chinese characters on the left and right sides of the target Chinese character in the text to be corrected according to the position of the target Chinese character in the target entry to construct the word to be inspected corresponding to the target entry. The server intercepts a number of Chinese characters from the left of the target Chinese character in the text to be corrected according to the number of characters to the left of the target Chinese character in the target entry; and intercepts a number of Chinese characters from the right of the target Chinese character in the text to be corrected according to the number of characters to the right of the target Chinese character in the target entry.

[0093] Exemplarily, the text to be corrected is "The doctor recommends using Amoxicillin as a specific medicine to treat pneumonia", the target entry is "Amoxicillin", and the target Chinese character is "莫". The number of characters to the left of the target Chinese character in the target entry is 1, and the number of characters to the right is 2. The server can intercept "阿" from the left of the target Chinese character in the text to be corrected and "西灵" from the right, so as to obtain the word to be inspected "阿莫西灵".

[0094] Step 313: For each word to be checked corresponding to the target entry, determine whether the matching degree between the word to be checked and the target entry is within a preset matching range.

[0095] Step 314: If yes, take the word to be checked as a candidate word, take the target entry corresponding to the word to be checked as a proposed correction word, and construct a candidate word-proposed correction word pair.

[0096] The degree of matching indicates the ratio of the number of identical characters in the target entry of the word to be checked to the total number of characters; the number of identical characters is the number of characters with the same Chinese characters in the same position, and the total number of characters is the total number of characters in the word to be checked.

[0097] For the words to be checked corresponding to each target entry, the server can compare whether the Chinese characters in each position of the target entry and the words to be checked are the same, and determine the ratio between the number of identical characters and the total number of characters as the degree of matching. After determining the degree of matching, it can be determined whether the degree of matching is within the matching range. Here, the matching range is used to filter out the words that may be wrong in the text to be corrected. In this case, if the words to be checked are exactly the same as the target entry, it means that the words to be checked are fine. If the target entries of the words to be checked are different, and the difference is very large, the meaning of the words to be checked may be completely irrelevant to the target entry. Therefore, the matching range can be used to filter out words that are similar enough to the target entry, but not completely similar. Exemplary, the preset matching range can be greater than or equal to 50% and less than 100%.

[0098] On the one hand, if the matching degree is not within the preset matching range, the word to be checked can be discarded. On the other hand, if the matching degree is within the preset matching range, the word to be checked can be used as a candidate word, and the target entry corresponding to the word to be checked can be used as a proposed correction word, thereby constructing a candidate word-proposed correction word pair.

[0099] After the above processing is performed on each word to be checked, several candidate word-to-be-corrected word pairs corresponding to the text to be corrected can be constructed.

[0100] In one embodiment, after determining that the degree of match between the word to be checked and the target entry is within a preset matching range, before constructing a candidate word-to-be-corrected word pair, the server may search for the word to be checked in a preset stop word list to determine whether the word to be checked is located in the stop word list. The stop word list includes a plurality of stop words. On the one hand, if the word to be checked is found, it means that the word to be checked is a stop word. At this time, the server may filter the word to be checked and no longer construct a candidate word-to-be-corrected word pair containing the word to be checked. On the other hand, if the word to be checked is not found, it means that the word to be checked is not a stop word. The server may continue to execute the step of constructing a candidate word-to-be-corrected word pair containing the word to be checked.

[0101] In one embodiment, after determining that the degree of match between the word to be checked and the target entry is within a preset matching range, before constructing a candidate word-to-be-corrected word pair, the server can determine whether the last character of the word to be checked and the first character after the word to be checked in the text to be corrected are both designated characters. Here, the designated characters can be characters that are not Chinese characters, such as numbers, letters, and punctuation marks.

[0102] On the one hand, if the last character of the word to be checked and the first character after the word to be checked in the text to be corrected are both designated characters, in this case, the last character of the word to be checked may form a word with the characters after the word to be checked. In other words, the word to be checked is not a single complete word. The server can filter the word to be checked and no longer construct a candidate word-to-be-corrected word pair containing the word to be checked.

[0103] On the other hand, if at least one of the last character of the word to be checked and the first character after the word to be checked in the text to be corrected is not a specified character, the word to be checked can be considered as a single complete word. The server can continue to execute the step of constructing a candidate word-to-be-corrected word pair containing the word to be checked.

[0104] In one embodiment, after determining that the degree of match between the word to be checked and the target entry is within a preset match range, before constructing a candidate word-to-be-corrected word pair, the server can determine whether the word to be checked and the target entry have already constructed a candidate word-to-be-corrected word pair. The server can put the constructed candidate word-to-be-corrected word pair into a word pair set, and before constructing a new candidate word-to-be-corrected word pair, the word to be checked and the target entry can be searched in the word pair set to determine whether a completely identical word pair is found.

[0105] On the one hand, if the same word pair is found, it means that a candidate word-to-be-corrected word pair has been constructed based on the above-mentioned word to be checked and the above-mentioned target entry. In this case, the server can filter the word to be checked and no longer repeatedly construct a candidate word-to-be-corrected word pair containing the word to be checked. On the other hand, if the same word pair is not found, it means that a candidate word-to-be-corrected word pair has not yet been constructed based on the above-mentioned word to be checked and the above-mentioned target entry. In this case, the server can continue to execute the step of constructing a candidate word-to-be-corrected word pair containing the word to be checked.

[0106] In one embodiment, when executing step 320, if the candidate word corresponds to at least two candidate word-to-be-corrected word pairs. For the above candidate words, the server can determine the similarity between the candidate word and the to-be-corrected word in each candidate word-to-be-corrected word pair containing the candidate word. The server can determine the similarity between the candidate word and the to-be-corrected word based on one or more similarity algorithms such as Euclidean distance, edit distance, Jaccard similarity, cosine similarity, etc.

[0107] Here, if the similarity is determined according to at least two similarity algorithms, weights may be preconfigured for different similarity algorithms according to application scenarios. After calculating multiple similarities for the candidate words and the words to be corrected, the multiple similarities are weighted and summed according to the weights corresponding to the different similarity algorithms to obtain the final similarity.

[0108] The server can sort the similarities corresponding to the word pairs of the same candidate word, determine the highest similarity, and use the candidate word-to-be-corrected word pair with the highest similarity as the designated candidate word-to-be-corrected word pair of the candidate word.

[0109] In one embodiment, see Figure 6 , is a schematic diagram of a text error correction method provided by an embodiment of the present application. Figure 6 As shown, after the system executing the text error correction method of the present application is started, multiple entries can be parsed from the target word pair to obtain an entry set, and each Chinese character in the entry is used as a key and the entry is used as a value to construct a mapping relationship between the Chinese character and the entry. The server can construct an inverted index corresponding to the target dictionary based on multiple mapping relationships.

[0110] The system receives the text to be corrected and performs error detection on the text to be corrected. During error detection, the system can search for a target entry in the inverted index based on each Chinese character in the text to be corrected, and intercept the word to be checked in the text to be corrected based on the target entry. The system can filter the word to be checked based on several filtering strategies, and construct a candidate word-to-be-corrected word pair based on the filtered word to be checked and the corresponding target entry.

[0111] The system can perform error correction on multiple word pairs. In the error correction stage, for the same candidate word, a designated candidate word-to-be-corrected word pair is determined from a number of word pairs containing the candidate word. When the similarity between the candidate word and the to-be-corrected word in the designated candidate word-to-be-corrected word pair reaches a similarity threshold, the candidate word can be determined to be an incorrect word, and the to-be-corrected word is a corrective word to correct the incorrect word.

[0112] After the system performs error correction processing on each word pair, it can generate an error correction result for the text to be corrected.

[0113] For example, the text to be corrected received by the system is "Doctors recommend the use of amoxicillin as a specific drug to treat pneumonia." The target dictionary is a dictionary of common prescription terms, and some entries of the constructed inverted index constructed based on the target dictionary can refer to Table 1.

[0114] The system takes the Chinese character "A" in the text to be corrected, and retrieves the target entries "Amoxicillin" and "Azlocillin" in the inverted index. In this case, the word to be detected "Amoxicillin" can be intercepted. After a series of filtering strategies, word pairs "Amoxicillin-Amoxicillin", "Amoxicillin-Azlocillin" can be constructed. Calculate the similarity for each of the two candidate word-correction word pairs respectively. It can be determined that the similarity of "Amoxicillin-Amoxicillin" is 1.014; the similarity of "Amoxicillin-Azlocillin" is 0.623. For the candidate word "Amoxicillin", the specified candidate word-correction word pair can be determined as "Amoxicillin-Amoxicillin".

[0115] The similarity 1.014 between the candidate word and the correction word in "Amoxicillin-Amoxicillin" is greater than the similarity threshold 0.7. Therefore, the system can determine that the candidate word "Amoxicillin" is an incorrect word, and "Amoxicillin" is the correction word for correcting this incorrect word.

[0116] Figure 7 is a block diagram of a text error correction device according to an embodiment of the present invention, as Figure 7 shown, the device may include:

[0117] A retrieval module 710, configured to retrieve each Chinese character of the text to be corrected one by one in the inverted index corresponding to the target dictionary according to a preset retrieval strategy, and obtain a plurality of candidate word-correction word pairs; wherein, the candidate word is a suspected incorrect word in the text to be corrected, and the correction word is an entry in the target dictionary;

[0118] A determination module 720, configured to determine a unique specified candidate word-correction word pair for each candidate word from several candidate word-correction word pairs containing the candidate word;

[0119] A judgment module 730, configured to judge whether the correction word in each specified candidate word-correction word pair is the correction word of the candidate word;

[0120] A generation module 740, configured to obtain the error correction result of the text to be corrected based on the judgment results of all specified candidate word-correction word pairs.

[0121] The implementation processes of the functions and roles of each module in the above device are specifically described in the implementation processes of the corresponding steps in the above text error correction method, and will not be elaborated here.

[0122] In several embodiments provided in the present application, the disclosed devices and methods may also be implemented in other ways. The device embodiments described above are merely schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram may represent a module, a program segment or a part of a code, and a module, a program segment or a part of a code contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0123] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0124] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium 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 various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.

Claims

1. A text error correction method, characterized in that: include: For each Chinese character in the text to be corrected, according to a preset search strategy, search the inverted index corresponding to the target dictionary one by one to obtain a plurality of candidate word-to-be-corrected word pairs; wherein the candidate word is a suspected erroneous word in the text to be corrected, and the to-be-corrected word is an entry in the target dictionary; the method of searching the inverted index corresponding to the target dictionary one by one according to the preset search strategy to obtain a plurality of candidate word-to-be-corrected word pairs includes: taking each Chinese character in the text to be corrected as a target Chinese character one by one, searching the inverted index for an entry corresponding to the target Chinese character as a target entry; searching the inverted index for an entry corresponding to the target Chinese character according to the position of the target Chinese character in the target entry, and the The position of the target Chinese character in the text to be corrected is used to determine the word to be checked corresponding to the target entry; wherein the word to be checked is a vocabulary that needs to be further checked to see if it belongs to a candidate word; for each word to be checked corresponding to the target entry, it is determined whether the degree of matching between the word to be checked and the target entry is within a preset matching range; wherein the degree of matching represents the ratio of the number of identical characters between the word to be checked and the target entry to the total number of characters, wherein the number of identical characters is the number of characters with the same Chinese character at the same position, and the total number of characters is the total number of characters in the word to be checked; if so, the word to be checked is used as a candidate word, and the target entry corresponding to the word to be checked is used as a word to be corrected, to construct the candidate word-to-corrected word pair; For each candidate word, a unique designated candidate word-to-be-corrected word pair is determined from a plurality of candidate word-to-be-corrected word pairs that include the candidate word, including: for each candidate word, a similarity between the candidate word and the to-be-corrected word in each candidate word-to-be-corrected word pair that includes the candidate word is determined; for each candidate word, the candidate word-to-be-corrected word pair with the highest similarity is used as the designated candidate word-to-be-corrected word pair of the candidate word; For each designated candidate word-to-be-corrected word pair, determining whether the to-be-corrected word is a corrected word of the candidate word; Based on the judgment results of all designated candidate word-to-be-corrected word pairs, the error correction result of the text to be corrected is obtained.

2. The method according to claim 1, characterized in that Before searching the inverted indexes corresponding to the target dictionary one by one to obtain a plurality of candidate word-to-be-corrected word pairs, the method further includes: Obtaining the target dictionary, and parsing a plurality of entries from the target dictionary; The inverted index is constructed based on each Chinese character in the multiple entries as a key; wherein the inverted index includes mapping relationships between multiple Chinese characters and entries containing the Chinese characters.

3. The method according to claim 1, characterized in that Before constructing the candidate word-to-be-corrected word pair, the method further includes: Determine whether the word to be checked is in a preset stop word list; If yes, filter the words to be checked; If not, continue to execute the step of constructing the candidate word-to-be-corrected word pair.

4. The method according to claim 1, characterized in that: Before constructing the candidate word-to-be-corrected word pair, the method further includes: Determine whether the last character of the word to be checked and the first character after the word to be checked in the text to be corrected are both designated characters; If yes, filter the word to be checked; If not, continue to execute the step of constructing the candidate word-to-be-corrected word pair.

5. The method according to claim 1, characterized in that Before constructing the candidate word-to-be-corrected word pair, the method further includes: Determining whether the word to be checked and the target entry have constructed a candidate word-to-be-corrected word pair; If yes, filter the words to be checked; If not, continue to execute the step of constructing the candidate word-to-be-corrected word pair.

6. A text error correction device, characterized in that: include: A retrieval module is used to retrieve each Chinese character in the error correction text one by one in the inverted index corresponding to the target dictionary according to a preset retrieval strategy, and obtain multiple candidate word-to-be-corrected word pairs; wherein the candidate word is a suspected erroneous word in the error correction text, and the to-be-corrected word is an entry in the target dictionary; the retrieval module is used to retrieve each Chinese character in the error correction text one by one in the inverted index corresponding to the target dictionary according to a preset retrieval strategy, and obtain multiple candidate word-to-be-corrected word pairs, including: taking each Chinese character in the error correction text as a target Chinese character, searching for an entry corresponding to the target Chinese character in the inverted index as a target entry; according to the position of the target Chinese character in the target entry, and the position of the target Chinese character in the text to be corrected, determine the word to be checked corresponding to the target entry; wherein the word to be checked is a vocabulary that needs to be further checked to see if it belongs to a candidate word; for each word to be checked corresponding to the target entry, determine whether the degree of matching between the word to be checked and the target entry is within a preset matching range; wherein the degree of matching represents the ratio of the number of identical characters between the word to be checked and the target entry to the total number of characters, wherein the number of identical characters is the number of characters with the same Chinese character at the same position, and the total number of characters is the total number of characters in the word to be checked; if so, take the word to be checked as a candidate word, take the target entry corresponding to the word to be checked as a proposed correction word, and construct the candidate word-proposed correction word pair; The determination module is used to determine, for each candidate word, a unique designated candidate word-to-be-corrected word pair from a plurality of candidate word-to-be-corrected word pairs including the candidate word, including: for each candidate word, determining the similarity between the candidate word and the to-be-corrected word in each candidate word-to-be-corrected word pair including the candidate word; for each candidate word, using the candidate word-to-be-corrected word pair with the highest similarity as the designated candidate word-to-be-corrected word pair of the candidate word; A judgment module, for judging, for each designated candidate word-to-be-corrected word pair, whether the to-be-corrected word therein is a corrected word of the candidate word; A generation module is used to obtain the error correction result of the text to be corrected based on the judgment results of all designated candidate word-to-be-corrected word pairs.

7. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to execute the text error correction method described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program can be executed by a processor to complete the text error correction method described in any one of claims 1-5.

Citation Information

Patent Citations

  • Error correction method and device based on language model, equipment and storage medium

    CN111428474A

  • Vocabulary error correction method and device, computer equipment and storage medium

    CN111737981A