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

By obtaining and determining the position of the target correction statement based on the preset correspondence relationship for error correction, the problem of insufficient text error correction speed and accuracy in the prior art is solved, and the rapid and accurate error correction effect is achieved, which is suitable for diversified inputs Scene.

CN113591456BActive Publication Date: 2024-12-03BEIJING XIAOMI MOBILE SOFTWARE CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110836693.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-23
Publication Date
2024-12-03
Estimated Expiration
2041-07-23

AI Technical Summary

Technical Problem

In the prior art, it is difficult to quickly and accurately deal with text errors caused by user input and speech recognition in text error correction, especially when the model is not relied on, and the error correction effect of local error keywords is poor.

Method used

By obtaining alternative correction statements based on preset correspondence, determining the target correction statement and its position in the text to be corrected, and replacing it, thereby realizing error correction and adapting to text input and voice input scenarios.

Benefits of technology

Save computing resources, strong adaptability, and can quickly and accurately correct text errors without relying on the model, which is suitable for diverse error correction scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113591456B_ABST
    Figure CN113591456B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a text correction method and device, electronic device and storage medium. The method comprises: obtaining a text to be corrected; based on a preset correspondence relationship, obtaining alternative correction sentences corresponding to characters contained in the text to be corrected; wherein the preset correspondence relationship comprises: a mapping relationship between key characters and correction sentences; determining a target correction sentence from the alternative correction sentences; determining the starting position and the ending position of the target correction sentence in the text to be corrected; replacing the part from the starting position to the ending position in the text to be corrected with the target correction sentence, and obtaining the corrected target text. By using this method, computing resources can be saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Text error correction is a relatively basic natural language processing technology. It is widely used in scenarios that rely on text processing, such as search, human-computer voice interaction, and retrieval. Specific applications include voice assistants, such as Xiaoai, Xiaodu, Siri, car voice assistants, customer service robots, or voice translation, etc.; search engines, such as Google and Baidu, etc.; input boxes of various applications (Application, App), such as Meituan, Youdao Dictionary, etc.

[0003] Text error correction is the first step in text processing. It identifies and corrects text errors caused by user input or speech recognition (Automatic Speech Recognition, ASR) to facilitate further text processing. User input errors include "Guangzhou Huangpu (Pu)", "Hami (Mi)", "I am suspected of underground (upper) frost", etc., and recognition errors caused by speech recognition errors or user dialects include "Southern Dynasty Four Hundred and Eighty-four (Temple)", "What is fun in Lanjing City", etc.

[0004] How to accurately and quickly correct text errors has always attracted much attention. Summary of the invention

[0005] The present invention provides a text error correction method and device, an electronic device and a storage medium.

[0006] According to a first aspect of an embodiment of the present disclosure, a text error correction method is provided, comprising:

[0007] Get the text to be corrected;

[0008] Based on a preset corresponding relationship, obtaining candidate correction sentences corresponding to the characters contained in the text to be corrected; wherein the preset corresponding relationship includes: a mapping relationship between key characters and correction sentences;

[0009] Determining a target correction sentence from the candidate correction sentences;

[0010] Determine the starting position and the ending position of the target correction sentence in the text to be corrected;

[0011] The target correction sentence is used to replace the portion from the starting position to the ending position in the text to be corrected, so as to obtain the corrected target text.

[0012] In some embodiments, determining a target correction sentence from the candidate correction sentences includes:

[0013] Determine K candidate correction sentences that meet preset conditions from the M candidate correction sentences; wherein K is less than or equal to M;

[0014] From the K candidate correction sentences, a sentence with the highest similarity to the text to be corrected is selected as the target correction sentence.

[0015] In some embodiments, the method further comprises:

[0016] After obtaining candidate correction sentences corresponding to the characters contained in the text to be corrected, counting the number of times each candidate correction sentence is selected;

[0017] The step of determining K candidate correction sentences satisfying a preset condition from the M candidate correction sentences comprises:

[0018] From the M candidate correction sentences, K candidate correction sentences with the highest number of selections are determined.

[0019] In some embodiments, selecting the sentence with the highest similarity to the text to be corrected from the K candidate correction sentences as the target correction sentence includes:

[0020] The edit distance between the text to be corrected and each of the candidate correction sentences is calculated, and the candidate correction sentence with the smallest edit distance is selected as the target correction sentence.

[0021] In some embodiments, determining the starting position and the ending position of the target correction sentence in the text to be corrected includes:

[0022] Selecting a first text segment having the same length as the target correction sentence from the text to be corrected;

[0023] Calculating the edit distance between each of the first text segments and the target correction sentence, and selecting the position of the starting character of the first text segment with the smallest edit distance in the text to be corrected as the starting position of the target correction sentence in the text to be corrected;

[0024] The end position is determined according to the start position of the target correction sentence in the text to be corrected.

[0025] In some embodiments, if there is more than one first text segment with the smallest edit distance, selecting the position of the starting character of the first text segment with the smallest edit distance in the text to be corrected as the starting position of the target correction sentence in the text to be corrected includes:

[0026] Comparing the positions of the starting characters of the first text segments with the smallest edit distances in the text to be corrected;

[0027] A position closer to the starting character position is selected as the starting position of the target correction sentence in the text to be corrected.

[0028] In some embodiments, determining the end position according to the start position of the target correction sentence in the text to be corrected includes:

[0029] Selecting a second text segment with the character at the starting position as the first character from the text to be corrected;

[0030] Calculate the edit distance between each of the second text segments and the target correction sentence, and select the position of the ending character corresponding to the second text segment with the smallest edit distance and an edit distance less than a preset distance threshold in the text to be corrected as the end position of the target text in the text to be corrected.

[0031] In some embodiments, the second text segment includes:

[0032] a segment having the starting position character as the first character and the second text segment having the same length as the target correction sentence;

[0033] A segment having the starting position character as the first character and a length of the second text segment that differs from the length of the target correction sentence within a preset length difference threshold range.

[0034] In some embodiments, the step of obtaining, based on a preset correspondence, candidate correction sentences corresponding to characters contained in the text to be corrected includes:

[0035] In the text to be corrected, determining target key characters to be searched that meet a preset character length condition;

[0036] Based on the target key characters, the candidate correction sentences corresponding to the target key characters are searched in the preset corresponding relationship.

[0037] In some embodiments, the key characters in the preset corresponding relationship include at least one of the following:

[0038] Correcting at least one character in a sentence; wherein, if the number of characters is multiple, the multiple characters are consecutive;

[0039] a character associated with at least one character in the correction sentence that is different from the character representation in the correction sentence;

[0040] Correct non-consecutive characters in sentences;

[0041] Correct a character sequence consisting of at least one character in the sentence and a preset identifier.

[0042] According to a second aspect of an embodiment of the present disclosure, a text error correction device is provided, comprising:

[0043] A first acquisition module is configured to acquire the text to be corrected;

[0044] The second acquisition module is configured to acquire candidate correction sentences corresponding to the characters contained in the text to be corrected based on a preset corresponding relationship; wherein the preset corresponding relationship includes: a mapping relationship between key characters and correction sentences;

[0045] A first determination module is configured to determine a target correction sentence from the candidate correction sentences;

[0046] A second determination module is configured to determine the starting position and the ending position of the target correction sentence in the text to be corrected;

[0047] The replacement module is configured to replace the portion from the starting position to the ending position in the text to be corrected with the target correction sentence to obtain the corrected target text.

[0048] In some embodiments, the first determination module is further configured to determine K candidate correction sentences that meet preset conditions from the M candidate correction sentences; wherein K is less than or equal to M; and select from the K candidate correction sentences the sentence with the highest similarity to the text to be corrected as the target correction sentence.

[0049] In some embodiments, the apparatus further comprises:

[0050] A third acquisition module is configured to obtain candidate correction sentences corresponding to the characters contained in the text to be corrected, and then count the number of times each candidate correction sentence is selected;

[0051] The first determination module is further configured to determine K candidate correction sentences with the highest number of selections from the M candidate correction sentences.

[0052] In some embodiments, the first determination module is further configured to calculate the edit distance between the text to be corrected and each of the candidate correction sentences, and select the candidate correction sentence with the smallest edit distance as the target correction sentence.

[0053] In some embodiments, the second determination module is further configured to select a first text segment with the same length as the target correction sentence in the text to be corrected; calculate the edit distance between each of the first text segments and the target correction sentence, and select the position of the starting character of the first text segment with the smallest edit distance in the text to be corrected as the starting position of the target correction sentence in the text to be corrected; and determine the end position according to the starting position of the target correction sentence in the text to be corrected.

[0054] In some embodiments, if the first text segment with the smallest edit distance is greater than one,

[0055] The second determination module is further configured to compare the positions of the starting characters of the first text segments with the smallest editing distances in the text to be corrected; and select a position closer to the starting character position as the starting position of the target correction sentence in the text to be corrected.

[0056] In some embodiments, the second determination module is further configured to select a second text segment with the character at the starting position as the first character in the text to be corrected; calculate the edit distance between each of the second text segments and the target correction sentence, and select the position of the ending character corresponding to the second text segment with the smallest edit distance and an edit distance less than a preset distance threshold in the text to be corrected as the end position of the target text in the text to be corrected.

[0057] In some embodiments, the second text segment includes:

[0058] a segment having the starting position character as the first character and the second text segment having the same length as the target correction sentence;

[0059] A segment having the starting position character as the first character and a length of the second text segment that differs from the length of the target correction sentence within a preset length difference threshold range.

[0060] In some embodiments, the second acquisition module is further configured to determine the target key characters to be queried that meet the preset character length conditions in the text to be corrected; based on the target key characters, query the alternative correction sentences corresponding to each of the target key characters in the preset corresponding relationship.

[0061] In some embodiments, the key characters in the preset corresponding relationship include at least one of the following:

[0062] Correcting at least one character in a sentence; wherein, if the number of characters is multiple, the multiple characters are consecutive;

[0063] a character associated with at least one character in the correction sentence that is different from the character representation in the correction sentence;

[0064] Correct non-consecutive characters in sentences;

[0065] Correct a character sequence consisting of at least one character in the sentence and a preset identifier.

[0066] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0067] processor;

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

[0069] Wherein, the processor is configured to execute the text error correction method as described in the first aspect above.

[0070] According to a fourth aspect of an embodiment of the present disclosure, there is provided a storage medium, including:

[0071] When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the text error correction method as described in the first aspect above.

[0072] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0073] In an embodiment of the present disclosure, the present disclosure obtains alternative correction sentences based on a dictionary (preset corresponding relationship), and then determines a target correction sentence from the alternative correction sentences, and performs correction after determining the position of the target correction sentence in the text to be corrected. There is no need to rely on a model to locate the range of erroneous characters, or to use an end-to-end model for correction, which can save computing resources. In addition, the error correction method of the present disclosure does not focus on correcting local erroneous keywords, but determines alternative correction sentences based on characters, and then replaces the alternative correction sentences based on their positions in the text to be corrected to achieve correction, so it can adapt to the scenarios of text input and voice input, and has the characteristics of strong adaptability.

[0074] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0075] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0076] Figure 1 It is a flow chart of a text error correction method shown in an embodiment of the present disclosure.

[0077] Figure 2 This is an example diagram of a method for processing a voice interaction scenario shown in an embodiment of the present disclosure.

[0078] Figure 3 It is an example diagram of a correspondence relationship shown in an embodiment of the present disclosure.

[0079] Figure 4 This is an example diagram of an alternative correction sentence query method shown in an embodiment of the present disclosure.

[0080] Figure 5 The figure is a diagram of a text error correction device according to an exemplary embodiment.

[0081] Figure 6 It is a block diagram of an electronic device shown in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0082] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0083] The application scenarios of text error correction are quite diverse. The types of error correction in different scenarios are different, and there are different methods for different error corrections. Even in specific scenarios, there may be some relatively simple and clever methods that can quickly and efficiently perform error corrections. For example, when correcting keywords given by users, since the keywords in specific scenarios and applications can be exhaustively enumerated (such as looking up words in an English dictionary), the search for candidate keywords can be completed efficiently and quickly based on the existing word list and specific data structure (such as the Burkhard Keller tree).

[0084] However, in other scenarios, it is necessary to correct the user's voice (query) or a piece of text. These voices / texts contain incorrect characters, but the location of the incorrect characters is not known in advance. Usually, this type of text correction needs to first locate one or more incorrect characters in the voice or text, then use a certain method to obtain the possible correct candidate characters, and finally correct the errors by sorting and scoring the candidate characters. In this type of error correction, statistical methods, machine learning, and deep learning are more mainstream means. Deep learning methods were developed after statistical methods and machine learning. They may be better than statistical and machine learning methods in terms of effect, but they consume more computing resources and time than statistical and machine learning methods. In real scenarios, the requirements for the performance, time consumption, and accuracy of the error correction module are different. Statistical and machine learning methods and deep learning have been widely used.

[0085] The present invention provides a text error correction method which is different from the above-mentioned method, so as to reduce the consumption of computing resources while taking into account the error correction performance. Figure 1 is a flow chart of a text error correction method shown in an embodiment of the present disclosure, such as Figure 1 As shown, the text error correction method applied to the electronic device comprises the following steps:

[0086] S11, obtaining the text to be corrected;

[0087] S12, based on a preset corresponding relationship, obtaining candidate correction sentences corresponding to the characters contained in the text to be corrected; wherein the preset corresponding relationship includes: a mapping relationship between key characters and correction sentences;

[0088] S13, determining a target correction sentence from the candidate correction sentences;

[0089] S14, determining the starting position and the ending position of the target correction sentence in the text to be corrected;

[0090] S15, replacing the portion from the starting position to the ending position in the text to be corrected with the target correction sentence to obtain a corrected target text.

[0091] In the embodiments of the present disclosure, the electronic devices include: mobile devices and fixed devices; the mobile devices include: mobile phones, tablet computers or wearable devices, etc. The fixed devices include but are not limited to personal computers (PC).

[0092] In step S11, the electronic device obtains the text to be corrected, which may be any text input by the user, or may be text obtained by voice recognition of voice information received by the voice device, which is not limited in the embodiments of the present disclosure.

[0093] For voice interaction applications, they process and recognize user intentions based on text content rather than directly based on the user's voice. Figure 2 is an example diagram of a method for processing a voice interaction scenario shown in an embodiment of the present disclosure, such as Figure 2 As shown, the user's voice input is first recognized as text content by ASR, and then text error correction technology is used to identify and correct errors in the text, so that the downstream text processing module can further process the text to meet the application requirements.

[0094] In the voice scenario, the types of text errors can be roughly divided into four types: 1. ASR recognition errors. If the voice contains more content, ASR recognition errors are more likely to occur; 2. Voice truncation problem, which is manifested as the recognition of the user's voice has stopped before the user has finished speaking, resulting in errors in the translated text; 3. Inaccurate ASR recognition content caused by the user's dialect, such as "Nuoxia (falling clouds) and the solitary wild goose fly together, and the autumn water and the sky are the same color"; 4. The user's own memory bias leads to errors in the text after ASR recognition. For example, the user may say "The moonlight is bright in front of the bed, and it is suspected to be frost on the ground (upper)", which is more likely to occur in long entities such as celebrity quotes, lyrics and poems.

[0095] It can be seen that recognizing the user's voice and obtaining the correct text content is the basis for the subsequent processing module to correctly identify the user's intention. Similarly, for non-voice scenarios, obtaining the correct text content based on the text input by the user is also the basis for correctly identifying the user's intention for subsequent processing.

[0096] It should be noted that the entities mentioned in the present disclosure include sentences, poems, lyrics or historical texts with correct grammatical relationships.

[0097] In step S12 of the present disclosure, the electronic device obtains the candidate correction sentences corresponding to the characters contained in the text to be corrected based on the preset corresponding relationship. Since the preset corresponding relationship includes the mapping relationship between the key characters and the correction sentences, the present disclosure can query the correction sentences corresponding to the characters in the preset corresponding relationship through the characters contained in the text to be corrected, and the correction sentences include a word or a group of syntactically related words.

[0098] It should be noted that the mapping relationship established in this disclosure between the key characters and the correction statements belongs to a kind of inverted index. Taking the long entity "The setting sun and the lone wild duck fly together" as an example, after knowing this entity, it is easy for us to know which characters are included in the entity, namely "落 (luò)", "霞 (xiá)", "与 (yǔ)", "孤 (gū)", "鹜 (wù)", "齐 (qí)", "飞 (fēi)". We can consider that there is a corresponding relationship between the long entity "The setting sun and the lone wild duck fly together" and the above Chinese characters, and this corresponding relationship is relatively simple. Taking "The setting sun and the lone wild duck fly together" as the keyword (key) and the above Chinese characters as the value (value), even without an index, we can conveniently know what the value is through the key "The setting sun and the lone wild duck fly together" literally. However, the reverse is not possible. The inverted index is to exchange the above value and key, and establish a corresponding relationship with the Chinese characters such as "落 (luò)" as the key and "The setting sun and the lone wild duck fly together" as the value. Therefore, this disclosure does not find which characters are included in a long entity through a long entity, but instead finds which long entities (i.e., alternative correction statements) contain these characters through a character.

[0099] In one embodiment, the key characters in the preset corresponding relationship include at least one of the following:

[0100] At least one character in the correction statement; wherein, if there are multiple characters, the multiple characters are consecutive;

[0101] Characters different from the character expression forms in the correction statement and associated with at least one character in the correction statement;

[0102] Non-consecutive characters in the correction statement;

[0103] A character sequence composed of at least one character in the correction statement and a preset identifier.

[0104] Taking the correction statement as Chinese text as an example, at least one character in the correction statement as the key character can be at least one Chinese character, including a single Chinese character or several consecutive Chinese characters. Characters different from the character expression forms in the correction statement and associated with at least one character in the correction statement can be the pinyin corresponding to at least one Chinese character. Non-consecutive characters in the correction statement can be a character sequence formed by separating one or more characters. A character sequence composed of at least one character in the correction statement and a preset identifier, for example, can be a character sequence composed of at least one Chinese character and ".", "-", etc. The preset identifier indicates that the character can be any character or can be empty.

[0105] For example, when constructing an inverted index, mappings can be established between characters of length n (n-grams) and long entities, as well as between character sequences extended from n-grams and long entities. Here, n in n-grams represents a number, and n is a positive integer. Taking "Before my bed a pool of light" as an example, the 1-grams it contains are each character that appears in the entity, namely "床 (chuáng)", "前 (qián)", "明 (míng)", "月 (yuè)", and "光 (guāng)". The 3-grams it contains are "床前明 (chuáng qián míng)", "前明月 (qián míng yuè)", and "明月光 (míng yuè guāng)".

[0106] Taking the key character in the preset correspondence as pinyin as an example, the inverted index based on pinyin takes into account the situation of users having regional accents. Taking "春 (chūn)" -> "春雨润如酥 (chūn yǔ rù sū)" as an example, the mapping relationship of pinyin is "chun" -> "春雨润如酥 (chūn yǔ rù sū)", and at the same time, a fuzzy mapping of "cun" -> "春雨润如酥 (chūn yǔ rù sū)" can also be established. Here, "chun" as a whole is a character (1-gram), rather than being considered as 4 characters in terms of letters. Considering more situations of fuzzy pinyin, it can be considered that "zang" and "zhang", "li" and "ni", "yin" and "ying", etc. are the same key value. Compared with the n-grams of Chinese characters, the n-grams of pinyin take into account the fault tolerance of dialects and may have better effects in applications.

[0107] Figure 3 It is an example diagram of a correspondence relationship shown in an embodiment of the present disclosure. As Figure 3 shown, it shows a kind of 3-grams and the character sequences extended based on it. The established mapping relationships include "床前月 (chuáng qián yuè)" -> "床前明月光 (chuáng qián míng yuè guāng)". Among them, the key character "床前月 (chuáng qián yuè)" belongs to the discontinuous characters in the correction statement. It also includes "床前.月 (chuáng qián.yuè)" -> "床前明月光 (chuáng qián míng yuè guāng)", where "." represents any possible character. The key character "床前.月 (chuáng qián.yuè)" belongs to the character group composed of at least one character in the correction statement and a preset identifier. As Figure 3 shown, the three characters "床 (chuáng)", "前 (qián)", and "月 (yuè)" form a character sequence. Compared with the continuous character sequence of 3-grams, this is a discontinuous character sequence, and the number of characters it contains is 3, which is an extended form of 3-grams.

[0108] It should be noted that in the embodiments of the present disclosure, the inverted index establishes the mapping relationship between n-grams and entities, as well as the mapping relationship between character sequences and entities. However, there is no restriction on the n-grams used, and the appropriate value of n can be selected according to specific circumstances. Generally, the range of n selected is 1-3. Since there may be errors in long entities in the text, in order to enable n-grams or character sequences to retrieve the correct characters, the value of n will not be too large. Different values of n result in some differences in the established inverted index.

[0109] Taking "Before my bed a pool of light" as an example, assume there is an error in the entity, which can be deleting a certain character, replacing a certain character, or inserting a certain character. All possible single-error situations are shown in Table 1 below. The characters with deletion marks in the figure represent the deleted characters, italic represents the situation where a character is replaced with another character, and the underlined characters represent the newly inserted characters.

[0110] Table 1. All possible situations of a single error in "Before my bed a pool of light"

[0111]

[0112] There are a total of 16 error situations in Table 1. For any of these situations, there is at least one correct 1-gram character and 2-gram character. That is, for n = 1, 2, the correct long entity "Before my bed a pool of light" can be retrieved through n-grams. However, for 3-grams, the situation is different. "Before my bed a pool of light" and "Before my bed a pool of light" do not contain any correct 3-gram characters. For these two situations, additional character sequences need to be introduced to solve the problem. As Figure 3 shown, the characters at positions 1, 2, and 4 can be split into two matching patterns: "Before the moon" and "Beforemoon", corresponding to the situation where the character at the 3rd position is replaced or deleted. This character sequence can just be used as a supplement to 3-grams to cover the correction of a single error when the entity length is 5 characters.

[0113] Assume that it is necessary to correct the situation of a single error. The keys required to establish the inverted index under different values of n are shown in Table 2 below. In Table 2, when n = 3, "Before the bright", "a pool of light" belong to 3-gram strings, and "Before the moon" and "Beforemoon" come from character sequences.

[0114] Table 2. Key values required to establish the inverted index for a single error in "Before my bed a pool of light"

[0115] The value of n key 1 bed, front, bright, moon, light 2 bed, front light, bright moon, moonlight 3 The moon is bright in front of the bed. The moon is bright in front of the bed.

[0116] It should be noted that, in the embodiments of the present disclosure, the number of required character sequences is related not only to n, but also to the length of the entity itself and the number of incorrect characters in the entity. Taking an entity with a length of 6 characters and n = 3 as an example, assuming there is one incorrect character, no additional character sequences may be required because, regardless of the position of the error, there must be a completely correct 3-grams character in this entity containing the error. However, if the number of incorrect characters is two, there may not be a complete correct 3-grams, and thus additional character sequences are required.

[0117] In one embodiment, obtaining the alternative correction statements corresponding to the characters included in the text to be corrected based on the preset correspondence relationship includes:

[0118] Determining, in the text to be corrected, target key characters that meet the preset character length condition to be queried;

[0119] Based on the target key characters, querying, in the preset correspondence relationship, the alternative correction statements corresponding to the target key characters.

[0120] In this embodiment, different character lengths can be set to determine the target key characters, so as to query the alternative correction statements according to the target key characters. Specifically, it is a process of applying a sliding window with a preset character length of n (this n is the same as the n in n-grams) to the text to be corrected, extracting the target key characters, and retrieving possible long entities (alternative correction statements) in the inverted index.

[0121] Taking the text to be corrected "What is the famous piece containing 'Luo Xia' and 'the solitary wild duck flying together'" as an example, Figure 4 It is an example diagram showing a method for querying alternative correction statements in the embodiments of the present disclosure. As Figure 4 shown, if the preset character length is 3, its corresponding 3-grams sliding window is as Figure 4 shown in the upper part. There are a total of 14 3-grams in this text to be corrected, starting from "containing Luo", "having Luo Xia" and ending with "piece is what". Each 3-grams will be used as a target key character (key) to find the long entity containing this key in the inverted index. Figure 4 The lower part corresponds to a sliding window of a character sequence. For the character sequence, the situation is the same as that of n-grams. The difference is that the sliding window is discontinuous. Similarly, the key extracted from the sliding window can be used to find the long entity containing these character sequences.

[0122] When establishing the corresponding relationship above, indexes are constructed for different n values ​​and pinyin. When actually searching for the text to be corrected, different n values ​​can be used for searching, or the text to be corrected can be converted into pinyin before searching. The disclosed embodiment is not limited to indexing n-grams of Chinese characters or specific n values.

[0123] In steps S13-S15, after obtaining the alternative correction sentences based on the aforementioned preset correspondence, the target correction sentence can be further determined from the alternative correction sentences, and the starting position and ending position of the target correction sentence in the text to be corrected can be determined, so as to replace it according to the position and obtain the corrected target text.

[0124] It should be noted that in the embodiments of the present disclosure, the text to be corrected itself may not contain any errors. After executing the method steps of the present disclosure, the alternative correction sentences searched in the preset corresponding relationship based on the correct characters are likely to be correct, and thus the originally correct text will not be turned into an incorrect text.

[0125] Among the related solutions, there is a method based on statistics / machine learning / deep learning, which is represented by dictionaries and language models. This type of method relies on the model to locate the range of erroneous characters. The data for training the model may be different from the distribution of the application scenario, and there will be deviations, which will cause the model to have the problem of misjudgment. Once the range of erroneous characters cannot be correctly located, it will lead to the inability to correct the text in the future. In one solution, the text is corrected end-to-end based on the deep model. Specifically, the text is input into the model, and the corrected text is directly output at the output end of the model. End-to-end model training requires the collection of some erroneous texts and the corresponding correct texts as training data to train the model. The accumulation of such annotated data requires manpower. In addition, the deployment of the deep model requires a certain amount of computing resources, and when providing services online, there are certain requirements for performance and time consumption. Therefore, this solution is not suitable for some occasions where the correction itself is not particularly important. In another solution, the dictionary and the rule are integrated. This method corrects the keywords given by the user by finding similar characters in the given dictionary. If the text provided by the user is not a keyword but a piece of text or voice, it is impossible to determine the position of the keyword in the text, and therefore it is impossible to correct the text or voice. It is only suitable for keyword correction scenarios.

[0126] In contrast, the present disclosure obtains alternative correction sentences based on a dictionary (preset corresponding relationship), and then determines the target correction sentence from the alternative correction sentences, and performs correction after determining the position of the target correction sentence in the text to be corrected. There is no need to rely on a model to locate the range of erroneous characters, or to use an end-to-end model for correction, which can save computing resources. In addition, the error correction method of the present disclosure does not focus on correcting local erroneous keywords, but determines alternative correction sentences based on characters, and then replaces the alternative correction sentences based on their positions in the text to be corrected to achieve correction. Therefore, it can adapt to the scenarios of text input and voice input, and has the characteristics of strong adaptability.

[0127] In one embodiment, determining a target correction sentence from the candidate correction sentences includes:

[0128] Determine K candidate correction sentences that meet preset conditions from the M candidate correction sentences; wherein K is less than or equal to M;

[0129] From the K candidate correction sentences, a sentence with the highest similarity to the text to be corrected is selected as the target correction sentence.

[0130] In an embodiment of the present disclosure, since there are many alternative correction sentences obtained by retrieving target key characters with different preset character lengths when obtaining alternative correction texts based on step S12, the present disclosure filters the results of the initial screening and then determines the target text, which can improve the speed of determining the target text.

[0131] It should be noted that when K candidate correction sentences that meet the preset conditions are determined from M candidate correction sentences, in one embodiment, satisfying the preset conditions may be that the length of the candidate correction sentence and the length of the text to be corrected are less than a preset length threshold. Since the text to be corrected input by the user is usually a sentence or a phrase in the scenario of voice input or manual input retrieval, the length of the most likely target correction sentence should be similar to the length of the input text to be corrected. In the embodiment of the present disclosure, if the K candidate correction sentences are screened out based on the length of the text, since the text length metric is also a similarity metric, then when selecting the sentence with the highest similarity with the text to be corrected from the K candidate correction sentences, it can be determined based on the edit distance, Jaro distance, etc., and the embodiment of the present disclosure does not limit this.

[0132] When K candidate correction sentences satisfying a preset condition are determined from the M candidate correction sentences, in another embodiment, the method further includes:

[0133] After obtaining candidate correction sentences corresponding to the characters contained in the text to be corrected, counting the number of times each candidate correction sentence is selected;

[0134] Determining K alternative correction statements that meet the preset conditions from the M alternative correction statements includes:

[0135] Determining the K alternative correction statements with the top selected times from the M alternative correction statements.

[0136] In this embodiment, when determining alternative correction statements based on the preset correspondence and the characters included in the text to be corrected, due to the retrieval based on the target key characters, intuitively, the potential entities included in the text to be interleaved should be retrieved more times by n-grams and character sequences. When n = 1, the number of times an entity is retrieved is equal to the number of common characters between this long entity and the text to be corrected. Taking "What is the famous piece containing 'Luo Xia' flying with 'Gu Wu'" as an example, the number of times the entity "Luo Xia and Gu Wu flying together" is retrieved is 5.

[0137] Taking the text to be corrected "In front of the window, the bright moon shines" as an example again. When n = 1, for "front", "bright", "moon", and "shine" among them, based on the preset correspondence, both the long entities "In front of the window, the bright moon shines" and "The bright moon shines among the pine trees" can be queried. Among them, the number of times "In front of the window, the bright moon shines" is detected is 4, and the number of times "The bright moon shines among the pine trees" is detected is 2. In fact, the one with more detected times, "In front of the window, the bright moon shines", is more likely to be the actual input text. Therefore, when the present disclosure filters alternative correction statements, it is reasonable to select according to the selected times.

[0138] In the embodiment of the present disclosure, since the target key characters of different n-grams in the text to be corrected may retrieve the same entity, and the number of candidate entities is relatively large, in order to facilitate the statistics of the number of times each entity is retrieved and subsequent sorting operations, what is actually retrieved is not the entity itself, but the digital identifier (Identity Document, ID) uniquely corresponding to the entity, and this digital identifier will be represented by an integer (int) number. For the retrieved entity, there will be a mapping (map) from the ID to the number of times it is retrieved.

[0139] As mentioned above, the entity with more retrieved times is more likely to appear in the text to be corrected. When the present disclosure screens out the K entities with the most retrieved times, the method optimized by the minimum heap can be adopted. The heap is a relatively typical data structure in the computer field, and the implementation method of the minimum heap is a common method for solving the topK problem. Since the mapping map from the entity ID to the number of times the entity is retrieved has been obtained before, what this step mainly does is to traverse the map to obtain the K entities with the most retrieved times. If the number of entities obtained in the first step is M, the time complexity of this step using the minimum heap is O(MlgK).

[0140] Here is a brief description of the relevant practices. The minimum heap is equivalent to a basket of size K. In order to find the K entities with the most searches, it is necessary to traverse all candidate entities. For each candidate entity traversed, if the basket is not full, the entity will be placed directly in the basket, and the minimum number of searches for the entity in the basket will be recorded. If the basket is full, the number of searches for the current candidate entity and the minimum number of searches for the entities in the basket will be compared. If the current candidate entity has a greater number of searches, the current candidate entity will be used to replace the entity with the least number of searches in the basket. Otherwise, nothing will be done. After traversing all entities, the entities retained in the basket are the K candidate correction statements with the highest number of selections.

[0141] It should be noted that the present disclosure is not limited to the use of the minimum heap method for sorting, and bubble sort, shell sort, etc. may also be used, which will not be described in detail here.

[0142] In one embodiment, selecting a sentence having the highest similarity to the text to be corrected from the K candidate correction sentences as the target correction sentence includes:

[0143] The edit distance between the text to be corrected and each of the candidate correction sentences is calculated, and the candidate correction sentence with the smallest edit distance is selected as the target correction sentence.

[0144] In the embodiment of the present disclosure, when determining the target correction sentence, the similarity may be determined based on the edit distance, and the candidate correction sentence with the smallest edit distance is selected as the target correction sentence.

[0145] First, let's introduce the editing operation and the edit distance. For a string, deleting a character, replacing a character, or inserting a character is called an editing operation. In some methods, swapping the positions of two characters in the original string is also called an editing operation. The edit distance refers to the minimum editing operation required to transform a string into another string. For example, "the moonlight in front of the bed" and "the moonlight in front of the window", changing "window" to "bed" can complete the correction of the latter wrong entity to the correct entity, so the edit distance between the two is 1. For a text with wrong characters, the edit distance between it and the real text can be used as a quantitative indicator of its error degree. The edit distance can be quickly solved using the dynamic programming (DP) algorithm.

[0146] With the edit distance, finding and locating the long entities that may appear in the text to be corrected is actually to find the character fragment (character sequence) of the text to be corrected, and the edit distance with the correction sentence in the given preset correspondence is as small as possible. Because the scale of entities in the preset correspondence is too large, we narrowed the scope of candidate correction sentences by selecting K candidate correction sentences from M candidate correction sentences. This step only requires comparing the edit distance between the obtained K candidate correction sentences and the fragment of the text to be corrected.

[0147] A text to be corrected has L characters, which contains L fragments with 1 character, L-1 fragments with 2 characters, Lx fragments with character length x (that is, the number of x-grams), ... the total number of fragments is L+L-1+L-2+...+1=L(L+1) / 2. This number of fragments is very large. Intuitively, if the text to be corrected contains a long entity, even if the long entity is wrong, the edit distance between the text to be corrected and the correct long entity should be smaller than that of other long entities. Therefore, the way to select the optimal entity is to directly calculate the edit distance between the K candidate correction sentences and the text to be corrected, and select the one with the smallest edit distance value as the optimal target correction sentence that may have appeared. There may be multiple entities with the smallest edit distance. For example, for "What is written in the November 4th Wind and Rain Masterpiece", the corresponding entities with an edit distance of 4 are "November 4th Wind and Rain Masterpiece" and "November 4th Wind and Rain Masterpiece Part Two". Both entities will be retained, that is, the final target correction sentence includes two.

[0148] In one embodiment, determining the starting position and the ending position of the target correction sentence in the text to be corrected includes:

[0149] Selecting a first text segment having the same length as the target correction sentence from the text to be corrected;

[0150] Calculating the edit distance between each of the first text segments and the target correction sentence, and selecting the position of the starting character of the first text segment with the smallest edit distance in the text to be corrected as the starting position of the target correction sentence in the text to be corrected;

[0151] The end position is determined according to the start position of the target correction sentence in the text to be corrected.

[0152] In the embodiment of the present disclosure, when determining the position of the target correction sentence in the text to be corrected, the starting position is also determined according to the edit distance, and the ending position is determined according to the starting position.

[0153] Specifically, when determining the starting position based on the edit distance, since the number of characters in the incorrect entity and the correct entity is not necessarily the same. For example, for "The setting sun and the lone wild duck fly together", the entity that appears in the text to be corrected may be "The setting sun and the lone wild duck fly together as one", "And the lone wild duck fly together", "The setting sun falls and the lone wild duck fly together", etc. If the number of characters contained in the target correction statement E (correct entity) is L_e, first, it is necessary to traverse all segments in the text to be corrected with the number of characters L_e, and calculate the edit distance between the entity E and each segment one by one. Of course, if the number of characters in all segments of the text to be corrected is less than L_e, it can be padded with a predetermined character, such as a space character, to make the segment length L_e and then calculate the edit distance. The first text segment P with the smallest edit distance to the correct entity E is considered to be the segment related to the correct entity E.

[0154] In one embodiment, if there is more than one first text segment with the smallest edit distance, the position of the starting character of the first text segment with the smallest edit distance in the text to be corrected is used as the starting position of the target correction statement in the text to be corrected, including:

[0155] Compare the positions of the starting characters of each first text segment with the smallest edit distance in the text to be corrected;

[0156] Select the position with the earlier starting character position as the starting position of the target correction statement in the text to be corrected.

[0157] In the embodiments of the present disclosure, considering that there may be multiple first text segments with the smallest edit distance. For example, in "This poem contains the setting sun and the lone wild duck fly together as one", the segments with the smallest edit distance to "The setting sun and the lone wild duck fly together" are "The setting sun and the lone wild duck fly together as one" and "The setting sun and the lone wild duck fly together". In this case, we adopt the forward matching method and retain the result of the first match, that is, the position with the earlier starting character position (if the position where "The" is located in the first match), as the starting position of the target correction statement in the text to be corrected.

[0158] In addition, it should be noted that in the embodiments of the present disclosure, the reason for adopting the forward matching method is that the normal reading order is from left to right, and the text to be corrected may include multiple different entities that need to be corrected. Therefore, based on the word order habit, adopting the forward matching method can reduce the possibility that the error correction crosses two entities to be corrected and makes the corrected statement chaotic.

[0159] After determining the starting position, the ending position of the target correction statement in the text to be corrected can be determined according to the starting position. In one embodiment, the determining the ending position according to the starting position of the target correction statement in the text to be corrected includes:

[0160] Selecting a second text segment with the character at the starting position as the first character from the text to be corrected;

[0161] Calculate the edit distance between each of the second text segments and the target correction sentence, and select the position of the ending character corresponding to the second text segment with the smallest edit distance and an edit distance less than a preset distance threshold in the text to be corrected as the end position of the target text in the text to be corrected.

[0162] In this embodiment, when determining the end position according to the start position, the second text segment is firstly intercepted with the character at the start position as the first character, and then the length of the second text segment is determined according to the edit distance to determine the end position.

[0163] In this embodiment, the end position is determined by calculating the edit distance between the segment after the characters are extended based on the first text segment P with the smallest edit distance and the target correction sentence, and the edit distance between the segment after the characters are reduced based on the first text segment P and the target correction sentence, to find the second text segment P' with the smallest edit distance, which is the segment where the target correction sentence appears in the text to be corrected. The corresponding edit distance value is the number of operations required from the second text segment P' to the target correction sentence.

[0164] Regardless of whether there is an entity in the text to be corrected, and whether the entity is wrong, the above steps will find a target correction sentence. Because the previous logic is to find an alternative correction sentence that may appear in the text to be corrected from the preset correspondence, and then determine the target correction sentence based on the edit distance. When determining the position of the target correction sentence in the text to be corrected, the similarity between the target correction sentence and the fragment in the text to be corrected is also determined based on the edit distance. However, in extreme cases, the edit distance is still very large. For example, the target correction sentence has a total of 7 characters. The edit distance between the second text fragment with the smallest edit distance and the target correction sentence may be 6. In this case, there is only one character in common between the target correction sentence and the second text fragment. Obviously, the second text fragment cannot be the target correction sentence with an error.

[0165] Therefore, the present disclosure also constrains the minimum editing distance, and selects the position of the end character corresponding to the second text segment that is less than the preset distance threshold in the text to be corrected as the end position. In the embodiment of the present disclosure, the preset distance threshold can be 1 or 2, that is, the difference between the target correction sentence and the erroneous segment in the text to be corrected does not exceed two editing operations. It should be noted that in the embodiment of the present disclosure, the smaller the preset distance threshold, the higher the accuracy of the error correction.

[0166] In the application of ancient poetry, for poems with more than 6 characters, if the edit distance between the found segment in the text to be corrected and a certain poem entity is less than 2, we will consider the segment in the text to be corrected to be the poem and make corrections. This correction is based on the characteristics of the ancient poetry field and long entities. Of course, if there are long entities in the text to be corrected and the expression is completely correct, the edit distance between the found segment and the entity is 0, and no correction is needed.

[0167] It should be noted that in the embodiments of the present disclosure, if there are multiple erroneous entity fragments in the text to be corrected, the corresponding entity fragments can be removed from the text to be corrected after performing an entity correction operation, and the correction can be performed again from the beginning on the new text to be corrected after the fragments are removed, and this process is repeated until no correction can be made.

[0168] It is understandable that the present disclosure adopts traditional technical means, combined with common means and algorithms such as inverted index, minimum heap sort and dynamic programming to solve edit distance, which has basically no requirements for computing resources and has the advantages of simple solution and saving computing resources. This technical solution can be used for online real-time error correction in voice interaction scenarios. Practice in the field of ancient poetry shows that for a long entity of about 80,000 words, a single error correction response takes less than 10ms, which meets the time-consuming requirements in an online environment.

[0169] Figure 5 FIG. 1 is a diagram of a text error correction device according to an exemplary embodiment. Figure 5 , the device comprises:

[0170] A first acquisition module 101 is configured to acquire a text to be corrected;

[0171] The second acquisition module 102 is configured to acquire candidate correction sentences corresponding to the characters contained in the text to be corrected based on a preset corresponding relationship; wherein the preset corresponding relationship includes: a mapping relationship between key characters and correction sentences;

[0172] A first determination module 103 is configured to determine a target correction sentence from the candidate correction sentences;

[0173] A second determination module 104 is configured to determine the starting position and the ending position of the target correction sentence in the text to be corrected;

[0174] The replacement module 105 is configured to replace the portion from the starting position to the ending position in the text to be corrected with the target correction sentence to obtain a corrected target text.

[0175] In some embodiments, the first determination module 103 is further configured to determine K candidate correction sentences that meet preset conditions from the M candidate correction sentences; wherein K is less than or equal to M; and select from the K candidate correction sentences the sentence with the highest similarity to the text to be corrected as the target correction sentence.

[0176] In some embodiments, the apparatus further comprises:

[0177] The third acquisition module 106 is configured to obtain candidate correction sentences corresponding to the characters contained in the text to be corrected, and then count the number of times each candidate correction sentence is selected;

[0178] The first determining module 103 is further configured to determine K candidate correction sentences with the highest number of selections from the M candidate correction sentences.

[0179] In some embodiments, the first determination module 103 is further configured to calculate the edit distance between the text to be corrected and each of the candidate correction sentences, and select the candidate correction sentence with the smallest edit distance as the target correction sentence.

[0180] In some embodiments, the second determination module 104 is further configured to select a first text segment with the same length as the target correction sentence in the text to be corrected; calculate the edit distance between each of the first text segments and the target correction sentence, and select the position of the starting character of the first text segment with the smallest edit distance in the text to be corrected as the starting position of the target correction sentence in the text to be corrected; and determine the end position according to the starting position of the target correction sentence in the text to be corrected.

[0181] In some embodiments, if the first text segment with the smallest edit distance is greater than one,

[0182] The second determination module 104 is further configured to compare the positions of the starting characters of the first text segments with the smallest editing distances in the text to be corrected; and select a position closer to the starting character position as the starting position of the target correction sentence in the text to be corrected.

[0183] In some embodiments, the second determination module 104 is further configured to select a second text segment with the character at the starting position as the first character in the text to be corrected; calculate the edit distance between each of the second text segments and the target correction sentence, and select the position of the ending character corresponding to the second text segment with the smallest edit distance and an edit distance less than a preset distance threshold in the text to be corrected as the end position of the target text in the text to be corrected.

[0184] In some embodiments, the second text segment includes:

[0185] a segment having the starting position character as the first character and the second text segment having the same length as the target correction sentence;

[0186] A segment having the starting position character as the first character and a length of the second text segment that differs from the length of the target correction sentence within a preset length difference threshold range.

[0187] In some embodiments, the second acquisition module 102 is further configured to determine the target key characters to be queried that meet the preset character length conditions in the text to be corrected; based on the target key characters, query the alternative correction sentences corresponding to each target key character in the preset corresponding relationship.

[0188] In some embodiments, the key characters in the preset corresponding relationship include at least one of the following:

[0189] Correcting at least one character in a sentence; wherein, if the number of characters is multiple, the multiple characters are consecutive;

[0190] a character associated with at least one character in the correction sentence that is different from the character representation in the correction sentence;

[0191] Correct non-consecutive characters in sentences;

[0192] Correct a character sequence consisting of at least one character in the sentence and a preset identifier.

[0193] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0194] Figure 6 8 is a block diagram of an electronic device 800 according to an exemplary embodiment. For example, the device 800 may be a mobile phone or a tablet computer.

[0195] Reference Figure 6 , the device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .

[0196] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0197] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0198] The power component 806 provides power to the various components of the device 800. The power component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.

[0199] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0200] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.

[0201] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0202] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, and the sensor assembly 814 can also detect the position change of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0203] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as Wi-Fi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0204] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.

[0205] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0206] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform a text error correction method, the method comprising:

[0207] Get the text to be corrected;

[0208] Based on a preset corresponding relationship, obtaining candidate correction sentences corresponding to the characters contained in the text to be corrected; wherein the preset corresponding relationship includes: a mapping relationship between key characters and correction sentences;

[0209] Determining a target correction sentence from the candidate correction sentences;

[0210] Determine the starting position and the ending position of the target correction sentence in the text to be corrected;

[0211] The target correction sentence is used to replace the portion from the starting position to the ending position in the text to be corrected, so as to obtain the corrected target text.

[0212] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0213] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A text error correction method, characterized in that: The method comprises: Get the text to be corrected; Based on a preset corresponding relationship, obtaining candidate correction sentences corresponding to the characters contained in the text to be corrected; wherein the preset corresponding relationship includes: a mapping relationship between key characters and correction sentences; Determining a target correction sentence from the candidate correction sentences; Determine the starting position and the ending position of the target correction sentence in the text to be corrected; Replace the portion from the starting position to the ending position in the text to be corrected with the target correction sentence to obtain a corrected target text; Wherein, determining the starting position and the ending position of the target correction sentence in the text to be corrected includes: Selecting a first text segment having the same length as the target correction sentence from the text to be corrected; Calculating the edit distance between each of the first text segments and the target correction sentence, and selecting the position of the starting character of the first text segment with the smallest edit distance in the text to be corrected as the starting position of the target correction sentence in the text to be corrected; Selecting a second text segment with the character at the starting position as the first character from the text to be corrected; Calculate the edit distance between each of the second text segments and the target correction sentence, and select the position of the ending character corresponding to the second text segment with the smallest edit distance and an edit distance less than a preset distance threshold in the text to be corrected as the end position of the target correction sentence in the text to be corrected.

2. The method according to claim 1, characterized in that: The step of determining a target correction sentence from the candidate correction sentences includes: Determine K candidate correction sentences that meet preset conditions from the M candidate correction sentences; wherein K is less than or equal to M; From the K candidate correction sentences, a sentence with the highest similarity to the text to be corrected is selected as the target correction sentence.

3. The method according to claim 2, characterized in that The method further comprises: After obtaining candidate correction sentences corresponding to the characters contained in the text to be corrected, counting the number of times each candidate correction sentence is selected; The step of determining K candidate correction sentences satisfying a preset condition from the M candidate correction sentences comprises: From the M candidate correction sentences, K candidate correction sentences with the highest number of selections are determined.

4. The method according to claim 2, characterized in that: The step of selecting, from the K candidate correction sentences, a sentence having the highest similarity to the text to be corrected as the target correction sentence comprises: The edit distance between the text to be corrected and each of the candidate correction sentences is calculated, and the candidate correction sentence with the smallest edit distance is selected as the target correction sentence.

5. The method according to claim 1, characterized in that If there is more than one first text segment with the smallest edit distance, selecting the position of the starting character of the first text segment with the smallest edit distance in the text to be corrected as the starting position of the target correction sentence in the text to be corrected includes: Comparing the positions of the starting characters of the first text segments with the smallest edit distances in the text to be corrected; A position closer to the starting character position is selected as the starting position of the target correction sentence in the text to be corrected.

6. The method according to claim 1, characterized in that The second text segment includes: a segment having the starting position character as the first character and the second text segment having the same length as the target correction sentence; A segment having the starting position character as the first character and a length of the second text segment that differs from the length of the target correction sentence within a preset length difference threshold range.

7. The method according to claim 1, characterized in that The step of obtaining, based on a preset corresponding relationship, candidate correction sentences corresponding to characters contained in the text to be corrected includes: In the text to be corrected, determining target key characters to be searched that meet a preset character length condition; Based on the target key characters, the candidate correction sentences corresponding to the target key characters are searched in the preset corresponding relationship.

8. The method according to claim 1, characterized in that The key characters in the preset corresponding relationship include at least one of the following: Correcting at least one character in a sentence; wherein, if the number of characters is multiple, the multiple characters are consecutive; a character associated with at least one character in the correction sentence that is different from the character representation in the correction sentence; Correct non-consecutive characters in sentences; Correct a character sequence consisting of at least one character in the sentence and a preset identifier.

9. A text error correction device, characterized in that: The device comprises: A first acquisition module is configured to acquire the text to be corrected; The second acquisition module is configured to acquire candidate correction sentences corresponding to the characters contained in the text to be corrected based on a preset corresponding relationship; wherein the preset corresponding relationship includes: a mapping relationship between key characters and correction sentences; A first determination module is configured to determine a target correction sentence from the candidate correction sentences; A second determination module is configured to determine the starting position and the ending position of the target correction sentence in the text to be corrected; A replacement module, configured to replace the portion from the starting position to the ending position in the text to be corrected with the target correction sentence, to obtain a corrected target text; Among them, the second determination module is also configured to select a first text segment with the same length as the target correction sentence in the text to be corrected; calculate the edit distance between each of the first text segments and the target correction sentence, select the position of the starting character of the first text segment with the smallest edit distance in the text to be corrected as the starting position of the target correction sentence in the text to be corrected; select a second text segment with the character at the starting position as the first character in the text to be corrected; calculate the edit distance between each of the second text segments and the target correction sentence, select the position of the ending character corresponding to the second text segment with the smallest edit distance and an edit distance less than a preset distance threshold in the text to be corrected as the ending position of the target correction sentence in the text to be corrected.

10. The device according to claim 9, characterized in that The first determination module is further configured to determine K candidate correction sentences that meet preset conditions from the M candidate correction sentences; wherein K is less than or equal to M; and select from the K candidate correction sentences the sentence with the highest similarity to the text to be corrected as the target correction sentence.

11. The device according to claim 10, characterized in that The device also includes: A third acquisition module is configured to obtain candidate correction sentences corresponding to the characters contained in the text to be corrected, and then count the number of times each candidate correction sentence is selected; The first determination module is further configured to determine K candidate correction sentences with the highest number of selections from the M candidate correction sentences.

12. The device according to claim 10, characterized in that The first determination module is further configured to calculate the edit distance between the text to be corrected and each of the candidate correction sentences, and select the candidate correction sentence with the smallest edit distance as the target correction sentence.

13. The device according to claim 9, characterized in that If the first text segment with the smallest edit distance is greater than one, The second determination module is further configured to compare the positions of the starting characters of the first text segments with the smallest editing distances in the text to be corrected; and select a position closer to the starting character position as the starting position of the target correction sentence in the text to be corrected.

14. The device according to claim 9, characterized in that The second text segment includes: a segment having the starting position character as the first character and the second text segment having the same length as the target correction sentence; A segment having the starting position character as the first character and a length of the second text segment that differs from the length of the target correction sentence within a preset length difference threshold range.

15. The device according to claim 9, characterized in that The second acquisition module is further configured to determine the target key characters to be queried that meet the preset character length condition in the text to be corrected; based on the target key characters, query the alternative correction sentences corresponding to each target key character in the preset corresponding relationship.

16. The device according to claim 9, characterized in that The key characters in the preset corresponding relationship include at least one of the following: Correcting at least one character in a sentence; wherein, if the number of characters is multiple, the multiple characters are consecutive; a character associated with at least one character in the correction sentence that is different from the character representation in the correction sentence; Correct non-consecutive characters in sentences; Correct a character sequence consisting of at least one character in the sentence and a preset identifier.

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

18. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the text error correction method as described in any one of claims 1 to 8.