Text correction method, text correction device, and electronic device

By generating a multi-dimensional set of replacement characters for text correction, the problems of low accuracy and insufficient user operation flexibility in existing technologies are solved, achieving more efficient and accurate text correction.

CN114510926BActive Publication Date: 2025-11-25VIVO MOBILE COMM CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210134582.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-14
Publication Date
2025-11-25
Estimated Expiration
2042-02-14

AI Technical Summary

Technical Problem

Existing text correction methods cannot effectively solve the problem of miscorrection, the accuracy of correction results is not high, the correction capability is limited, and the user operation flexibility is low.

Method used

By generating replacement character sets for the target error location from multiple dimensions, including semantic, phonetic, and visually similar replacement character sets, a target replacement character set is generated, and error correction is performed based on this set, providing multiple error correction candidates for the user to choose from.

Benefits of technology

It improves the accuracy and comprehensiveness of error correction, and enhances the flexibility and efficiency of user operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114510926B_ABST
    Figure CN114510926B_ABST
Patent Text Reader

Abstract

The application discloses a text error correction method, a text error correction device and an electronic equipment, and belongs to the field of artificial intelligence. The text error correction method comprises the following steps: determining a target error position from a target text; processing a target character at the target error position to generate a semantic replacement character set, a homophonic replacement character set and a homograph replacement character set corresponding to the target character; generating a target replacement character set corresponding to the target character based on the semantic replacement character set, the homophonic replacement character set and the homograph replacement character set; and correcting the target text based on the target replacement character set; wherein the replacement character in the semantic replacement character set is a character similar in semantics to the target character, the replacement character in the homophonic replacement character set is a character similar in pronunciation to the target character, and the replacement character in the homograph replacement character set is a character similar in character shape to the target character.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of artificial intelligence, and particularly relates to a text error correction method, a text error correction device and an electronic device. BACKGROUND

[0002] When a user uses an input device to input text, the input device performs error correction processing on the text to improve the correctness of the text. For example, based on the error correction of homophones, after the user selects a proofreading mode to input related text, if the text contains homophone errors, the input method displays a single error correction result at the error position, so that the user can select whether to correct the error.

[0003] The error correction method provided by the input method cannot solve the problem of "incorrect correction", and the error correction ability is relatively single, and the accuracy of the error correction result is not high. SUMMARY

[0004] The embodiments of the application aim to provide a text error correction method, a text error correction device and an electronic device, which can solve the problem of low accuracy of the existing error correction result.

[0005] In a first aspect, the embodiments of the application provide a text error correction method, which comprises:

[0006] determining a target error position from a target text;

[0007] processing a target character at the target error position to generate a semantic replacement character set, a homophone replacement character set and a homograph replacement character set corresponding to the target character;

[0008] generating a target replacement character set corresponding to the target character based on the semantic replacement character set, the homophone replacement character set and the homograph replacement character set;

[0009] performing error correction on the target text based on the target replacement character set;

[0010] wherein the replacement characters in the semantic replacement character set are characters similar in semantics to the target character, the replacement characters in the homophone replacement character set are characters similar in pronunciation to the target character, and the replacement characters in the homograph replacement character set are characters similar in character shape to the target character.

[0011] In a second aspect, the embodiments of the application provide a text error correction device, which comprises:

[0012] a first determination module configured to determine a target error position from a target text;

[0013] The first processing module is configured to process a target character at the target error position to generate a semantic replacement character set, a homophonic replacement character set and a homograph replacement character set corresponding to the target character;

[0014] The second processing module is configured to generate a target replacement character set corresponding to the target character based on the semantic replacement character set, the homophonic replacement character set and the homograph replacement character set;

[0015] The third processing module is configured to correct the target text based on the target replacement character set.

[0016] The replacement character in the semantic replacement character set is a character with similar semantics to the target character, the replacement character in the homophonic replacement character set is a character with similar pronunciation to the target character, and the replacement character in the homograph replacement character set is a character with similar shape to the target character.

[0017] In a third aspect, an electronic device is provided, which includes a processor and a memory. The memory stores programs or instructions executable on the processor. When the programs or instructions are executed by the processor, the steps of the method according to the first aspect are implemented.

[0018] In a fourth aspect, a readable storage medium is provided, which stores programs or instructions. When the programs or instructions are executed by a processor, the steps of the method according to the first aspect are implemented.

[0019] In a fifth aspect, a chip is provided, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is configured to execute programs or instructions to implement the method according to the first aspect.

[0020] In a sixth aspect, a computer program product is provided, which is stored in a storage medium. The program product is executed by at least one processor to implement the method according to the first aspect.

[0021] In the embodiments of the present application, by generating a target replacement character set corresponding to a target error position from multiple dimensions, the accuracy, precision and comprehensiveness of the target replacement characters in the target replacement character set can be improved. Based on the target replacement character set, the target text is corrected, and on the basis of providing more target replacement characters to the user, the target replacement characters with higher correctness are preferentially displayed to the user, thereby helping to improve the correction efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0022] Figure 1 is one of the flowcharts of the text correction method provided by the embodiments of the present application;

[0023] Figure 2 Figure 2 is a flowchart of a text correction method according to an embodiment of the present application;

[0024] Figure 3 Figure 3 is a flowchart of a text correction method according to an embodiment of the present application;

[0025] Figure 4 Figure 4 is a flowchart of a text correction method according to an embodiment of the present application;

[0026] Figure 5 Figure 5 is a flowchart of a text correction method according to an embodiment of the present application;

[0027] Figure 6 Figure 6 is an interface diagram of a text correction method according to an embodiment of the present application;

[0028] Figure 7 Figure 7 is a structural diagram of a text correction device according to an embodiment of the present application;

[0029] Figure 8 Figure 8 is a structural diagram of an electronic device according to an embodiment of the present application;

[0030] Figure 9 Figure 9 is a hardware diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0031] The technical solutions in the embodiments of the present application will be clearly described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some, but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art belong to the scope of protection of the present application.

[0032] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of a kind and do not limit the number of objects, for example, the first object can be one or more. In addition, "and / or" in the specification and claims indicates at least one of the connected objects, and the character " / ", generally indicates that the front and rear associated objects are in an "or" relationship.

[0033] In the related art, there are two ways to correct text:

[0034] One, error correction based on homophonic type. After the user inputs the related text, if it is detected that the text has homophonic error, the input method will prompt the replacement position and replacement word, and let the user choose whether to correct the error, such as correcting "weather really Hao" to "weather really good".

[0035] Second, error correction based on homographic type. After the user inputs the related text, if it is detected that the text has homographic error, the input method will prompt the replacement position and replacement word, and let the user choose whether to correct the error, such as correcting "end" in "the water flow of the end" to "turbulent".

[0036] The above two text correction methods have the following problems:

[0037] On the one hand, the current input method only gives a unique correction result for each error, the number of candidates is small, and the user can only choose to accept or not accept the correction, thereby leading to a narrow range of use, and the mis-correction problem cannot be effectively addressed.

[0038] On the other hand, when the algorithm does not detect errors, it is directly determined that the text input by the user is correct, and the user's operation flexibility is low.

[0039] On the other hand, whether it is based on homophonic type error correction or homographic type error correction, the corresponding error correction ability is limited, and the coverage is less, thereby affecting the ability of error correction.

[0040] The text correction method, text correction device, electronic device and readable storage medium provided by the embodiments of the present application will be described in detail below in combination with the accompanying drawings and through specific embodiments and application scenarios.

[0041] The text correction method can be applied to a terminal, and can be executed by hardware or software in the terminal.

[0042] The terminal includes, but is not limited to, a mobile phone or a tablet computer having a display screen and other portable communication devices. It should also be understood that in some embodiments, the terminal can not be a portable communication device, but a desktop computer having a display screen.

[0043] In each of the following embodiments, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal can include one or more other physical user interface devices such as a physical keyboard, a mouse, and a joystick.

[0044] The text correction method provided in the embodiments of the present application can be executed by an electronic device or a functional module or functional entity capable of implementing the text correction method in the electronic device. The electronic device mentioned in the embodiments of the present application includes but is not limited to a mobile phone, a tablet computer, a computer, a camera, a wearable device, and the like. The text correction method provided in the embodiments of the present application is described below by taking an electronic device as an example.

[0045] As shown in Figure 1 The text correction method includes steps 110, 120, 130, and 140.

[0046] Step 110: determining a target error position from a target text;

[0047] In this step, the target text is a text input by a user and requiring correction, for example, a word, a phrase, a paragraph, or an article input by the user.

[0048] The error position is a position of a character having an error in the target text, or a position of a character having a probability of error greater than a preset value in the target text.

[0049] In the same target text, there can be one or more error characters, and therefore, there can be one or more error positions.

[0050] The target error position is a position of a character requiring correction in the one or more error positions.

[0051] It can be understood that, in the case that the input device is working normally, the user can input the target text through the input device, including but not limited to text input through an input method or voice input.

[0052] It should be noted that the determination of the target error position can be automatic or manual, and the specific determination manner will be described in subsequent embodiments, which is not described herein.

[0053] In the actual execution process, one or more error positions in the same target text can be constructed into a set to generate a candidate set of error positions, denoted as Candidate.

[0054] Step 120: processing a target character in the target error position to generate a semantic replacement character set, a homophonic replacement character set, and a homographic replacement character set corresponding to the target character; wherein the replacement character in the semantic replacement character set is a character similar in semantics to the target character, the replacement character in the homophonic replacement character set is a character similar in pronunciation to the target character, and the replacement character in the homographic replacement character set is a character similar in shape to the target character.

[0055] In this step, the replacement character is a character used to replace the target character at the target error position in the target text.

[0056] It can be understood that the characters with similar semantics, i.e. the characters with similar meanings or the characters with similar entities, are generally used for error correction of very used characters or proper nouns, including but not limited to place names, personal names, organization names, game names, and movie names, etc. For example, "fish" Hangzhou and Yuhang District.

[0057] The characters with similar pinyins, i.e. the characters with the same or similar pronunciations, include the characters with the same pinyin and tone, and the characters with the same pinyin but different tones, such as "good" and "Hao".

[0058] The characters with similar shapes, i.e. the characters with similar shapes or strokes, such as "end" and "turbulent".

[0059] Each of the semantic replacement character set, the similar pronunciation replacement character set, and the similar shape replacement character set can include multiple replacement characters, for example, 30 or 50 replacement characters; and different character sets can include some of the same replacement characters, or can include different replacement characters.

[0060] In actual execution, multiple initial semantic replacement characters corresponding to the target character can be generated based on the semantic meaning possessed by the target error position. For example, after the user inputs fish Hangzhou, the terminal identifies the possible semantic meaning at this position as a proper place name based on semantics, and generates a semantic replacement word "Yuhang District" similar to "fish Hangzhou", and collects the "Yuhang District" in the semantic replacement character set.

[0061] Based on the pinyin of the target character at the target error position, multiple similar pronunciation replacement characters are generated. Taking "fish Hangzhou" as an example, based on the pinyin "yu" of "fish", other characters with similar pronunciations are generated, such as "and", "domain", "on", "remainder", "rain", and "pre", etc., and "and", "domain", "on", "remainder", "rain", and "pre" are collected in the similar pronunciation replacement character set.

[0062] Based on the shape of the target character at the target error position, multiple similar shape replacement characters are generated. For example, based on the shape of "fish", other characters with similar shapes or strokes are generated, such as "turtle", "complex", and "ready", etc., and "turtle", "complex", and "ready" are collected in the similar shape replacement character set.

[0063] The implementation of step 120 is described below through specific embodiments.

[0064] In some embodiments, the semantic replacement character set includes a first semantic replacement character set and a second semantic replacement character set, and step 120 can include:

[0065] Based on the target vocabulary, a plurality of initial semantic replacement characters corresponding to the target error position and a generation probability corresponding to the initial semantic replacement characters are generated;

[0066] Based on the generation probability, N initial semantic replacement characters are determined, and the N initial semantic replacement characters are sorted based on the generation probability to generate the first semantic replacement character set;

[0067] The target characters corresponding to the target error position are replaced by the first semantic replacement characters in the first semantic replacement character set, respectively;

[0068] A replacement score is generated based on the conditional probability corresponding to the first semantic replacement character;

[0069] The first semantic replacement characters in the first semantic replacement character set are sorted based on the replacement score to generate the second semantic replacement character set.

[0070] In this embodiment, N is a positive integer, and the value of N can be customized by the user, such as being set to 30 or 50, etc., which is not limited in the present application.

[0071] The initial semantic replacement character is any semantic replacement character generated based on the target vocabulary.

[0072] The first semantic replacement character set is a character set determined based on the generation probability of the initial semantic replacement character, and the semantic replacement characters in the first semantic replacement character set can be the initial semantic replacement characters sorted from high to low in generation probability; the second semantic replacement character set is a character set determined based on the replacement score of the first semantic replacement character, and the semantic replacement characters in the second semantic replacement character set can be the first semantic replacement characters sorted from high to low in replacement score.

[0073] The generation probability is the size of the probability of generating the initial semantic replacement character when the target vocabulary is used to generate the initial semantic replacement character at the target error position, for example, when the target vocabulary is used to replace the "fish" in "Yuhang District", the probability of generating "YU" is a, and the probability of generating "YU" is b, and a > b.

[0074] It should be noted that the target vocabulary referred to in this embodiment is a common word dictionary, and of course, in other embodiments, the target vocabulary can also be customized, which is not limited in the present application.

[0075] In some embodiments, a bidirectional encoder representation from transformers (Bert) model can be used to generate the recall score of the initial semantic replacement character, and the recall score can be used as the generation probability.

[0076] The substitution score is used to characterize the accuracy of the new word obtained after the first semantic substitution character replaces the target character in the entire target text.

[0077] In some embodiments, perplexity (ppl) scores may be used to represent replacement scores.

[0078] Understandably, PPL is used to estimate the probability of a string appearing based on each character. For example, for a string S of length n, the probability can be calculated using the formula:

[0079]

[0080] Determine the ppl of the string S, where p(wi|w1,…,wi-1) is the conditional probability, and w i This is used to represent the i-th character in string S. For example, for the target text "Welcome to Yuhang District", after replacing "fish" with "yu", the above formula is used to estimate the probability of the phrase "Welcome to Yuhang District" based on "Yuhang District", thus generating a PPL score of c corresponding to "Yuhang District". After replacing "fish" with "yu", the above formula is used to estimate the probability of the phrase "Welcome to Yuhang District" based on "Yuhang District", thus generating a PPL score of d corresponding to "Yuhang District", where c > d.

[0081] In actual execution, after obtaining multiple initial semantic replacement characters and their corresponding generation probabilities and replacement scores, the initial semantic replacement characters can be sorted from high to low based on their generation probabilities to obtain the top N initial semantic replacement characters, thus obtaining the first semantic replacement set; then, the target number of initial semantic replacement characters are re-sorted based on their replacement scores to obtain the second semantic replacement set.

[0082] For example, select the top 50 initial semantic replacement characters with the highest generation probability to generate the first semantic replacement character set. The initial semantic replacement characters in this first semantic replacement character set are the first semantic replacement characters.

[0083] Then, based on the replacement score of the first semantic replacement character, the first semantic replacement character is reordered to generate a second semantic replacement character set. The semantic replacement characters in this second semantic replacement character set are the second semantic replacement characters.

[0084] It is understandable that for the same initial semantic replacement character, its corresponding generation probability and replacement score may not be the same. Therefore, for any two initial semantic replacement characters, the generation probability of one initial semantic replacement character may be higher than that of the other initial semantic replacement character, but its corresponding replacement score may be lower than that of the other initial semantic replacement character.

[0085] Therefore, the initial semantic replacement characters in the first semantic replacement character set and the second semantic replacement character set are the same, but the order of the same initial semantic replacement character in the first semantic replacement character set and the second semantic replacement character set may not be exactly the same.

[0086] For example, such as Figure 3 As shown, in the actual execution process, for each error position in the Candidate, the corresponding words can be replaced with the [MASK] identifier in order from front to back. The BERT model is used to obtain the probability of generating all characters at the target error position, and the number of initial semantic replacement characters and the generation probability of each initial semantic replacement character are obtained. Then, the target number of initial semantic replacement characters with the highest generation probability are selected as the first semantic replacement characters with similar semantics. For example, the top 50 initial semantic characters are selected as the first semantic replacement characters with similar semantics. The specific process is as follows.

[0087] 1) For pos∈Candidate, replace it with [MASK], and denote the new text as NewEerrorSentence, where pos is used to represent the position of the character in the target text, and NewEerrorSentence is the new text obtained after replacing the character at each error position with the [MASK] identifier;

[0088] 2) The error locations marked with [MASK] are modeled using BERT to obtain a semantic representation h, where h is the set of all possible semantic information generated at the error location in the target text;

[0089] 3) Use the Classifier classification layer to process h and obtain the probability Vocab Pro of the initial semantic replacement character with similar semantics corresponding to the target error position in the target vocabulary. Vocab Pro is the generation probability of the initial semantic replacement character with similar semantics generated based on the target vocabulary, which is also the recall score.

[0090] 4) Obtain the top 50 characters with higher probabilities from Vocabulary Pro, and use them as a candidate set of first semantic replacement characters that are semantically similar to the target error location, denoted as:

[0091] wordCandidate = [(Bert1, BertScore1), …, (Bert50, BertScore50)]

[0092] wherein, wordCandidate is the first semantic replacement character set corresponding to the target character, Bert1 is the first first semantic replacement character corresponding to the target character, Bert50 is the 50th first semantic replacement character corresponding to the target character, BertScore1 is the generation probability corresponding to the first first semantic replacement character, and BertScore50 is the generation probability corresponding to the 50th first semantic replacement character.

[0093] In this embodiment, the generation probability corresponding to the initial semantic replacement character, i.e., the recall score, is calculated by the BERT recall function, which has high accuracy.

[0094] In some embodiments, the first semantic replacement characters in the first semantic replacement character set can also be sorted in descending order of generation probability, denoted as bert channel.

[0095] Figure 4 An error correction example of the target text "today weather really Hao" is shown, wherein the top several first semantic replacement characters in the bert channel are "good" and "great".

[0096] After obtaining wordCandidate, the ppl score of each first semantic replacement character in wordCandidate after replacing the target character is calculated using a language model, and wordCandidate is reordered based on the ppl score to obtain pplCandidate, wherein the pplCandidate is the second semantic replacement character, and the specific process is as follows.

[0097] 1) can be calculated by the formula:

[0098]

[0099] The ppl score of each first semantic replacement character in wordCandidate after replacing the target character at the target error position is calculated, wherein ppl is the replacement score, i.e., the semantic score, p(wi|w1,…,wi-1) is the ngram conditional probability, wi is the character corresponding to the i-th position in the target text, and n is the length of the target text.

[0100] Thus, pplCandidate is obtained, denoted as:

[0101] pplCandidate = [(ppl1, pplScore1),..., (ppl50, pplScore50)]

[0102] wherein pplCandidate is the second semantic replacement character set corresponding to the target character, ppl1 is the first second semantic replacement character corresponding to the target character, ppl50 is the 50th second semantic replacement character corresponding to the target character, pplScore1 is the generation probability corresponding to the first second semantic replacement character, and pplScore50 is the generation probability corresponding to the 50th second semantic replacement character.

[0103] In some embodiments, the second semantic replacement characters in the second semantic replacement character set can also be sorted in descending order of the replacement score, denoted as the ppl channel.

[0104] With continued reference to Figure 4 wherein the top several second semantic replacement characters in the ppl channel are “good” and “hot”, and the like.

[0105] In some embodiments, the phonetic proximity score can be represented using the edit distance, and the smaller the edit distance, the higher the phonetic proximity score.

[0106] Based on the pinyin of the target character at the target error position, such as “hao”, the edit distance (i.e., the length of the extension) is calculated with the phonetic of the target vocabulary in sequence, and the first 50 characters with the smallest edit distance are obtained, denoted as yinjinCandidate:

[0107] yinjinCandidate = [(PY1, PyScore1),..., (PY50, PyScore50)]

[0108] wherein yinjinCandidate is the phonetic proximity replacement character set, PY1 is the first phonetic proximity replacement character corresponding to the target character, PY50 is the 50th phonetic proximity replacement character corresponding to the target character, PyScore1 is the edit distance corresponding to the first phonetic proximity replacement character, and PyScore50 is the edit distance corresponding to the 50th phonetic proximity replacement character.

[0109] In some embodiments, the phonetic proximity replacement characters in the phonetic proximity replacement character set can be sorted in descending order of the phonetic proximity score, denoted as the PY channel.

[0110] With continued reference to Figure 4 wherein the top several phonetic proximity replacement characters in the PY channel are “good” and “bad”, and the like.

[0111] The yinjinCandidate is sorted in descending order of the PyScore, and is denoted as a PY channel.

[0112] In some embodiments, the shape proximity score can be represented using an edit distance. The smaller the edit distance, the higher the shape proximity score.

[0113] Based on the character shape of the target character at the target error position, such as Hao (stroke number: 4413121251), where the numbers represent stroke numbers, the edit distance is calculated with the character shapes in the target vocabulary, and the first 50 characters with the smallest edit distance are obtained, denoted as xingjinCandidate:

[0114] xingjinCandidate = [(ZX1, ZxScore1), …, (ZX50, ZxScore50)]

[0115] where xingjinCandidate is a shape proximity replacement character set, ZX1 is the first shape proximity replacement character corresponding to the target character, ZX50 is the 50th shape proximity replacement character corresponding to the target character, ZxScore1 is the edit distance corresponding to the first shape proximity replacement character, and ZxScore50 is the edit distance corresponding to the 50th shape proximity replacement character.

[0116] In some embodiments, the shape proximity replacement characters in the shape proximity replacement character set can be sorted in descending order of the shape proximity score, denoted as a ZX channel.

[0117] Continuing to refer to Figure 4 where the top few shape proximity replacement characters in the ZX channel are "different" and "high".

[0118] In this step, on the one hand, the semantic replacement characters are sorted and selected from the perspectives of generation probability and replacement score, which helps to better support the entity word correction capability; on the other hand, by generating replacement character sets corresponding to each dimension from multiple dimensions such as semantics (entity), sound proximity, and shape proximity, the problem of incomplete generated replacement characters caused by single dimension calculation can be avoided, which helps to improve the accuracy and comprehensiveness of the final generated target replacement character set in the subsequent process.

[0119] Step 130, based on the semantic replacement character set, the sound proximity replacement character set, and the shape proximity replacement character set, a target replacement character set corresponding to the target character is generated.

[0120] In this step, the target replacement character set is the final generated and displayed replacement character set.

[0121] One or more replacement characters are selected from the semantic replacement character set, the homophonic replacement character set and the homographic replacement character set respectively, and based on all the extracted replacement characters, a final replacement character set is generated, and the final replacement character set is output as a correction candidate set for error correction.

[0122] It can be understood that, in the case that the semantic replacement character set includes the first semantic replacement character set and the second semantic replacement character set, one or more replacement characters are selected from the first semantic replacement character set, the second semantic replacement character set, the homophonic replacement character set and the homographic replacement character set respectively, and based on all the extracted replacement characters, a final replacement character set is generated, and the final replacement character set is output as a correction candidate set for error correction.

[0123] In actual execution, the terminal outputs and displays the target replacement character set for the user to select, the user selects a target replacement character in the target replacement character set, and the terminal determines the target replacement character as the final replacement character in response to the user input, replaces the target character at the target position in the target text with the target replacement character, updates the target text, and thus completes the text correction.

[0124] The specific implementation of step 130 is described below.

[0125] In some embodiments, step 130 can include:

[0126] extracting a target semantic replacement character from the semantic replacement character set, a target homophonic replacement character from the homophonic replacement character set, and a target homographic replacement character from the homographic replacement character set;

[0127] generating a target feature fusion vector based on the target replacement character, the target replacement character including the target semantic replacement character, the target homophonic replacement character and the target homographic replacement character;

[0128] generating a target replacement character set corresponding to the target character based on the target feature fusion vector.

[0129] In this embodiment, the semantic replacement character set can be any one or more of the first semantic replacement character set and the second semantic replacement character set.

[0130] In the case that the semantic replacement character set is the first semantic replacement character set, the target semantic replacement character is the target first semantic replacement character; in the case that the semantic replacement character set is the second semantic replacement character set, the target semantic replacement character is the target second semantic replacement character; in the case that the semantic replacement character set includes the first semantic replacement character set and the second semantic replacement character set, the target semantic replacement character includes the target first semantic replacement character and the target second semantic replacement character.

[0131] The target replacement character set includes the replacement characters extracted from the semantic replacement character set, the homophonic replacement character set, and the homograph replacement character set, that is, the target replacement character set includes target semantic replacement characters, target homophonic replacement characters, and target homograph replacement characters.

[0132] The target feature fusion vector is generated based on the target replacement character, which can be generated based on the target semantic replacement character, the target homophonic replacement character, and the target homograph replacement character.

[0133] The following describes an embodiment with the semantic replacement character set including a first semantic replacement character set and a second semantic replacement character set.

[0134] In some embodiments, step 130 can include:

[0135] The target first semantic replacement character is extracted from the first semantic replacement character set, the target second semantic replacement character is extracted from the second semantic replacement character set, the target homophonic replacement character is extracted from the homophonic replacement character set, and the target homograph replacement character is extracted from the homograph replacement character set.

[0136] The target feature fusion vector is generated based on the target first semantic replacement character, the target second semantic replacement character, the target homophonic replacement character, and the target homograph replacement character.

[0137] The target replacement character set corresponding to the target character is generated based on the target feature fusion vector.

[0138] In this embodiment, the target first semantic replacement character is at least one first semantic replacement character with the highest generation probability extracted from the first semantic replacement character set, the target second semantic replacement character is at least one second semantic replacement character with the highest replacement score extracted from the second semantic replacement character set, the target homophonic replacement character is at least one homophonic replacement character with the highest homophonic score extracted from the homophonic replacement character set, and the target homograph replacement character is at least one homograph replacement character with the highest homograph score extracted from the homograph replacement character set.

[0139] It can be understood that one or more top-ranked replacement characters can be extracted from each replacement character set, such as 2 or 3 top-ranked replacement characters extracted from each replacement character set.

[0140] The following describes an embodiment with 2 top-ranked replacement characters extracted from each replacement character set.

[0141] For example, the top 2 replacement characters in each of the Bert channel, the ppl channel, the PY channel, and the ZX channel are selected as the final mixed candidate set, and the following is obtained:

[0142] Top8 = [Bert1, Bert2, ppl1, ppl2, PY1, PY2, ZX1, ZX2]

[0143] wherein, top8 is the final mixed candidate set, Bert1 and Bert2 are two first semantic replacement characters with top 2 generation probabilities in the Bert channel, ppl1 and ppl2 are two second semantic replacement characters with top 2 replacement scores in the ppl channel, PY1 and PY2 are two phonetically similar replacement characters with top 2 phonetically similar scores in the PY channel, and ZX1 and ZX2 are two graphically similar replacement characters with top 2 replacement scores in the ZX channel.

[0144] With reference to Figure 4 the final mixed candidate set includes: “good”, “great”, “good”, “hot”, “good”, “bad”, “bad”, and “high”.

[0145] The replacement characters in the final mixed candidate set are fused and processed, and a target feature fusion vector is generated.

[0146] wherein, the target feature fusion vector is a vector for representing all replacement characters in the final mixed candidate set and numerical values corresponding to the replacement characters.

[0147] In this step, one or more replacement characters are selected from the replacement character set corresponding to multiple dimensions such as semantics, phonetic similarity, and graphical similarity, to generate a target feature fusion vector, which has higher comprehensiveness, so that the replacement characters contained in the target replacement character set generated based on the target feature fusion vector are more comprehensive and accurate.

[0148] In some embodiments, the target feature fusion vector is generated based on the target replacement character, including:

[0149] obtaining a target semantic score of a target semantic replacement character, a target phonetically similar score of a target phonetically similar replacement character, and a target graphically similar score of a target graphically similar replacement character;

[0150] generating a target feature fusion vector based on the target semantic replacement character, the target semantic score, the target phonetically similar replacement character, the target phonetically similar score, the target graphically similar replacement character, and the target graphically similar score.

[0151] In this embodiment, the target replacement character includes a target semantic replacement character, a target phonetically similar replacement character, and a target graphically similar replacement character.

[0152] It can be understood that the target semantic replacement character can include at least one of a target first semantic replacement character and a target second semantic replacement character.

[0153] In a case where the semantic replacement character set is the first semantic replacement character set, the target semantic replacement character is a target first semantic replacement character; in a case where the semantic replacement character set is the second semantic replacement character set, the target semantic replacement character is a target second semantic replacement character; in a case where the semantic replacement character set includes the first semantic replacement character set and the second semantic replacement character set, the target semantic replacement character includes the target first semantic replacement character and the target second semantic replacement character.

[0154] The target semantic score includes at least one of the target generation probability and the target replacement score, and the target semantic score has a corresponding relationship with the target semantic replacement character.

[0155] For example, in a case where the target semantic replacement character is the target first semantic replacement character, the target semantic score is the target generation probability; in a case where the target semantic replacement character is the target second semantic replacement character, the target semantic score is the target replacement score.

[0156] The following takes an example of the target semantic replacement character including the target first semantic replacement character and the target second semantic replacement character to describe this embodiment.

[0157] In some embodiments, generating the target feature fusion vector based on the target replacement character can include:

[0158] obtaining a target generation probability of the target first semantic replacement character, a target replacement score of the target second semantic replacement character, a target phonetic proximity score of the target phonetic proximity replacement character, and a target graphemic proximity score of the target graphemic proximity replacement character;

[0159] generating the target feature fusion vector based on the target first semantic replacement character, the target generation probability, the target second semantic replacement character, the target replacement score, the target phonetic proximity replacement character, the target phonetic proximity score, the target graphemic proximity replacement character, and the target graphemic proximity score.

[0160] In this embodiment, the target generation probability is the generation probability of the target first semantic replacement character, the target replacement score is the replacement score of the second semantic replacement character, the target phonetic proximity score is the phonetic proximity score of the target phonetic proximity replacement character, and the target graphemic proximity score is the graphemic proximity score of the target graphemic proximity character.

[0161] The following takes the Top8 set as an example to describe this embodiment.

[0162] After obtaining Top8 = [Bert1, Bert2, ppl1, ppl2, PY1, PY2, ZX1, ZX2], the id in the target vocabulary vocab is found for Top8, as follows: Figure 4As shown in the formula, the id of "good" in the vocab is 27, and the id of "great" in the vocab is 50; and the position of each replacement character is obtained according to the ascending order of the id, which can be obtained by the formula:

[0163] index = getSortIndex(getVocabIndex(w) for w in Top8, word), word ∈ Top8

[0164] The position of each replacement character is obtained, where word is a replacement character in Top8, w represents any one of the replacement characters in Top8, getVocabIndex function is used to obtain the id of w in the target vocabulary, getSoreIndex function is used to obtain the sorting position of word in all replacement characters in Top8, and index is used to represent the sorting position of w in Top8.

[0165] As shown in the formula, the id of "good" in the vocab is 27, and the id of "great" in the vocab is 50; and the position of each replacement character is obtained according to the ascending order of the id, which can be obtained by the formula: Figure 4

[0166] For the correct character, the one-hot vector of its index is declared as the prediction target of the model prediction, which can be obtained by the formula:

[0167] label = [0, …, 1 index , 0]

[0168] The prediction result is obtained, where label is a vector of the target length, for example, a vector of length 8, and index represents the sorting position of the correct character in the final mixed candidate set, where the index position is 1, and the remaining positions are 0.

[0169] As shown in the formula, the id of "good" in the vocab is 27, and the id of "great" in the vocab is 50; and the position of each replacement character is obtained according to the ascending order of the id, which can be obtained by the formula: Figure 4

[0170] In this step, a small vocabulary classification model based on word ID alignment is used to score the replacement characters in the mixed replacement character set, which has high accuracy.

[0171] Then, for the replacement characters in Top8 and their scores in the four channels, the formula is used:

[0172] ​​feature = [Bert1, Bert2, pp1, ppl2, PY1, PY2, ZX1, ZX2, BertScore1, BertScore2, pplScore1, pplScore2, PyScore1, PyScore2, ZxScore1, ZxScore2, Bert1==ppl1, Bert1==PY1, Bert==ZX1, PY1==PPL1, ZX==PPl1, ZX1==PY1, Max(aisle), aisle in(wordCandidate, pplCandidate, xingjinCandidate, xingjinCandidate)

[0173] Min(aisle), aisle in(wordCandidate, pplCandidate, xingjinCandidate, xingjinCandidate)]

[0174] constructing a target feature fusion vector, wherein the feature is the target feature fusion vector, the BertScore is a generation probability corresponding to a first semantic replacement character in a Bert channel, the pplScore is a replacement score corresponding to a second semantic replacement character in a ppl channel, the PyScore is a homophone score corresponding to a homophone replacement character in a PY channel, and the ZxScore is a grapheme score corresponding to a grapheme replacement character in a ZX channel.

[0175] After obtaining the target feature fusion vector, a target replacement character set corresponding to a target character can be generated based on the target feature fusion vector.

[0176] The target replacement character set includes replacement characters corresponding to the target feature fusion vector, and all replacement characters are sorted in descending order of the final target score.

[0177] For example, based on the final candidate set ["good", "bar", "good", "hot", "good", "bad", "bad", "high"], the final target replacement character set is ["good", "bar", "hot", "bad", "bad", "high"].

[0178] In this embodiment, one or more replacement characters are selected from the replacement character sets corresponding to multiple dimensions such as semantics, homophones, and graphemes to generate a final mixed candidate set, and a target feature fusion vector is generated based on the generation probability, replacement score, homophone score, and grapheme score corresponding to the replacement characters in the mixed candidate set, which can significantly improve the comprehensiveness and accuracy of the results.

[0179] In some embodiments, based on the target feature fusion vector, the target replacement character set corresponding to the target character can be generated, which can include:

[0180] Based on the target feature fusion vector, a target score corresponding to the target replacement character is generated.

[0181] Based on the target score, the target replacement characters are sorted to generate the target replacement character set corresponding to the target character.

[0182] In this embodiment, the target score is used to represent the probability that the target replacement character is a correct word.

[0183] It should be noted that the target score is different from the above-mentioned target semantic score, target phonetic score and target graphemic score. The target score is a score generated by fusing semantic, pronunciation and grapheme evaluation indexes.

[0184] It can be understood that one or more replacement characters are extracted from the semantic replacement character set, the phonetic replacement character set and the graphemic replacement character set, respectively, and these replacement characters ultimately form a new set, i.e., the final mixed candidate set. The replacement characters in the final mixed candidate set are the target replacement characters.

[0185] Each target replacement character in the final mixed candidate set corresponds to a target score.

[0186] Based on the numerical value of the target score, all target replacement characters in the final mixed candidate set are sorted, i.e., the target semantic replacement characters, the target phonetic replacement characters and the target graphemic replacement characters are sorted based on the target score, so as to generate the target replacement character set corresponding to the target character.

[0187] In actual execution process, after obtaining the final mixed candidate set, the probability that each target replacement character in the final mixed candidate set is a correct word is calculated, and the target replacement characters in the final mixed candidate set are sorted according to the probability, so as to generate the target replacement character set.

[0188] For example, for the final candidate set ["good", "bar", "good", "hot", "good", "bad", "bad", "high"], the target score corresponding to "good" is p1, the target score corresponding to "bar" is p2, the target score corresponding to "hot" is p3, the target score corresponding to "bad" is p4, the target score corresponding to "bad" is p5, and the target score corresponding to "high" is p6, wherein p1>p2>p3>p4>p5>p6.

[0189] Then, the replacement characters of "good", "bar", "hot", "bad", "poor" and "high" are sorted according to the target scores to generate the target replacement character set as [good, bar, hot, bad, poor, high].

[0190] After generating the target replacement character set, the target replacement character set can be displayed for the user to select one of them as the correction result at the target position in the target text.

[0191] In this embodiment, by scoring the target feature fusion vector, the target scores of each replacement character in the mixed candidate set corresponding to the target feature fusion vector are generated, and the replacement characters are sorted based on the target scores to preferentially display the replacement characters with higher accuracy to the user, thereby helping to reduce the user's time to find the correct replacement character and improving the correction efficiency.

[0192] In some embodiments, a neural network model can be used to generate the target scores of each replacement character in the mixed candidate set corresponding to the target fusion feature vector.

[0193] The embodiment will be described in detail below.

[0194] For example, an optimized distributed gradient boosting library (eXtreme Gradient Boosting, XGBoost) model can be used as a neural network model for generating target scores.

[0195] In actual execution, feature is input into the XGBoost model as an input vector of the XGBoost model, and the XGBoost model outputs the target score. The XGBoost model is trained with the sample fusion feature vector as the sample and the sample score corresponding to the sample fusion feature vector as the sample label.

[0196] In the actual training process, the XGBoost model can be trained with (feature, label) as training data, where feature in (feature, label) is the sample fusion feature vector, and label is the sample label.

[0197] In some embodiments, the model training can also be performed by constructing training data through data enhancement to enhance the robustness of the model. It mainly includes two steps of selecting "error-prone positions" and replacing them with "error-prone samples".

[0198] Wherein, for the selection of "error-prone positions", the formula:

[0199] s = s origen -stop1

[0200] s, where s is the score corresponding to the error-prone position, used to represent the probability of error at this position, s origen is the Bert score corresponding to the original character at the current position, s top1 is the score corresponding to the character with the highest Bert score at the current position.

[0201] It can be understood that the smaller the score s is, the more likely the current position is to be replaced. For each sample, the position most likely to be replaced, i.e. the position corresponding to the smallest s, is selected as the "error-prone position".

[0202] For replacement of "error-prone samples", the replacement can be performed by the formula:

[0203] w = argmax w (s w w in D)

[0204] where w is the character with the highest Bert score at the current position, D is the confusion set of the replaced position, and argmax w is used to select the character with the highest Bert score from the set D as the replacement character, s w is the Bert score when the character at the current position is w. That is, the character with the highest Bert score at the "error-prone position" is selected, i.e. the most likely to be confused character, to replace the original character.

[0205] Through the above two steps, an enhanced data set can be constructed to train the overall model, thereby improving the accuracy of the model output.

[0206] It should be noted that the target feature fusion vector obtained in each actual application process can be used as a training sample in the subsequent training model process.

[0207] In this embodiment, the XGBoost model is used to score the target feature fusion vector, which has high learning ability, and as the training samples gradually expand, the final output of the training result will also be more and more accurate.

[0208] Step 140, based on the target replacement character set, correcting the target text.

[0209] In this step, after the target replacement character set is generated, the target replacement character set can be displayed for the user to select one of the target replacement character set as the correction result of the target position in the target text, so that the terminal replaces the target character in the target text with the target replacement character selected by the user to complete the correction of the target text. According to the text correction method provided in the embodiments of the present application, the target replacement character set corresponding to the target error position is generated from multiple dimensions, which can improve the accuracy, precision and comprehensiveness of the target replacement characters contained in the target replacement character set; based on the target replacement character set, the target text is corrected, and on the basis of providing more target replacement characters to the user, the target replacement characters with higher correctness can be preferentially displayed to the user, thereby helping to improve the correction efficiency.

[0210] It should be noted that, in some embodiments, as shown in FIG. 1 10, before step 1 10, the method can further include: Figure 2

[0211] receiving a second input of the user;

[0212] determining a correction mode in response to the second input.

[0213] In this embodiment, the correction mode includes an automatic correction mode and a manual correction mode.

[0214] The second input is used to determine the correction mode.

[0215] The second input can be the same as the first input, such as a touch input, a physical key input, a voice input, or a character input, which will be described in subsequent embodiments and will not be repeated here.

[0216] In actual execution process, the first input can further include a first sub-input and a second sub-input, wherein the first sub-input is used to display a correction interface, and the second sub-input is used to determine the correction mode.

[0217] For example, the user clicks a correction target control in an input method for entering a "correction" interface to realize the first sub-input. The terminal displays the correction interface and enters the correction word mode in response to the first sub-input.

[0218] The user clicks a mode selection control for selecting a correction mode on the correction interface as shown in FIG. 1 1 1 to realize the second sub-input, thereby entering the corresponding correction mode. Figure 6 For example, if the user clicks an automatic correction mode control on the correction interface as shown in FIG. 1 1 1, the terminal determines the correction mode as the automatic correction mode; or the user clicks a manual correction mode control on the correction interface as shown in FIG. 1 1 2, the terminal determines the correction mode as the manual correction mode.

[0219] Figure 6 Figure 6 ​​​When the manual correction mode control on the error correction interface is selected, the terminal determines the error correction mode as the manual correction mode.

[0220] In this embodiment, by providing multiple error correction modes such as automatic error correction or user-defined error correction, and supporting user to select the error correction mode by himself, the user can select the best error correction mode based on the actual situation, thereby significantly improving the flexibility and universality of error correction.

[0221] The following continues to refer to Figure 2 , and the implementation of step 110 of the embodiment of the present application is specifically described from two different implementation angles.

[0222] I. Automatically determining the target error position

[0223] In this embodiment, step 110 can include:

[0224] segmenting the target text to generate a set of word vectors;

[0225] calculating the error probability of each character in the set of word vectors;

[0226] In the case where the error probability is greater than the target threshold, the position corresponding to the character is determined as the target error position.

[0227] In this embodiment, the set of word vectors is a set of vectors including single words or phrases in the target text, denoted as EerrorSentence.

[0228] In actual execution process, the target text can be segmented by words. For example, the target text "today weather really Hao" can be segmented into a set of word vectors including "today", "weather", "really", "Hao", and the like.

[0229] Then, the MacBert language model is used to model EerrorSentence to obtain its semantic representation H=[H1,…,Hn]; where H is a set of semantic representations corresponding to each word vector segmented from the target text, and n is the number of word vectors segmented from the target text.

[0230] As Figure 5 shown, each position of H is processed using a multilayer perceptron (MLP) to obtain the probability Error of whether the character at each position is incorrect, Error∈R2; where Error[0] represents the correct probability that the character at the current position is correct, represented by the correct probability; Error[1] represents the probability that the character at the current position is incorrect, represented by the error probability.

[0231] When Error[1]>Error[0], that is, in the case of error probability greater than the target threshold, the position corresponding to the character is determined as the target error position, and the target error position is included in the candidate error position set, denoted as Candidate.

[0232] The target threshold is not less than 50%.

[0233] For example, the terminal calculates the error probability of the character in the word vectors of "today", "weather", "true", "Hao", etc. respectively, and determines the position of "Hao" in the target text "today weather true Hao" as the target error position in the case of calculating the error probability corresponding to "Hao" exceeding the correct probability.

[0234] In this embodiment, the target error position is detected and determined by the MacBert function, which has high accuracy.

[0235] II. User manually determines the target error position

[0236] In this embodiment, step 110 can include:

[0237] Receiving the first input of the target text by the user;

[0238] In response to the first input, the target error position is determined.

[0239] In this embodiment, the first input is used to determine the target error position.

[0240] The first input can be at least one of the following ways:

[0241] First, the first input can be a touch operation, including but not limited to click operation, sliding operation and pressing operation, etc.

[0242] In this embodiment, receiving the first input of the user can be receiving the touch operation of the user on the display area of the display screen of the terminal.

[0243] For example, in the interface state of displaying the target text, the target control corresponding to each character in the target text is displayed in the current interface, and the target control is touched to realize the first input; or the first input is set as continuous multiple taps or long press on the target position of the display area within the target time interval.

[0244] Second, the first input can be a physical key input.

[0245] In this embodiment, the terminal is provided with physical keys such as mouse or keyboard on the body, and the first input of the user can be received by receiving the first input of the user moving and pressing the corresponding physical keys; the first input can also be a combination operation of pressing multiple physical keys at the same time.

[0246] Thirdly, the first input can be a voice input.

[0247] In this embodiment, when receiving a voice input such as "the weather is really hot today", the terminal can determine the position of "hot" as the target error position.

[0248] Of course, in other embodiments, the first input can also be in other forms, including but not limited to character input, etc., which can be determined according to actual needs, and the embodiments of the present application are not limited thereto.

[0249] In actual execution, when the user inputs the target text "the weather is really hot today", the user can long press the position of "hot" in the correction editing box as shown in Figure 6 to realize the first input.

[0250] The terminal determines the position corresponding to "hot" as the target error position in response to the first input, thereby realizing the self-defined error position.

[0251] According to the text correction method provided in the embodiments of the present application, by providing two ways of automatically determining the target error position and manually determining the target error position by the user, the error position can be automatically selected or defined by the user, which can enable the user to select the best correction method based on the actual situation, avoid the situation that the user cannot correct the error by himself / herself when the target text is incorrect and the terminal does not automatically identify the error, thereby significantly improving the flexibility and universality of the correction.

[0252] The text correction method provided in the embodiments of the present application can be executed by a text correction device. In the embodiments of the present application, the text correction device is taken as an example to illustrate the text correction device provided in the embodiments of the present application.

[0253] The embodiments of the present application also provide a text correction device.

[0254] As shown in Figure 7 , the text correction device comprises a first determining module 710, a first processing module 720, a second processing module 730 and a third processing module 740.

[0255] The first determining module 710 is configured to determine a target error position from a target text.

[0256] The first processing module 720 is configured to process a target character at the target error position to generate a semantic replacement character set, a homophone replacement character set and a homograph replacement character set corresponding to the target character.

[0257] The second processing module 730 is configured to generate a target replacement character set corresponding to the target character based on the semantic replacement character set, the homophonic replacement character set and the homograph replacement character set.

[0258] The third processing module 740 is configured to perform error correction on the target text based on the target replacement character set.

[0259] The replacement character in the semantic replacement character set is a character similar in semantics to the target character, the replacement character in the homophonic replacement character set is a character similar in pronunciation to the target character, and the replacement character in the homograph replacement character set is a character similar in shape to the target character.

[0260] The text error correction apparatus provided in the embodiments of the present application can improve the accuracy, precision and comprehensiveness of the target replacement characters in the target replacement character set by generating the target replacement character set corresponding to the target error position from multiple dimensions, and can improve the error correction efficiency by preferentially displaying the target replacement characters with higher correctness to the user on the basis of providing more target replacement characters to the user.

[0261] In some embodiments, the semantic replacement character set includes a first semantic replacement character set and a second semantic replacement character set, and the first processing module 720 is further configured to:

[0262] generate a plurality of initial semantic replacement characters corresponding to the target error position and generation probabilities corresponding to the initial semantic replacement characters based on the target vocabulary;

[0263] determine N initial semantic replacement characters based on the generation probabilities, sort the N initial semantic replacement characters based on the generation probabilities, and generate the first semantic replacement character set;

[0264] replace the target character corresponding to the target error position with the first semantic replacement character in the first semantic replacement character set;

[0265] generate a replacement score corresponding to the first semantic replacement character based on a conditional probability corresponding to the first semantic replacement character;

[0266] sort the first semantic replacement characters in the first semantic replacement character set based on the replacement score, and generate the second semantic replacement character set.

[0267] In some embodiments, the second processing module 730 is further configured to:

[0268] extract the target semantic replacement character from the semantic replacement character set, extract the target homophonic replacement character from the homophonic replacement character set, and extract the target homograph replacement character from the homograph replacement character set.

[0269] The target feature fusion vector is generated based on a target replacement character, and the target replacement character includes a target semantic replacement character, a target homophone replacement character, and a target homograph replacement character.

[0270] The target replacement character set corresponding to the target character is generated based on the target feature fusion vector.

[0271] In some embodiments, the second processing module 730 can be further configured to:

[0272] The target semantic score of the target semantic replacement character, the target homophone score of the target homophone replacement character, and the target homograph score of the target homograph replacement character are obtained.

[0273] The target feature fusion vector is generated based on the target semantic replacement character, the target semantic score, the target homophone replacement character, the target homophone score, the target homograph replacement character, and the target homograph score.

[0274] In some embodiments, the second processing module 730 can be further configured to:

[0275] The target score corresponding to the target replacement character is generated based on the target feature fusion vector.

[0276] The target replacement character set corresponding to the target character is generated by sorting the target replacement characters based on the target score.

[0277] In some embodiments, the apparatus can further include:

[0278] The fourth processing module is configured to split the target text to generate a word vector set.

[0279] The fifth processing module is configured to calculate an error probability of each character in the word vector set.

[0280] The first determining module 710 is further configured to determine the position corresponding to the character as the target error position when the error probability is greater than a target threshold.

[0281] In some embodiments, the apparatus can further include:

[0282] The first receiving module is configured to receive a first input of a user on the target text.

[0283] The first determining module 710 is further configured to determine the target error position in response to the first input.

[0284] The text correction apparatus in the embodiments of the present application can be an electronic device, or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted electronic device, a Mobile Internet Device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), and can also be a server, a Network Attached Storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, and the like, and the embodiments of the present application are not limited in this regard.

[0285] The text correction apparatus in the embodiments of the present application can be a device with an operating system. The operating system can be an Android operating system, an IOS operating system, or other possible operating systems, and the embodiments of the present application are not limited in this regard.

[0286] The text correction apparatus provided in the embodiments of the present application can implement the method embodiments, and each process of the method embodiments is not repeated here. Figures 1 to 6 The text correction apparatus provided in the embodiments of the present application can implement the method embodiments, and each process of the method embodiments is not repeated here.

[0287] Optionally, as shown in Figure 8 The present application also provides an electronic device 800, which includes a processor 801, a memory 802, and a program or instruction stored in the memory 802 and executable on the processor 801. When the program or instruction is executed by the processor 801, each process of the above-mentioned text correction method embodiments is implemented, and the same technical effects are achieved. Each process of the above-mentioned text correction method embodiments is not repeated here.

[0288] It should be noted that the electronic device in the embodiments of the present application includes the mobile electronic device and the non-mobile electronic device described above.

[0289] Figure 9 A hardware structure schematic diagram of an electronic device according to an embodiment of the present application is shown in FIG. 8.

[0290] The electronic device 900 includes, but is not limited to, a radio frequency unit 901, a network module 902, an audio output unit 903, an input unit 904, a sensor 905, a display unit 906, a user input unit 907, an interface unit 908, a memory 909, and a processor 910, and the like.

[0291] Those skilled in the art can understand that the electronic device 900 can further include a power supply (such as a battery) for supplying power to each component, and the power supply can be logically connected to the processor 910 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. Figure 9 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device can include more or fewer components than the figure, or combine certain components, or different component arrangements, which are not described here.

[0292] The processor 910 is configured to:

[0293] determine a target error position from the target text;

[0294] process the target character at the target error position to generate a semantic replacement character set, a homophone replacement character set, and a homograph replacement character set corresponding to the target character;

[0295] generate a target replacement character set corresponding to the target character based on the semantic replacement character set, the homophone replacement character set, and the homograph replacement character set;

[0296] correct the target text based on the target replacement character set;

[0297] The replacement characters in the semantic replacement character set are characters similar in semantics to the target character, the replacement characters in the homophone replacement character set are characters similar in pronunciation to the target character, and the replacement characters in the homograph replacement character set are characters similar in shape to the target character.

[0298] According to the electronic device provided in the embodiments of the present application, the target replacement character set corresponding to the target error position is generated from multiple dimensions, which can improve the accuracy, precision, and comprehensiveness of the target replacement characters in the target replacement character set. Based on the target replacement character set, the target text is corrected, and on the basis of providing more target replacement characters to the user, the target replacement characters with higher correctness are preferentially displayed to the user, thereby helping to improve the correction efficiency.

[0299] Optionally, the semantic replacement character set includes a first semantic replacement character set and a second semantic replacement character set, and the processor 910 is further configured to:

[0300] generate a plurality of initial semantic replacement characters corresponding to the target error position and a generation probability corresponding to the initial semantic replacement characters based on the target vocabulary;

[0301] determine N initial semantic replacement characters based on the generation probability, sort the N initial semantic replacement characters based on the generation probability, and generate a first semantic replacement character set;

[0302] replace the target characters corresponding to the target error position with the first semantic replacement characters in the first semantic replacement character set respectively;

[0303] generate a replacement score corresponding to the first semantic replacement character based on a conditional probability corresponding to the first semantic replacement character;

[0304] sort the first semantic replacement characters in the first semantic replacement character set based on the replacement score, and generate a second semantic replacement character set.

[0305] Optionally, the processor 910 can also be configured to:

[0306] extract a target semantic replacement character from the semantic replacement character set, a target homophone replacement character from the homophone replacement character set, and a target homograph replacement character from the homograph replacement character set;

[0307] generate a target feature fusion vector based on the target replacement character, the target replacement character including the target semantic replacement character, the target homophone replacement character, and the target homograph replacement character;

[0308] generate a target replacement character set corresponding to the target character based on the target feature fusion vector.

[0309] Optionally, the processor 910 can also be configured to:

[0310] obtain a target semantic score of the target semantic replacement character, a target homophone score of the target homophone replacement character, and a target homograph score of the target homograph replacement character;

[0311] generate a target feature fusion vector based on the target semantic replacement character, the target semantic score, the target homophone replacement character, the target homophone score, the target homograph replacement character, and the target homograph score.

[0312] Optionally, the processor 910 can also be configured to:

[0313] generate a target score corresponding to the target replacement character based on the target feature fusion vector;

[0314] sort the target replacement characters based on the target score, and generate a target replacement character set corresponding to the target character.

[0315] Optionally, the processor 910 can also be configured to:

[0316] segmenting the target text to generate a set of word vectors;

[0317] calculating an error probability of each character in the set of word vectors;

[0318] determining the position corresponding to the character as a target error position if the error probability is greater than a target threshold.

[0319] Optionally,

[0320] The user input unit 907 is configured to receive a first input of a target text from a user.

[0321] The processor 910 is further configured to determine a target error position in response to the first input.

[0322] It should be understood that in the embodiments of the present application, the input unit 904 can include a graphics processing unit (GPU) 9041 and a microphone 9042. The graphics processing unit 9041 processes image data of a still picture or a video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 906 can include a display panel 9061, which can be configured in the form of a liquid crystal display, an organic light-emitting diode, etc. The user input unit 907 includes at least one of a touch panel 9071 and other input devices 9072. The touch panel 9071 is also called a touch screen. The touch panel 9071 can include a touch detection device and a touch controller. The other input devices 9072 can include, but are not limited to, a physical keyboard, function keys (such as volume control keys, on-off keys, etc.), a trackball, a mouse, an operation lever, and the like, which will not be described here.

[0323] The memory 909 can be used to store software programs and various data. The memory 909 can mainly include a first storage area storing programs or instructions and a second storage area storing data, wherein the first storage area can store an operating system, application programs or instructions required by at least one function (such as a sound playing function, an image playing function, etc.), etc. In addition, the memory 909 can include a volatile memory or a non-volatile memory, or the memory 909 can include both volatile and non-volatile memories. The non-volatile memory can be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically EPROM (EEPROM), or a flash memory. The volatile memory can be a Random Access Memory (RAM), a Static RAM (SRAM), a Dynamic RAM (DRAM), a Synchronous DRAM (SDRAM), a Double Data Rate SDRAM (DDR SDRAM), an Enhanced SDRAM (ESDRAM), a Synch link DRAM (SLDRAM), and a Direct Rambus RAM (DRRAM). The memory 909 in the embodiments of the present application includes but is not limited to these and any other suitable types of memories.

[0324] The processor 910 can include one or more processing units; optionally, the processor 910 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and an application program, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 910.

[0325] The embodiments of the present application also provide a readable storage medium, the readable storage medium stores programs or instructions, the programs or instructions are executed by a processor to realize the processes of the above-mentioned text error correction method embodiments, and the same technical effects can be achieved. To avoid repetition, details are not described here.

[0326] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes a computer readable storage medium, such as a computer readable only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0327] The chip provided by the embodiment of the present application includes a processor and a communication interface, the communication interface is coupled with the processor, the processor is used to run programs or instructions, realizes the processes of the text correction method embodiments described above, and can achieve the same technical effects. To avoid repetition, it will not be described here.

[0328] It should be understood that the chip mentioned in the embodiment of the present application can also be referred to as a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0329] It should be noted that in this document, the term "comprise", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "comprises a" does not exclude the presence of additional identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the method and device in the embodiment of the present application is not limited to the order of performing the functions as shown or discussed, but can also include performing the functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method can be performed in an order different from the described order, and various steps can also be added, omitted or combined. In addition, the features described with reference to some examples can be combined in other examples.

[0330] From the above description of the embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment method can be realized by means of software and necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk, etc.), including a plurality of instructions for making a terminal (which can be a mobile phone, computer, server or network equipment, etc.) execute the method described in each embodiment of the present application.

[0331] The embodiments of the present application are described above with reference to the accompanying drawings, but the present application is not limited to the specific embodiments described above, and the specific embodiments described above are merely illustrative, but not restrictive, and a person of ordinary skill in the art can make many forms under the inspiration of the present application without departing from the purpose of the present application and the scope protected by the claims.

Claims

1. A method of text correction, characterized by, The method comprises the following steps: determining a target error position from a target text; processing a target character at the target error position to generate a semantic replacement character set, a homophone replacement character set and a homograph replacement character set corresponding to the target character; extracting a target semantic replacement character from the semantic replacement character set, a target homophone replacement character from the homophone replacement character set and a target homograph replacement character from the homograph replacement character set; obtaining a target semantic score of the target semantic replacement character, a target homophone score of the target homophone replacement character and a target homograph score of the target homograph replacement character; generating a target feature fusion vector based on the target semantic replacement character, the target semantic score, the target homophone replacement character, the target homophone score, the target homograph replacement character and the target homograph score; generating a target score corresponding to a target replacement character based on the target feature fusion vector; the target replacement character comprises the target semantic replacement character, the target homophone replacement character and the target homograph replacement character; sorting the target replacement character based on the target score to generate a target replacement character set corresponding to the target character; correcting the target text based on the target replacement character set; wherein the replacement characters in the semantic replacement character set are characters similar in semantics to the target character, the replacement characters in the homophone replacement character set are characters similar in pronunciation to the target character, and the replacement characters in the homograph replacement character set are characters similar in character shape to the target character.

2. The text correction method of claim 1, wherein, The semantic replacement character set comprises a first semantic replacement character set and a second semantic replacement character set, and the processing of the target character at the target error position to generate the semantic replacement character set, the homophone replacement character set and the homograph replacement character set corresponding to the target character comprises: generating a plurality of initial semantic replacement characters corresponding to the target error position and generation probabilities corresponding to the initial semantic replacement characters based on a target vocabulary; determining N initial semantic replacement characters based on the generation probabilities and sorting the N initial semantic replacement characters based on the generation probabilities to generate the first semantic replacement character set; replacing the target character corresponding to the target error position with a first semantic replacement character in the first semantic replacement character set; generating a replacement score based on the conditional probability corresponding to the first semantic replacement character; sorting the first semantic replacement characters in the first semantic replacement character set based on the replacement score to generate the second semantic replacement character set.

3. The text correction method according to claim 1 or 2, characterized in that, The method of determining a target error position from a target text comprises: segmenting the target text to generate a word vector set; calculating an error probability of each character in the word vector set; determining the position corresponding to the character as the target error position if the error probability is greater than a target threshold value; or receiving a first input of a user on the target text; determining the target error position in response to the first input.

4. A text correction apparatus characterized by comprising: The method comprises the following steps: a first determining module for determining a target error position from a target text; The first processing module is configured to process a target character at a target error position, and generate a semantic replacement character set, a homophone replacement character set, and a homograph replacement character set corresponding to the target character; The second processing module is configured to extract a target semantic replacement character from the semantic replacement character set, extract a target homophone replacement character from the homophone replacement character set, and extract a target homograph replacement character from the homograph replacement character set; obtain a target semantic score of the target semantic replacement character, a target homophone score of the target homophone replacement character, and a target homograph score of the target homograph replacement character; generate a target feature fusion vector based on the target semantic replacement character, the target semantic score, the target homophone replacement character, the target homophone score, the target homograph replacement character, and the target homograph score; and generate a target score corresponding to a target replacement character based on the target feature fusion vector; The target replacement character includes the target semantic replacement character, the target homophone replacement character, and the target homograph replacement character; and the target replacement character set corresponding to the target character is generated by sorting the target replacement character based on the target score. The third processing module is configured to correct the target text based on the target replacement character set. The replacement character in the semantic replacement character set is a character similar in semantics to the target character, the replacement character in the homophone replacement character set is a character similar in pronunciation to the target character, and the replacement character in the homograph replacement character set is a character similar in shape to the target character.

5. The text correction apparatus according to claim 4, characterized by The semantic replacement character set includes a first semantic replacement character set and a second semantic replacement character set, and the first processing module is further configured to: generate a plurality of initial semantic replacement characters corresponding to the target error position and generation probabilities corresponding to the initial semantic replacement characters based on a target vocabulary; determine N initial semantic replacement characters based on the generation probabilities, and sort the N initial semantic replacement characters based on the generation probabilities to generate the first semantic replacement character set; replace the target character corresponding to the target error position with a first semantic replacement character in the first semantic replacement character set; generate a replacement score corresponding to the first semantic replacement character based on a conditional probability corresponding to the first semantic replacement character; sort the first semantic replacement characters in the first semantic replacement character set based on the replacement score to generate the second semantic replacement character set.

6. The text correction apparatus according to claim 4 or 5, characterized by Further comprising: The fourth processing module is configured to segment the target text to generate a word vector set. The fifth processing module is configured to calculate an error probability of each character in the word vector set. The first determining module is further configured to determine the position corresponding to the character as the target error position if the error probability is greater than a target threshold. Alternatively, further comprising: The first receiving module is configured to receive a first input of a user on the target text. The first determining module is further configured to determine the target error position in response to the first input.

7. An electronic device, comprising: A computer program product comprising a computer readable storage medium having stored thereon a program or instructions which, when executed by a processor, implement the steps of the text correction method according to any one of claims 1-3.

8. A readable storage medium, characterized by, A computer program product comprising a computer readable storage medium having stored thereon a program or instructions which, when executed by a processor, implement the steps of the text correction method according to any one of claims 1-3.

Citation Information

Patent Citations

  • Text error correction method and device, equipment and medium

    CN111274785A

  • Text error correction method and device, electronic equipment and readable storage medium

    CN112001169A

  • Text error correction method, system and device and readable storage medium

    CN112016310A

  • Text error correction method and device, computer storage medium and computer program product

    CN113673228A