Chinese spelling error detection and correction method, device, electronic device and storage medium

By comparing the sound and shape vectors generated by the learning model, combining semantic information, determining the error position and type of Chinese characters, and using the optimal path parameters to correct it, the problem of low efficiency of Chinese characters' similar error recognition and correction in the existing technology is solved, and the problem of low efficiency of Chinese characters' similar error recognition and correction in the existing technology is improved. The accuracy of Chinese spelling error correction.

CN115081430BActive Publication Date: 2024-12-06INST OF AUTOMATION CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210576165.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-24
Publication Date
2024-12-06
Estimated Expiration
2042-05-24

AI Technical Summary

Technical Problem

The prior art is difficult to efficiently identify and correct similar errors of complex Chinese characters, and is inefficient in selecting candidates for decoding incorrect characters.

Method used

The comparative learning model is used to generate the pronunciation and similarity vectors of Chinese characters, combined with semantic vectors and full sentence vectors, and the position and type of wrong Chinese characters are determined through gating mechanisms and weighted summing, and corrected through the optimal path parameters.

Benefits of technology

It improves the accuracy of detection and correction of similar errors in complex Chinese characters and improves the quality of correction of Chinese spelling errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115081430B_ABST
    Figure CN115081430B_ABST
Patent Text Reader

Abstract

The present invention provides a Chinese spelling error detection and correction method, device, electronic device and storage medium, belonging to the field of natural language processing technology, the method comprising: inputting a Chinese character input sequence into a contrastive learning model, obtaining similar character vectors corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; based on the similar character vectors, detecting the wrong Chinese characters in the Chinese character input sequence, obtaining the position and type of the wrong Chinese characters; encoding the Chinese character input sequence, obtaining the encoding vector corresponding to the Chinese character input sequence; based on the similar character vectors, the position and type of the wrong Chinese characters, and the encoding vectors, correcting the wrong Chinese characters in the Chinese character input sequence, and obtaining the optimal corrected text. Through the pronunciation similarity relationship and the glyph similarity relationship of each Chinese character, the error detection and correction of the wrong Chinese characters in the Chinese character input sequence are realized, the accuracy of the detection and correction of similar errors of complex Chinese characters is improved, and the correction quality of Chinese spelling error correction is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a Chinese spelling error detection and correction method, device, electronic equipment and storage medium. Background Art

[0002] Chinese spelling correction is an emerging hot topic in the field of natural language processing. Its goal is to identify spelling errors such as word misuse and word disorder in Chinese texts, and modify the erroneous texts into correct texts.

[0003] In the related art, most of the research on Chinese spelling correction focuses on the integration of prior knowledge such as pronunciation and glyph. The usual practice is to use an encoder to encode pronunciation and glyph, use Chinese character semantics, pronunciation and glyph information to jointly detect spelling errors in text, and correct spelling errors.

[0004] However, the related technology only regards the pronunciation and glyph information as an independent feature of Chinese characters. In the fusion process, the prior knowledge such as the pronunciation and glyph information is more used in the error detection end. The similarity between different Chinese characters in pronunciation and glyph is not considered in the error detection and correction process. As a result, it is difficult to efficiently identify errors in more complex Chinese character similar error recognition scenarios, and it is difficult to make efficient selections for the decoding candidates for the erroneous characters during the correction process of the erroneous characters. Summary of the invention

[0005] The present invention provides a Chinese spelling error detection and correction method, device, electronic device and storage medium, which are used to solve the defect of the prior art that it is difficult to efficiently identify similar errors of Chinese characters and correct errors, and realize the detection and correction of similar errors of complex Chinese characters.

[0006] The present invention provides a Chinese spelling error detection and correction method, comprising:

[0007] Inputting a Chinese character input sequence into a contrastive learning model, obtaining similar character vectors corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; the similar character vectors include a sound similarity vector and a shape similarity vector; the sound similarity vector is used to represent the similarity relationship between the pronunciations of each Chinese character; the shape similarity vector is used to represent the similarity relationship between the shapes of each Chinese character; the contrastive learning model is obtained based on training of sample Chinese character triples;

[0008] Based on the similar character vectors, detecting the wrong Chinese characters in the Chinese character input sequence, and obtaining the position and type of the wrong Chinese characters;

[0009] Encode the Chinese character input sequence to obtain a coding vector corresponding to the Chinese character input sequence;

[0010] Based on the similar character vector, the position and type of the erroneous Chinese character, and the encoding vector, the erroneous Chinese characters in the Chinese character input sequence are corrected to obtain an optimal corrected text.

[0011] According to a Chinese spelling error detection and correction method provided by the present invention, the method detects erroneous Chinese characters in the Chinese character input sequence based on the similar word vectors, and obtains the position and type of the erroneous Chinese characters in the Chinese character input sequence, including:

[0012] splicing the semantic vector, the phonetic vector, the form vector of each Chinese character in the Chinese character input sequence and the full sentence vector corresponding to the Chinese character input sequence to obtain a splicing vector;

[0013] Based on the splicing vector, calculating the sound similarity gating value and the shape similarity gating value of each Chinese character;

[0014] Based on the sound-similar gating value and the shape-similar gating value, the position and type of the erroneous Chinese characters in the Chinese character input sequence are determined.

[0015] According to a Chinese spelling error detection and correction method provided by the present invention, the position and type of the erroneous Chinese characters in the Chinese character input sequence are determined based on the sound similarity gating value and the shape similarity gating value, including:

[0016] Using the sound similarity gating value and the shape similarity gating value as weights of the sound similarity vector and the shape similarity vector respectively;

[0017] Performing weighted summation on the semantic vector, the sound-similar vector, and the shape-similar vector to obtain a fusion vector;

[0018] Based on the fusion vector, the position and type of the erroneous Chinese characters in the Chinese character input sequence are determined.

[0019] According to a Chinese spelling error detection and correction method provided by the present invention, the method corrects the erroneous Chinese characters in the Chinese character input sequence based on the similar word vector, the position and type of the erroneous Chinese characters in the Chinese character input sequence, and the encoding vector to obtain the optimal corrected text, including:

[0020] Based on the position and type of the erroneous Chinese character, the encoding vector is decoded to calculate the top K semantic candidates of the erroneous Chinese character;

[0021] Determine the sound-similar vector and the shape-similar vector of the erroneous Chinese character based on the position and type of the erroneous Chinese character;

[0022] Determine first M similar candidates based on the K semantic candidates, the sound similarity vectors and the shape similarity vectors;

[0023] Determine the optimal path parameter based on the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vector corresponding to the Chinese character at the adjacent position of the erroneous Chinese character;

[0024] Based on the optimal path parameters, an optimal correction text is determined.

[0025] According to a Chinese spelling error detection and correction method provided by the present invention, the first M similar candidates are determined based on the K semantic candidates, the sound-similar vectors and the shape-similar vectors, including:

[0026] Based on the K semantic candidates, the sound-similar vectors and the shape-similar vectors, calculating the similarities between the K semantic candidates and the sound-similar vectors and the shape-similar vectors respectively;

[0027] The similarities are sorted, and similar candidates corresponding to the first M similarities are selected.

[0028] According to a Chinese spelling error detection and correction method provided by the present invention, the optimal path parameter is determined based on the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vector corresponding to the Chinese character at the adjacent position of the erroneous Chinese character, including:

[0029] Based on the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vectors corresponding to the Chinese characters at adjacent positions of the erroneous Chinese character, respectively calculating the dependency relationship values ​​between the vectors corresponding to the M similar candidates and the vector corresponding to the erroneous Chinese character;

[0030] Based on the dependency values, a maximum dependency value is selected as an optimal path parameter.

[0031] The present invention also provides a Chinese spelling error detection and correction device, comprising:

[0032] A contrastive learning module is used to input a Chinese character input sequence into a contrastive learning model, and obtain similar character vectors corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; the similar character vectors include a sound similarity vector and a shape similarity vector; the sound similarity vector is used to represent the similarity relationship between the pronunciations of each Chinese character; the shape similarity vector is used to represent the similarity relationship between the shapes of each Chinese character; the contrastive learning model is obtained by training based on sample Chinese character triples;

[0033] An error detection module, used for detecting erroneous Chinese characters in a Chinese character input sequence based on the similar character vectors, and obtaining the position and type of the erroneous Chinese characters;

[0034] An encoding module, used to encode the Chinese character input sequence to obtain an encoding vector corresponding to the Chinese character input sequence;

[0035] The error correction module is used to correct the erroneous Chinese characters in the Chinese character input sequence based on the similar word vector, the position and type of the erroneous Chinese characters, and the encoding vector to obtain an optimal corrected text.

[0036] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned Chinese spelling error detection and correction methods is implemented.

[0037] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for detecting and correcting Chinese spelling errors as described in any one of the above-mentioned apparatuses and methods.

[0038] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned Chinese spelling error detection and correction methods.

[0039] The Chinese spelling error detection and correction method, device, electronic device and storage medium provided by the present invention obtain the pronunciation similarity relationship and the glyph similarity relationship of each Chinese character in a Chinese character input sequence through a comparative learning model, and then integrate the pronunciation similarity relationship and the glyph similarity relationship into the error detection process of the Chinese character input sequence. Based on the error detection results of the erroneous Chinese characters, the erroneous Chinese characters in the Chinese character input sequence are corrected, thereby realizing the error detection and correction of the erroneous Chinese characters in the Chinese character input sequence, improving the accuracy of detection and correction of similar errors of complex Chinese characters, and improving the correction quality of Chinese spelling error correction. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0041] Figure 1 This is one of the flow charts of the Chinese spelling error detection and correction method provided by the present invention;

[0042] Figure 2 It is a structural schematic diagram of the contrastive learning model provided by the present invention;

[0043] Figure 3 This is the second flow chart of the Chinese spelling error detection and correction method provided by the present invention;

[0044] Figure 4 It is a schematic diagram of the process of Chinese spelling error detection provided by the present invention;

[0045] Figure 5 This is the second flow chart of the Chinese spelling error detection and correction method provided by the present invention;

[0046] Figure 6 It is a schematic diagram of the process of Chinese spelling error correction provided by the present invention;

[0047] Figure 7 It is a structural schematic diagram of the Chinese spelling error detection and correction device provided by the present invention;

[0048] Figure 8 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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.

[0050] The Chinese spelling error detection and correction method provided by the present invention is described in detail below through some embodiments and application scenarios in conjunction with the accompanying drawings.

[0051] The present invention provides a Chinese spelling error detection and correction method, which can be applied to the error correction scenario of erroneous text, inputs a Chinese character input sequence into a contrastive learning model, obtains similar character vectors corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; the similar character vectors include sound-similar vectors and shape-similar vectors; the sound-similar vectors are used to represent the similarity relationship between the pronunciations of each Chinese character; the shape-similar vectors are used to represent the similarity relationship between the shapes of each Chinese character; the contrastive learning model is obtained based on sample Chinese character triples training; based on the similar character vectors, detects the erroneous Chinese characters in the Chinese character input sequence, and obtains the position and type of the erroneous Chinese characters; encodes the Chinese character input sequence, and obtains the encoding vector corresponding to the Chinese character input sequence; based on the similar character vectors, the position and type of the erroneous Chinese characters, and the encoding vectors, corrects the erroneous Chinese characters in the Chinese character input sequence, and obtains the optimal corrected text. By integrating the pronunciation similarity and the shape similarity into the error detection process of the Chinese character input sequence, the erroneous Chinese characters in the Chinese character input sequence are corrected based on the error detection results of the erroneous Chinese characters, thereby realizing error detection and correction of erroneous Chinese characters in the Chinese character input sequence, improving the accuracy of detection and correction of similar errors of complex Chinese characters, and improving the correction quality of Chinese spelling correction.

[0052] Combine the following Figure 1-Figure 6 The Chinese spelling error detection and correction method of the present invention is described.

[0053] Figure 1 This is one of the flow diagrams of the Chinese spelling error detection and correction method provided by the present invention. As Figure 1 shown, the method includes steps 101 to 104, where:

[0054] Step 101: Input the Chinese character input sequence into the contrast learning model to obtain the similar character vectors corresponding to each Chinese character in the Chinese character input sequence output by the contrast learning model; the similar character vectors include phonetic similarity vectors and shape similarity vectors; the phonetic similarity vectors are used to represent the phonetic similarity relationships of each Chinese character; the shape similarity vectors are used to represent the shape similarity relationships of each Chinese character; the contrast learning model is trained based on sample Chinese character triples.

[0055] It should be noted that the Chinese spelling error detection and correction method provided by the present invention can be applied to the error correction scenario of error texts. The execution subject of this method can be a Chinese spelling error detection and correction device, such as an electronic device, or a control module in the Chinese spelling error detection and correction device for executing the Chinese spelling error detection and correction method.

[0056] Optionally, the contrast learning model is trained based on sample Chinese character triples. Before introducing the error detection and correction process of the contrast learning model in detail, a brief description of the training process of this contrast learning model is given first, including the following implementation processes:

[0057] Step 1): Extract a similar Chinese character confusion set from the Chinese spelling correction dataset;

[0058] Specifically, the Chinese spelling correction dataset includes error texts, error characters, the positions of the error characters in the error texts, and the correction characters corresponding to the error characters. For example, assume there is an error text "Everything is useless", the error characters are "济" and "的", the position of the error character "济" in the error text is "6", the position of the error character "的" in the error text is "7", the correction character corresponding to the error character "济" is "记", the correction character corresponding to the error character "的" is "得", and the correction result corresponding to the error text is "Everything is not remembered".

[0059] In practice, the error characters in the error text and the correction characters corresponding to the error characters are extracted by using regular expressions or the method of taking key-value pairs from a dictionary, and the error characters and the correction characters corresponding to the error characters are stored in the form of a dictionary. For example, dictionary = {济: 记, 的: 得}.

[0060] Step 2): Expand the extracted similar Chinese character confusion set in combination with the keyboard edit distance, and construct a Chinese character similarity dataset based on the expanded similar Chinese character confusion set.

[0061] Specifically, based on the QWERTY keyboard layout, fully considering the keyboard distance and the combination ways between legal initials and finals at the keyboard distance, according to the extracted similar Chinese character confusion set, the error characters and correction characters in the similar Chinese character confusion set are expanded to obtain the phonetically similar characters corresponding to the error characters and correction characters in the similar Chinese character confusion set respectively.

[0062] For example, for the pinyin "Han", in the QWERTY keyboard layout, the letter "H" is adjacent to "G", "Y", "U", "J", "N", and "B". Excluding "U", the remaining adjacent letters are all initials. The combination of the remaining adjacent letters and the final "an" can generate a large number of phonetically similar characters with different initials but the same final. Considering these combinations of initials and the final "an" as phonetic confusions of "Han", the phonetically similar characters corresponding to the error characters and correction characters in the similar Chinese character confusion set are obtained respectively.

[0063] In practice, according to the phonetically similar characters corresponding to the error characters and correction characters in the expanded similar Chinese character confusion set respectively, based on the error characters, correction characters, and phonetically similar characters, a Chinese character similarity dataset is constructed. Among them, the Chinese character similarity dataset includes Chinese character triples, and the Chinese character triples include phonetic triples or shape triples. For example, the phonetic triple (济 - ji, 记 - ji, 拆 - chai), where "济 - ji" is the anchor Chinese character unit, and "记 - ji" and "拆 - chai" are the phonetically similar Chinese character unit and non - phonetically similar Chinese character unit of the anchor Chinese character respectively.

[0064] During the training process of the contrastive learning model, the Chinese character triples in the similar Chinese character dataset are encoded into vectors, and a supervised contrastive learning model is used to explicitly model the similarity relationship between Chinese character triples.

[0065] Specifically, a pre - trained language model, for example, the Bidirectional Encoder Representations from Transformers (BERT) model, is used to encode the Chinese character triples in the similar Chinese character dataset into vectors, obtaining the vectors corresponding to the Chinese character triples. Among them, a is the vector of the anchor Chinese character unit, is the vector of the similar Chinese character unit, is the vector of the non - similar Chinese character unit; the vector is input into the contrastive learning model. The contrastive learning model reduces the cosine distance between the vector of the anchor Chinese character unit and the vector of the similar Chinese character unit in the high - dimensional space, and increases the cosine distance between the vector of the anchor Chinese character unit and the vector of the non - similar Chinese character unit, that is, reduces the distance between the anchor Chinese character unit and the vector of the similar Chinese character unit, and increases the distance between the anchor Chinese character unit and the non - similar Chinese character unit.

[0066] In practice, the objective function used by the contrastive learning model is as follows:

[0067]

[0068] where sim is the cosine similarity of vectors, τ is the temperature coefficient, N is the number of samples in the mini-batch used during training, is the vector of similar Chinese character units corresponding to the anchor Chinese character unit vector in each batch of training samples; is the vector of dissimilar Chinese character units corresponding to the anchor Chinese character unit vector in each batch of training samples; The gradient of L is calculated using the gradient descent method, and the cosine distances between the anchor Chinese character unit vector and the similar Chinese character unit vector, and between the anchor Chinese character unit vector and the dissimilar Chinese character unit vector corresponding to the Chinese character triple are deduced and optimized in the reverse direction. a For example, for the phonetic similarity triple (济 - ji, 记 - ji, 拆 - chai), the phonetic similarity triple (济 - ji, 记 - ji, 拆 - chai) is input into the contrastive learning model. The contrastive learning model continuously pulls the characters "济 - ji" and "记 - ji" closer, while pushing the characters "济 - ji" and "拆 - chai" apart. In this way, the Chinese character unit representations of each Chinese character in the phonetic similarity triple (济 - ji, 记 - ji, 拆 - chai) are continuously optimized, and finally the phonetic similarity relationships of each Chinese character are explicitly incorporated into the Chinese character representations.

[0069] It should be noted that when the Chinese character triple is a shape similarity triple, the contrastive learning model incorporates the shape similarity relationships of each Chinese character into the Chinese character representations.

[0070] Optionally, for a trained contrastive learning model, an input sequence of Chinese characters is input into the contrastive learning model to obtain the similar character vectors of each Chinese character output by the contrastive learning model. Among them, the similar character vector includes a phonetic similarity vector and a shape similarity vector. The phonetic similarity vector is used to represent the phonetic similarity relationships of each Chinese character; the shape similarity vector is used to represent the shape similarity relationships of each Chinese character. Among them, the input sequence of Chinese characters can be a single Chinese character, a word, or a sentence. The form of the input sequence of Chinese characters can be two forms. One form is "济 - ji", and the other form is "济 - 氵齐".

[0071] For example, for a trained contrastive learning model, when the input sequence of Chinese characters input into the contrastive learning model is "济 - ji", the contrastive learning model outputs the phonetic similarity vector of "济"; when the input sequence of Chinese characters input into the contrastive learning model is "济 - 氵齐", the contrastive learning model outputs the shape similarity vector of "济".

[0072]

[0073] ​​Step 102: Based on the similar character vectors, detect the erroneous Chinese characters in the Chinese character input sequence, and obtain the position and type of the erroneous Chinese characters.

[0074] Specifically, a Chinese character input sequence is input into a pre-trained language model to obtain the full sentence vector and semantic vector of each Chinese character corresponding to the Chinese character input sequence output by the pre-trained language model, wherein the semantic vector is used to represent the semantic relationship of each Chinese character; according to the sound-similar vector and shape-similar vector corresponding to each Chinese character in the Chinese character input sequence obtained by the contrastive learning model, and the full sentence vector and semantic vector of each Chinese character corresponding to the Chinese character input sequence output by the pre-trained language model, the erroneous Chinese characters in the Chinese character input sequence are detected to obtain the position and type of the erroneous Chinese characters in the Chinese character input sequence. The type of the erroneous Chinese characters includes at least one of the following: correct Chinese characters, sound-similar Chinese characters, and shape-similar Chinese characters.

[0075] Step 103: Encode the Chinese character input sequence to obtain a coding vector corresponding to the Chinese character input sequence.

[0076] Specifically, an encoder is used to encode all Chinese characters included in the Chinese character input sequence to obtain word vectors corresponding to each Chinese character, thereby obtaining an encoding vector corresponding to the Chinese character input sequence, which is a vector sequence composed of word vectors corresponding to each Chinese character in the Chinese character input sequence.

[0077] Step 104: Based on the similar character vector, the position and type of the erroneous Chinese character, and the encoding vector, correct the erroneous Chinese character in the Chinese character input sequence to obtain an optimal corrected text.

[0078] Specifically, based on the similar character vectors corresponding to each Chinese character in the Chinese character input sequence obtained by the contrastive learning model, that is, the shape-similarity vector and sound-similarity vector of each Chinese character, the position and type of the erroneous Chinese characters in the detected Chinese character input sequence, and the encoding vector obtained by encoding by the encoder, the erroneous Chinese characters in the Chinese character input sequence are corrected to obtain the optimal corrected text.

[0079] The Chinese spelling error detection and correction method provided by the embodiment of the present invention integrates the pronunciation similarity relationship and the shape similarity relationship into the error detection process of the Chinese character input sequence, and corrects the erroneous Chinese characters in the Chinese character input sequence based on the error detection results of the erroneous Chinese characters, thereby realizing the error detection and correction of erroneous Chinese characters in the Chinese character input sequence, improving the accuracy of detection and correction of similar errors of complex Chinese characters, and improving the correction quality of Chinese spelling error correction.

[0080] Figure 2 is a schematic diagram of the structure of the contrastive learning model provided by the present invention, such as Figure 2As shown, the character "平 - ping" is encoded by the Encoder to obtain the encoding vector corresponding to the character "平 - ping"; the character "热 - re" is encoded by the Encoder to obtain the encoding vector corresponding to the character "热 - re"; the character "河 - he" is encoded by the Encoder to obtain the encoding vector corresponding to the character "河 - he"; and the similar - pronunciation Chinese character units "苹 - ping" and non - similar - pronunciation Chinese character units "吃 - chi" that form a phonetically similar triple with the anchor Chinese character unit "平 - ping", the similar - pronunciation Chinese character units "惹 - re" and non - similar - pronunciation Chinese character units "冷 - leng" that form a phonetically similar triple with the anchor Chinese character unit "热 - re", and the similar - pronunciation Chinese character units "何 - he" and non - similar - pronunciation Chinese character units "每 - mei" that form a phonetically similar triple with the anchor Chinese character unit "河 - he" are respectively encoded by the Encoder to obtain the encoding vectors corresponding to "苹 - ping", "吃 - chi", "惹 - re", "冷 - leng", "何 - he", and "每 - mei" respectively.

[0081] In practice, during the process of training the contrastive learning model, the contrastive learning model continuously reduces the cosine distance between the anchor Chinese character unit "平 - ping" and the similar Chinese character unit "苹 - ping", and increases the cosine distance between the anchor Chinese character unit "平 - ping" and the non - similar - pronunciation Chinese character units ("吃 - chi", "惹 - re", "冷 - leng", "何 - he", "每 - mei"), thereby training to obtain Chinese character vectors containing Chinese character similarity information.

[0082] Figure 3 It is the second flow schematic diagram of the Chinese spelling error detection and correction method provided by the present invention. As Figure 3 shown, the method includes steps 301 - 306, where:

[0083] Step 301: Input the Chinese character input sequence into the contrastive learning model to obtain the similar - character vectors corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; the similar - character vectors include phonetic - similarity vectors and shape - similarity vectors; the phonetic - similarity vectors are used to represent the phonetic - similarity relationships of each Chinese character; the shape - similarity vectors are used to represent the shape - similarity relationships of each Chinese character; the contrastive learning model is trained based on sample Chinese character triples.

[0084] Regarding the description and explanation of step 301, reference can be made to the description and explanation of step 101 above, and the same technical effects can be achieved. To avoid repetition, it will not be elaborated here.

[0085] Step 302: Concatenate the semantic vectors, phonetic - similarity vectors, shape - similarity vectors of each Chinese character in the Chinese character input sequence and the full - sentence vector corresponding to the Chinese character input sequence to obtain a concatenated vector.

[0086] Specifically, input the Chinese character input sequence into a pre-trained language model, such as the BERT model, to obtain the semantic vectors of each Chinese character in the Chinese character input sequence and the full-sentence CLS vector corresponding to the Chinese character input sequence. For example, for the Chinese character input sequence "什么事都不济的", taking the incorrect character "济" as an example, input "什么事都不济的" into the pre-trained language model to obtain the semantic vector E s corresponding to the incorrect Chinese character "济", and the full-sentence CLS vector E cls .

[0087] In practice, based on inputting the Chinese character input sequence into the contrastive learning model, the homophonic vector E p and the shape-similar vector E g corresponding to each Chinese character are obtained. Concatenate the semantic vector E s , the homophonic vector E p , the shape-similar vector E g and the full-sentence CLS vector E cls of each Chinese character in the Chinese character input sequence to obtain a concatenated vector.

[0088] Step 303: Calculate the homophonic gating value and the shape-similar gating value of each Chinese character based on the concatenated vector.

[0089] Specifically, input the concatenated vector into the fully connected layer, and calculate the homophonic gating value and the shape-similar gating value of each Chinese character based on the gating mechanism. The calculation methods are shown in the following formulas (2) and (3), where:

[0090] g p =σ(W p [E s ,E p ,E g ,E cls )+b p ) (2)

[0091] g g =σ(W g [E s ,E p ,E g ,E cls )+b g ) (3)

[0092] where W p , W g , b p , b g are all learnable parameters, g p is the homophonic gating value, g g is the shape-similar gating value, and σ is the activation function (sigmod).

[0093] Step 304: Determine the position and type of the erroneous Chinese character in the Chinese character input sequence based on the sound-similar gating value and the shape-similar gating value.

[0094] Specifically, according to the calculated sound-similar gating value and shape-similar gating value of each Chinese character, the position and type of the erroneous Chinese characters in the Chinese character input sequence can be determined.

[0095] Step 305: encode the Chinese character input sequence to obtain a coding vector corresponding to the Chinese character input sequence.

[0096] Step 306: Based on the character vector, the position and type of the erroneous Chinese character, and the encoding vector, correct the erroneous Chinese character in the Chinese character input sequence to obtain an optimal corrected text.

[0097] Optionally, the description and explanation of steps 305-306 may refer to the above description and explanation of steps 103-104, and the same technical effect can be achieved. To avoid repetition, they are not described here.

[0098] The Chinese spelling error detection and correction method provided by the embodiment of the present invention splices the semantic vector, the sound-like vector, the shape-like vector of each Chinese character in the Chinese character input sequence and the full sentence vector corresponding to the Chinese character input sequence, and then calculates the sound-like gating value and the shape-like gating value of each Chinese character based on the spliced ​​vector, determines the position and type of the erroneous Chinese characters in the Chinese character input sequence, and realizes the fusion of the pronunciation similarity relationship and the shape similarity relationship into the error detection process of the Chinese character input sequence, and then corrects the erroneous Chinese characters in the Chinese character input sequence based on the error detection results of the erroneous Chinese characters, thereby improving the accuracy of detection and correction of similar errors of complex Chinese characters and improving the correction quality of Chinese spelling error correction.

[0099] Optionally, the specific implementation process of the above step 304 includes the following methods:

[0100] Mode 1: using the sound similarity gating value and the shape similarity gating value as weights of the sound similarity vector and the shape similarity vector respectively;

[0101] Mode 2, performing weighted summation on the semantic vector, the sound-similar vector and the shape-similar vector to obtain a fusion vector;

[0102] Mode 3: determining the position and type of the erroneous Chinese characters in the Chinese character input sequence based on the fusion vector.

[0103] Specifically, the phonetic similarity gating values and the graphic similarity gating values of each calculated Chinese character are respectively used as the weights of the phonetic similarity vector and the graphic similarity vector of each Chinese character. Then, the phonetic similarity vector of each Chinese character is multiplied by the phonetic similarity gating value, and the graphic similarity vector of each Chinese character is multiplied by the graphic similarity gating value. Finally, the result of multiplying the phonetic similarity vector of each Chinese character by the phonetic similarity gating value, the result of multiplying the graphic similarity vector by the graphic similarity gating value, and the semantic vector of each Chinese character are added together to obtain a fusion vector.

[0104] In practice, the fusion vector is input into a gated fusion embedding layer to obtain the semantic vector, phonetic similarity vector, and graphic similarity vector corresponding to each Chinese character after weighted fusion. Then, the semantic vector, phonetic similarity vector, and graphic similarity vector corresponding to each Chinese character after weighted fusion are input into a self-attention layer to obtain the relationship between the word vector of each Chinese character at the current position and the word vectors at other positions output by the self-attention layer. Then, the result output by the self-attention layer is input into a classifier, and the classifier classifies each Chinese character to obtain a classification result marked with a label, thereby obtaining the position and type of the incorrect Chinese character in the Chinese character input sequence. Among them, the type includes at least one of the following: correct Chinese character, phonetic similarity Chinese character, and graphic similarity Chinese character.

[0105] Figure 4 is a schematic flowchart of Chinese spelling error detection provided by the present invention. As Figure 4 shown, taking the input (Input): "Deeply promote the construction of world-class universities" and the incorrect Chinese character "摧" as an example, the process of detecting the position and type of the incorrect Chinese character in the Chinese character input sequence is described as follows:

[0106] Input "Deeply promote the construction of world-class universities" into the pre-trained language model to obtain the semantic vector E of the character "摧" s and the CLS vector E of the whole sentence cls ; input "Deeply promote the construction of world-class universities" into the contrastive learning model to obtain the phonetic similarity vector E of the character "摧" p , the graphic similarity vector E g ; splice the semantic vector E of the character "摧" s , the phonetic similarity vector E p , the graphic similarity vector E g and the CLS vector E of the whole sentence corresponding to the Chinese character input sequence cls to obtain a spliced vector, and then use a gating mechanism to calculate the phonetic similarity gating value g corresponding to the phonetic similarity vector of "摧" p and the graphic similarity gating value g corresponding to the graphic similarity vector of "摧" g , and use the phonetic similarity gating value g corresponding to the phonetic similarity vector p as the weight of the phonetic similarity vector, and use the graphic similarity gating value g corresponding to the graphic similarity vector g as the weight of the graphic similarity vector.

[0107] Further, perform weighted summation on the semantic vector E of the character "摧" s , the homophonic vector E p and the shape-similar vector E g to obtain a fused vector; input the fused vector into the Gate Fused Embeddings layer, then input the result output by the Gate Fused Embeddings layer into the Attention Layer, and then input the result output by the Attention Layer into the Classifier to obtain the classification result of the classifier. The classification result is labeled with Labels, where O represents the correct Chinese character, G represents a shape-similar error, and P represents a homophonic error.

[0108] Figure 5 is the third flow schematic diagram of the Chinese spelling error detection and correction method provided by the present invention. As Figure 5 shown, the method includes Step 501 - Step 508, where:

[0109] Step 501, input the Chinese character input sequence into the contrast learning model to obtain the similar character vectors corresponding to each Chinese character in the Chinese character input sequence output by the contrast learning model; the similar character vectors include homophonic vectors and shape-similar vectors; the homophonic vector is used to represent the homophonic relationship of each Chinese character; the shape-similar vector is used to represent the shape-similar relationship of each Chinese character; the contrast learning model is trained based on sample Chinese character triples.

[0110] Step 502, based on the similar character vectors, detect the incorrect Chinese characters in the Chinese character input sequence, and obtain the positions and types of the incorrect Chinese characters.

[0111] Step 503, encode the Chinese character input sequence to obtain the encoded vector corresponding to the Chinese character input sequence.

[0112] For the descriptions and explanations of Steps 501 - 503, reference can be made to the descriptions and explanations of the above-mentioned Steps 101 - 103, and the same technical effects can be achieved. To avoid repetition, they will not be elaborated here.

[0113] Step 504, based on the positions and types of the incorrect Chinese characters, decode the encoded vector and calculate the top K semantic candidates of the incorrect Chinese characters.

[0114] Specifically, according to the position and type of erroneous Chinese characters in the Chinese character input sequence, the encoding vector corresponding to the Chinese character input sequence is input into the normalization function (Softmax), Softmax decodes the encoding vector, and calculates the pronunciation similarity between the encoding vector corresponding to the Chinese character input sequence and the pronunciation-similar vector of the Chinese character in the vocabulary and the shape similarity between the encoding vector and the shape-similar vector of the Chinese character in the vocabulary, and selects the top K pronunciation-similar candidates and K shape-similar candidates as the top K semantic candidates.

[0115] Step 505: Determine the sound-similar vector and the shape-similar vector of the erroneous Chinese character based on the position and type of the erroneous Chinese character.

[0116] Specifically, based on the position and type of the erroneous Chinese character and the contrastive learning model, the sound-similar vector and shape-similar vector of each Chinese character in the Chinese character input sequence are obtained, and the sound-similar vector and shape-similar vector of the erroneous Chinese character are determined.

[0117] Step 506: Determine the first M similar candidates based on the K semantic candidates, the sound similarity vectors and the shape similarity vectors.

[0118] Specifically, based on the K semantic candidates of the erroneous Chinese character, the sound-like vector and the shape-like vector of the erroneous Chinese character, the pronunciation similarity between the encoding vector of the erroneous Chinese character and the weighted vector of the sound-like vector corresponding to the erroneous Chinese character and the sound-like vectors of the K semantic candidates in the vocabulary is calculated respectively, as is the shape similarity between the encoding vector of the erroneous Chinese character and the weighted vector of the shape-like vector corresponding to the erroneous Chinese character and the shape-like vectors of the K semantic candidates in the vocabulary. The pronunciation similarity, shape similarity and confidence are sorted respectively to determine the top M similar candidates.

[0119] Step 507, determining the optimal path parameters based on the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vector corresponding to the Chinese character adjacent to the erroneous Chinese character.

[0120] Optionally, the vector corresponding to the Chinese character adjacent to the erroneous Chinese character may be the vector corresponding to the Chinese character before the erroneous Chinese character, or the vector corresponding to the Chinese character after the erroneous Chinese character; the optimal path parameter represents the maximum dependency value between the vector of the erroneous Chinese character and the vectors corresponding to the M similar candidates.

[0121] Step 508: Determine the optimal corrected text based on the optimal path parameters.

[0122] Specifically, according to the optimal path parameters, a similar candidate with the largest dependency value is determined, thereby determining the optimal corrected text.

[0123] The Chinese spelling error detection and correction method provided by the present invention decodes the encoding vector corresponding to the Chinese character input sequence according to the position and type of the erroneous Chinese character, and calculates the first K semantic candidates of the erroneous Chinese character; then determines the sound similarity vector and the shape similarity vector of the erroneous Chinese character according to the position and type of the erroneous Chinese character; determines the first M similar candidates according to the K semantic candidates of the erroneous Chinese character, the sound similarity vector and the shape similarity vector of the erroneous Chinese character; determines the optimal path parameters according to the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vector corresponding to the Chinese character at the adjacent position of the erroneous Chinese character; determines the optimal correction text based on the optimal path parameters, realizes the fusion of the pronunciation similarity relationship and the shape similarity relationship into the error correction process of the Chinese character input sequence, and then corrects the erroneous Chinese characters in the Chinese character input sequence, improves the accuracy of detection and correction of similar errors of complex Chinese characters, and improves the correction quality of Chinese spelling error correction.

[0124] Optionally, the specific implementation process of the above step 506 includes the following steps:

[0125] Step 1) based on the K semantic candidates, the sound-similar vectors and the shape-similar vectors, calculating the similarities between the K semantic candidates and the sound-similar vectors and the shape-similar vectors respectively;

[0126] Step 2) Sort the similarities and select similar candidates corresponding to the first M similarities.

[0127] Specifically, according to the K semantic candidates of the wrong Chinese character, the sound-like vector and the shape-like vector of the wrong Chinese character, the pronunciation similarity of the encoding vector of the wrong Chinese character and the weighted vector of the sound-like vector corresponding to the wrong Chinese character and the sound-like vector of the K semantic candidates in the vocabulary, and the shape similarity of the encoding vector of the wrong Chinese character and the weighted vector of the shape-like vector corresponding to the wrong Chinese character and the shape-like vector of the K semantic candidates in the vocabulary are sorted by the pronunciation similarity, shape similarity and confidence, and the first M are selected as similar candidates. Among them, M is less than or equal to L.

[0128] Optionally, the specific implementation process of the above step 507 includes the following steps:

[0129] Step 1) based on the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vectors corresponding to the Chinese characters at adjacent positions of the erroneous Chinese character, respectively calculate the dependency relationship values ​​between the vectors corresponding to the M similar candidates and the vector corresponding to the erroneous Chinese character;

[0130] Step 2) Based on the dependency values, select the maximum dependency value as the optimal path parameter.

[0131] Specifically, according to the vectors corresponding to M similar candidates respectively, the vector corresponding to the wrong Chinese character, and the vectors corresponding to the Chinese characters at the adjacent positions of the wrong Chinese character, calculate the dependency relationship values between the vectors corresponding to M similar candidates respectively and the vector corresponding to the wrong Chinese character. Through maximum likelihood estimation, obtain the maximum dependency relationship value, and select the maximum dependency relationship value as the optimal path parameter.

[0132] Figure 6 is a schematic flow chart of Chinese spelling correction provided by the present invention. As Figure 6 shown, taking the Chinese character input sequence "什么事都不济的", the wrong Chinese characters "济" and "的" as examples, the error correction process of the wrong Chinese characters in the Chinese character input sequence will be described:

[0133] Input "什么事都不济的" into the Detector and Encoder. The Detector consists of a contrastive learning model and a pre-trained language model. Among them, the contrastive learning model outputs the phonetic similarity vectors and graphic similarity vectors of each Chinese character in "什么事都不济的", and the pre-trained language model outputs the full-sentence CLS vector corresponding to "什么事都不济的" and the semantic vectors of each Chinese character. This semantic vector is used to represent the semantic relationship of each Chinese character; based on the phonetic similarity vectors and graphic similarity vectors of each Chinese character in "什么事都不济的" output by the contrastive learning model and the full-sentence CLS vector and the semantic vectors of each Chinese character output by the pre-trained language model, detect the positions and types of the wrong Chinese characters in "什么事都不济的", and obtain the positions and types of the wrong Chinese characters "济" and "的" in "什么事都不济的" output by the detector, that is, the error detection result: {(6, 济), (7, 的)}; the Encoder outputs the encoding vector corresponding to "什么事都不济的"; input the encoding vector corresponding to "什么事都不济的" into Softmax, and Softmax decodes the encoding vector corresponding to "什么事都不济的"; according to the positions and types of the wrong Chinese characters "济" and "的" output by the detector, calculate the phonetic similarity between the encoding vectors corresponding to "济" and "的" and the phonetic vectors of the Chinese characters in the vocabulary, and the graphic similarity between this encoding vector and the graphic vectors of the Chinese characters in the vocabulary respectively, and select the top 6 phonetic candidates and graphic candidates as the top 6 semantic candidates of the wrong Chinese characters respectively. That is, the semantic candidates of "济" are "济", "记", "济", "做", "计", "值", and the semantic candidates of "的" are "的", "的", "得", "了", "于", "心".

[0134] Further, according to the positions and types of the incorrect Chinese characters, and the contrast learning model, the phonetic similarity vectors and graphic similarity vectors of each Chinese character in the Chinese character input sequence are obtained, and the phonetic similarity vectors and graphic similarity vectors of the incorrect Chinese characters "ji" and "de" are determined; then, the K semantic candidates of the incorrect Chinese characters "ji" and "de", the phonetic similarity vectors and graphic similarity vectors of the incorrect Chinese characters "ji" and "de" are input into the Filter. The Filter calculates the phonetic similarity between the weighted vector of the encoding vector of the incorrect Chinese character and the phonetic similarity vector of the Chinese character corresponding to the incorrect Chinese character in the word list for each of the K semantic candidates, and the graphic similarity between the weighted vector of the encoding vector of the incorrect Chinese character and the graphic similarity vector of the Chinese character corresponding to the incorrect Chinese character in the word list for each of the K semantic candidates, respectively. The phonetic similarity, graphic similarity, and confidence are sorted, and the top 3 semantic candidates corresponding to the cosine similarity are selected as the similar candidates. Thus, the similar candidates for "ji" are "ji", "ji", "ji", and the similar candidates for "de" are "de", "di", "de".

[0135] Further, the vectors w i,m and w i+1,n corresponding to the 3 similar candidates respectively, the vector h i corresponding to the incorrect Chinese character, and the vector h i+1 corresponding to the Chinese character at the adjacent position of the incorrect Chinese character are input into the Dependency Searcher, that is, they are input into the Multi-Head Attention, Add and LayerNorm, and Feed Forward Network included in the Dependency Searcher in sequence. The dependency relationship values between the vectors w i,m and w i+1,n corresponding to the 3 similar candidates respectively and the vector h i corresponding to the incorrect Chinese character are calculated respectively, and the calculation is repeated 8 times. The maximum dependency relationship value is obtained through maximum likelihood estimation, and the maximum dependency relationship value is selected as the optimal path parameter; according to the optimal path parameter, the optimal corrected text is determined as "I don't remember anything".

[0136] The Chinese spelling error detection and correction device provided by the present invention will be described below. The Chinese spelling error detection and correction device described below can be correspondingly referred to the Chinese spelling error detection and correction method described above.

[0137] Figure 7 is a schematic structural diagram of the Chinese spelling error detection and correction device provided by the present invention. As Figure 7 shown, the Chinese spelling error detection and correction device 700 includes: a contrast learning module 701, an error detection module 702, an encoding module 703, and an error correction module 704; wherein:

[0138] The contrastive learning module 701 is used to input a Chinese character input sequence into a contrastive learning model, and obtain similar character vectors corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; the similar character vectors include a sound similarity vector and a shape similarity vector; the sound similarity vector is used to represent the similarity relationship between the pronunciations of each Chinese character; the shape similarity vector is used to represent the similarity relationship between the shapes of each Chinese character; the contrastive learning model is obtained by training based on sample Chinese character triples;

[0139] An error detection module 702 is used to detect erroneous Chinese characters in the Chinese character input sequence based on the similar character vectors, and obtain the position and type of the erroneous Chinese characters;

[0140] The encoding module 703 is used to encode the Chinese character input sequence to obtain an encoding vector corresponding to the Chinese character input sequence;

[0141] The error correction module 704 is used to correct the erroneous Chinese characters in the Chinese character input sequence based on the similar character vector, the position and type of the erroneous Chinese characters, and the encoding vector to obtain the optimal corrected text.

[0142] The Chinese spelling error detection and correction device provided by the embodiment of the present invention integrates the pronunciation similarity relationship and the shape similarity relationship into the error detection process of the Chinese character input sequence, and corrects the erroneous Chinese characters in the Chinese character input sequence based on the error detection results of the erroneous Chinese characters, thereby realizing error detection and correction of erroneous Chinese characters in the Chinese character input sequence, improving the accuracy of detection and correction of similar errors of complex Chinese characters, and improving the correction quality of Chinese spelling error correction.

[0143] Optionally, the error detection module 702 is specifically configured to:

[0144] splicing the semantic vector, the phonetic vector, the form vector of each Chinese character in the Chinese character input sequence and the full sentence vector corresponding to the Chinese character input sequence to obtain a splicing vector;

[0145] Based on the splicing vector, calculating the sound similarity gating value and the shape similarity gating value of each Chinese character;

[0146] Based on the sound-similar gating value and the shape-similar gating value, the position and type of the erroneous Chinese characters in the Chinese character input sequence are determined.

[0147] Optionally, the error detection module 702 is specifically configured to:

[0148] Using the sound similarity gating value and the shape similarity gating value as weights of the sound similarity vector and the shape similarity vector respectively;

[0149] Performing weighted summation on the semantic vector, the sound-similar vector, and the shape-similar vector to obtain a fusion vector;

[0150] Based on the fusion vector, the position and type of the erroneous Chinese characters in the Chinese character input sequence are determined.

[0151] Optionally, the error correction module 704 is specifically configured to:

[0152] Based on the position and type of the erroneous Chinese character, the encoding vector is decoded to calculate the top K semantic candidates of the erroneous Chinese character;

[0153] Determine the sound-similar vector and the shape-similar vector of the erroneous Chinese character based on the position and type of the erroneous Chinese character;

[0154] Determine first M similar candidates based on the K semantic candidates, the sound similarity vectors and the shape similarity vectors;

[0155] Determine the optimal path parameter based on the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vector corresponding to the Chinese character at the adjacent position of the erroneous Chinese character;

[0156] Based on the optimal path parameters, an optimal correction text is determined.

[0157] Optionally, the error correction module 704 is specifically configured to:

[0158] Based on the K semantic candidates, the sound-similar vectors and the shape-similar vectors, calculating the similarities between the K semantic candidates and the sound-similar vectors and the shape-similar vectors respectively;

[0159] The similarities are sorted, and similar candidates corresponding to the first M similarities are selected.

[0160] Optionally, the error correction module 704 is specifically configured to:

[0161] Based on the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vectors corresponding to the Chinese characters at adjacent positions of the erroneous Chinese character, respectively calculating the dependency relationship values ​​between the vectors corresponding to the M similar candidates and the vector corresponding to the erroneous Chinese character;

[0162] Based on the dependency values, a maximum dependency value is selected as an optimal path parameter.

[0163] Figure 8 is a schematic diagram of the physical structure of an electronic device, such as Figure 8As shown, the electronic device 800 may include: a processor (processor) 810, a communication interface (Communications Interface) 820, a memory (memory) 830 and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 can call the logic instructions in the memory 830 to execute a Chinese spelling error detection and correction method, which includes: inputting a Chinese character input sequence into a contrastive learning model to obtain a word vector corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; the word vector includes a sound-like vector and a shape-like vector; the sound-like vector is used to represent the pronunciation similarity relationship of each Chinese character; the shape-like vector is used to represent the shape similarity relationship of each Chinese character; the contrastive learning model is obtained based on sample Chinese character triples training; based on the word vector, the erroneous Chinese characters in the Chinese character input sequence are detected to obtain the position and type of the erroneous Chinese characters; the Chinese character input sequence is encoded to obtain the encoding vector corresponding to the Chinese character input sequence; based on the word vector, the position and type of the erroneous Chinese characters, and the encoding vector, the erroneous Chinese characters in the Chinese character input sequence are corrected to obtain the optimal corrected text.

[0164] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0165] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the Chinese spelling error detection and correction method provided by the above methods, which includes: inputting a Chinese character input sequence into a contrastive learning model to obtain a word vector corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; the word vector includes a sound-like vector and a shape-like vector; the sound-like vector is used to represent the pronunciation similarity relationship of each Chinese character; the shape-like vector is used to represent the shape similarity relationship of each Chinese character; the contrastive learning model is obtained based on sample Chinese character triples training; based on the word vector, the erroneous Chinese characters in the Chinese character input sequence are detected to obtain the position and type of the erroneous Chinese characters; the Chinese character input sequence is encoded to obtain the encoding vector corresponding to the Chinese character input sequence; based on the word vector, the position and type of the erroneous Chinese characters, and the encoding vector, the erroneous Chinese characters in the Chinese character input sequence are corrected to obtain the optimal corrected text.

[0166] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the Chinese spelling error detection and correction method provided by the above-mentioned methods, the method comprising: inputting a Chinese character input sequence into a contrastive learning model to obtain a word vector corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; the word vector comprises a sound-like vector and a shape-like vector; the sound-like vector is used to represent the pronunciation similarity relationship of each Chinese character; the shape-like vector is used to represent the shape similarity relationship of each Chinese character; the contrastive learning model is obtained based on sample Chinese character triples training; based on the word vector, detecting the erroneous Chinese characters in the Chinese character input sequence, and obtaining the position and type of the erroneous Chinese characters; encoding the Chinese character input sequence to obtain the encoding vector corresponding to the Chinese character input sequence; based on the word vector, the position and type of the erroneous Chinese characters, and the encoding vector, correcting the erroneous Chinese characters in the Chinese character input sequence to obtain the optimal corrected text.

[0167] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0168] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0169] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A Chinese spelling error detection and correction method, characterized in that: include: Inputting a Chinese character input sequence into a contrastive learning model, obtaining similar character vectors corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; the similar character vectors include a sound-similar vector and a shape-similar vector; the sound-similar vector is used to represent the similarity relationship between the pronunciations of each Chinese character; the shape-similar vector is used to represent the similarity relationship between the shapes of each Chinese character; the contrastive learning model is obtained by training based on sample Chinese character triples; the Chinese character triples include sound-similar triples or shape-similar triples; Based on the similar character vectors, detecting the wrong Chinese characters in the Chinese character input sequence, and obtaining the position and type of the wrong Chinese characters; Encode the Chinese character input sequence to obtain a coding vector corresponding to the Chinese character input sequence; Based on the similar character vector, the position and type of the erroneous Chinese character, and the encoding vector, correct the erroneous Chinese character in the Chinese character input sequence to obtain an optimal corrected text; The detecting, based on the similar character vectors, erroneous Chinese characters in the Chinese character input sequence, and obtaining the position and type of the erroneous Chinese characters in the Chinese character input sequence comprises: splicing the semantic vector, the phonetic vector, the form vector of each Chinese character in the Chinese character input sequence and the full sentence vector corresponding to the Chinese character input sequence to obtain a splicing vector; Based on the splicing vector, calculating the sound similarity gating value and the shape similarity gating value of each Chinese character; Using the sound similarity gating value and the shape similarity gating value as weights of the sound similarity vector and the shape similarity vector respectively; Performing weighted summation on the semantic vector, the sound-similar vector, and the shape-similar vector to obtain a fusion vector; Based on the fusion vector, the position and type of the erroneous Chinese characters in the Chinese character input sequence are determined.

2. The Chinese spelling error detection and correction method according to claim 1, characterized in that: The method of correcting the erroneous Chinese characters in the Chinese character input sequence based on the similar character vector, the position and type of the erroneous Chinese characters in the Chinese character input sequence, and the encoding vector to obtain an optimal corrected text includes: Based on the position and type of the erroneous Chinese character, the encoding vector is decoded to calculate the top K semantic candidates of the erroneous Chinese character; Determine the sound-similar vector and the shape-similar vector of the erroneous Chinese character based on the position and type of the erroneous Chinese character; Determine first M similar candidates based on the K semantic candidates, the sound similarity vectors and the shape similarity vectors; Determine the optimal path parameter based on the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vector corresponding to the Chinese character at the adjacent position of the erroneous Chinese character; Based on the optimal path parameters, an optimal correction text is determined.

3. The Chinese spelling error detection and correction method according to claim 2, characterized in that: The determining the first M similar candidates based on the K semantic candidates, the sound similarity vectors and the shape similarity vectors includes: Based on the K semantic candidates, the sound-similar vectors and the shape-similar vectors, calculating the similarities between the K semantic candidates and the sound-similar vectors and the shape-similar vectors respectively; The similarities are sorted, and similar candidates corresponding to the first M similarities are selected.

4. The Chinese spelling error detection and correction method according to claim 2, characterized in that: The determining of the optimal path parameter based on the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vector corresponding to the Chinese character at the adjacent position of the erroneous Chinese character comprises: Based on the vectors corresponding to the M similar candidates, the vector corresponding to the erroneous Chinese character, and the vectors corresponding to the Chinese characters at adjacent positions of the erroneous Chinese character, respectively calculating the dependency relationship values ​​between the vectors corresponding to the M similar candidates and the vector corresponding to the erroneous Chinese character; Based on the dependency values, a maximum dependency value is selected as an optimal path parameter.

5. A Chinese spelling error detection and correction device, characterized in that: include: A contrastive learning module, for inputting a Chinese character input sequence into a contrastive learning model, and obtaining similar character vectors corresponding to each Chinese character in the Chinese character input sequence output by the contrastive learning model; the similar character vectors include a sound-similar vector and a shape-similar vector; the sound-similar vector is used to represent the similarity relationship between the pronunciations of each Chinese character; the shape-similar vector is used to represent the similarity relationship between the shapes of each Chinese character; the contrastive learning model is obtained by training based on sample Chinese character triples; the Chinese character triples include sound-similar triples or shape-similar triples; An error detection module, used for detecting erroneous Chinese characters in a Chinese character input sequence based on the similar character vectors, and obtaining the position and type of the erroneous Chinese characters; An encoding module, used to encode the Chinese character input sequence to obtain an encoding vector corresponding to the Chinese character input sequence; An error correction module, used for correcting the erroneous Chinese characters in the Chinese character input sequence based on the similar character vector, the position and type of the erroneous Chinese characters, and the encoding vector, to obtain an optimal corrected text; The error detection module is specifically used for: splicing the semantic vector, the phonetic vector, the form vector of each Chinese character in the Chinese character input sequence and the full sentence vector corresponding to the Chinese character input sequence to obtain a splicing vector; Based on the splicing vector, calculating the sound similarity gating value and the shape similarity gating value of each Chinese character; Using the sound similarity gating value and the shape similarity gating value as weights of the sound similarity vector and the shape similarity vector respectively; Performing weighted summation on the semantic vector, the sound-similar vector, and the shape-similar vector to obtain a fusion vector; Based on the fusion vector, the position and type of the erroneous Chinese characters in the Chinese character input sequence are determined.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the Chinese spelling error detection and correction method as claimed in any one of claims 1 to 4 is implemented.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the Chinese spelling error detection and correction method as claimed in any one of claims 1 to 4 is implemented.

8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the Chinese spelling error detection and correction method as claimed in any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Voice recognition error correction method and man-machine conversation system

    CN110428822A

  • Text error correction method and system

    CN111310443A