An intelligent error correction method and device integrating semantics and pronunciation
By dividing the text to be tested into several sentences, combining the error correction model and the dynamic recognition method of typos, and combining the semantics and pronunciation, the problem of insufficient proofreading ability of homophones is solved, and the accuracy and efficiency of error correction are improved.
Patent Information
- Application Number
- CN202310862209.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-13
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2043-07-13
AI Technical Summary
The existing text error correction technology is not very accurate when processing homophones, and the traditional error correction model and typo recognition algorithm are relatively inefficient.
An intelligent error correction method that combines semantics and pronunciation is adopted. By dividing the text to be tested into several sentences, a preset error correction model is used to generate error detection probability vectors and error correction probability vectors, and the error correction results are obtained in combination with the typo dynamic recognition method, and the final error correction results are finally filtered based on the error correction probability.
It improves the proofreading ability of homophones, improves the accuracy and efficiency of error correction, and reduces the probability of correcting correct texts.
Smart Images

Figure CN116956880B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent error correction technology, and in particular to an intelligent error correction method and device integrating semantics and pronunciation. Background Art
[0002] With the development of natural language processing technology, many application scenarios, such as speech recognition, retrieval, intent recognition and dialogue systems, involve text error correction. Therefore, text error correction is a crucial branch of natural language processing technology.
[0003] At present, text error correction generally relies on traditional error correction models or typos recognition algorithms. However, traditional error correction models can only support contextual semantic understanding, and have poor proofreading capabilities for homophones, resulting in a low proofreading accuracy rate. Current typos recognition algorithms require matching all characters in the text to be tested with multiple word libraries, resulting in low proofreading efficiency. Summary of the invention
[0004] The present invention provides an intelligent error correction method and device integrating semantics and pronunciation, which can optimize the proofreading capability of homophones and improve the accuracy and efficiency of error correction.
[0005] In order to solve the above technical problems, the present invention provides an intelligent error correction method integrating semantics and pronunciation, comprising:
[0006] Divide the text to be tested into sentences to form a number of sentences to be tested;
[0007] Using a preset error correction model, generate an error detection probability vector and an error correction probability vector of the sentence to be tested;
[0008] Generate a plurality of first character combinations according to the error detection probability vector and the error correction probability vector of the sentence to be tested, and determine the plurality of first character combinations as first error correction results; wherein the first character combination includes a first character to be corrected and a first correction character;
[0009] Using a preset dynamic method for identifying wrong characters, a plurality of second character combinations corresponding to the sentence to be tested are generated, and the plurality of second character combinations are determined as second error correction results; wherein the second character combination includes a second character to be corrected and a second correction character;
[0010] Determining whether the first error correction result and the second error correction result have the same character combination;
[0011] If the first error correction result and the second error correction result have the same character combination, determining the error correction probability of the first character to be corrected in the same character combination;
[0012] When the error correction probability of the first character to be corrected in the same character combination is less than the preset probability, determining the error correction result of the text to be tested as the second error correction result;
[0013] When the first error correction result and the second error correction result do not have the same character combination, or the error correction probability of the first character to be corrected in the same character combination is greater than the preset probability, the error correction result of the text to be tested is determined to be the combination of the first error correction result and the second error correction result.
[0014] The present invention first divides a text to be tested into a plurality of sentences to be tested, which can shorten the content length of the text to be corrected and improve the error correction efficiency; inputs the sentences to be tested into a preset error correction model to obtain a first error correction result, and then uses the wrong character dynamic recognition method to obtain a second error correction result for the sentences to be tested; determines whether the first error correction result and the second error correction result have overlapping parts, and if so, determines the error correction probability of the overlapping character combination, and if the error correction probability is less than the preset probability, the error correction result of the text to be tested is the second error correction result; if there is no overlapping character combination, or the error correction probability of the overlapping character combination is greater than the preset probability, the error correction result of the text to be tested is the combination of the first error correction result and the second error correction result; uses the error correction model and the wrong character dynamic recognition method to obtain two error correction results for the text to be tested in turn, and then further screens out the final error correction result of the text to be tested according to the error correction probability, which can improve the accuracy of text correction and reduce the probability of correcting the correct text.
[0015] Furthermore, the preset error correction model is used to generate an error detection probability vector and an error correction probability vector of the sentence to be tested, specifically:
[0016] Using the preset error correction model, each sentence to be tested is feature transformed and 3 ID mappings are performed to generate the character ID, sentence ID and pinyin ID of the sentence to be tested respectively;
[0017] Using the embedding layer in the error correction model, an inference operation is performed on the collection of the character ID and the sentence ID of the sentence to be tested to generate a first semantic vector;
[0018] The embedding layer in the error correction model is used to perform inference operations on the pinyin ID of the sentence to be tested to generate a first pinyin vector;
[0019] An error detection probability vector and an error correction probability vector of the sentence to be tested are generated according to the first semantic vector and the first phonetic vector.
[0020] The present invention utilizes an error correction model, first performs id mapping three times on each sentence to be tested, and then performs inference operation according to the result of the id mapping to obtain a first semantic vector and a first phonetic vector respectively, integrating the semantic features and phonetic features of the text. Based on these two vectors, a more accurate and precise error detection probability vector and error correction probability vector can be obtained.
[0021] Furthermore, the preset error correction model is used to perform feature conversion on each sentence to be tested, and 3 ID mappings are performed to generate the character ID, sentence ID and pinyin ID of the sentence to be tested respectively, specifically:
[0022] Use the preset Chinese character id mapping table to convert each sentence to be tested into the corresponding character id;
[0023] Sort each sentence to be tested in positive order and convert each sentence to be tested into a corresponding sentence id;
[0024] Use the preset pinyin id mapping table to convert each sentence to be tested into a corresponding pinyin id.
[0025] The present invention utilizes a Chinese character ID mapping table and a pinyin ID mapping table to flexibly convert semantic features and phonetic features of the sentences to be tested, thereby improving the proofreading capability of homophones; and by sorting the sentences to be tested in positive order, the context of the sentences to be tested can be distinguished, thereby improving the recognition accuracy.
[0026] Further, the generating of the error detection probability vector and the error correction probability vector of the sentence to be tested according to the first semantic vector and the first phonetic vector is specifically:
[0027] Encoding the first semantic vector using an encoder layer in an error correction model to generate a first encoding result;
[0028] Inputting the first encoding result into the error checking layer in the error correction model to form a first error checking vector, and using the softmax function to map and transform the first error checking vector to generate an error checking probability vector of the sentence to be tested;
[0029] Multiplying the error checking probability vector with the first semantic vector and the first phonetic vector respectively to form a first multiplication result and a second multiplication result, and adding the first multiplication result and the second multiplication result to form a character phonetic vector;
[0030] The encoder layer in the error correction model is used to encode the character pinyin vector to generate a second encoding result;
[0031] The second encoding result is input into the error correction layer in the error correction model to generate an error correction probability vector for the sentence to be tested.
[0032] Furthermore, the method generates a plurality of first character combinations according to the error detection probability vector and the error correction probability vector of the sentence to be tested, specifically:
[0033] According to the error checking probability vector of the sentence to be tested, obtaining a number of first characters to be corrected in a number of sentences to be tested;
[0034] Determine a first correction character corresponding to each first character to be corrected according to the error correction probability vector of the sentence to be tested and a plurality of characters to be corrected;
[0035] Each first character to be corrected is combined with a corresponding first correction character to form a plurality of first character combinations.
[0036] Furthermore, the preset dynamic identification method for wrong characters is used to generate a plurality of second character combinations corresponding to the sentence to be tested, specifically:
[0037] Use the preset media industry vocabulary to filter and shield each sentence to be tested;
[0038] Mark the unmasked characters in each sentence to be tested as suspicious characters;
[0039] Using a preset similar word library and a preset homophone word library in sequence, a first suspicious character in the sentence to be tested is replaced with a first replacement character, wherein the first replacement character includes a similar suspicious character and a homophone suspicious character;
[0040] If the replaced sentence to be tested can be blocked by the media industry vocabulary, then marking the first suspicious character as the second character to be corrected, and the first replacement character as the second corrected character;
[0041] Each second character to be corrected is combined with a corresponding second correction character to form a plurality of second character combinations.
[0042] The present invention uses a media industry vocabulary to filter and shield the sentence to be tested, which can omit the proofreading work of the correct content and greatly shorten the content length of the proofreading text; then similar characters and homophones are replaced on the sentence to be tested. If the replaced sentence to be tested can be shielded by the media industry vocabulary, it can be determined that the sentence to be tested contains characters to be corrected, and the similar characters or homophones used for replacement can be determined as the corresponding correction characters; the characters to be corrected and the corresponding correction characters can be obtained more conveniently and quickly, thereby improving the error correction efficiency.
[0043] Furthermore, the text to be tested is divided into sentences to form a number of sentences to be tested, specifically:
[0044] Using the period in the text to be tested as a dividing standard, the text to be tested is divided into a plurality of first sentences;
[0045] If the number of characters in the first sentence is greater than the maximum length preset value, the first sentence whose number of characters is greater than the maximum length preset value is divided into a plurality of second sentences with the maximum length preset value as the length standard;
[0046] The first sentence and all second sentences whose number of characters is not greater than the preset maximum length are determined as sentences to be tested.
[0047] Furthermore, the preset error correction model is specifically:
[0048] Acquire historical corpus containing typos; wherein the historical corpus includes first data with typos marked and second data without typos marked;
[0049] Performing data enhancement on the second data by using a homophone word replacement method;
[0050] Dividing the first data and the second data after data enhancement into a plurality of training sentences whose lengths do not exceed a preset maximum length;
[0051] Using the plurality of training sentences as training sample sets, training the Ernie-CSC model;
[0052] The Ernie-CSC model after training is determined as the error correction model.
[0053] The invention provides an intelligent error correction method integrating semantics and pronunciation. The method comprises the following steps: firstly dividing a text to be tested into a plurality of sentences to be tested, thereby shortening the content length of the text to be corrected and accelerating the error correction efficiency; inputting the sentences to be tested into a preset error correction model, thereby obtaining a first error correction result; and then using a dynamic wrong character recognition method to obtain a second error correction result for the sentences to be tested; judging whether the first error correction result and the second error correction result have overlapping parts, and if so, judging the error correction probability of the overlapping character combination, and if the error correction probability is less than the preset probability, then the error correction result of the text to be tested is the second error correction result; if there is no overlapping character combination, or the error correction probability of the overlapping character combination is greater than the preset probability, then the error correction result of the text to be tested is the combination of the first error correction result and the second error correction result; using the error correction model and the dynamic wrong character recognition method to obtain two error correction results for the text to be tested in turn, and then further screening the final error correction result of the text to be tested according to the error correction probability, thereby improving the accuracy of text error correction and reducing the probability of correcting the correct text.
[0054] Accordingly, the present invention provides an intelligent error correction device integrating semantics and pronunciation, comprising: a division module, a vector generation module, a first result generation module, a second result generation module, a first judgment module, a second judgment module, a first result determination module, and a second result determination module;
[0055] The division module is used to divide the text to be tested into sentences to form a plurality of sentences to be tested;
[0056] The vector generation module is used to generate an error detection probability vector and an error correction probability vector of the sentence to be tested by using a preset error correction model;
[0057] The first result generating module is used to generate a plurality of first character combinations according to the error detection probability vector and the error correction probability vector of the sentence to be tested, and determine the plurality of first character combinations as the first error correction results; wherein the first character combination includes a first character to be corrected and a first correction character;
[0058] The second result generation module is used to generate a plurality of second character combinations corresponding to the sentence to be tested by using a preset dynamic wrong character recognition method, and determine the plurality of second character combinations as the second error correction result; wherein the second character combination includes a second character to be corrected and a second correction character;
[0059] The first judgment module is used to judge whether the first error correction result and the second error correction result have the same character combination;
[0060] The second judgment module is used for judging the error correction probability of the first character to be corrected in the same character combination if the first error correction result and the second error correction result have the same character combination;
[0061] The first result determination module is used to determine that the error correction result of the text to be tested is the second error correction result when the error correction probability of the first character to be corrected in the same character combination is less than a preset probability;
[0062] The second result determination module is used to determine that the error correction result of the text to be tested is the combination of the first error correction result and the second error correction result when there is no identical character combination between the first error correction result and the second error correction result, or the error correction probability of the first character to be corrected in the same character combination is greater than a preset probability.
[0063] Further, the vector generation module includes: a mapping unit, a first operation unit, a second operation unit and a generation unit;
[0064] The mapping unit is used to use a preset error correction model to perform feature conversion on each sentence to be tested, perform 3 ID mappings, and generate a character ID, a sentence ID, and a pinyin ID of the sentence to be tested respectively;
[0065] The first operation unit is used to perform reasoning operation on the collection of the character ID and the sentence ID of the sentence to be tested by using the embedding layer in the error correction model to generate a first semantic vector;
[0066] The second operation unit is used to use the embedding layer in the error correction model to perform an inference operation on the pinyin ID of the sentence to be tested to generate a first pinyin vector;
[0067] The generating unit is used to generate an error detection probability vector and an error correction probability vector of the sentence to be tested according to the first semantic vector and the first phonetic vector.
[0068] The present invention provides an intelligent error correction device integrating semantics and pronunciation, which optimizes the proofreading capability of homophones and improves the accuracy and efficiency of error correction based on the organic combination of modules. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 A flow chart of an embodiment of an intelligent error correction method integrating semantics and pronunciation provided by the present invention;
[0070] Figure 2 A schematic diagram of the structure of an embodiment of the error correction model provided by the present invention;
[0071] Figure 3 A schematic diagram of a flow chart of an embodiment of a method for dynamically identifying wrong characters provided by the present invention;
[0072] Figure 4 A schematic structural diagram of an embodiment of an intelligent error correction device integrating semantics and pronunciation provided by the present invention. DETAILED DESCRIPTION
[0073] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0074] Example 1
[0075] See also Figure 1 , is a flow chart of an embodiment of an intelligent error correction method for integrating semantics and pronunciation provided by the present invention, the method includes steps 101 to 108, each step is specifically as follows:
[0076] Step 101: Divide the text to be tested into sentences to form a number of sentences to be tested.
[0077] Furthermore, in an embodiment of the present invention, the text to be tested is divided into sentences to form a number of sentences to be tested, specifically:
[0078] Using the period in the text to be tested as a dividing standard, the text to be tested is divided into a plurality of first sentences;
[0079] If the number of characters in the first sentence is greater than the maximum length preset value, the first sentence whose number of characters is greater than the maximum length preset value is divided into a plurality of second sentences with the maximum length preset value as the length standard;
[0080] The first sentence and all second sentences whose number of characters is not greater than the preset maximum length are determined as sentences to be tested.
[0081] In the first embodiment of the present invention, there are multiple sentences in the text to be tested. The text to be tested is divided into sentences as units, which can shorten the text content of each proofreading. The maximum length of the sentence to be tested is also set. If the divided sentence to be tested is greater than the maximum length preset value, the sentence to be tested is divided again as a unit of the maximum length preset value, and finally the text to be tested is divided into several sentences whose text lengths are not greater than the maximum length preset value.
[0082] Step 102: Generate an error detection probability vector and an error correction probability vector of the sentence to be tested using a preset error correction model.
[0083] Furthermore, in the embodiment of the present invention, the preset error correction model is specifically:
[0084] Acquire historical corpus containing typos; wherein the historical corpus includes first data with typos marked and second data without typos marked;
[0085] Performing data enhancement on the second data by using a homophone word replacement method;
[0086] Dividing the first data and the second data after data enhancement into a plurality of training sentences whose lengths do not exceed a preset maximum length;
[0087] Using the plurality of training sentences as training sample sets, training the Ernie-CSC model;
[0088] The Ernie-CSC model after training is determined as the error correction model.
[0089] In the first embodiment of the present invention, the error correction model is formed using the Ernie-CSC model, and a historical corpus containing typos can be selected to form a training sample set for training. The content containing typos in the manuscript is marked by manual annotation, and the corpus data containing typos can be automatically screened out as historical corpus. Among them, there are also typos that are not marked in the historical corpus, so in order to achieve a balanced data volume of positive and negative samples, it is necessary to perform data enhancement processing on the historical corpus that does not contain typos, and homophonic words can be used to randomly replace the original text, thereby improving the robustness and generalization ability of the model.
[0090] Furthermore, in an embodiment of the present invention, a preset error correction model is used to generate an error detection probability vector and an error correction probability vector of the sentence to be tested, specifically:
[0091] Using the preset error correction model, each sentence to be tested is feature transformed and 3 ID mappings are performed to generate the character ID, sentence ID and pinyin ID of the sentence to be tested respectively;
[0092] Using the embedding layer in the error correction model, an inference operation is performed on the collection of the character ID and the sentence ID of the sentence to be tested to generate a first semantic vector;
[0093] The embedding layer in the error correction model is used to perform inference operations on the pinyin ID of the sentence to be tested to generate a first pinyin vector;
[0094] An error detection probability vector and an error correction probability vector of the sentence to be tested are generated according to the first semantic vector and the first phonetic vector.
[0095] In the first embodiment of the present invention, the error correction model is used to perform id mapping three times on each sentence to be tested, and then an inference operation is performed based on the result of the id mapping, so as to obtain a first semantic vector that integrates the semantic features of the sentence to be tested and a first phonetic vector that integrates the phonetic features of the sentence to be tested. Based on these two vectors, a more accurate and precise error detection probability vector and error correction probability vector can be obtained.
[0096] Furthermore, in the embodiment of the present invention, a preset error correction model is used to perform feature conversion on each sentence to be tested, and 3 ID mappings are performed to generate the character ID, sentence ID and pinyin ID of the sentence to be tested, respectively, as follows:
[0097] Use the preset Chinese character id mapping table to convert each sentence to be tested into the corresponding character id;
[0098] Sort each sentence to be tested in positive order and convert each sentence to be tested into a corresponding sentence id;
[0099] Use the preset pinyin id mapping table to convert each sentence to be tested into a corresponding pinyin id.
[0100] As an example of the first embodiment of the present invention, feature conversion is performed on each sentence to be tested, and character id mapping, sentence id mapping and pinyin id mapping are performed respectively, specifically:
[0101] 1) Character ID mapping: The Chinese character ID mapping table contains more than 10,000 commonly used Chinese characters. Each Chinese character corresponds to a unique ID. The sentence to be tested can be converted into a character ID through the Chinese character ID mapping table. For example:
[0102] Sentence = I am Zhang San.
[0103] Character id=[start_id,id1,id2,id3,id4,end_id];
[0104] 2) Sentence ID mapping: Within the maximum length range, it is necessary to distinguish the relationship between sentences. Therefore, sentences are assigned IDs (starting from 0) in a positive order to form the sentence ID of the sentence to be tested. For example:
[0105] Sentence = I am Zhang San. I am 18 years old.
[0106] sentence_id = [0,0,0,0,0,1,1,1,1,1];
[0107] 3) Pinyin ID mapping: The Pinyin ID mapping table contains more than 10,000 commonly used Pinyins. Each Pinyin corresponds to a unique ID. The sentences to be tested are converted into Pinyins, and then converted into Pinyin IDs through the Pinyin ID mapping table.
[0108] Sentence = I am Zhang San.
[0109] pinyin=wo shi zhang san.
[0110] Pinyin id = [id1, id2, id3, id4].
[0111] In the first embodiment of the present invention, the Chinese character ID mapping table and the Pinyin ID mapping table are used to flexibly convert the semantic features and phonetic features of the test sentence, thereby improving the proofreading ability of homophones; the test sentences are sorted in positive order, which can distinguish the context of the test sentences and improve the recognition accuracy.
[0112] Further, in an embodiment of the present invention, an error detection probability vector and an error correction probability vector of the sentence to be tested are generated according to the first semantic vector and the first phonetic vector, specifically:
[0113] Encoding the first semantic vector using an encoder layer in an error correction model to generate a first encoding result;
[0114] Inputting the first encoding result into the error checking layer in the error correction model to form a first error checking vector, and using the softmax function to map and transform the first error checking vector to generate an error checking probability vector of the sentence to be tested;
[0115] Multiplying the error checking probability vector with the first semantic vector and the first phonetic vector respectively to form a first multiplication result and a second multiplication result, and adding the first multiplication result and the second multiplication result to form a character phonetic vector;
[0116] The encoder layer in the error correction model is used to encode the character pinyin vector to generate a second encoding result;
[0117] The second encoding result is input into the error correction layer in the error correction model to generate an error correction probability vector for the sentence to be tested.
[0118] In the first embodiment of the present invention, the collection of the character ID and sentence ID of the sentence to be tested is used as the input of the embedding layer in the error correction model, and after reasoning operation, the first semantic vector can be obtained. The pinyin ID of the sentence to be tested is used as the input of the embedding layer in the error correction model, and after reasoning operation, the first pinyin vector can be obtained. The first semantic vector is encoded by the encoder layer of the error correction model, and the encoding result is input to the error checking layer to obtain the first error checking vector. The first error checking vector is mapped and converted by the softmax function to obtain the error checking probability vector. The error checking probability vector is multiplied with the first semantic vector and the first pinyin vector respectively, and then the two multiplication results are added to obtain the text pinyin vector, wherein the obtained text pinyin vector combines semantic information and phonetic information, which can enhance the information expression ability of the vector. The text pinyin vector can be encoded by the encoder layer of the error correction model, and the encoding result is input to the error correction layer to obtain the error correction probability.
[0119] As an example of the first embodiment of the present invention, the error detection probability vector of each character is a vector of length 2, representing the probability of correctness and error, respectively. It is assumed here that the index corresponding to the correct probability is 0, and the index corresponding to the error probability is 1. The error detection probability of each character is argmaxed to extract the index corresponding to the maximum probability value. If the index corresponding to the character is 0, the character is correct, and the corresponding value of the error detection probability vector of the character in the corresponding sentence to be tested is 0. Conversely, for example, assuming that the first character is the first word of the first sentence to be tested:
[0120] The probability of error detection of the first character = [0.8, 0.2];
[0121] The index corresponding to the error detection probability of the first character = 0;
[0122] The error detection probability of the first sentence to be tested = [1, x, ..., y];
[0123] Among them; x is the index corresponding to the second word of the first sentence to be tested, and y is the index corresponding to the last word of the first sentence to be tested.
[0124] As an example of the first embodiment of the present invention, assuming that there are 10,000 characters in the dictionary, the error correction probability vector of each character is a 1x10,000 vector, and the character in the dictionary corresponding to the largest probability value in the vector is the character with the highest possibility of correction of the character, for example:
[0125] Assume that the second character is '气' (qi). If the maximum probability value in the error correction probability vector of the second character corresponds to the character '汽' (qi) in the dictionary, then it is most likely to modify the second character '气' to '汽'.
[0126] Therefore, the error correction probability vector of the second sentence to be tested where the second character is located is an nx10000 vector, where n is the number of characters in the second sentence to be tested.
[0127] Step 103: Generate a number of first character combinations based on the error detection probability vector and the error correction probability vector of the sentence to be tested, and determine the number of first character combinations as the first error correction result; wherein, the first character combination includes the first character to be error corrected and the first corrected character.
[0128] Further, in the embodiment of the present invention, generating a number of first character combinations based on the error detection probability vector and the error correction probability vector of the sentence to be tested is specifically as follows:
[0129] Obtain a number of first characters to be error corrected in the number of sentences to be tested according to the error detection probability vector of the sentence to be tested;
[0130] Determine the first corrected character corresponding to each first character to be error corrected according to the error correction probability vector of the sentence to be tested and the number of characters to be error corrected;
[0131] Combine each first character to be error corrected and the corresponding first corrected character to form a number of first character combinations.
[0132] In the first embodiment of the present invention, after obtaining the error detection probability vector and the error correction probability vector of each sentence to be tested, a number of character combinations can be determined, and each character combination includes a character to be error corrected and the corrected character that it is most likely to be modified to.
[0133] As an example of the first embodiment of the present invention, see Figure 2, is a structural diagram of an embodiment of the error correction model provided by the present invention, and the error correction model includes a data layer, a feature layer and a training layer. The data layer is to obtain historical corpus, and perform data screening and data enhancement on it to form a proofreading corpus that conforms to the training model; the proofreading corpus is input into the feature layer, assuming that the maximum length of the sentence of the error correction model is 128, the proofreading corpus is segmented to form a number of sentences with a maximum length of 128 to form a training sample; the training sample is respectively subjected to token_id mapping, token_type_id mapping and pinyin_id mapping, and three mapping results of token_ids (character id), token_type_id (sentence id) and pinyin_ids (pinyin id) are formed respectively. These three mapping results are input into the training layer, and the error detection probability vector and the error correction probability vector are generated through the Ernie-CSC-embedings layer, Ernie-CSC-emcoder layer, Ernie-CSC-correction-layer layer and Ernie-CSC-detection-layer layer of the training layer in turn.
[0134] Step 104: using a preset dynamic method for identifying wrong characters, generate a plurality of second character combinations corresponding to the sentence to be tested, and determine the plurality of second character combinations as a second error correction result; wherein the second character combination includes a second character to be corrected and a second correction character.
[0135] Furthermore, in an embodiment of the present invention, a preset dynamic method for identifying wrong characters is used to generate a plurality of second character combinations corresponding to the sentence to be tested, specifically:
[0136] Use the preset media industry vocabulary to filter and shield each sentence to be tested;
[0137] Mark the unmasked characters in each sentence to be tested as suspicious characters;
[0138] Using a preset similar word library and a preset homophone word library in sequence, a first suspicious character in the sentence to be tested is replaced with a first replacement character, wherein the first replacement character includes a similar suspicious character and a homophone suspicious character;
[0139] If the replaced sentence to be tested can be blocked by the media industry vocabulary, then marking the first suspicious character as the second character to be corrected, and the first replacement character as the second corrected character;
[0140] Each second character to be corrected is combined with a corresponding second correction character to form a plurality of second character combinations.
[0141] As an example of an embodiment of the present invention, the media industry thesaurus covers more than two hundred thousand commonly used words in the media industry, which are used to screen and filter correct words in manuscripts and judge misspelled words. For example: [media, industry,..., new media]. The similar word thesaurus covers nearly one hundred thousand similar-shaped characters, which are used to identify similar characters in suspected misspelled words. For example [person: enter, enter: person,....., already: oneself, oneself: already]. The homophone thesaurus covers nearly one hundred thousand homophones, which are used to identify homophones in suspected misspelled words. For example [qi: qi, qi: qi,....., severe: calendar, calendar: severe].
[0142] In the first embodiment of the present invention, using the media industry thesaurus to perform filtering and shielding processing on the sentence to be tested can omit the proofreading work of correct content, and greatly shorten the content length of the proofread text; then perform similar character and homophone replacement on the sentence to be tested. If the sentence to be tested after replacement can be shielded by the media industry thesaurus, it can be determined that the sentence to be tested contains characters to be corrected, and the similar characters or homophones used for replacement can be determined as the corresponding corrected characters; the characters to be corrected and the corresponding corrected characters can be obtained more conveniently and quickly, improving the error correction efficiency.
[0143] As an example of an embodiment of the present invention, see Figure 3 , which is a schematic flowchart of an embodiment of the dynamic misspelled word recognition method provided by the present invention. Select the media industry thesaurus, similar word thesaurus, and homophone thesaurus from multiple proofreading thesauruses. Assume that the sentence to be tested is "I am Zhang San, from Guangzhou, and I am eighteen years old this year." After shielding processing through the media industry thesaurus, it becomes "**Zhang San***Guangzhou*This year is***." Therefore, "Zhang San", "Guangzhou", and "This year is" can be marked, and the marked characters are replaced using the similar word thesaurus and the homophone thesaurus. The replaced characters are "Zhang San", "Guangzhou", and "This year is", then it can be determined that the characters to be corrected are "涨", "洲", and "令", and the corresponding corrected characters are "张", "州", and "今".
[0144] Step 105: Determine whether there are the same character combinations in the first error correction result and the second error correction result.
[0145] Step 106: If there are the same character combinations in the first error correction result and the second error correction result, then determine the error correction probability of the first character to be corrected in the same character combination.
[0146] Step 107: When the error correction probability of the first character to be corrected in the same character combination is less than the preset probability, determine that the error correction result of the text to be tested is the second error correction result.
[0147] Step 108: When the first error correction result and the second error correction result do not have the same character combination, or the error correction probability of the first character to be corrected in the same character combination is greater than a preset probability, determine that the error correction result of the text to be tested is a combination of the first error correction result and the second error correction result.
[0148] In summary, the first embodiment of the present invention provides an intelligent error correction method that integrates semantics and pronunciation. The text to be tested is first divided into a number of sentences to be tested, which can shorten the content length of the text to be corrected and speed up the error correction efficiency. These sentences to be tested are input into a preset error correction model to obtain a first error correction result, and then these sentences to be tested are used to obtain a second error correction result by using a dynamic wrong character recognition method. It is determined whether the first error correction result and the second error correction result have overlapping parts. If so, the error correction probability of the overlapping character combination is determined. If the error correction probability is less than the preset probability, the error correction result of the text to be tested is the second error correction result. If there is no overlapping character combination, or the error correction probability of the overlapping character combination is greater than the preset probability, the error correction result of the text to be tested is a combination of the first error correction result and the second error correction result. The text to be tested is successively obtained by using an error correction model and a dynamic wrong character recognition method to obtain two error correction results, and then the final error correction result of the text to be tested is further screened out according to the error correction probability, which can improve the accuracy of text correction and reduce the probability of correcting the correct text.
[0149] Example 2
[0150] See also Figure 4 , is a schematic diagram of the structure of an embodiment of an intelligent error correction device integrating semantics and pronunciation provided by the present invention, the device comprises a division module 201, a vector generation module 202, a first result generation module 203, a second result generation module 204, a first judgment module 205, a second judgment module 206, a first result determination module 207 and a second result determination module 208;
[0151] The division module 201 is used to divide the text to be tested into sentences to form a number of sentences to be tested;
[0152] The vector generation module 202 is used to generate an error detection probability vector and an error correction probability vector of the sentence to be tested by using a preset error correction model;
[0153] The first result generating module 203 is used to generate a plurality of first character combinations according to the error detection probability vector and the error correction probability vector of the sentence to be tested, and determine the plurality of first character combinations as the first error correction results; wherein the first character combination includes a first character to be corrected and a first correction character;
[0154] The second result generation module 204 is used to generate a plurality of second character combinations corresponding to the sentence to be tested by using a preset dynamic wrong character recognition method, and determine the plurality of second character combinations as the second error correction result; wherein the second character combination includes a second character to be corrected and a second corrected character;
[0155] The first judgment module 205 is used to judge whether the first error correction result and the second error correction result have the same character combination;
[0156] The second judgment module 206 is used to judge the error correction probability of the first character to be corrected in the same character combination if the first error correction result and the second error correction result have the same character combination;
[0157] The first result determination module 207 is used to determine that the error correction result of the text to be tested is a second error correction result when the error correction probability of the first character to be corrected in the same character combination is less than a preset probability;
[0158] The second result determination module 208 is used to determine that the error correction result of the text to be tested is a combination of the first error correction result and the second error correction result when there is no identical character combination between the first error correction result and the second error correction result, or the error correction probability of the first character to be corrected in the same character combination is greater than a preset probability.
[0159] Further, in the second embodiment of the present invention, the vector generation module 202 includes: a mapping unit, a first operation unit, a second operation unit and a generation unit;
[0160] The mapping unit is used to use a preset error correction model to perform feature conversion on each sentence to be tested, perform 3 ID mappings, and generate a character ID, a sentence ID, and a pinyin ID of the sentence to be tested respectively;
[0161] The first operation unit is used to perform reasoning operation on the collection of the character ID and the sentence ID of the sentence to be tested by using the embedding layer in the error correction model to generate a first semantic vector;
[0162] The second operation unit is used to use the embedding layer in the error correction model to perform an inference operation on the pinyin ID of the sentence to be tested to generate a first pinyin vector;
[0163] The generating unit is used to generate an error detection probability vector and an error correction probability vector of the sentence to be tested according to the first semantic vector and the first phonetic vector.
[0164] Further, in the second embodiment of the present invention, the mapping unit includes a first mapping subunit, a second mapping subunit and a third mapping subunit;
[0165] The first mapping subunit is used to convert each sentence to be tested into a corresponding character id using a preset Chinese character id mapping table;
[0166] The second mapping subunit is used to sort each sentence to be tested in positive order and convert each sentence to be tested into a corresponding sentence id;
[0167] The third mapping subunit is used to convert each sentence to be tested into a corresponding pinyin id using a preset pinyin id mapping table.
[0168] Further, in the second embodiment of the present invention, the generating unit includes a first encoding subunit, a first generating subunit, a second generating subunit, a second encoding subunit and a third generating subunit;
[0169] The first encoding subunit is used to encode the first semantic vector by using the encoder layer in the error correction model to generate a first encoding result;
[0170] The first generating subunit is used to input the first encoding result into the error checking layer in the error correction model to form a first error checking vector, and use the softmax function to map and transform the first error checking vector to generate an error checking probability vector of the sentence to be tested;
[0171] The second generating subunit is used for multiplying the error checking probability vector with the first semantic vector and the first phonetic vector respectively to form a first multiplication result and a second multiplication result, and adding the first multiplication result and the second multiplication result to form a character phonetic vector;
[0172] The second encoding subunit is used to encode the character pinyin vector using the encoder layer in the error correction model to generate a second encoding result;
[0173] The third generating subunit is used to input the second encoding result into the error correction layer in the error correction model to generate an error correction probability vector for the sentence to be tested.
[0174] Further, in the second embodiment of the present invention, the first result generating module 203 includes an acquiring unit, a character determining unit and a first forming unit;
[0175] The acquisition unit is used to acquire a plurality of first characters to be corrected in a plurality of sentences to be tested according to the error checking probability vector of the sentences to be tested;
[0176] The character determination unit is used to determine a first correction character corresponding to each first character to be corrected according to the error correction probability vector of the sentence to be tested and a plurality of characters to be corrected;
[0177] The first forming unit is used for combining each first to-be-corrected character with the corresponding first correction character to form a plurality of first character combinations.
[0178] Further, in the second embodiment of the present invention, the second result generating module 204 includes a first shielding unit, a marking unit, a replacing unit, a second shielding unit and a second forming unit;
[0179] The first shielding unit is used to filter and shield each sentence to be tested by using a preset media industry vocabulary;
[0180] The marking unit is used to mark the unshielded characters in each sentence to be tested as suspicious characters;
[0181] The replacement unit is used to sequentially use a preset similar word library and a homophone word library to replace the first suspicious character in the sentence to be tested with a first replacement character, wherein the first replacement character includes a similar suspicious character and a homophone suspicious character;
[0182] The second shielding unit is used for marking the first suspicious character as the second character to be corrected and the first replacement character as the second correction character if the replaced sentence to be tested can be shielded by the media industry vocabulary;
[0183] The second forming unit is used for combining each second character to be corrected with the corresponding second correction character to form a plurality of second character combinations.
[0184] Further, in the second embodiment of the present invention, the division module 201 includes a first division unit, a second division unit and a sentence determination unit;
[0185] The first division unit is used to divide the text to be tested into a plurality of first sentences based on the period in the text to be tested as a division standard;
[0186] The second division unit is used for dividing the first sentence whose number of characters is greater than the maximum length preset value into a plurality of second sentences with the maximum length preset value as the length standard if the number of characters of the first sentence is greater than the maximum length preset value;
[0187] The sentence determination unit is used to determine the first sentence whose number of characters is not greater than the preset maximum length value and all the second sentences as sentences to be tested.
[0188] Furthermore, in the second embodiment of the present invention, the preset error correction model is specifically:
[0189] Acquire historical corpus containing typos; wherein the historical corpus includes first data with typos marked and second data without typos marked;
[0190] Performing data enhancement on the second data by using a homophone word replacement method;
[0191] Dividing the first data and the second data after data enhancement into a plurality of training sentences whose lengths do not exceed a preset maximum length;
[0192] Using the plurality of training sentences as training sample sets, training the Ernie-CSC model;
[0193] The Ernie-CSC model after training is determined as the error correction model.
[0194] In summary, the second embodiment of the present invention provides an intelligent error correction device that integrates semantics and pronunciation. Based on the organic combination of modules, the text to be tested is first divided into a number of sentences to be tested, which can shorten the content length of the text to be corrected and speed up the error correction efficiency; these sentences to be tested are input into a preset error correction model to obtain a first error correction result, and then these sentences to be tested are used to obtain a second error correction result using a dynamic recognition method for wrong characters; it is determined whether the first error correction result and the second error correction result have overlapping parts, and if so, the error correction probability of the overlapping character combination is determined, and if the error correction probability is less than the preset probability, the error correction result of the text to be tested is the second error correction result; if there is no overlapping character combination, or the error correction probability of the overlapping character combination is greater than the preset probability, the error correction result of the text to be tested is a combination of the first error correction result and the second error correction result; the text to be tested is successively obtained by using the error correction model and the dynamic recognition method for wrong characters to obtain two error correction results, and then the final error correction result of the text to be tested is further screened out according to the error correction probability, which can improve the accuracy of text correction and reduce the probability of correcting the correct text.
[0195] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.
Claims
1. An intelligent error correction method integrating semantics and pronunciation, characterized in that: include: Divide the text to be tested into sentences to form a number of sentences to be tested; Using a preset error correction model, generate an error detection probability vector and an error correction probability vector of the sentence to be tested; Generate a plurality of first character combinations according to the error detection probability vector and the error correction probability vector of the sentence to be tested, and determine the plurality of first character combinations as first error correction results; wherein the first character combination includes a first character to be corrected and a first correction character; Using a preset dynamic method for identifying wrong characters, a plurality of second character combinations corresponding to the sentence to be tested are generated, and the plurality of second character combinations are determined as second error correction results; wherein the second character combination includes a second character to be corrected and a second correction character; Determining whether the first error correction result and the second error correction result have the same character combination; If the first error correction result and the second error correction result have the same character combination, determining the error correction probability of the first character to be corrected in the same character combination; When the error correction probability of the first character to be corrected in the same character combination is less than the preset probability, determining the error correction result of the text to be tested as the second error correction result; When the first error correction result and the second error correction result do not have the same character combination, or the error correction probability of the first character to be corrected in the same character combination is greater than a preset probability, determining that the error correction result of the text to be tested is a combination of the first error correction result and the second error correction result; The method of using a preset error correction model to generate an error detection probability vector and an error correction probability vector of the sentence to be tested is specifically as follows: Using the preset error correction model, each sentence to be tested is feature transformed and 3 ID mappings are performed to generate the character ID, sentence ID and pinyin ID of the sentence to be tested respectively; Using the embedding layer in the error correction model, an inference operation is performed on the collection of the character ID and the sentence ID of the sentence to be tested to generate a first semantic vector; The embedding layer in the error correction model is used to perform inference operations on the pinyin ID of the sentence to be tested to generate a first pinyin vector; Generate an error detection probability vector and an error correction probability vector of the sentence to be tested according to the first semantic vector and the first phonetic vector; The method of using a preset dynamic method for identifying wrong characters to generate a plurality of second character combinations corresponding to the sentence to be tested is specifically: Use the preset media industry vocabulary to filter and shield each sentence to be tested; Mark the unmasked characters in each sentence to be tested as suspicious characters; Using a preset similar word library and a preset homophone word library in sequence, a first suspicious character in the sentence to be tested is replaced with a first replacement character, wherein the first replacement character includes a similar suspicious character and a homophone suspicious character; If the replaced sentence to be tested can be blocked by the media industry vocabulary, then marking the first suspicious character as the second character to be corrected, and the first replacement character as the second corrected character; Each second character to be corrected is combined with a corresponding second correction character to form a plurality of second character combinations.
2. The intelligent error correction method integrating semantics and pronunciation according to claim 1 is characterized in that: The preset error correction model is used to perform feature conversion on each sentence to be tested, and 3 ID mappings are performed to generate the character ID, sentence ID and pinyin ID of the sentence to be tested respectively, specifically: Use the preset Chinese character id mapping table to convert each sentence to be tested into the corresponding character id; Sort each sentence to be tested in positive order and convert each sentence to be tested into a corresponding sentence id; Use the preset pinyin id mapping table to convert each sentence to be tested into a corresponding pinyin id.
3. The intelligent error correction method integrating semantics and pronunciation according to claim 1 is characterized in that: The step of generating an error detection probability vector and an error correction probability vector of the sentence to be tested according to the first semantic vector and the first phonetic vector is specifically as follows: Encoding the first semantic vector using an encoder layer in an error correction model to generate a first encoding result; Inputting the first encoding result into the error checking layer in the error correction model to form a first error checking vector, and using the softmax function to map and transform the first error checking vector to generate an error checking probability vector of the sentence to be tested; Multiplying the error checking probability vector with the first semantic vector and the first phonetic vector respectively to form a first multiplication result and a second multiplication result, and adding the first multiplication result and the second multiplication result to form a character phonetic vector; The encoder layer in the error correction model is used to encode the character pinyin vector to generate a second encoding result; The second encoding result is input into the error correction layer in the error correction model to generate an error correction probability vector for the sentence to be tested.
4. The intelligent error correction method integrating semantics and pronunciation according to claim 1, characterized in that: The method generates a plurality of first character combinations according to the error detection probability vector and the error correction probability vector of the sentence to be tested, specifically: According to the error checking probability vector of the sentence to be tested, obtaining a number of first characters to be corrected in a number of sentences to be tested; Determine a first correction character corresponding to each first character to be corrected according to the error correction probability vector of the sentence to be tested and a plurality of characters to be corrected; Each first character to be corrected is combined with a corresponding first correction character to form a plurality of first character combinations.
5. The intelligent error correction method integrating semantics and pronunciation according to claim 1 is characterized in that: The text to be tested is divided into sentences to form a number of sentences to be tested, specifically: Using the period in the text to be tested as a dividing standard, the text to be tested is divided into a plurality of first sentences; If the number of characters in the first sentence is greater than the maximum length preset value, the first sentence whose number of characters is greater than the maximum length preset value is divided into a plurality of second sentences with the maximum length preset value as the length standard; The first sentence and all second sentences whose number of characters is not greater than the preset maximum length are determined as sentences to be tested.
6. The intelligent error correction method integrating semantics and pronunciation according to claim 1, characterized in that: The preset error correction model is specifically: Acquire historical corpus containing typos; wherein the historical corpus includes first data with typos marked and second data without typos marked; Performing data enhancement on the second data by using a homophone word replacement method; Dividing the first data and the second data after data enhancement into a plurality of training sentences whose lengths do not exceed a preset maximum length; Using the plurality of training sentences as training sample sets, training the Ernie-CSC model; The Ernie-CSC model after training is determined as the error correction model.
7. An intelligent error correction device integrating semantics and pronunciation, characterized in that: include: A division module, a vector generation module, a first result generation module, a second result generation module, a first judgment module, a second judgment module, a first result determination module, and a second result determination module; The division module is used to divide the text to be tested into sentences to form a plurality of sentences to be tested; The vector generation module is used to generate an error detection probability vector and an error correction probability vector of the sentence to be tested by using a preset error correction model; The first result generating module is used to generate a plurality of first character combinations according to the error detection probability vector and the error correction probability vector of the sentence to be tested, and determine the plurality of first character combinations as the first error correction results; wherein the first character combination includes a first character to be corrected and a first correction character; The second result generation module is used to generate a plurality of second character combinations corresponding to the sentence to be tested by using a preset dynamic wrong character recognition method, and determine the plurality of second character combinations as the second error correction result; wherein the second character combination includes a second character to be corrected and a second correction character; The first judgment module is used to judge whether the first error correction result and the second error correction result have the same character combination; The second judgment module is used for judging the error correction probability of the first character to be corrected in the same character combination if the first error correction result and the second error correction result have the same character combination; The first result determination module is used to determine that the error correction result of the text to be tested is a second error correction result when the error correction probability of the first character to be corrected in the same character combination is less than a preset probability; The second result determination module is used to determine that the error correction result of the text to be tested is a combination of the first error correction result and the second error correction result when there is no identical character combination between the first error correction result and the second error correction result, or the error correction probability of the first character to be corrected in the same character combination is greater than a preset probability; Wherein, the vector generation module includes: a mapping unit, a first operation unit, a second operation unit and a generation unit; The mapping unit is used to use a preset error correction model to perform feature conversion on each sentence to be tested, perform 3 ID mappings, and generate a character ID, a sentence ID, and a pinyin ID of the sentence to be tested respectively; The first operation unit is used to perform reasoning operation on the collection of character ID and sentence ID of the sentence to be tested by using the embedding layer in the error correction model to generate a first semantic vector; The second operation unit is used to use the embedding layer in the error correction model to perform an inference operation on the pinyin ID of the sentence to be tested to generate a first pinyin vector; The generating unit is used to generate an error detection probability vector and an error correction probability vector of the sentence to be tested according to the first semantic vector and the first phonetic vector; Wherein, the second result generating module comprises a first shielding unit, a marking unit, a replacing unit, a second shielding unit and a second forming unit; The first shielding unit is used to filter and shield each sentence to be tested by using a preset media industry vocabulary; The marking unit is used to mark the unshielded characters in each sentence to be tested as suspicious characters; The replacement unit is used to sequentially use a preset similar word library and a homophone word library to replace the first suspicious character in the sentence to be tested with a first replacement character, wherein the first replacement character includes a similar suspicious character and a homophone suspicious character; The second shielding unit is used for marking the first suspicious character as the second character to be corrected and the first replacement character as the second correction character if the replaced sentence to be tested can be shielded by the media industry vocabulary; The second forming unit is used for combining each second character to be corrected with the corresponding second correction character to form a plurality of second character combinations.
Citation Information
Patent Citations
Automatically correcting method for text misspellings and server
CN106776501A
End-to-end Chinese speech text error correction method and device and storage medium
CN114444479A