Text error correction method, device, computer storage medium and computer program product
By segmenting and vectorizing the text to be corrected, and combining the probability and similarity of candidate characters, the problem of low error correction efficiency and accuracy caused by similar pronunciation and glyphs of Chinese characters in the existing technology is solved, and higher text quality is achieved. Error correction accuracy.
Patent Information
- Application Number
- CN202111020960.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-01
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-09-01
AI Technical Summary
In the existing technology, in text error correction, the search space of confusion sets for Chinese characters with similar pronunciation and glyphs is too large, resulting in low error correction efficiency and reduced accuracy, and cannot effectively handle spelling errors that have neither similar pronunciation nor similar glyphs.
By segmenting the text to be corrected, semantic, pronunciation and glyph vectors are generated, feature vectors are calculated, and the error correction results are determined based on the probability and similarity of candidate characters, taking into account the semantic, pronunciation and glyph information of the text.
It improves the accuracy of text error correction and can handle spelling errors with similar pronunciation and similar glyphs in the traditional solution, while effectively handling spelling errors that have neither similar pronunciation nor similar glyphs.
Smart Images

Figure CN113673228B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a text error correction method, device, computer storage medium, and computer program product. Background Art
[0002] With the continuous development of computer software technology, people usually use various input tools to input text. Compared with phonetic languages such as English, ideographic languages such as Chinese, although they express rich and diverse meanings, are prone to spelling, similar shapes, and similar pronunciations. On the one hand, spelling errors will make the text more easily misunderstood and affect communication efficiency; on the other hand, in many rigorous document scenarios, such as judicial, contract, news releases, etc., the requirements for spelling errors are very strict.
[0003] In order to ensure the correctness of the input, the input text needs to be corrected. In the prior art, taking Chinese characters as an example, the purpose of error correction is achieved by obtaining a confusion set of Chinese characters in the text to be corrected (the confusion set is a set of multiple candidate characters with similar pronunciation and glyphs to the Chinese characters), then selecting candidate characters from the confusion set, and then determining the output result of the text to be corrected based on the candidate characters.
[0004] However, there are a lot of Chinese characters, and there are also a lot of Chinese characters with similar pronunciation and glyphs, which makes the search space of the confusion set of Chinese characters very large. Selecting candidate characters from the confusion set to correct the text to be corrected is not only inefficient but also reduces the accuracy of correction. Other ideographic characters similar to Chinese characters, such as Japanese and Korean, also have the same problem. Summary of the invention
[0005] In view of this, an embodiment of the present application provides a text error correction solution to at least partially solve the above-mentioned problem.
[0006] According to a first aspect of an embodiment of the present application, a text correction method is provided, comprising: segmenting a text to be corrected to obtain a plurality of characters in the text to be corrected; obtaining semantic vectors, pronunciation vectors and glyph vectors respectively corresponding to the plurality of characters, and generating feature vectors of the plurality of characters based on the semantic vectors, the pronunciation vectors and the glyph vectors; obtaining, based on the feature vectors of the plurality of characters, the probability that the plurality of characters in the text to be corrected are respectively mapped to a plurality of candidate characters in a vocabulary; calculating, based on the sound-shape vectors of the plurality of characters and the sound-shape vector of the vocabulary, a similarity representing the relationship between the text to be corrected and a correct text, wherein the sound-shape vector is generated based on the pronunciation vector and the glyph vector; and determining, based on the probabilities of the plurality of candidate characters and the similarities, an output result of the text to be corrected.
[0007] According to a second aspect of an embodiment of the present application, a text correction device is provided, comprising: a segmentation module, used to segment a text to be corrected, and obtain a plurality of characters in the text to be corrected; a feature vector generation module, used to obtain semantic vectors, pronunciation vectors and glyph vectors respectively corresponding to the plurality of characters, and generate feature vectors of the plurality of characters according to the semantic vectors, the pronunciation vectors and the glyph vectors; a probability determination module, used to obtain, according to the feature vectors of the plurality of characters, the probabilities that the plurality of characters in the text to be corrected are respectively mapped to a plurality of candidate characters in a vocabulary; a similarity calculation module, used to calculate the similarity between the text to be corrected and a correct text according to the sound-shape vectors of the plurality of characters and the sound-shape vector of the vocabulary, wherein the sound-shape vector is generated according to the pronunciation vector and the glyph vector; and an output result module, used to determine the output result of the text to be corrected according to the probabilities of the plurality of candidate characters and the similarities.
[0008] According to a third aspect of an embodiment of the present application, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the text correction method described in the first aspect.
[0009] According to a fourth aspect of an embodiment of the present application, a computer storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the text error correction method as described in the first aspect is implemented.
[0010] According to a fifth aspect of an embodiment of the present application, a computer program product is provided, comprising computer instructions, wherein the computer instructions instruct a computing device to perform operations corresponding to the text error correction method described in the first aspect.
[0011] The text error correction scheme provided in the embodiment of the present application is to segment the text to be corrected, obtain multiple characters in the text to be corrected; obtain semantic vectors, pronunciation vectors and glyph vectors corresponding to the multiple characters respectively, and generate feature vectors of multiple characters according to the semantic vectors, pronunciation vectors and glyph vectors. Since the semantics, pronunciation and glyphs corresponding to the characters are considered, the information carried by the generated feature vectors is richer and the text features expressed are more accurate. According to the feature vectors of multiple characters, the probability that multiple characters in the text to be corrected are mapped to multiple candidate characters in the vocabulary is obtained; according to the sound-shape vectors of the multiple characters and the sound-shape vectors of the vocabulary, the similarity between the text to be corrected and the correct text is calculated, and the conversion probability from the text to be corrected to the correct text is calculated by considering the sound-shape vector of the text to obtain the similarity, wherein the sound-shape vector is generated according to the pronunciation vector and the glyph vector. Then, according to the probability and similarity of multiple candidate characters, the output result of the text to be corrected is determined. Since the semantics, pronunciation and glyphs of the characters are considered when determining the probability of multiple candidate characters, the pronunciation and glyphs of the characters are considered when determining the similarity. By combining the probabilities and similarities of multiple candidate characters, the text correction scheme provided in the embodiment of the present application can not only handle spelling errors with similar pronunciations and similar glyphs in traditional schemes, but can also effectively handle spelling errors that are neither similar in pronunciation nor similar in glyphs, thereby improving the accuracy of text correction. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0013] Figure 1 A flowchart of a text error correction method provided in an embodiment of the present application;
[0014] Figure 2 An application scenario diagram of a text error correction method provided in an embodiment of the present application;
[0015] Figure 3 A flowchart of another text error correction method provided in an embodiment of the present application;
[0016] Figure 4 A structural block diagram of a text error correction device provided in an embodiment of the present application;
[0017] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0018] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.
[0019] It should be noted that the first and second in this application are only for distinguishing the names and do not represent an order relationship. They cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated, for example, the first normalization function and the second normalization function.
[0020] The specific implementation of the embodiment of the present application is further explained below in conjunction with the accompanying drawings of the embodiment of the present application.
[0021] Embodiment 1
[0022] like Figure 1 As shown, it is a flowchart of a text error correction method provided by an embodiment of the present application, and the text error correction method comprises the following steps:
[0023] Step S101, segment the text to be corrected to obtain multiple characters in the text to be corrected.
[0024] In this example, the text to be corrected can be segmented by character segmentation, and the text to be corrected can be segmented into multiple characters. In the embodiment of the present application, the text to be corrected at least includes ideographic text such as Chinese. In addition, it can also include other texts and characters, such as: English, French, Korean, Japanese, numbers, Greek, punctuation, etc.
[0025] Take the text to be corrected as an example, including Chinese, English, numbers and punctuation marks. Set the text to be corrected as "I was shocked at 11 o'clock and ate KFC". First, segment the text to be corrected to obtain multiple characters in the text to be corrected, that is, "I was shocked at 11 o'clock and ate KFC". In this example, Chinese characters are segmented into single characters, punctuation marks are segmented into single characters, and numbers, English, special symbols, etc. are segmented to retain their integrity. For example, "11 o'clock" is segmented into "11|points"; "11:00" is segmented into "11:00"; "January 1, 2021" is segmented into "2021|year|01|month|01|day"; "2021-01-01" is segmented into "|2021-01-01|". However, those skilled in the art should understand that in many cases, the text to be corrected may only contain ideographic text, so it can be segmented into single characters.
[0026] Step S102: Obtain semantic vectors, pronunciation vectors and glyph vectors corresponding to a plurality of characters respectively, and generate feature vectors of the plurality of characters according to the semantic vectors, pronunciation vectors and glyph vectors.
[0027] For each character, a semantic vector of the character is generated according to the semantics of the character, and the semantic vector can also be understood as a character vector; a pronunciation vector of the character is generated according to the pronunciation of the character; a glyph vector of the character is generated according to the glyph of the character; a feature vector of the character is generated according to the semantic vector of the character, the pronunciation vector of the character, and the glyph vector of the character, thereby obtaining feature vectors of multiple characters. Optionally, the sum of the semantic vector, the pronunciation vector, and the glyph vector is taken as a feature vector, and the feature vector can be understood as a comprehensive vector that comprehensively considers semantics, pronunciation, and glyph.
[0028] Taking the characters "wo" and "jin" as examples to explain the semantics, pronunciation and character shape, "wo" includes "wo, you, he, she, it" in terms of semantics; includes characters with homophones or near pronunciations of "wo", such as "wo, oh, lie, wo"; includes characters with the same radical or similar character shape as "wo", such as "wo, hungry, oh, e, find". "Jin" includes "jin, ming, hou, zuo" in terms of semantics; includes characters with homophones or near pronunciations of "jin", such as "jin, jing, jing, jin, jin" in terms of pronunciation; includes characters with the same radical or similar character shape as "jin", such as "jin, lian, ling, niang, cen, han, quilt, juan, tan".
[0029] It should be noted that when the text is vectorized in the embodiment of the present application, the semantics, pronunciation and glyph of the text can be encoded respectively through the encoding model to obtain the semantic vector, pronunciation vector and glyph vector of the text. The encoding model can be any appropriately set machine learning model that can be used to vectorize the text. The embodiment of the present application does not limit the specific structure of the machine learning model used, as long as it can encode the text to obtain a vector.
[0030] Step S103: Obtain, based on the feature vectors of the multiple characters, the probabilities that the multiple characters in the text to be corrected are respectively mapped to the multiple candidate characters in the vocabulary.
[0031] The vocabulary includes a large number of candidate characters. For the feature vector of each character obtained after the segmentation of the text to be corrected, each character obtained after the segmentation is mapped to multiple candidate characters in the vocabulary, and the probability of each character corresponding to the multiple candidate characters can be obtained. The probability of each character in the text to be corrected being mapped to multiple candidate characters in the vocabulary can be understood as the probability distribution of each character in the vocabulary. For example, there are 10,000 candidate characters in the vocabulary, and each character corresponds to 10,000 probabilities. The probability in this example is used to represent the confidence that the character matches the candidate characters respectively.
[0032] Step S104, calculating the similarity between the text to be corrected and the correct text based on the phonetic-graphic vectors of the multiple characters and the phonetic-graphic vectors of the vocabulary, wherein the phonetic-graphic vector is generated based on the pronunciation vector and the glyph vector.
[0033] The feature vector in the above step S102 is a vector that comprehensively considers the semantic vector, the pronunciation vector and the glyph vector. The sound-shape vector in this example is a vector that comprehensively considers the pronunciation vector and the glyph vector. The sound-shape vector of the vocabulary includes the sound-shape vector of each candidate character in the vocabulary. For each character in the text to be corrected, the similarity between the sound-shape vector of the character and the sound-shape vector of each candidate character is calculated, and the similarity is used to characterize the similarity between the text to be corrected and the correct text.
[0034] It should be noted that this example considers the pronunciation and glyphs of the text when calculating the similarity, but does not consider the semantics of the text. This is because in the mathematical formula, after the signal (message) passes through a system (channel), it wants to generate a correct (message), but due to the influence of the wrong type (noise, reflected in the semantics), an incorrect (message) is generated. Therefore, in this example, only the influence of the pronunciation vector and glyph vector on the text is considered, and the semantic vector, i.e., noise, is not considered. By calculating the similarity between the sound and glyph vectors, the probability P(e|c) representing the incorrect text being typed from the correct text is obtained, where e is the incorrect text and c is the correct text, and then P(e|c)×P(c) is obtained to obtain the probability of the correct text being typed from the incorrect text.
[0035] Step S105: Determine the output result of the text to be corrected according to the probabilities of the multiple candidate characters and the similarities.
[0036] For each character, the output result of each character is obtained according to the probability of each character in the text to be corrected being mapped to multiple candidate characters in the vocabulary, and the similarity between each character and the multiple candidate characters, and the output result of the text to be corrected is determined according to the output result of each character. Since the semantics, pronunciation and glyph of the characters are considered when determining the probability of multiple candidate characters, and the pronunciation and glyph of the characters are considered when determining the similarity. Compared with the scheme of selecting multiple candidate characters through a single confusion set, the text correction scheme provided by the embodiment of the present application, through the combination of the probability and similarity of multiple candidate characters, can not only handle spelling errors with similar pronunciation and similar glyphs in traditional schemes, but also can effectively handle spelling errors that are neither similar in pronunciation nor similar in glyphs, thereby improving the accuracy of text correction.
[0037] In this example, the output result of the text to be corrected can be the output text directly, or it can be the output text corresponding to multiple characters, or it can be the correction result corresponding to the wrong characters. Set the text to be corrected to "I ate KFC at 11 o'clock today". In one possible way, the output result is "I ate KFC at 11 o'clock today"; in another possible way, the output result can also be "I-I, terrified-today, day-day, 11-11, dot-dot, eat-eat, KFC-KFC"; in another possible way, the output result is the correction result "terrified-today". The above multiple ways can all be applied to the solutions of the embodiments of the present application.
[0038] like Figure 2 As shown, Figure 2 A schematic diagram of an application scenario of a text correction method provided in an embodiment of the present application. Set the text to be corrected as "I was shocked at 11 o'clock and ate KFC", segment the text to be corrected into characters, and obtain multiple characters in the text to be corrected, that is, "I was shocked at 11 o'clock and ate KFC". Encode the multiple characters after segmentation to obtain semantic vectors, pronunciation vectors and glyph vectors corresponding to the multiple characters, and generate feature vectors of the multiple characters based on the semantic vectors, pronunciation vectors and glyph vectors, and then obtain the probability of each character in the text to be corrected being mapped to multiple candidate characters in the vocabulary based on the feature vectors of the multiple characters. According to the phonetic and glyph vectors of the multiple characters and the phonetic and glyph vectors of the vocabulary, calculate the similarity between the text to be corrected and the correct text. Then, according to the probability and similarity of the multiple candidate characters, determine the output result of the text to be corrected. Figure 2 The output result is taken as an example to illustrate that the output result is output text, and the output result is "I ate KFC at 11 o'clock today."
[0039] The text error correction scheme provided in the embodiment of the present application is to segment the text to be corrected, obtain multiple characters in the text to be corrected; obtain semantic vectors, pronunciation vectors and glyph vectors corresponding to the multiple characters respectively, and generate feature vectors of multiple characters according to the semantic vectors, pronunciation vectors and glyph vectors. Since the semantics, pronunciation and glyphs corresponding to the characters are considered, the information carried by the generated feature vectors is richer and the text features expressed are more accurate. According to the feature vectors of multiple characters, the probability that multiple characters in the text to be corrected are mapped to multiple candidate characters in the vocabulary is obtained; according to the sound-shape vectors of the multiple characters and the sound-shape vectors of the vocabulary, the similarity between the text to be corrected and the correct text is calculated, and the conversion probability from the text to be corrected to the correct text is calculated by considering the sound-shape vector of the text to obtain the similarity, wherein the sound-shape vector is generated according to the pronunciation vector and the glyph vector. Then, according to the probability and similarity of multiple candidate characters, the output result of the text to be corrected is determined. Since the semantics, pronunciation and glyphs of the characters are considered when determining the probability of multiple candidate characters, the pronunciation and glyphs of the characters are considered when determining the similarity. By combining the probabilities and similarities of multiple candidate characters, the text correction scheme provided in the embodiment of the present application can not only handle spelling errors with similar pronunciations and similar glyphs in traditional schemes, but can also effectively handle spelling errors that are neither similar in pronunciation nor similar in glyphs, thereby improving the accuracy of text correction.
[0040] The text error correction method of the embodiment of the present application can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.) and PCs, etc.
[0041] Embodiment 2
[0042] Embodiment 2 of the present application is based on the solution of embodiment 1. Optionally, in an example of the embodiment of the present application, the embodiment of the present application may include the following steps S301-S307, such as: Figure 3 As shown, it is a step flow chart of another text error correction method provided in an embodiment of the present application.
[0043] Step S301: segment the text to be corrected to obtain multiple characters in the text to be corrected.
[0044] Optionally, in one embodiment of the present application, the text to be corrected includes at least one of phonetic characters, numbers and special characters in addition to ideographic characters. When segmenting the text, in step S301, it can also be implemented by the following steps: segmenting the ideographic characters in the text to be corrected into single characters to obtain multiple ideographic characters; segmenting at least one of the phonetic characters, numbers and other characters in the text to be corrected according to preset segmentation rules to obtain multiple segmented characters; the multiple characters include multiple ideographic characters and multiple segmented characters.
[0045] Ideographic characters include but are not limited to Chinese, Korean, Japanese and other characters. When segmenting the ideographic characters, the ideographic characters are segmented into individual characters. For example, if the ideographic characters are Chinese, Chinese is segmented into individual Chinese characters.
[0046] Phonetic characters include, but are not limited to, characters in English, French, and Greek, and other characters include, but are not limited to, punctuation marks, spaces, ratios, and other symbols used to assist in recording text. When segmenting phonetic characters, numbers, and other characters, segmentation is performed according to preset segmentation rules, retaining their integrity, and obtaining multiple segmented characters. However, it is not limited thereto. In practical applications, the preset segmentation rules can be appropriately set by those skilled in the art according to actual needs, or determined by analyzing a large number of segmentation rules used in a large number of character segmentation processes, and the embodiments of the present application do not limit this.
[0047] Step S302, generate a semantic vector according to the semantics of the text, generate a pronunciation vector according to the pronunciation of the text, and generate a glyph vector according to the glyph of the text; generate feature vectors of multiple characters according to the semantic vector, the pronunciation vector and the glyph vector.
[0048] For example, the semantics, pronunciation and glyph of a text are encoded separately through an encoding model to obtain a semantic vector, a pronunciation vector and a glyph vector of the text, and the sum of the semantic vector, the pronunciation vector and the glyph vector is taken as a feature vector.
[0049] However, the present invention is not limited to this. In practical applications, the above semantic vectors, pronunciation vectors and glyph vectors may also be pre-generated in other ways and directly obtained and used when in use.
[0050] Step S303: For each character among the multiple characters, encode the feature vector of the character to obtain the hidden state of the feature vector of the character.
[0051] For each character, the feature vector of the character is encoded by the encoding model in the embodiment of the present application to obtain the hidden state of the feature vector of the character. The encoding model for encoding the feature vector of the character to obtain the hidden state in the embodiment of the present application may include but is not limited to a neural network (NN), a convolutional neural network (CNN), a recurrent neural network (RNN), a long short-term memory network (LSTM), a bidirectional LSTM, and a transformer.
[0052] Taking LSTM as an example, LSTM is a long short-term memory neural network suitable for processing sequence data. By encoding the feature vector through LSTM, it can be understood as integrating the context information of each word in the text to be corrected into the feature vector to obtain the hidden state of the feature vector of the word, which is also the feature data output by the current hidden layer.
[0053] Step S304: classify the hidden state of the feature vector of the character based on the candidate characters in the vocabulary to obtain the probability that the character is mapped to multiple candidate characters in the vocabulary.
[0054] In the embodiment of the present application, the hidden state of the feature vector of the text is classified based on the candidate text in the vocabulary through the classification model. By way of example, the classification model can be a network for classifying hidden states, such as a forward classification network based on the Softmax function. The embodiment of the present application does not limit the specific structure of the classification model, as long as the classification model can be used to classify based on the hidden state and map the feature vector of the text to each candidate text in the vocabulary. For example, the vocabulary includes 10,000 words, and the feature vector of the text is encoded using a long short-term neural network to obtain the encoded hidden state H. The classification model classifies the hidden state H to obtain the probability that the text is mapped to multiple candidate texts in the vocabulary.
[0055] Optionally, in one embodiment of the present application, step S304 can also be implemented by the following steps: classifying the hidden state of the feature vector of the character based on the candidate characters in the vocabulary according to the classification model to obtain the initial probability of the character being mapped to multiple candidate characters in the vocabulary; normalizing the initial probability of the character being mapped to multiple candidate characters in the vocabulary by a first normalization function to obtain the probability of the character being mapped to multiple candidate characters in the vocabulary.
[0056] In this example, the classification model and the normalization function are combined to classify the text and obtain the probability of the text being mapped to multiple candidate texts in the vocabulary. For example, the vocabulary includes 10,000 words. The hidden state H is classified by the classification model and the normalization function to obtain 10,000 probabilities of the text being mapped in the vocabulary, and the sum of their probabilities is 1. The classification of the hidden state is achieved by the classification model and the normalization function, so that when the output result is determined by the probability and similarity of mapping to multiple candidate texts in the subsequent process, the error of the output result is reduced. Optionally, the normalization function in this example can be a softmax function.
[0057] It should be noted that in the embodiment of the present application, in step S304, only the classification model may be used to classify the hidden state, without normalizing the probabilities mapped to multiple candidate characters, because in the subsequent step S306, the product of the sound-shape vector is normalized to obtain the similarity, and then the step of multiplying the probabilities and similarities of multiple candidate characters is performed. Since the similarity is the normalized product of the sound-shape vector, even if the probabilities mapped to multiple candidate characters are not normalized, it will not affect the accuracy of the similarity probability of the text to be corrected.
[0058] Step S305, generate a pronunciation vector of the vocabulary according to the pronunciation of multiple candidate characters in the vocabulary; generate a glyph vector of the vocabulary according to the glyphs of multiple candidate characters in the vocabulary; generate a phonetic-graphic vector of the vocabulary according to the sum of the pronunciation vector of the vocabulary and the glyph vector of the vocabulary.
[0059] In this example, the phonetic-graphic vector of the vocabulary includes the phonetic-graphic vectors of multiple candidate characters in the vocabulary. For example, the pronunciation and glyphs of multiple candidate characters in the vocabulary are encoded by the encoding model to obtain the pronunciation vector and glyph vector, and the sum of the pronunciation vector and glyph vector is used as the phonetic-graphic vector, thereby obtaining the phonetic-graphic vectors of multiple candidate characters in the vocabulary.
[0060] The execution order of the above steps S301 to S304 and step S305 is not specific, and they can also be executed in parallel, which is not limited in the embodiment of the present application.
[0061] In addition, it should be noted that this step is an optional step. In practical applications, the sound shape vectors pre-generated in other ways can also be directly obtained and used.
[0062] Step S306: multiply the phonetic-graphic vectors of the plurality of characters and the phonetic-graphic vector of the vocabulary to obtain a phonetic-graphic vector product; and normalize the phonetic-graphic vector product according to a second normalization function to obtain a similarity.
[0063] In this example, the sound-shape vectors of multiple characters in the text to be corrected are multiplied with the sound-shape vectors of the vocabulary to obtain the sound-shape vector product, which reflects the similarity of each character in the text to be corrected mapped to each candidate character in the vocabulary, but the gap between these multiple similarities is large. If the multiple similarities are directly multiplied with the probability of multiple candidate characters, the similarity probability obtained will have errors, thereby reducing the accuracy of determining the output result based on the similarity probability. Therefore, in this example, the sound-shape vector product is normalized by a normalization function to obtain a similarity between the text to be corrected and the correct text. The sound-shape vector is normalized by a normalization function to obtain a similarity, so that when the probability and similarity of mapping to multiple candidate characters are used to determine the output result in the future, the error of the output result is reduced. Optionally, the normalization function in this example can be a softmax function.
[0064] Step S307, multiply the probabilities and similarities of the multiple candidate characters to obtain the similarity probability of the text to be corrected; and use the text corresponding to the maximum probability in the similarity probability of the text to be corrected as the output result of the text to be corrected.
[0065] In this example, the probabilities of multiple candidate characters represent the probabilities of each character being mapped to multiple candidate characters in the vocabulary, and the similarities represent the similarities of each character being mapped to each candidate character in the vocabulary. The probabilities and similarities of multiple candidate characters are multiplied to obtain the similarity probability of each character in the text to be corrected. Furthermore, the text corresponding to the maximum probability in the similarity probability can be used as the output result of the text to be corrected.
[0066] Set the text to be corrected as "我惊天11点,吃KFC". For example, the candidate word corresponding to the maximum similarity probability of the character "我" is "我", the candidate word corresponding to the maximum similarity probability of the character "惊" is "今", the candidate word corresponding to the maximum similarity probability of the character "天" is "天", the candidate word corresponding to the maximum similarity probability of the character "点" is "点", the candidate word corresponding to the maximum similarity probability of the character "吃" is "吃", and the numbers "11" and the English abbreviation "KFC" remain unchanged. In this example, the output result of the text to be corrected can be in the following three ways. Example 1: Use the candidate word corresponding to the maximum similarity probability of each character in the similarity probability as the output result of the text to be corrected. The output result is "我-我,惊-今,天-天,11-11,点-点,吃-吃,KFC-KFC". Example 2: Construct an output text based on the candidate word corresponding to the maximum similarity probability of each character in the similarity probability, and use the output text as the output result of the text to be corrected. The output result is "我今天11点,吃KFC". Example 3: Use the corrected text as the output result of the text to be corrected. Specifically, use the candidate word corresponding to the maximum similarity probability of each incorrect character in the similarity probability as the output result of the text to be corrected. The output result is "惊-今".
[0067] In the prior art, when correcting text, a confusion set of similar pronunciations and similar glyphs is usually constructed in advance. For the confusion set of similar pronunciations and similar glyphs, a lot of manual intervention is required to establish the relationship between similar pronunciations and similar glyphs. When correcting the text to be corrected, first generate multiple candidate words using the pre-constructed confusion set, then sort the multiple candidate words, and select the candidate word with the highest occurrence probability at the current position, so as to obtain the output result of the text to be corrected.
[0068] However, the confusion set restricts the search space to words with similar pronunciations and similar glyphs to reduce the search space. However, this also limits the accuracy of text correction. On the one hand, the confusion set itself cannot accurately model the similarity degree of the phonetic and glyphic similarity between words. On the other hand, using only the confusion set of similar pronunciations and similar glyphs makes the text correction scheme unable to handle spelling mistakes that are neither similar in pronunciation nor in glyph, reducing the accuracy of text correction.
[0069] In the embodiment of the present application, multiple characters are obtained by segmenting the characters, and each character is vectorized according to semantics, pronunciation and glyph. Since the semantics, pronunciation and glyph corresponding to the characters are comprehensively considered when generating feature vectors, the generated feature vectors carry more abundant information and express more accurate text features. The hidden state of the characters is obtained by encoding the feature vectors according to the context information, and the hidden state is classified using a classification network and a normalization function to obtain the probability of each character being mapped to multiple candidate characters in the vocabulary. The similarity between each character and multiple candidate characters in the vocabulary is calculated, and the similarity represents the similarity between the text to be corrected and the correct text. The similarity probability is calculated according to the probabilities and similarities of the multiple candidate characters, so as to obtain the output result according to the similarity probability. Since the semantics, pronunciation and glyph of the characters are considered when determining the probabilities of multiple candidate characters, the pronunciation and glyph of the characters are considered when determining the similarity. By combining the probabilities and similarities of multiple candidate characters, the text correction scheme provided in the embodiment of the present application can not only handle spelling errors with similar pronunciations and similar glyphs in traditional schemes, but can also effectively handle spelling errors that are neither similar in pronunciation nor similar in glyphs, thereby improving the accuracy of text correction.
[0070] It should be noted that the main purpose of the embodiment of the present application is to correct the error of Chinese characters, obtain the hidden state through character segmentation, character vectorization, context information encoding, obtain the probability of each character being mapped to multiple candidate characters in the vocabulary, calculate the similarity between each character and multiple candidate characters in the vocabulary, calculate the similarity probability based on the probability and similarity of multiple candidate characters, and thus obtain the output result based on the similarity probability. For characters such as numbers, English and punctuation marks, the above steps will also be processed, but because the output results of characters such as numbers, English and punctuation marks are not considered when training the model used in the above steps, the model is mainly updated by the back propagation algorithm for the output results of Chinese. It can be understood that for the phonetic characters, numbers and special characters in the text to be corrected, the above steps will also be executed when correcting the error, and the above steps do not process them in any way. In the output result, the characters that are the same as the phonetic characters, numbers and special characters are not changed.
[0071] Three machine learning models are used in the above steps S301 to S307, which are respectively a coding model part for vectorizing text to obtain semantic vectors, pronunciation vectors and glyph vectors, a coding model part for encoding the feature vectors of text to obtain hidden states, and a classification model part for classifying the hidden states of the feature vectors of text. The embodiment of the present application also includes a process of training the above machine learning models.
[0072] Optionally, in one embodiment of the present application, a parallel corpus containing erroneous text and correct text corresponding to the erroneous text is obtained; a training sample is constructed based on the parallel corpus; a machine learning model is trained based on the training sample so that the trained machine learning model executes the text error correction method; wherein the machine learning model includes: an encoding model part for vectorizing text, an encoding model part for encoding a feature vector of the text to obtain a hidden state, and a classification model part for classifying the hidden state of the feature vector of the text.
[0073] The parallel corpus includes the incorrect text and the correct text corresponding to the incorrect text. For example, the incorrect text is "There are countless storms in life", and the correct text is "There are countless storms in human voices". Based on the parallel corpus, training samples are constructed, and then the machine learning model is trained based on the training samples.
[0074] It should be noted that when training the machine learning model, in order to facilitate the distinction between the encoding model that vectorizes the text and the encoding model that encodes the feature vector of the text to obtain the hidden state, the neural network model is used in this example to represent the encoding model that encodes the feature vector of the text to obtain the hidden state. In this example, the neural network model can be understood as the encoding model.
[0075] The specific training steps include: segmenting the error text sample to obtain multiple first characters in the error text, segmenting the correct text sample corresponding to the error text to obtain multiple second characters in the correct text. Encode the semantics, pronunciation and glyphs of multiple first characters according to the initial encoding model, generate semantic vectors, pronunciation vectors and glyph vectors of multiple first characters, and add the sum of the semantic vectors, pronunciation vectors and glyph vectors as the feature vector. For each of the multiple first characters, encode the feature vector of the first character according to the initial neural network model to obtain the hidden state of the feature vector of the first character. According to the initial classification model, the hidden state of the feature vector of the first character is classified based on the candidate characters in the vocabulary to obtain the probability that the first character is mapped to multiple candidate characters in the vocabulary. Multiply the sound and shape vectors of the multiple first characters and the sound and shape vector of the vocabulary, and obtain the similarity between the error text sample and the correct text sample through the normalization function. According to the probability and similarity that the multiple first characters in the error sample are mapped to multiple candidate characters in the vocabulary, the output result of the error text sample is determined. According to the loss function, the loss value is calculated by combining the output results of the erroneous text sample and multiple second characters in the correct text; the initial encoding model, the initial classification model and the initial neural network model are trained according to the loss value to obtain the encoding model, the classification model and the neural network model.
[0076] When the three machine learning models are trained using the training samples, the model parameters of the machine learning models are continuously adjusted and updated iteratively until the training termination condition is reached to obtain the trained encoding model, classification model and neural network model. The training termination condition is, for example, the number of training times reaches a preset number of times, or the prediction result of the machine learning model is within a preset deviation range, etc. For example, the loss function used in the training step can be a cross entropy loss function.
[0077] In the embodiment of the present application, by learning the training data, a coding model for vectorizing the text, a coding model for encoding the feature vector of the text to obtain the hidden state, and a classification model for classifying the hidden state of the feature vector of the text are obtained. Through the above three machine learning models, the probability of each text being mapped to multiple candidate texts in the vocabulary is obtained more accurately, and combined with the sound-shape similarity between the wrong text and the correct text, the problem that the confusion set itself cannot accurately model the degree of similarity between the sound and shape of the characters in the traditional scheme is solved. The text error correction scheme provided in the embodiment of the present application can not only handle spelling errors with similar pronunciation and similar glyphs in the traditional scheme, but also effectively handle spelling errors that are neither similar in pronunciation nor similar in glyphs, thereby improving the accuracy of text error correction.
[0078] The text error correction method of the embodiment of the present application can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.) and PCs, etc.
[0079] Embodiment 3
[0080] In this embodiment, the text error correction method of the embodiment of the present application is described by taking the use of a machine learning model for text error correction as an example. The machine learning model includes: an encoding model part for vectorizing the text, an encoding model part for encoding the feature vector of the text to obtain a hidden state, and a classification model part for classifying the hidden state of the feature vector of the text.
[0081] Below, we first briefly describe the training process of the machine learning model. The training process includes:
[0082] (I) Construct training samples.
[0083] Specifically, a parallel corpus containing an erroneous text and a correct text corresponding to the erroneous text may be obtained; and a training sample may be constructed based on the parallel corpus.
[0084] For example, parallel corpus is annotated, and a pair of misspelled sentences and their correct spelled sentences is input, for example, the incorrect sentence "The wind and rain in the human voice are countless" ---> the correct sentence "The wind and rain in life are countless", and the incorrect sentence and the correct sentence are segmented to obtain the incorrect sentence src = [the wind and rain in the human voice are countless] and the correct sentence tgt = [the wind and rain in life are countless], as well as the multiple characters corresponding to them. Based on this, a training sample is constructed.
[0085] (ii) training the machine learning model according to the training samples so that the trained machine learning model executes the text error correction method.
[0086] Specifically, it may include:
[0087] 2.1. The coding model part for vectorizing the text of the machine learning model is used to perform the following steps: (1) semantic vectorization is performed on each text in src according to the semantics of each text in the error text such as src, which can also be understood as word vectorization, to obtain a semantic vector matrix E_v formed by the semantic vectors of multiple texts in src; (2) pronunciation vectorization is performed on each text in src according to the pronunciation of the text, to obtain a pronunciation vector matrix E_p formed by the pronunciation vectors of multiple texts in src; (3) glyph vectorization is performed on each text in src according to the glyph of the text, to obtain a glyph vector matrix E_s formed by the glyph vectors of multiple texts in src; (4) E_v, E_p and E_s are added together to obtain a feature vector E of the text in src, E=E_v+E_p+E_s. The coding model part in this step can be any appropriate coding model that can be vectorized.
[0088] 2.2. The feature vector matrix E of the characters in src is input into the encoding model part which encodes the feature vectors of the characters to obtain the hidden state. In this example, it is a multi-layer bidirectional LSTM network, which performs encoding based on the sentence context information to obtain the hidden state H. It is then passed through the classification model part which is used to classify the hidden state of the feature vector of the characters, such as a forward classification network, to obtain the probability P_vocab that each character in src is mapped to all candidate characters in the vocabulary V.
[0089] It should be noted that the LSTM in this example can also be an encoding model of other network structures, as long as it can encode the feature vector matrix E of the text to obtain the hidden state H, and the embodiments of the present application do not limit this.
[0090] 3.1. Perform the same operations as (2) and (3) in 2.1 on multiple candidate characters in the vocabulary V to obtain the pronunciation vector matrix EV_p and the character vector matrix EV_s of the vocabulary V. Add EV_p and EV_s to obtain the pronunciation and character vector matrix E_vocab of the vocabulary, where E_vocab = EV_p + EV_s. At the same time, add E_p and E_s obtained in (2) and (3) of src to obtain the pronunciation and character vector matrix E_src of the src sentence, where E_src = E_p + E_s. Multiply the pronunciation and character vector matrix E_vocab with the pronunciation and character vector matrix E_src, and then pass them through the softmax function of the classification model to obtain the similarity matrix P_similar between each character in src and each candidate character in the vocabulary V.
[0091] 3.2. Multiply the probability P_vocab and the similarity matrix P_similar to get the similarity probability P'.
[0092] 3.3. According to the similarity probability P' and tgt, the loss value is calculated by the cross entropy loss function. According to the loss value, the machine learning model is trained by the back propagation algorithm, the model parameters of the machine learning model are adjusted, and iterative updates are performed until the training termination condition is reached.
[0093] After the training process is completed, the trained machine learning model has the function of text error correction. The process of text error correction based on the trained machine learning model is as follows, including:
[0094] Process (I) is to segment the text to be corrected to obtain multiple characters of the text to be corrected.
[0095] Take the text to be corrected as an example, which includes Chinese, punctuation, English and numbers. Chinese and punctuation are cut into single characters, and English and numbers are kept and segmented to preserve their integrity. For example, the text to be corrected "I was shocked at 11 o'clock and ate KFC" is segmented into "I|Shock|Day|11|Point|,|Eat|KFC".
[0096] Process (ii): for each of the multiple characters, the encoding model part for vectorizing the characters is used to vectorize the characters according to the characters and their pronunciation and shape, that is, the semantics, pronunciation and glyph of the characters are vectorized, and the feature vector of the characters is determined according to the obtained semantic vector, pronunciation vector and glyph vector. Then, the feature vector of the character is passed through the encoding model part (the aforementioned LSTM network in this example) for encoding the feature vector of the character to obtain the hidden state and the classification model part for classifying the hidden state of the feature vector of the character, and the probability P_vocab of each segmented segment (i.e. each character) in the text to be corrected being mapped to all candidate characters in a given vocabulary V is obtained.
[0097] Process (three), calculate the similarity based on the phonetic-graphic vector of each character in the text to be corrected and the phonetic-graphic vector of all candidate characters in the vocabulary V, and obtain the similarity P_similar between the text to be corrected and the correct text after normalization, and determine the output similarity probability P' according to the product of the probability P_vocab and the similarity P_similar, P'=P_vocab×P_similar. Generate the correction result according to the similarity probability P' to obtain the spelling check result. For example, the probabilities in the similarity probability P' can be sorted, and the candidate character with the largest probability can be selected as the output result. The similarity P_similar can also be understood as the similarity of the conversion probability between the erroneous text and the correct text.
[0098] In this example, we can effectively use contextual semantic information to generate candidate characters based on LSTM, and train the encoding model used to vectorize the characters so that the similarity model can determine a more accurate sound-shape similarity P_similar. This solves the problem that the confusion set itself cannot accurately model the similarity between characters in the traditional solution. At the same time, by combining the similarity P_similar with the probability P_vocab, we can handle spelling errors that are neither similar in pronunciation nor similar in shape.
[0099] Text error correction schemes for Western European languages such as English are relatively mature and mainly rely on word-granularity inspection and correction. However, Chinese is very different from Western European languages such as English. First, there are a large number of Chinese characters, with more than 3,000 commonly used Chinese characters, which makes the search space of confusion sets in Chinese error correction schemes much larger than that of English. Second, the length of Chinese words is generally short, and if there are spelling errors, it often has a greater impact on the semantics of the words. Traditional Chinese error correction schemes usually pre-construct confusion sets of similar pronunciations and similar glyphs. The confusion set represents a set of candidate characters with similar characters in the text to be corrected. For confusion sets with similar pronunciations and similar glyphs, a lot of manual intervention is required to construct the relationship between similar pronunciations and similar glyphs. According to the confusion sets of similar pronunciations and similar glyphs, the search space is limited to characters with similar pronunciations and similar glyphs, thereby reducing the search space. The confusion set is a set of candidate characters that is manually set and has a rigidly limited candidate range, which limits the error correction performance of traditional Chinese error correction schemes. Specifically, on the one hand, the confusion set itself cannot accurately model the degree of similarity between characters in sound and shape; on the other hand, only using the confusion set of similar pronunciation and similar shape makes the text correction scheme unable to handle spelling errors that are neither similar in pronunciation nor in shape, reducing the accuracy of text correction.
[0100] The embodiment of the present application provides a text error correction scheme, which obtains a coding model for vectorizing text, a coding model for encoding the feature vector of text to obtain a hidden state, and a classification model for classifying the hidden state of the feature vector of text through learning of training data. The machine learning model can accurately model the similarity between characters in sound and shape, and adaptively learn the similarity relationship between the pronunciation and shape of characters, while being different from the similarity constraints of candidate characters in the traditional "hard" confusion set. It can not only handle spelling errors with similar pronunciation and similar shape in traditional schemes, but also effectively handle spelling errors that are neither similar in pronunciation nor similar in shape, thereby improving the accuracy of text error correction.
[0101] The text error correction method of the embodiment of the present application can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.) and PCs, etc.
[0102] Embodiment 4:
[0103] Based on any of the text error correction methods described in the above embodiments 1 to 3, the present application embodiment provides a text error correction device, such as Figure 4 As shown, Figure 4 A text correction device is provided in an embodiment of the present application. The text correction device 40 includes: a segmentation module 401, which is used to segment the text to be corrected and obtain multiple characters in the text to be corrected; a feature vector generation module 402, which is used to obtain semantic vectors, pronunciation vectors and glyph vectors corresponding to the multiple characters, and generate feature vectors of the multiple characters according to the semantic vectors, pronunciation vectors and glyph vectors; a probability determination module 403, which is used to obtain the probability that the multiple characters in the text to be corrected are mapped to multiple candidate characters in the vocabulary according to the feature vectors of the multiple characters; a similarity calculation module 404, which is used to calculate the similarity between the text to be corrected and the correct text according to the sound-shape vectors of the multiple characters and the sound-shape vector of the vocabulary, wherein the sound-shape vector is generated according to the pronunciation vector and the glyph vector; an output result module 405, which is used to determine the output result of the text to be corrected according to the probabilities and similarities of the multiple candidate characters.
[0104] Optionally, in one embodiment of the present application, the probability determination module 403 is also used to encode the feature vector of each character among multiple characters to obtain the hidden state of the feature vector of the character; the hidden state of the feature vector of the character is classified based on the candidate characters in the vocabulary to obtain the probability that the character is mapped to multiple candidate characters in the vocabulary.
[0105] Optionally, in one embodiment of the present application, the probability determination module 403 is also used to classify the hidden state of the feature vector of the text based on the candidate text in the vocabulary according to the classification model, and obtain the initial probability of the text being mapped to multiple candidate texts in the vocabulary; normalize the initial probability of the text being mapped to multiple candidate texts in the vocabulary by a first normalization function, and obtain the probability of the text being mapped to multiple candidate texts in the vocabulary.
[0106] Optionally, in an embodiment of the present application, the similarity calculation module 404 is further used to multiply the phonetic-morphological vectors of multiple characters and the phonetic-morphological vectors of the vocabulary to obtain the phonetic-morphological vector product; and normalize the phonetic-morphological vector product according to a second normalization function to obtain the similarity.
[0107] Optionally, in one embodiment of the present application, the output result module 405 is also used to multiply the probabilities and similarities of multiple candidate texts to obtain the similarity probability of the text to be corrected; and the text corresponding to the maximum probability in the similarity probability of the text to be corrected is used as the output result of the text to be corrected.
[0108] Optionally, in one embodiment of the present application, the text correction device 40 also includes a sound-shape vector calculation module, which is used to generate a pronunciation vector of the vocabulary according to the pronunciation of multiple candidate characters in the vocabulary; generate a glyph vector of the vocabulary according to the glyphs of multiple candidate characters in the vocabulary; and generate a sound-shape vector of the vocabulary according to the sum of the pronunciation vector of the vocabulary and the glyph vector of the vocabulary.
[0109] Optionally, in one embodiment of the present application, the text to be corrected includes at least one of phonetic characters, numbers and special characters in addition to ideographic characters; the segmentation module 401 is also used to segment the ideographic characters in the text to be corrected into single characters to obtain multiple ideographic characters; segment at least one of the phonetic characters, numbers and other characters in the text to be corrected according to preset segmentation rules to obtain multiple segmented characters; the multiple characters include multiple ideographic characters and multiple segmented characters.
[0110] Optionally, in one embodiment of the present application, the text correction device 40 also includes a training module, which is used to obtain a parallel corpus containing erroneous text and correct text corresponding to the erroneous text; construct training samples based on the parallel corpus; train the machine learning model based on the training samples so that the trained machine learning model executes the text correction method; wherein the machine learning model includes: an encoding model part for vectorizing text, an encoding model part for encoding the feature vector of the text to obtain a hidden state, and a classification model part for classifying the hidden state of the feature vector of the text.
[0111] The text error correction device of the embodiment of the present application is used to implement the corresponding text error correction method in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here. In addition, the functional implementation of each module in the text error correction device of the embodiment of the present application can refer to the description of the corresponding part in the aforementioned method embodiment, which will not be repeated here.
[0112] Embodiment 5
[0113] Based on any of the text error correction methods described in the above embodiments 1 to 3, the present application embodiment provides an electronic device. It should be noted that the text error correction method of the present application embodiment can be executed by any appropriate electronic device with text error correction capability, including but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.) and PCs, etc. Figure 5 As shown, Figure 5 The electronic device 50 may include a processor 502, a communication interface 504, a memory 506, and a communication bus 508.
[0114] The processor 502 , the communication interface 504 , and the memory 506 communicate with each other via a communication bus 508 .
[0115] The communication interface 504 is used to communicate with other electronic devices or servers.
[0116] The processor 502 is used to execute the computer program 510, and specifically can execute the relevant steps in the above text error correction method embodiment.
[0117] Specifically, the computer program 510 may include computer program codes including computer operation instructions.
[0118] The processor 502 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0119] The memory 506 is used to store the computer program 510. The memory 506 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0120] The specific implementation of each step in program 510 can refer to the corresponding description of the corresponding steps and units in the above text error correction method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above-mentioned method embodiment, which will not be repeated here.
[0121] Embodiment 6
[0122] Based on the text error correction method described in the above-mentioned embodiments 1 to 3, an embodiment of the present application provides a computer storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the text error correction method described in embodiments 1 to 3.
[0123] Based on the text error correction method described in the above-mentioned embodiments 1 to 3, an embodiment of the present application provides a computer program product, including computer instructions, which instruct a computing device to perform operations corresponding to the text error correction method described in embodiments 1 to 3.
[0124] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.
[0125] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor or programmable or dedicated hardware (such as an ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the text error correction method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the text error correction method shown herein, the execution of the code converts the general-purpose computer into a dedicated computer for executing the text error correction method shown herein.
[0126] Those of ordinary skill in the art will appreciate that the various exemplary units and method steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.
[0127] The above implementation methods are only used to illustrate the embodiments of the present application, and are not limitations on the embodiments of the present application. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present application. The scope of patent protection of the embodiments of the present application should be limited by the claims.
Claims
1. A text error correction method, comprising: Segment the text to be corrected to obtain multiple characters in the text to be corrected; Obtaining semantic vectors, pronunciation vectors and glyph vectors corresponding to the plurality of characters respectively, and generating feature vectors of the plurality of characters according to the semantic vectors, the pronunciation vectors and the glyph vectors; For each character in the plurality of characters, a feature vector of the character is encoded to obtain a hidden state of the feature vector of the character; Classifying the hidden state of the feature vector of the character based on the candidate characters in the vocabulary to obtain the probability that the character is mapped to multiple candidate characters in the vocabulary, wherein the probabilities are used to represent the confidence that the character matches the candidate characters respectively; Calculate the similarity between the text to be corrected and the correct text according to the sound-shape vectors of the multiple characters and the sound-shape vector of the vocabulary, wherein the sound-shape vector is generated according to the pronunciation vector and the glyph vector, and the similarity is obtained by normalizing the product of the sound-shape vectors, and the product of the sound-shape vectors is the product of the sound-shape vectors of the multiple characters and the sound-shape vector of the vocabulary; Multiplying the probabilities of the plurality of candidate characters by the similarity to obtain a similarity probability of the text to be corrected; The text corresponding to the maximum probability among the similar probabilities of the text to be corrected is used as the output result of the text to be corrected.
2. The method according to claim 1, wherein: The hidden state of the feature vector of the character is classified based on the candidate characters in the vocabulary to obtain the probability that the character is mapped to multiple candidate characters in the vocabulary, including: Classifying the hidden state of the feature vector of the word based on the candidate words in the word list according to the classification model to obtain initial probabilities of the word being mapped to multiple candidate words in the word list; The initial probabilities of the character being mapped to the multiple candidate characters in the vocabulary are normalized by a first normalization function to obtain the probabilities of the character being mapped to the multiple candidate characters in the vocabulary.
3. The method according to claim 1, wherein: The similarity is obtained by normalizing the product of the sound-shape vectors, including: The product of the sound-shape vectors is normalized according to a second normalization function to obtain the similarity.
4. The method according to claim 1, wherein: The method further comprises: Generating a pronunciation vector of the vocabulary according to the pronunciations of a plurality of candidate characters in the vocabulary; Generating a glyph vector of the vocabulary according to the glyphs of a plurality of candidate characters in the vocabulary; The phonetic-graphic vector of the vocabulary is generated according to the sum of the pronunciation vector of the vocabulary and the glyph vector of the vocabulary.
5. The method according to claim 1, wherein: The text to be corrected includes at least one of phonetic characters, numbers and special characters in addition to ideographic characters; The segmenting of the text to be corrected to obtain multiple characters in the text to be corrected includes: Segmenting the ideographic characters in the text to be corrected into single characters to obtain multiple ideographic characters; Segment at least one of the phonetic characters, numbers and other characters in the text to be corrected according to a preset segmentation rule to obtain a plurality of segmented characters; The plurality of characters include the plurality of ideographic characters and the plurality of segmentation characters.
6. The method according to any one of claims 1 to 5, further comprising: Obtain a parallel corpus containing an erroneous text and a correct text corresponding to the erroneous text; Constructing training samples according to the parallel corpus; The machine learning model is trained according to the training samples so that the trained machine learning model executes the text error correction method; wherein the machine learning model includes: an encoding model part for vectorizing the text, an encoding model part for encoding the feature vector of the text to obtain a hidden state, and a classification model part for classifying the hidden state of the feature vector of the text.
7. A text error correction device, comprising: A segmentation module, used for segmenting the text to be corrected to obtain multiple characters in the text to be corrected; A feature vector generation module, used to obtain semantic vectors, pronunciation vectors and glyph vectors corresponding to the plurality of characters respectively, and generate feature vectors of the plurality of characters according to the semantic vectors, the pronunciation vectors and the glyph vectors; A probability determination module is used to encode the feature vector of each of the multiple characters to obtain the hidden state of the feature vector of the character; classify the hidden state of the feature vector of the character based on the candidate characters in the vocabulary to obtain the probability that the character is mapped to multiple candidate characters in the vocabulary, wherein the probability is used to represent the confidence that the character matches the candidate characters respectively; A similarity calculation module, used for calculating the similarity between the text to be corrected and the correct text according to the sound-shape vectors of the multiple characters and the sound-shape vectors of the vocabulary, wherein the sound-shape vector is generated according to the pronunciation vector and the glyph vector, and the similarity is obtained by normalizing the product of the sound-shape vectors, and the sound-shape vector product is the product of the sound-shape vectors of the multiple characters and the sound-shape vector of the vocabulary; The output result module is used to multiply the probabilities of the multiple candidate characters and the similarities to obtain the similarity probabilities of the text to be corrected; and the text corresponding to the maximum probability in the similarity probabilities of the text to be corrected is used as the output result of the text to be corrected.
8. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the text error correction method as described in any one of claims 1 to 6 is implemented.
9. A computer program product, comprising computer instructions, wherein the computer instructions instruct a computing device to execute operations corresponding to the text error correction method as described in any one of claims 1-6.
