Text error correction method and device, electronic equipment, storage medium and program product
Through a multi-stage error correction method, combined with pre-training models and data enhancement technology, the problem of insufficient error correction applicability in the existing technology is solved, and high-accuracy correction of various text errors is achieved.
Patent Information
- Application Number
- CN202410575029.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-10
- Publication Date
- 2024-10-18
AI Technical Summary
Existing text error correction technology only targets a single type of text errors and cannot effectively handle multiple error types, resulting in low error correction accuracy and insufficient applicability.
Adopt a multi-stage error correction method to perform word-level, word and punctuation error correction processing respectively. Use pre-trained models for character prediction, word analysis and punctuation prediction, and combine data enhancement and mask processing to improve the accuracy and adaptability of error correction. .
It significantly improves the accuracy and applicability of text error correction, can effectively correct typos, over-characters, under-characters and punctuation errors, and enhances the ability to handle multiple error types of error correction.
Smart Images

Figure CN118798173A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of text error correction, and in particular to a text error correction method, device, electronic device, storage medium and program product. Background Art
[0002] Due to random user input, handwriting input methods that are prone to errors, unclear product names, etc., incorrect character strings account for as much as 10%-15% of input text, which makes Chinese text error correction a necessary choice. Once the language user does not master the language well or is careless, resulting in inappropriate wording, misattribution, etc., it is easy to cause the "butterfly effect" of "a slight error leads to a great error". Therefore, text error correction technology is crucial.
[0003] In the prior art, only a single type of text error is corrected. For example, text error correction is performed by using the minimum edit distance between character strings. This method only corrects "wrong characters" and does not take into account word errors, extra characters, missing characters, punctuation errors, etc. In short, the existing text error correction scheme only corrects a single type of error, has weak applicability in actual scenarios, and has poor error correction accuracy. Summary of the invention
[0004] The present disclosure provides a text error correction method, device, electronic device, storage medium and program product, which are used to enrich the error correction types to a certain extent and improve the error correction accuracy and scene adaptability.
[0005] In a first aspect, the present disclosure provides a text correction method, including: performing word-level correction processing on a first sentence to be processed to obtain a second sentence, performing word-level correction processing on the second sentence to obtain a third sentence, and performing punctuation correction processing on the third sentence to obtain a fourth sentence.
[0006] In one embodiment of the first aspect, a first sentence to be processed is subjected to word-level error correction processing to obtain a second sentence, including: using a pre-trained first prediction model to perform character prediction on each character position in the first sentence to obtain a set of candidate characters corresponding to each character position, performing character analysis on the set of candidate characters for each character position from a shape and / or pronunciation dimension to obtain a target character corresponding to each character position, and replacing the character at the corresponding character position in the first sentence with the target character to obtain the second sentence.
[0007] In another embodiment of the first aspect, the method also includes: obtaining a seed sentence, performing data enhancement processing on the seed sentence, and obtaining a sentence set corresponding to the seed sentence; wherein the data enhancement processing includes: forward and reverse translation processing, using the seed sentence and the sentence set as training samples, and training the first prediction model.
[0008] In another embodiment of the first aspect, the method further includes: obtaining a training sentence set; performing masking on some sentences in the training sentence set to obtain training samples; and training the first prediction model using the training samples.
[0009] In another embodiment of the first aspect, character analysis is performed on a set of candidate characters for each character position from the dimensions of character shape and / or pronunciation to obtain a target character corresponding to each character position, including: for any character position, obtaining the character shape similarity and / or pronunciation similarity of each candidate character in the candidate character set; and determining the target character corresponding to the character position based on the confidence of each candidate character output by the first prediction model, as well as the character shape similarity and / or pronunciation similarity.
[0010] In another embodiment of the first aspect, word error correction processing is performed on the second sentence to obtain a third sentence, including: performing word segmentation processing on the second sentence to obtain words to be processed; based on the second sentence, obtaining the mutual information value and / or unilateral entropy of each word to be processed; wherein the unilateral entropy includes: left entropy and / or right entropy; based on the mutual information value and / or unilateral entropy, verifying the correctness of each word to be processed; when any word to be processed fails the verification, obtaining a target word of the word to be processed, and replacing the word to be processed in the second sentence with the target word.
[0011] In another embodiment of the first aspect, based on the mutual information value and / or the one-sided entropy, the correctness of each word to be processed is verified, including: for any word to be processed, comparing the mutual information value with a preset first threshold; and / or, comparing the one-sided entropy with a preset second threshold; when the mutual information value is less than the first threshold, or the one-sided entropy is less than the second threshold, it is determined that the verification of the word to be processed fails.
[0012] In another embodiment of the first aspect, punctuation correction processing is performed on the third sentence to obtain a fourth sentence, including: using a pre-trained second prediction model to perform punctuation prediction on the third sentence to obtain a punctuation prediction result of the third sentence; the punctuation prediction result includes: punctuation position, candidate punctuation and its accuracy; based on the punctuation prediction result, punctuation correction processing is performed on the third sentence to obtain a fourth sentence.
[0013] In another embodiment of the first aspect, before using the pre-trained second prediction model to predict punctuation for the third sentence and obtaining the punctuation prediction result of the third sentence, the method also includes: detecting repeated punctuation in the third sentence and correcting the repeated punctuation.
[0014] In another embodiment of the first aspect, the method further includes: acquiring an error correction task in a task queue; and performing statement splitting on the error correction task.
[0015] In a second aspect, the present disclosure provides a text correction device, including: a word-level correction module, used to perform word-level correction processing on a first sentence to be processed to obtain a second sentence; a word correction module, used to perform word correction processing on the second sentence to obtain a third sentence; and a punctuation correction module, used to perform punctuation correction processing on the third sentence to obtain a fourth sentence.
[0016] In a third aspect, the present disclosure provides an electronic device, comprising: a memory for storing computer-readable instructions; and a processor for executing the computer-readable instructions so that the electronic device executes the method as described in any embodiment of the first aspect.
[0017] In a fourth aspect, the present disclosure provides a non-transitory computer-readable storage medium for storing computer-readable instructions, which, when executed by a processor, causes the processor to execute the method described in any embodiment of the first aspect.
[0018] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the method described in any embodiment of the first aspect.
[0019] The present disclosure provides a text error correction method, device, electronic device, storage medium and program product. In the present disclosure, the sentence (i.e., sentence) is used as the smallest unit for error correction processing, and in the specific error correction process, the word-level error, word-level error, and punctuation error in the sentence are respectively corrected in turn. In this way, firstly, the word-level error correction is performed, which can effectively reduce the error rate of word error correction and punctuation error correction; afterwards, after the word error correction is performed, the error rate of punctuation error correction can also be reduced, thereby improving the overall error correction effect. Moreover, this error correction scheme can realize accurate error correction of multiple error correction types. For example, it can realize error correction of wrong words based on word-level errors, and can accurately correct multi-word errors and few-word errors through sub-domain error correction. In addition, it also involves the correction of punctuation errors, so that accurate error correction of multiple error types can be realized. In summary, the technical solution provided by the present disclosure can enrich the error correction types to a certain extent, and improve the error correction accuracy and scene adaptability.
[0020] It is to be understood that both the foregoing general description and the following detailed description are exemplary, and are intended to provide further explanation of the technology as claimed. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The above and other purposes, features and advantages of the present disclosure will become more apparent by describing the embodiments of the present disclosure in more detail in conjunction with the accompanying drawings. The accompanying drawings are used to provide a further understanding of the embodiments of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. In the accompanying drawings, the same reference numerals generally represent the same components or steps.
[0022] Figure 1 A flowchart of a text error correction method provided by an embodiment of the present disclosure;
[0023] Figure 2 A flowchart of the BERT model provided in the embodiment of the present disclosure;
[0024] Figure 3 A schematic diagram of a data enhancement process provided by an embodiment of the present disclosure;
[0025] Figure 4 A practical application flow chart of text error correction provided by an embodiment of the present disclosure;
[0026] Figure 5 A structural block diagram of a text error correction device provided by an embodiment of the present disclosure;
[0027] Figure 6 A hardware block diagram of an electronic device provided in an embodiment of the present disclosure;
[0028] Figure 7 A schematic diagram of a computer-readable storage medium provided for an embodiment of the present disclosure. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present disclosure more obvious, the exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described here.
[0030] Currently, the methods for users to input text include but are not limited to any one of handwriting, voice input, and keyboard input. Regardless of the above input method, there may be situations where users input incorrectly, resulting in unclear information transmission and even economic losses. For example, in the field of life insurance, due to text input errors, users may purchase the wrong product, or cause staff to have a misunderstanding of the user's intention.
[0031] In order to solve the above problems, the present disclosure provides a text error correction method, and different error correction methods are set for different text error types. Figure 1A flowchart of a text error correction method provided by an embodiment of the present disclosure is shown in FIG. Figure 1 As shown, the above method may include:
[0032] S101, performing word-level error correction processing on a first sentence to be processed to obtain a second sentence.
[0033] S102, performing word error correction processing on the second sentence to obtain a third sentence.
[0034] S103, performing punctuation correction processing on the third sentence to obtain a fourth sentence.
[0035] In this embodiment, the text error type may include: at least one of a word level error, a word error, and a punctuation error. Among them, a word level error may cause a word error, thereby causing a change in the meaning conveyed by the text. Since the punctuation error problem does not only involve rule processing scenarios, but often involves the understanding of the text and the sentence as a whole, a change in the meaning of the text may cause a punctuation error. Therefore, in order to reduce text errors as much as possible, it is necessary to correct the word level errors first, then correct the word errors, avoid changes in the meaning conveyed by the text, and then correct the punctuation errors. Among them, word level errors can be classified according to different user input methods, or they can be classified according to typesetting errors. There is no specific limitation here, and it can be determined according to actual conditions. Among them, the word level errors caused by different user input methods include at least one of the following: glyph errors and pronunciation errors. For example, glyph errors are: sorghum-sorghum, and pronunciation errors are: Mi Yue Chuan-Mi Yue Chuan.
[0036] In an illustrative embodiment, after acquiring the text, the text can be segmented into multiple minimum scheduling units according to certain rules, so as to assist in understanding the structure and context of the text and improve the accuracy of error correction. The segmentation rules may include, but are not limited to: segmentation according to punctuation marks, segmentation according to words, and segmentation according to at least one of a preset number of characters. There is no specific restriction on the selection of specific segmentation rules. Different segmentation rules may correspond to different error types, and can be selected according to actual conditions. For ease of understanding, sentences (i.e., sentences) can be used as the minimum scheduling unit, which can reduce the amount of data processing while ensuring the meaning of the text. As shown in step S101, the first sentence to be processed in the text can be subjected to word-level error correction processing, and the erroneous characters can be corrected to obtain a second sentence with corrected word-level errors.
[0037] After obtaining the corrected second sentence, further word correction processing and punctuation correction processing may be performed on it.
[0038] In an illustrative embodiment, as shown in step S102, since the punctuation error problem is not only related to the rule processing scenario, it often involves the understanding of the text and the sentence as a whole. For example, the text is: "I don't know who can get through this road? But I must go on unswervingly." Among them, "Who can get through this road" has a question word, but it is an unknown object. The whole sentence is a declarative sentence with a subject-object relationship. Question marks cannot be used, and question marks should be changed to commas. The text or sentence after word-level error correction processing and word error correction processing can more accurately express the original meaning of the user, thereby improving the accuracy of subsequent punctuation error correction processing. Word error correction processing may include but is not limited to performing vocabulary matching, judging the relevance between characters in a word, and judging whether the word has a relatively fixed meaning and usage. Among them, the standard for judging the relevance between characters in a word is not limited, and confidence can be used for judgment, or entropy value can be used for judgment. The vocabulary here can be understood as a technical vocabulary or a commonly used vocabulary. When the judgment result is that the word is not considered to be applicable in practice, that is, the word is not a real word, the closest correct word can be obtained and replaced to obtain a third sentence with the word error corrected.
[0039] Finally, as shown in step S103, punctuation error correction processing can be performed on the third sentence. The punctuation error correction processing may include but is not limited to: at least one of determining whether the punctuation mark is repeated and determining whether the punctuation mark is correct. When it is determined that the punctuation mark is wrong, it can be corrected to obtain a fourth sentence with the punctuation error corrected.
[0040] The above is a text error correction method provided by the present disclosure. It should be understood that the above embodiments are only for the convenience of understanding, and the present disclosure does not limit the type and order of text error correction, which can be selected according to actual conditions.
[0041] There is no specific limitation on the specific processing method of word-level error correction as mentioned in the above step S101. For example, the first sentence can be input into the model to obtain a corrected second sentence, or a word-level correction data set containing the correspondence between errors and correct sentences can be used for comparison to obtain a second sentence after the word errors are corrected.
[0042] In an illustrative embodiment, when using the model to perform word-level error correction processing on the first sentence, specific steps may include: using a pre-trained first prediction model to perform character prediction on each character position in the first sentence to obtain a set of candidate characters corresponding to each character position.
[0043] From the dimension of character shape and / or character pronunciation, character analysis is performed on the candidate character set at each character position to obtain the target character corresponding to each character position.
[0044] The characters at corresponding character positions in the first sentence are replaced with the target characters to obtain a second sentence.
[0045] In this embodiment, the first prediction model can predict a set of candidate characters for each character position in the first sentence, analyze each candidate character in the candidate character set, obtain a target character, and replace the character at the corresponding character position in the first sentence with the target character to obtain a second sentence. The candidate character set may include at least one candidate character, and the candidate character may be understood as the character predicted by the first prediction model according to the context and scene of the first sentence, and the target character may be understood as the best candidate character predicted by the first prediction model. Among them, the first prediction model may include but is not limited to: at least one of a language understanding model (Bidirectional Encoder Representations from Transformers, BERT), a generative pre-trained model (Generative Pre-trained Transformer, GPT), a text-to-text transfer transformer model (Text-to-Text Transfer Transformer, T5), and an enhanced language model (Enhanced Representation through knowledge Integration, ERNIE). The number of elements contained in the candidate character set is not specifically limited. For example, the first prediction model may be a BERT model, Figure 2 A flowchart of the BERT model provided in the embodiment of the present disclosure is shown in FIG. Figure 2 As shown, after obtaining the first sentence, the BERT model can correct its glyph errors and pronunciation errors. For the position of any character in the first sentence, the first prediction model can list 5 candidate characters for character analysis and select the best character for replacement to obtain the second sentence, which effectively improves the prediction speed of the first prediction model. At the same time, the flexibility and versatility of the model are also guaranteed.
[0046] When character analysis is performed on candidate characters and target characters are selected, the first prediction model can be used to obtain each candidate character in the candidate character set, and the character analysis method can be used to analyze the candidate characters from the perspective of character shape and / or character pronunciation to obtain the possibility that the candidate character is the target character, and the candidate character with the highest probability is taken as the target character. The parameters used to characterize the possibility that the candidate character is the target character are not specifically limited here, and may include but are not limited to any one of confidence, model score, and edit distance.
[0047] In a schematic embodiment, the first prediction model may first obtain the glyph similarity and / or the phonetic similarity. And based on the above similarities, it can calculate the confidence of the first sentence when applying any candidate character, sort the candidate characters in the candidate character set, and take the candidate character with the highest confidence as the target character. The rule for representing the candidate character set is not specifically limited here. For example, the glyph of the candidate character can be represented using the IDS of the Unicode standard, or can be represented by dot matrix notation, vector representation method, structure discrimination method, or semantic component analysis method. The phonetic of the candidate character can be represented using the pronunciation of Chinese characters in the CJK Unified Ideographs, or can be represented by international phonetic symbols, Chinese tone symbols, etc. Further, if the first prediction model generates highly consistent predictions for candidate characters with relatively high similarities, then it can be considered that the model has relatively high confidence in the predictions of these candidate characters. At this time, a screening program (such as Filter, Lambda, Reduce, etc.) can be used to screen these candidate characters again. The finally obtained candidate character is determined as the target character corresponding to the character position, and the target character replaces the character at the corresponding character position in the first sentence, thereby obtaining the second sentence.
[0048] As above, the character-level error correction of the first sentence can be realized, and the second sentence after correcting the character-level error can be obtained.
[0049] After obtaining the second sentence, word-level error correction can be performed on the second sentence. The specific processing method for word-level error correction of the second sentence mentioned in the above step S102 is not limited. The first prediction model can directly compare the second sentence with the words in the word list and correct the second sentence according to the comparison result. It can also analyze the words in the second sentence and correct the second sentence according to the analysis result. The word list here can be understood as a technical word list or a common word list.
[0050] In a schematic embodiment, a word segmentation tool can be used to segment the second sentence. For example, Jieba can be used to segment the second sentence and count the word frequencies. After word segmentation and counting the word frequencies, some words may be found to be unhelpful for analysis, such as stop words (such as "de", "le", etc.), misspelled words, words irrelevant to the theme, etc. These words can be cleaned. And they are entered into the word segmentation word list for use as the subsequent optimized version of word segmentation iteration.
[0051] In another embodiment, when the first prediction model corrects the second sentence using the analysis result, it can specifically include: performing word segmentation processing on the second sentence to obtain the words to be processed.
[0052] Based on the second sentence, obtain the mutual information value and / or unilateral entropy of each word to be processed, where the unilateral entropy includes: left entropy and / or right entropy.
[0053] Based on the mutual information value and / or one-sided entropy, the correctness of each word to be processed is verified.
[0054] When any of the to-be-processed words fails verification, a target word of the to-be-processed word is obtained, and the to-be-processed word in the second sentence is replaced with the target word.
[0055] In this embodiment, the second sentence can be firstly segmented. The segmentation method is not specifically limited here. The first prediction model can use a pre-stored vocabulary to traverse and divide the second sentence, or the segmentation model can be used to divide the second sentence. The segmentation model can include but is not limited to at least one of the following: a hidden Markov model, a maximum entropy model, a conditional random field model, etc. After the second sentence is segmented, at least one word to be processed can be obtained. Further, it can be determined whether the word to be processed is a real word according to certain rules. For example, the unilateral entropy and / or mutual information value of the word to be processed can be calculated. Among them, the mutual information value can be understood as the strength of the correlation between the characters contained in the word to be processed, that is, the higher the mutual information value, the stronger the correlation between the characters of the word to be processed, and the more likely the word to be processed is a real word. The unilateral entropy can be understood as the size of the information content of the unilateral word. Specifically, if a word may appear in multiple situations, its entropy value may be higher. The unilateral entropy can include: left entropy and right entropy. According to the one-sided entropy and / or mutual information value, the correctness of the word to be processed can be judged, that is, whether the word to be processed is a real word. The relationship between the one-sided word information content and the one-sided entropy can be satisfied as follows:
[0056] H_left / right=-∑p(w i )*log(p(w i ));
[0057] Among them, p(w i ) can be the information content on the left or right side of the word to be processed;
[0058] H_left can be the left entropy of the word to be processed;
[0059] H_right may be the right entropy of the word to be processed.
[0060] The mutual information value is related to the frequency of occurrence of each character in the word to be processed:
[0061]
[0062] Wherein, I(X;Y) can be the mutual information value of the words to be processed;
[0063] p(x) can be the frequency of occurrence of character x when the word to be processed contains character y;
[0064] p(y) can be the frequency of occurrence of character y when the word to be processed contains character x;
[0065] p(x, y) may be the frequency of occurrence of a character combination in the word to be processed.
[0066] After obtaining the mutual information value and / or unilateral entropy of the words to be processed, the wrong words can be excluded according to the preset threshold value, and the closest words can be searched in the existing vocabulary to replace them, so as to obtain the corrected third sentence. That is, for any word to be processed, the mutual information value is compared with the preset first threshold value, and / or the unilateral entropy is compared with the preset second threshold value. When the mutual information value is less than the first threshold value, or the unilateral entropy is less than the second threshold value, it is determined that the verification of the word to be processed fails, and the word to be processed is determined to be an incorrect word. After replacing the incorrect word, a third sentence after correcting the error of the word is obtained. If it is determined that the word to be processed is a correct word, and the word does not exist in the existing vocabulary, the word can be added to the vocabulary.
[0067] After the third sentence is obtained, punctuation correction processing can be performed on it. The punctuation correction processing here can use the model to perform correction processing on it.
[0068] In an illustrative embodiment, repeated punctuations in the third sentence can be detected and corrected. The third sentence is predicted using the pre-trained second prediction model to obtain a punctuation prediction result for the third sentence. The punctuation prediction result may include at least one of the following: punctuation position, candidate punctuation and its accuracy. The third sentence is corrected based on the punctuation prediction result to obtain a fourth sentence.
[0069] It should be understood that the present disclosure does not specifically limit the type of the second prediction model, and the second prediction model may include but is not limited to at least one of the following: a masked language-model (MLM), ERNIE, and BERT.
[0070] In an illustrative embodiment, when the second prediction model is the ERNIE model, after first determining whether the punctuation mark is repeated, the repeated punctuation mark is corrected according to the determination result. Then, the ERNIE model is used to predict the position of the punctuation mark in the third sentence. If the punctuation mark exists in the punctuation mark prediction result and the accuracy of the model is greater than the prediction threshold, the punctuation mark is replaced. Otherwise, no correction is performed, thereby obtaining the fourth sentence. The present disclosure does not specifically limit the size of the prediction threshold, and it can be determined according to actual conditions.
[0071] Furthermore, in order to ensure the accuracy of the first prediction model and the second prediction model, they need to be trained continuously, and the training samples and rules can be determined according to the actual situation.
[0072] In an illustrative embodiment, the first prediction model uses the BERT model as an example. During training, a large number of sentences or texts can be used as a set of training sentences. The training sentence performs a mask operation on the characters according to a preset probability, and the mask operation may include but is not limited to: at least one of a hiding operation, a replacement operation, a deletion operation, an addition operation, and a retention operation. Among them, among the characters subjected to the mask operation, a hiding operation is performed on the character according to a first preset ratio, which is used to train the first prediction model to predict the hidden characters in the training sentence through the context. The character is replaced according to a second preset ratio, which is used to train the first prediction model for error correction. Among them, the replacement operation may be to replace the character with a sound-similar character, or to replace the character with a shape-similar character, which is not specifically limited. Further, the character may also be retained according to a third preset ratio, that is, the original character is retained to avoid overfitting of the model during the learning process. It should be noted that the first preset ratio, the second preset ratio, and the third preset ratio are only for the convenience of understanding. In practical applications, their specific sizes and arrangements are not limited, and can be determined according to actual conditions.
[0073] Furthermore, in order to make the error correction range of the first prediction model more accurate, the first prediction model can be fine-tuned, that is, the model can be more adaptive to correct texts in a certain field.
[0074] In an illustrative embodiment, still taking the BERT model as an example, when fine-tuning the model, you can first construct seed sentences in the relevant field through manual methods (such as prompt engineering). The seed sentence here can be understood as the initial text prompt, and to some extent, it can be understood as the keyword in this field. After obtaining the seed sentence, it can be subjected to data enhancement processing. Data enhancement processing includes but is not limited to at least one of the following: synonym replacement processing, expansion processing, forward and reverse translation processing, etc. Synonym replacement processing is to replace the keywords or phrases in the seed sentence with their synonyms or near synonyms, thereby generating a sentence set. Expansion processing can be understood as inputting the seed sentence into a preset template to obtain a sentence set. Forward and reverse translation processing is to translate the seed sentence into other languages, obtain multiple candidate seed sentences after multiple translations, and then screen the candidate seed sentences to obtain a sentence set. For the convenience of understanding, Figure 3 A flowchart of a data enhancement process provided by an embodiment of the present disclosure is shown in FIG. Figure 3As shown, after manually constructing the template, the seed sentence can be translated into English to obtain C (C is an integer greater than 1) candidate sets, and then these C candidates are translated back to the original language, and each candidate has C candidates. Therefore, a seed sentence can obtain C*C candidate seed sentences, sort these C*C candidate seed sentences, and screen to obtain K new seed sentences to obtain a sentence set. Among them, K is an integer greater than zero, and the specific number is not limited here.
[0075] When training the second prediction model, taking the ERNIE model as an example, in an exemplary embodiment, the training samples can be first divided into three categories: character level, phrase level and entity level. Through the above three levels, the training samples can be masked to improve the model's knowledge understanding of words and phrases, and predict punctuation marks until the accuracy of the predicted punctuation marks exceeds a preset threshold.
[0076] In summary, for the text error correction method provided by the present disclosure, the above embodiments can be freely combined according to actual conditions, and the present disclosure has no specific limitations on this.
[0077] In an exemplary embodiment, the above embodiment may be applied to a system. Figure 4 A practical application flow chart of text error correction provided by the embodiment of the present disclosure, such as Figure 4 As shown, the system may include: an interface access layer and a processing layer. Among them, the interface access layer may be responsible for interacting with an external system or user, and its functions may include model calling, parameter configuration, and adjusting API interfaces. The processing layer may correct the input text. The specific process may include: after obtaining the text input by the user or external system, a task flow may be generated, and after scheduling, the task flow enters the JOB queue, the JOB queue may divide the text, obtain at least one sentence, and send the sentence to the error correction module, and the error correction module corrects the sentence according to the order sent by the JOB queue. In the correction module, the sentence needs to be processed by character level error correction, word error correction, and punctuation error correction in sequence, and the corrected text can be obtained, and the text error correction rate and recall rate are calculated according to the corrected text. Among them, the recall rate can be understood as the ability of the error correction model to correctly predict the sample, and the sentence with a recall rate greater than 90% is selected as the seed sentence for the subsequent error correction model to be fine-tuned, and the first prediction model and the second prediction model used in the error correction module are optimized. When optimizing the first prediction model, the sentence can be masked, and the masked words in the sentence can be predicted by the context. When optimizing the second prediction model, the sentences can be classified and masked to improve the model's knowledge of words and phrases, thereby training its punctuation prediction ability.
[0078] The present disclosure also provides a text error correction device. Figure 5 A structural block diagram of a text error correction device provided by an embodiment of the present disclosure, such as Figure 5 As shown, the text error correction device 500 includes:
[0079] The word-level error correction module 501 is used to perform word-level error correction on the first sentence to be processed to obtain a second sentence; the word-level error correction module 502 is used to perform word-level error correction on the second sentence to obtain a third sentence; the punctuation error correction module 503 is used to perform punctuation error correction on the third sentence to obtain a fourth sentence.
[0080] In an exemplary embodiment, the character-level error correction module 501 is also used to use a pre-trained first prediction model to perform character prediction on each character position in the first sentence, obtain a set of candidate characters corresponding to each character position, perform character analysis on the set of candidate characters at each character position from the dimensions of character shape and / or pronunciation, obtain a target character corresponding to each character position, and replace the character at the corresponding character position in the first sentence with the target character to obtain a second sentence.
[0081] In an exemplary embodiment, the text correction device 500 is also used to obtain a seed sentence, perform data enhancement processing on the seed sentence, and obtain a sentence set corresponding to the seed sentence; wherein the data enhancement processing includes: forward and reverse translation processing, using the seed sentence and the sentence set as training samples to train the first prediction model.
[0082] In an exemplary embodiment, the text error correction device 500 is further used to obtain a training sentence set; perform masking on some sentences in the training sentence set to obtain training samples; and use the training samples to train the first prediction model.
[0083] In an exemplary embodiment, the character-level error correction module 501 is also used to obtain the glyph similarity and / or pronunciation similarity of each candidate character in the candidate character set for any character position; based on the confidence of each candidate character output by the first prediction model, as well as the glyph similarity and / or pronunciation similarity, determine the target character corresponding to the character position.
[0084] In an exemplary embodiment, the word correction module 502 is also used to perform word segmentation processing on the second sentence to obtain words to be processed; based on the second sentence, the mutual information value and / or one-sided entropy of each word to be processed is obtained; wherein the one-sided entropy includes: left entropy and / or right entropy; based on the mutual information value and / or one-sided entropy, the correctness of each word to be processed is verified; when any word to be processed fails the verification, the target word of the word to be processed is obtained, and the word to be processed in the second sentence is replaced with the target word.
[0085] In an exemplary embodiment, the word-level error correction module 501 is also used to compare the mutual information value with a preset first threshold for any word to be processed; and / or, to compare the one-sided entropy with a preset second threshold; when the mutual information value is less than the first threshold, or the one-sided entropy is less than the second threshold, it is determined that the verification of the word to be processed fails.
[0086] In an exemplary embodiment, the punctuation correction module 503 is also used to use the pre-trained second prediction model to predict punctuation for the third sentence to obtain a punctuation prediction result for the third sentence; the punctuation prediction result includes: punctuation position, candidate punctuation and its accuracy; based on the punctuation prediction result, the third sentence is corrected to obtain a fourth sentence.
[0087] In an exemplary embodiment, the punctuation correction module 503 is further configured to detect repeated punctuation in the third sentence and perform correction processing on the repeated punctuation.
[0088] In an exemplary embodiment, the text correction device 500 is further used to obtain the correction tasks in the task queue; and perform sentence splitting on the correction tasks.
[0089] Figure 6 A hardware block diagram of an electronic device provided in an embodiment of the present disclosure. The electronic device 600 according to an embodiment of the present disclosure includes at least a processor; and a memory for storing computer-readable instructions. When the computer-readable instructions are loaded and executed by the processor, the processor executes the text error correction method described in any of the above embodiments of the present disclosure.
[0090] Figure 6 The electronic device 600 shown specifically includes: a central processing unit (CPU) 601, a graphics processing unit (GPU) 602 and a memory 603. These units are interconnected via a bus 604. The central processing unit (CPU) 601 and / or the graphics processing unit (GPU) 602 can be used as the above-mentioned processor, and the memory 603 can be used as the above-mentioned memory for storing computer-readable instructions. In addition, the electronic device 600 may also include a communication unit 605, a storage unit 606, an output unit 607, an input unit 608 and an external device 609, which are also connected to the bus 604.
[0091] Figure 7 A schematic diagram of a computer-readable storage medium provided in an embodiment of the present disclosure. Figure 7As shown, a computer-readable storage medium 700 according to an embodiment of the present disclosure has computer-readable instructions 701 stored thereon. When the computer-readable instructions 701 are executed by a processor, the text correction method described with reference to the above figures according to any of the foregoing embodiments of the present disclosure is executed. The computer-readable storage medium includes, but is not limited to, for example, volatile memory and / or non-volatile memory. Volatile memory may, for example, include random access memory (RAM) and / or cache memory (cache), etc. Non-volatile memory may, for example, include read-only memory (ROM), hard disk, flash memory, optical disk, magnetic disk, etc.
[0092] The present disclosure further provides a computer program product, including a computer program, which, when executed by a processor, implements the text error correction method described in any of the foregoing embodiments of the present disclosure.
[0093] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.
[0094] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0095] The block diagrams of the devices, apparatuses, equipment, and systems involved in this disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including," "comprising," "having," and the like are open words, referring to "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or," and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.
[0096] Additionally, as used herein, "or" used in a list of items beginning with "at least one" indicates a separate list, so that, for example, a list of "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not mean that the example described is preferred or better than other examples.
[0097] It should also be noted that in the system and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0098] Various changes, substitutions, and modifications of the techniques described herein may be made without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of the present disclosure is not limited to the specific aspects of the processes, machines, manufactures, compositions of events, means, methods, and actions described above. Currently existing or later to be developed processes, machines, manufactures, compositions of events, means, methods, or actions that perform substantially the same functions or achieve substantially the same results as the corresponding aspects described herein may be utilized. Thus, the appended claims include such processes, machines, manufactures, compositions of events, means, methods, or actions within their scope.
[0099] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0100] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A text error correction method, characterized in that: The method comprises: Perform word-level error correction processing on the first sentence to be processed to obtain a second sentence; Performing word error correction processing on the second sentence to obtain a third sentence; Punctuation correction is performed on the third sentence to obtain a fourth sentence.
2. The method according to claim 1, characterized in that The performing word-level error correction processing on the first sentence to be processed to obtain a second sentence comprises: Using a pre-trained first prediction model to perform character prediction on each character position in the first sentence to obtain a set of candidate characters corresponding to each character position; Performing character analysis on the candidate character set at each character position from the dimension of character shape and / or character pronunciation to obtain a target character corresponding to each character position; The target character is used to replace the character at the corresponding character position in the first sentence to obtain the second sentence.
3. The method according to claim 2, characterized in that The method further comprises: Get the seed sentence; Performing data enhancement processing on the seed sentence to obtain a sentence set corresponding to the seed sentence; wherein the data enhancement processing includes: forward and reverse translation processing; The seed sentence and the sentence set are used as training samples to train the first prediction model.
4. The method according to claim 2, characterized in that: The method further comprises: Get the training sentence set; Masking some sentences in the training sentence set to obtain training samples; The first prediction model is trained using the training samples.
5. The method according to claim 2, characterized in that: The character analysis of the candidate character set at each character position is performed from the dimension of character shape and / or character pronunciation to obtain the target character corresponding to each character position, including: For any of the character positions, obtaining the glyph similarity and / or pronunciation similarity of each candidate character in the candidate character set; The target character corresponding to the character position is determined based on the confidence of each candidate character output by the first prediction model, as well as the character shape similarity and / or the character pronunciation similarity.
6. The method according to any one of claims 1 to 5, characterized in that: The performing word error correction processing on the second sentence to obtain a third sentence includes: Performing word segmentation processing on the second sentence to obtain words to be processed; Based on the second sentence, obtaining the mutual information value and / or one-sided entropy of each word to be processed; wherein the one-sided entropy includes: left entropy and / or right entropy; Based on the mutual information value and / or the one-sided entropy, verify the correctness of each word to be processed; When any of the to-be-processed words fails verification, a target word of the to-be-processed word is obtained, and the to-be-processed word in the second sentence is replaced with the target word.
7. The method according to claim 6, characterized in that Based on the mutual information value and / or the one-sided entropy, verifying the correctness of each word to be processed includes: For any of the words to be processed, the mutual information value is compared with a preset first threshold; and / or the one-sided entropy is compared with a preset second threshold; When the mutual information value is smaller than the first threshold, or the one-sided entropy is smaller than the second threshold, it is determined that the to-be-processed word fails verification.
8. The method according to any one of claims 1 to 7, characterized in that: The step of performing punctuation correction processing on the third sentence to obtain a fourth sentence includes: Using the pre-trained second prediction model to perform punctuation prediction on the third sentence, to obtain a punctuation prediction result of the third sentence; the punctuation prediction result includes: punctuation position, candidate punctuation and its accuracy; Punctuation correction is performed on the third sentence based on the punctuation prediction result to obtain the fourth sentence.
9. The method according to claim 8, characterized in that Before performing punctuation prediction on the third sentence using the pre-trained second prediction model to obtain the punctuation prediction result of the third sentence, the method further includes: Repeated punctuation marks in the third sentence are detected and corrected.
10. The method according to any one of claims 1 to 9, characterized in that: The method further comprises: Get the error correction task in the task queue; Sentence splitting is performed on the error correction task.
11. A text error correction device, characterized in that: The device comprises: A word-level error correction module, used for performing word-level error correction processing on the first sentence to be processed to obtain a second sentence; A word error correction module, used for performing word error correction processing on the second sentence to obtain a third sentence; The punctuation correction module is used to perform punctuation correction processing on the third sentence to obtain a fourth sentence.
12. An electronic device, characterized in that: include: a memory for storing computer readable instructions; as well as A processor is used to run the computer-readable instructions so that the electronic device executes the method according to any one of claims 1 to 10.
13. A non-transitory computer-readable storage medium for storing computer-readable instructions, characterized in that: When the computer-readable instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 10.
14. A computer program product, characterized in that The method comprises a computer program, which implements the method according to any one of claims 1 to 10 when being executed by a processor.
Citation Information
Cited By
Text error correction method and device based on post-processing discriminator, equipment and medium
CN119623459A
Chinese error correction method and device
CN121072519A
