A text correction method, system, and device

By combining coarse-grained and fine-grained sentiment classification methods, this text correction method identifies and corrects semantic errors in idioms and other phrases, solving the problem that existing technologies cannot correct inconsistencies in text sentiment and achieving a more efficient text correction effect.

CN115712714BActive Publication Date: 2026-01-23IFLYTEK CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211506783.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-28
Publication Date
2026-01-23
Estimated Expiration
2042-11-28

AI Technical Summary

Technical Problem

Existing text correction technologies cannot effectively correct inconsistencies between emotion and context caused by the improper use of idioms, colloquialisms, and other phrases, resulting in semantic errors in the text not being identified and corrected.

Method used

By combining coarse-grained and fine-grained sentiment classification, consistency detection is performed to identify and correct semantic errors in the text. The text encoding results are used to determine whether the overall sentiment and the sentiment classification of each position are consistent. The coarse-grained and fine-grained sentiment analysis models are then optimized in the consistency detection model.

Benefits of technology

It achieves deep text correction, ensuring smooth text and semantic accuracy, improving the accuracy and consistency of error correction, and filling the gap in existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115712714B_ABST
    Figure CN115712714B_ABST
Patent Text Reader

Abstract

The application discloses a text error correction method, system and device, and the text error correction method comprises the following steps: receiving a text to be corrected; performing coarse-grained sentiment analysis on the text to be corrected to obtain a first coarse-grained sentiment classification result; performing fine-grained sentiment analysis on a phrase expressing sentiment in the text to be corrected to obtain a first fine-grained sentiment classification result of the phrase, wherein the first coarse-grained sentiment classification result and the first fine-grained sentiment classification result both comprise positive sentiment and negative sentiment; judging whether the first coarse-grained sentiment classification result is consistent with the first fine-grained sentiment classification result to obtain a consistency detection result; if the consistency detection result is inconsistent, taking the phrase as a phrase to be corrected, performing error correction on the phrase to be corrected to obtain a corrected text, and outputting the consistency detection result and the corrected text. The application realizes a deep error correction mechanism for the text and fills the technical gap.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a text correction method, system, and device. Background Technology

[0002] With the development of information technology, we have entered a digital age, with more and more documents being presented in electronic form, and the number of documents is exploding. Proofreading and correcting these documents consumes a significant amount of manpower and time. On the other hand, thanks to the digitization of documents, people can utilize automatic text correction technology to speed up proofreading and correction, greatly improving work efficiency.

[0003] Text correction technology, or text correction system, works by receiving a piece of text that may contain various errors such as grammar and vocabulary, processing it, locating and correcting the possible errors, and returning the location and correction results to the user.

[0004] Currently available text correction solutions primarily focus on word-level correction (including but not limited to: typo correction, text correction after speech-to-text conversion, and text correction after OCR recognition), as well as grammatical correction (including but not limited to: missing words, redundant words, word order errors, sentence structure errors), and punctuation errors. These errors mostly result in awkward sentences and occasionally cause ambiguity. However, besides these common error types, there is another category: errors caused by the incorrect use of idioms, colloquialisms, and proverbs, leading to inconsistencies between the implied meaning and the context. These errors do not cause grammatical inconsistencies but can make it difficult for people to understand the intended meaning of the text and do not conform to common expression habits.

[0005] For example, in the sentence "Xiaoming happily moved to his new home, and he and his friends celebrated together," the idiom "celebrating together" is usually used in a negative sense, which is inconsistent with the overall positive emotion of the sentence. Therefore, it is an error of emotional consistency. This type of error is difficult to classify as a grammatical error, misspelling, or punctuation error.

[0006] Therefore, existing technical solutions for text correction only remain at a superficial level, such as word and grammar, and cannot correct inappropriate praise or criticism or inconsistent sentiment in the context of sentences at the semantic level.

[0007] In addition, existing technologies do not correct improper use of phrases such as idioms and colloquialisms, resulting in a need to improve the overall quality of text correction. Summary of the Invention

[0008] In view of the above, the present invention aims to provide a text correction method, system and device, which determines whether there are semantic errors in the text by detecting the consistency between coarse-grained sentiment classification and fine-grained sentiment classification, and performs error correction on this basis, realizing a deep text correction mechanism and filling a technological gap.

[0009] The technical solution adopted in this invention is as follows:

[0010] In a first aspect, the present invention provides a text correction method, comprising:

[0011] Receive the text to be corrected;

[0012] Coarse-grained sentiment analysis is performed on the text to be corrected to obtain the first coarse-grained sentiment classification result; fine-grained sentiment analysis is performed on the phrases in the text to be corrected to obtain the first fine-grained sentiment classification result of the phrases. Both the first coarse-grained sentiment classification result and the first fine-grained sentiment classification result include positive sentiment and negative sentiment.

[0013] Determine whether the first coarse-grained sentiment classification result is consistent with the first fine-grained sentiment classification result to obtain the consistency detection result;

[0014] If the consistency check result is inconsistent, the phrase will be treated as a phrase to be corrected.

[0015] In one possible implementation, performing coarse-grained sentiment analysis on the text to be corrected includes:

[0016] The text to be corrected is first encoded to obtain the first encoding sequence. The vector representation of the first position of the first encoding sequence represents the overall semantic information of the text to be corrected.

[0017] Sentiment classification is performed on the vector representation of the first position of the first encoded sequence to obtain the first coarse-grained sentiment classification result.

[0018] In one possible implementation, fine-grained sentiment analysis is performed on the text to be corrected, including:

[0019] The text to be corrected is encoded a second time to obtain a second encoding sequence. The phrase at each position in the text to be corrected corresponds to the vector representation of the corresponding position in the second encoding sequence.

[0020] Sentiment classification is performed on the vector representations corresponding to the phrases representing emotions to obtain the first fine-grained sentiment classification results for the phrases.

[0021] In one possible implementation, obtaining the consistency detection result specifically includes:

[0022] Calculate the first similarity between the first coarse-grained sentiment classification result and the first fine-grained sentiment classification result;

[0023] If the first similarity is greater than the first threshold, the consistency detection result is consistent; otherwise, the consistency detection result is inconsistent.

[0024] In one possible implementation, the text correction method also includes:

[0025] Correct the errors in the selected phrases, obtain the corrected text, and output the consistency check result and the corrected text.

[0026] In one possible implementation, the phrase to be corrected is corrected to obtain the corrected text, specifically including:

[0027] A third encoding is performed on the phrase to be corrected and all phrases in the knowledge base to obtain the first semantic representation of the phrase to be corrected and the second semantic representation of the phrases in the knowledge base, and the second similarity between the first semantic representation and the second semantic representation of all phrases in the knowledge base is calculated.

[0028] A fourth encoding is performed on the phrase to be corrected and all phrases in the knowledge base to obtain the first sentiment representation of the phrase to be corrected and the second sentiment representation of the phrases in the knowledge base. The third similarity between the first sentiment representation and the second sentiment representation of all phrases in the knowledge base is then calculated.

[0029] All second similarities above the second threshold are obtained as fourth similarities, and all third similarities above the third threshold are obtained as fifth similarities. The in-library phrase corresponding to the highest value in the fourth similarity and / or the highest value in the fifth similarity is taken as the corrected phrase.

[0030] The combination of the corrected phrase and the text to be corrected is used as the corrected text.

[0031] In one possible implementation, prior to coarse-grained and fine-grained sentiment analysis, the following is also included:

[0032] The text to be corrected is segmented into sentences to obtain at least one clause;

[0033] and,

[0034] For each clause, coarse-grained sentiment analysis, fine-grained sentiment analysis, consistency sentiment detection, and error correction are performed.

[0035] In one possible implementation, the text to be corrected is segmented into sentences using transition words and coordinate words as the smallest dividing units.

[0036] In one possible implementation, a consistency detection model is used to obtain the consistency detection result; training the consistency detection model includes:

[0037] Coarse-grained sentiment analysis and fine-grained sentiment analysis were performed on the training text to obtain the second coarse-grained sentiment classification result and the second fine-grained sentiment classification result of the phrases representing sentiment in the training text.

[0038] The vector representations corresponding to all second fine-grained sentiment classification results that are in the same direction as the second coarse-grained sentiment classification results are grouped into same-direction vector groups, and the vector representations corresponding to all second fine-grained sentiment classification results that are in the opposite direction to the second coarse-grained sentiment classification results are grouped into opposite-direction vector groups.

[0039] Each first vector representation in the same-direction vector group is combined with all second vector representations in the opposite-direction vector group to form a computational combination;

[0040] For each calculation combination, the similarity between the first vector representation and the third vector representation corresponding to the second coarse-grained sentiment classification result is calculated as the sixth similarity; the similarity between the second vector representation and the third vector representation is calculated as the seventh similarity; the sum of the difference between the seventh similarity and the sixth similarity and the first preset value is calculated as the first sum, and the larger of the first sum and the second preset value is used as the loss value of the calculation combination.

[0041] The sum of all calculated combined loss values ​​is used as the loss value for the training text;

[0042] The model is iteratively trained using the loss values ​​from the training text.

[0043] Secondly, the present invention provides a text error correction system, including a receiving module, a coarse-grained sentiment analysis module, a fine-grained sentiment analysis module, a consistency detection module, and an error correction module;

[0044] The receiving module is used to receive the text to be corrected;

[0045] The coarse-grained sentiment analysis module is used to perform coarse-grained sentiment analysis on the text to be corrected, and obtain the first coarse-grained sentiment classification result;

[0046] The fine-grained sentiment analysis module is used to perform fine-grained sentiment analysis on phrases at each position in the text to be corrected, and obtain the first fine-grained sentiment classification result of the phrases; both the first coarse-grained sentiment classification result and the first fine-grained sentiment classification result include positive sentiment and negative sentiment.

[0047] The consistency detection module is used to determine whether the first coarse-grained sentiment classification result is consistent with the first fine-grained sentiment classification result, and obtain the consistency detection result;

[0048] The error correction module is used to treat phrases as phrases to be corrected when the consistency detection result is inconsistent, correct the phrases to be corrected, obtain the corrected text, and output the consistency detection result and the corrected text.

[0049] In one possible implementation, the coarse-grained sentiment analysis module includes a first encoding module and a first classification module;

[0050] The first encoding module is used to perform a first encoding on the text to be corrected, and obtain a first encoding sequence. The vector representation of the first position of the first encoding sequence represents the overall semantic information of the text to be corrected.

[0051] The first classification module is used to perform sentiment classification on the vector representation of the first position of the first encoded sequence to obtain the first coarse-grained sentiment classification result.

[0052] In one possible implementation, the error correction module includes a semantic similarity calculation module, a sentiment similarity calculation module, a filtering module, and a combination module;

[0053] The semantic similarity calculation module is used to perform third encoding on the phrase to be corrected and all phrases in the knowledge base, to obtain the first semantic representation of the phrase to be corrected and the second semantic representation of the phrase, and to calculate the second similarity between the first semantic representation and the second semantic representation of all phrases;

[0054] The sentiment similarity calculation module is used to perform a fourth encoding on the phrase to be corrected and all phrases in the knowledge base, to obtain the first sentiment representation of the phrase to be corrected and the second sentiment representation of the phrase, and to calculate the third similarity between the first sentiment representation and the second sentiment representation of all phrases;

[0055] The filtering module is used to obtain all second similarities above the second threshold as fourth similarities, and all third similarities above the third threshold as fifth similarities, and to take the phrase corresponding to the highest value in the fourth similarity and / or the highest value in the fifth similarity as the corrected phrase;

[0056] The combination module is used to combine the corrected phrase and the text to be corrected into the corrected text.

[0057] In one possible implementation, the text correction system also includes a sentence segmentation module, which is used to segment the text to be corrected into sentences to obtain at least one clause.

[0058] Thirdly, the present invention provides a text correction device, comprising:

[0059] One or more processors, memory, and one or more computer programs, wherein the one or more computer programs are stored in memory, and the one or more computer programs include instructions that, when executed by a text correction device, cause the text correction device to perform the text correction method described above.

[0060] The core concept of this invention lies in determining the presence of semantic errors in text through consistency detection between coarse-grained and fine-grained sentiment classification. Based on this, error correction is performed, achieving high-level text correction at both the semantic and sentiment levels. This ensures fluent and semantically correct text with consistent semantic coherence, filling a technological gap. Secondly, this invention divides the text into multiple clauses and performs semantic error correction on each clause, providing finer-grained correction and significantly improving accuracy. Furthermore, this invention utilizes the vector representation of the first position in the text encoding result to determine the overall sentiment of the text. Based on this, it determines whether the sentiment classification of each position in the text is consistent with the entire text, fully utilizing information from different levels of text encoding for more accurate semantic correction. Further, during the error correction process, replacement words are selected from both semantic and sentiment perspectives, ensuring dual consistency of replacement words. Finally, in the consistency detection model, the training results from all positions of the training text are combined to calculate the loss value. This simultaneously trains the consistency detection model and optimizes both the coarse-grained and fine-grained sentiment analysis models. Attached Figure Description

[0061] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described below with reference to the accompanying drawings, wherein:

[0062] Figure 1 A flowchart of the text correction method provided by the present invention;

[0063] Figure 2 A flowchart for obtaining the corrected text provided by the present invention;

[0064] Figure 3 A structural diagram of the text correction system provided by this invention;

[0065] Figure 4 A schematic diagram of the structure of the text correction device provided by the present invention. Detailed Implementation

[0066] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0067] In view of the aforementioned core concept, this invention provides an embodiment of at least one text correction method, such as... Figure 1 As shown, it may include the following steps:

[0068] S110: Receive the text T to be corrected.

[0069] S120: Perform coarse-grained sentiment analysis on the text to be corrected to obtain the first coarse-grained sentiment classification result; perform fine-grained sentiment analysis on the phrases representing sentiment in the text to be corrected to obtain the first fine-grained sentiment classification result of the phrases. Both the first coarse-grained sentiment classification result and the first fine-grained sentiment classification result include positive sentiment and negative sentiment.

[0070] In one possible implementation, performing coarse-grained sentiment analysis on the text to be corrected includes:

[0071] P1: Perform the first encoding on the text to be corrected to obtain the first encoding sequence. The vector representation of the first position of the first encoding sequence represents the overall semantic information of the text to be corrected.

[0072] P2: Perform sentiment classification on the vector representation of the first position of the first encoded sequence to obtain the first coarse-grained sentiment classification result.

[0073] In one possible implementation, a classification model based on a Transformer encoder (a coarse-grained sentiment analysis model) is used to perform coarse-grained sentiment analysis on the entire sentence. In P1, a tokenizer (such as the BERT tokenizer) corresponding to the Transformer encoder is used to convert the text to be corrected into a sequence of tokens that the model can understand. Then, the Transformer encoder (such as the BERT encoder) encodes the token sequence to obtain the first encoded sequence. The vector representation Y1 at the first position of the first encoded sequence represents the overall semantic information of the text to be corrected, and the vector representations after the second position are the vector representations of the tokens at the corresponding positions. In P2, the vector representation Y1 is fed into a classifier. This classifier is a single-layer connected network used to perform binary classification on the vector representation Y1, with the classification result being either positive or negative sentiment. This classification result is used as the first coarse-grained sentiment classification result.

[0074] In one possible implementation, the vector representation Y1 is used as the overall sentiment representation of the text to be corrected.

[0075] For example, coarse-grained sentiment analysis is performed on the sentence "Xiaoming happily moved to his new home, and he and his friends celebrated together" to obtain the vector representation Y1, which represents the overall sentiment of the sentence.

[0076] It's important to note that during the training phase, labeled sentiment classification data is used to train the Transformer encoder's classification model (Transformer encoder + classifier). Each training sample is a sentence, labeled with its sentiment polarity (positive or negative). The sentence is input into the model, and the training model outputs a binary classification result, representing the sentence's sentiment polarity. After training, because the vector representation Y1 in the Transformer encoder's output sequence contains sufficient information for the classifier to determine the sentiment polarity, vector representation Y1 is used as the overall sentiment representation of the sentence.

[0077] In another possible implementation, a combination of other encoders and classifiers can be used to obtain the first coarse-grained sentiment classification result.

[0078] In one possible implementation, fine-grained sentiment analysis of the text to be corrected includes:

[0079] Q1: Perform a second encoding on the text to be corrected to obtain a second encoding sequence. The phrase at each position in the text to be corrected corresponds to the vector representation of the corresponding position in the second encoding sequence.

[0080] Q2: Perform sentiment classification on the vector representations corresponding to the phrases representing sentiment to obtain the first fine-grained sentiment classification results for the phrases.

[0081] In one possible implementation, a sequence labeling model based on a Transformer encoder (fine-grained sentiment analysis model) is used to identify the main sentiment-containing phrases in the text to be corrected and obtain their sentiment representations, thereby achieving fine-grained sentiment analysis.

[0082] Steps Q1 and P1 can be the same process, wherein the text to be corrected is segmented using the tokenizer corresponding to the Transformer encoder to obtain multiple phrases, each phrase corresponding to a token, and each token corresponding to a position in the second encoding sequence. Thus, the second encoding sequence contains the vector representation T corresponding to each phrase. i (i = 1, ..., L), where L is the sentence length. It should be noted that the phrase here can be a single character, or it can be a phrase, idiom, or proverb, etc.

[0083] In Q2, sentiment classification is performed on the vector representations of the sentiment-representing phrases after the second position in the second encoding sequence to obtain the first fine-grained sentiment classification result for each sentiment-representing phrase.

[0084] In one possible implementation, the vector representation T corresponding to the phrases representing emotions is used. i This serves as a fine-grained expression of sentiment for the phrase.

[0085] For example, in the sentence "Xiaoming happily moved to his new home, and he and his friends celebrated their success," the model simultaneously detects the sentiment words "happy" and "celebrated their success," and provides the vector representations T of the sentiment words "happy" and "celebrated their success" respectively. i and T j .

[0086] It should be noted that during the training of the sequence labeling model based on the Transformer encoder, the model is trained in the form of sequence labeling and the sentiment of sentiment-rich phrases is classified.

[0087] In another possible implementation, a combination of other encoders and classifiers can be used to obtain the first fine-grained sentiment classification result.

[0088] S130: Determine whether the first coarse-grained sentiment classification result is consistent with the first fine-grained sentiment classification result, and obtain the consistency detection result. If the consistency detection result is consistent, proceed to S150; if the consistency detection result is inconsistent, proceed to S140.

[0089] In one possible implementation, when obtaining the consistency detection result, a first similarity is first calculated between the first coarse-grained sentiment classification result and the first fine-grained sentiment classification result. If the first similarity is greater than a first threshold, the consistency detection result is consistent; otherwise, the consistency detection result is inconsistent.

[0090] In one possible implementation, the first similarity score is calculated using cosine similarity:

[0091] similarity = cosine(Y1,T) i (1)

[0092] Understandably, other methods (such as Euclidean distance) can also be used to calculate the first similarity.

[0093] In one possible implementation, a consistency detection model is used to obtain the consistency detection result. Training the consistency detection model includes:

[0094] R1: Perform coarse-grained sentiment analysis and fine-grained sentiment analysis on the training text to obtain the second coarse-grained sentiment classification result and the second fine-grained sentiment classification result of the phrases representing sentiment in the training text.

[0095] R2: Group the vector representations corresponding to all second fine-grained sentiment classification results that are in the same direction as the second coarse-grained sentiment classification results into a same-direction vector group, and group the vector representations corresponding to all second fine-grained sentiment classification results that are in the opposite direction to the second coarse-grained sentiment classification results into an opposite-direction vector group.

[0096] Here, the vector representation of the overall sentiment of the training text is denoted as the third vector representation Y2 (corresponding to the second coarse-grained sentiment classification result). The fine-grained sentiment representations in the same and opposite directions as Y2 are denoted as... and in, T + T represents a group of vectors in the same direction. - This represents the reverse vector group.

[0097] R3: Combine each first vector representation in the same-direction vector group with all second vector representations in the opposite-direction vector group to form a computational combination. For example, if the same-direction vector group includes T1 and T2, and the opposite-direction vector group includes T3 and T4, then there are four computational combinations, namely (T1, T3), (T1, T4), (T2, T3), and (T2, T4).

[0098] R4: For each computational combination, calculate the similarity between the first and third vector representations as the sixth similarity; calculate the similarity between the second and third vector representations as the seventh similarity; calculate the sum of the difference between the seventh and sixth similarities and a first preset value as the first sum, and take the larger of the first sum and the second preset value as the loss value L of the computational combination. con ,Right now

[0099]

[0100] in, This represents the seventh similarity score (using cosine similarity as an example). The sixth similarity (taking cosine similarity as an example) is represented by τ, the first preset value is represented by 0, and the second preset value is represented by 0.

[0101] If T + If it is an empty set, then let If T - If it is an empty set, then let

[0102] R5: Use the sum of all calculated combined loss values ​​as the loss value for the training text.

[0103] R6: Iteratively train the model using the loss values ​​from the training text.

[0104] Therefore, during the training of the consistency detection model, the vectors in the same direction are brought closer together. The similarity to the overall sentiment representation Y2 widens the gap between the inverse vector and the inverse vector. The similarity to the overall sentiment representation Y2. Furthermore, since the overall sentiment representation and fine-grained sentiment representation are given by the coarse-grained sentiment analysis model and the fine-grained sentiment analysis model respectively, optimizing the above loss is equivalent to further training the two models, aiming to improve the accuracy of sentiment representation in the consistency detection task.

[0105] In another possible implementation, the difference between the sum of similarities between all in-direction vectors and the overall sentiment representation and the sum of similarities between all in-direction vectors and the overall sentiment representation can be used as the loss value for the training samples to achieve iterative training.

[0106] S140: Select phrases with inconsistent consistency detection results as phrases to be corrected and complete text correction.

[0107] In a preferred implementation, in step S140, after obtaining the phrase to be corrected, the phrase to be corrected is further corrected to obtain the corrected text, and the consistency detection result and the corrected text are output.

[0108] In one possible implementation, such as Figure 2 As shown, the phrase to be corrected is corrected to obtain the corrected text, specifically including:

[0109] S1401: Perform a third encoding on the phrase to be corrected and all phrases in the knowledge base to obtain the first semantic representation of the phrase to be corrected and the second semantic representation of the phrases in the knowledge base, and calculate the second similarity between the first semantic representation and the second semantic representation of all phrases in the knowledge base.

[0110] Let p denote the phrase to be corrected, and e denote the phrase in the external knowledge base. i , (i=1,…N), where N is the number of phrases in the knowledge base.

[0111] In one possible implementation, a model such as BERT is used to encode the phrase to be corrected and the phrase in the library to obtain the corresponding semantic representation, the first semantic representation being denoted as w. p The second semantic representation is denoted as w. ei The cosine similarity between the first and second semantic representations is used as the second similarity score (simw). i :

[0112] simw i =cosine(w p ,w ei (3)

[0113] Understandably, other encoders can be used to obtain the first semantic representation and the second semantic representation, and other similarity calculation methods can also be selected to obtain the second similarity.

[0114] S1402: Perform a fourth encoding on the phrase to be corrected and all in-library phrases in the knowledge base to obtain the first sentiment representation of the phrase to be corrected and the second sentiment representation of the in-library phrases, and calculate the third similarity between the first sentiment representation and the second sentiment representations of all in-library phrases.

[0115] In a possible implementation, use the above fine-grained sentiment analysis model to encode the phrase p to be corrected and the in-library phrase e i to obtain the first sentiment representation denoted as Y3 and the second sentiment representation T ei . Use the cosine similarity between the first sentiment representation and the second sentiment representation as the third similarity simT i :

[0116] simT i = cosine(Y3, T ei ) (4)

[0117] S1403: Obtain all second similarities higher than the second threshold as the fourth similarity, and obtain all third similarities higher than the third threshold as the fifth similarity, and use the in-library phrase corresponding to the highest value in the fourth similarity and / or the highest value in the fifth similarity as the correction phrase.

[0118] S1404: Use the combination of the correction phrase and the text to be corrected as the corrected text.

[0119] Thus, when obtaining the correction phrase, it not only ensures the semantic consistency between the correction phrase and the phrase to be corrected, but also ensures the sentiment consistency between the correction phrase and the text to be corrected, thereby correcting the sentiment error.

[0120] For example, for the sentence "Xiaoming happily moved to a new home, and he and his friends celebrated", during the error correction process, it is recognized that the sentiment of the in-library phrase "overjoyed" is similar to the original sentence, and at the same time, the semantic of the non-sentiment part is similar to "celebrated", so "overjoyed" is used as the correction phrase.

[0121] In another possible implementation, the correction phrase can also be determined by querying a relational database or the like.

[0122] If the text to be corrected needs to be corrected, the consistency detection result and the corrected text need to be output, where the consistency detection result is the inconsistent detection result.

[0123] In one possible implementation, the corrected text includes the text to be corrected and the corrected phrase. When outputting the corrected text, the text to be corrected and the corrected phrase are output simultaneously. The erroneous phrase in the text to be corrected is highlighted or marked with other prompts to indicate that the phrase needs to be corrected or to remind the user to pay attention. The output corrected phrase serves as a suggested correction result.

[0124] For example, when outputting the corrected text for the sentence "Xiaoming happily moved to his new home, and he and his friends celebrated together", the phrase "celebrated together" is specially marked to indicate that it needs to be corrected or that the user should pay attention, and "excited" is returned as the suggested correction result.

[0125] Understandably, in another possible implementation, the phrase to be corrected in the text to be corrected is replaced with a corrected phrase, and then the replaced text is output as the corrected text.

[0126] S150: Outputs consistency check results that do not require error correction.

[0127] In a preferred implementation, between S110 and S120, the text T to be corrected is further segmented into clauses to obtain at least one clause {s1,s2,…,s}. n Furthermore, for each clause s i For (i = 1, 2, ..., n) coarse-grained sentiment analysis, fine-grained sentiment analysis, consistent sentiment detection, and error correction, please refer to S120-S150.

[0128] One possible implementation involves segmenting the text to be corrected into sentences according to the semantics of the punctuation marks themselves, based on existing grammatical rules. For example, the text to be corrected could be divided into at least one sentence, using punctuation marks such as periods and question marks as the smallest units.

[0129] In a preferred implementation, the text to be corrected is segmented into sentences using transition words and coordinate words as the smallest unit of division. For example, based on the above implementation, if a sentence contains a transition word or coordinate word, the part before the transition word or coordinate word and the part after the transition word or coordinate word are each treated as a clause. For example, sentences such as "although...but...", "despite...however...", and "sometimes...sometimes..." all contain transition words or coordinate words, and can be split into two clauses.

[0130] As an example, the sentence "Although I like football, I hate playing football" contains a transition word, so it is split into two clauses: "Although I like football" and "But I hate playing football". The sentence "Xiaoming happily moved to his new home, and he and his friends celebrated" does not contain a transition word, so it is not split and is treated as a single clause.

[0131] Corresponding to the above embodiments and preferred solutions, the present invention also provides an embodiment of a text correction system, such as... Figure 3 As shown, it may specifically include a receiving module 310, a coarse-grained sentiment analysis module 320, a fine-grained sentiment analysis module 330, a consistency detection module 340, and an error correction module 350.

[0132] The receiving module 310 is used to receive the text to be corrected.

[0133] The coarse-grained sentiment analysis module 320 is used to perform coarse-grained sentiment analysis on the text to be corrected, and obtain the first coarse-grained sentiment classification result.

[0134] The fine-grained sentiment analysis module 330 is used to perform fine-grained sentiment analysis on phrases at each position in the text to be corrected, and obtain the first fine-grained sentiment classification result of the phrases; both the first coarse-grained sentiment classification result and the first fine-grained sentiment classification result include positive sentiment and negative sentiment.

[0135] The consistency detection module 340 is used to determine whether the first coarse-grained sentiment classification result is consistent with the first fine-grained sentiment classification result, and obtain the consistency detection result.

[0136] The error correction module 350 is used to treat the phrase as the phrase to be corrected when the consistency detection result is inconsistent, correct the phrase to be corrected, obtain the corrected text, and output the consistency detection result and the corrected text.

[0137] In one possible implementation, the coarse-grained sentiment analysis module 320 includes a first encoding module 3201 and a first classification module 3202.

[0138] The first encoding module 3201 is used to perform a first encoding on the text to be corrected, and obtain a first encoding sequence. The vector representation of the first position of the first encoding sequence represents the overall semantic information of the text to be corrected.

[0139] The first classification module 3202 is used to perform sentiment classification on the vector representation of the first position of the first encoded sequence to obtain the first coarse-grained sentiment classification result.

[0140] In one possible implementation, the fine-grained sentiment analysis module 330 includes a second encoding module 3301 and a second classification module 3302.

[0141] The second encoding module 3301 is used to perform a second encoding on the text to be corrected, and obtain a second encoding sequence. Each phrase in the text to be corrected corresponds to the vector representation of the corresponding position in the second encoding sequence.

[0142] The second classification module 3302 is used to perform sentiment classification on the vector representations corresponding to the phrases representing emotions, and obtain the first fine-grained sentiment classification result of the phrases.

[0143] In one possible implementation, the error correction module 350 includes a semantic similarity calculation module 3501, an emotion similarity calculation module 3502, a filtering module 3503, and a combination module 3504.

[0144] The semantic similarity calculation module 3501 is used to perform third encoding on the phrase to be corrected and all phrases in the knowledge base, to obtain the first semantic representation of the phrase to be corrected and the second semantic representation of the phrase, and to calculate the second similarity between the first semantic representation and the second semantic representation of all phrases.

[0145] The sentiment similarity calculation module 3502 is used to perform a fourth encoding on the phrase to be corrected and all phrases in the knowledge base, to obtain the first sentiment representation of the phrase to be corrected and the second sentiment representation of the phrase, and to calculate the third similarity between the first sentiment representation and the second sentiment representation of all phrases.

[0146] The filtering module 3503 is used to obtain all second similarities above a second threshold as fourth similarities, and to obtain all third similarities above a third threshold as fifth similarities, and to take the phrase corresponding to the highest value in the fourth similarity and / or the highest value in the fifth similarity as the corrected phrase.

[0147] The combination module 3504 is used to combine the corrected phrase and the text to be corrected as the corrected text.

[0148] In one possible implementation, the text correction system further includes a sentence segmentation module 360, which is used to segment the text to be corrected into sentences to obtain at least one clause.

[0149] The above should be understood Figure 3 The division of components in the illustrated text correction system is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or physically separated. These components can be implemented entirely in software via processing element calls; entirely in hardware; or partially in software via processing element calls and partially in hardware. For example, a particular module can be a separate processing element or integrated into a chip in an electronic device. The implementation of other components is similar. Furthermore, these components can be fully or partially integrated together or implemented independently. During implementation, each step of the above method or each of the above components can be completed through integrated logic circuits in the hardware of the processor element or through software instructions.

[0150] For example, these components can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more Digital Signal Processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, these components can be integrated together to form a System-On-a-Chip (SOC).

[0151] Based on the above embodiments and preferred solutions, those skilled in the art will understand that, in practice, the present invention is applicable to various implementation methods. The present invention is illustrated by the following carrier:

[0152] (1) A text correction device, which may include:

[0153] One or more processors, a memory, and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions that, when executed by the device, cause the device to perform the steps / functions of the foregoing embodiments or equivalent embodiments.

[0154] Figure 4 This is a schematic diagram illustrating the structure of an embodiment of the text correction device of the present invention. The device can be an electronic device or a circuit device built into such an electronic device. The electronic device can be a PC, server, smart terminal (mobile phone, tablet, watch, glasses, etc.), smart TV, audio equipment, speaker, set-top box, remote control, smart screen, ATM, robot, drone, ICV, smart (car) and in-vehicle equipment, etc. This embodiment does not limit the specific form of the text correction device.

[0155] Specifically, such as Figure 4As shown, the text correction device 900 includes an input unit 960, a display unit 970, a processor 910, and a memory 930. The processor 910 and the memory 930 can communicate with each other via an internal connection to transmit control and / or data signals. The memory 930 stores computer programs, and the processor 910 retrieves and runs the computer programs from the memory 930. The processor 910 and the memory 930 can be combined into a single processing device, but more commonly they are independent components. The processor 910 executes the program code stored in the memory 930 to achieve the aforementioned functions. In specific implementations, the memory 930 can be integrated into the processor 910, or it can be independent of the processor 910. The display unit 970 may include a display screen.

[0156] In addition, to further enhance the functionality of the text correction device 900, the device 900 may also include one or more of an audio circuit 980, a camera 990, and a sensor 901, etc. The audio circuit may also include a speaker 982, a microphone 984, etc.

[0157] Furthermore, the text correction device 900 may also include a power supply 950 for providing power to various devices or circuits in the device 900.

[0158] It should be understood that Figure 4 The text correction device 900 shown can implement the various processes of the method provided in the foregoing embodiments. The operation and / or function of each component in the device 900 can respectively implement the corresponding processes in the above method embodiments. For details, please refer to the foregoing descriptions of the embodiments of methods, devices, etc., and detailed descriptions are appropriately omitted here to avoid repetition.

[0159] It should be understood that Figure 4 The processor 910 in the text correction device 900 shown can be a system-on-a-chip (SoC). The processor 910 may include a central processing unit (CPU) and may further include other types of processors, such as a graphics processing unit (GPU), which will be described in detail below.

[0160] In summary, the various processors or processing units inside the processor 910 can work together to implement the previous method flow, and the corresponding software programs of each processor or processing unit can be stored in the memory 930.

[0161] (2) A readable storage medium storing a computer program or the above-described device, which, when executed, causes a computer to perform the steps / functions of the foregoing embodiments or equivalent embodiments.

[0162] In several embodiments provided by this invention, any function, if implemented as a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, certain technical solutions of this invention, or the parts that contribute to the prior art, or parts of such technical solutions, can be embodied in the form of software products as described below.

[0163] (3) A computer program product (which may include the above-described apparatus) that, when run on a terminal device, causes the terminal device to execute the text correction method of the foregoing embodiments or equivalent embodiments.

[0164] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the above implementation methods can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the above-mentioned computer program products may include, but are not limited to, APP; continuing from the foregoing, the above-mentioned device / terminal may be a computer device (e.g., mobile phone, PC terminal, cloud platform, server, server cluster, or network communication device such as media gateway, etc.). Furthermore, the hardware structure of the computer device may specifically include: at least one processor, at least one communication interface, at least one memory, and at least one communication bus; the processor, communication interface, and memory can all communicate with each other through the communication bus. The processor may be a central processing unit (CPU), DSP, microcontroller, or digital signal processor, and may also include a GPU, an embedded neural network processing unit (NPU), and an image signal processor (ISP). The processor may also include a specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. Furthermore, the processor may have the function of operating one or more software programs, which may be stored in a storage medium such as a memory. The aforementioned memory / storage medium may include: non-volatile memory, such as a non-removable disk, USB flash drive, portable hard drive, optical disc, etc., as well as read-only memory (ROM), random access memory (RAM), etc.

[0165] In this embodiment of the invention, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent the existence of A alone, A and B simultaneously, or B alone. A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects have an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of singular or plural items. For example, at least one of a, b, and c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, and c can be single or multiple.

[0166] Those skilled in the art will recognize that the modules, units, and method steps described in the embodiments disclosed in this specification can be implemented using electronic hardware, computer software, and a combination of electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention.

[0167] Furthermore, the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. In particular, for embodiments such as apparatus and devices, since they are basically similar to the method embodiments, the relevant parts can be referred to the description of the method embodiments. The apparatus, devices, and other embodiments described above are merely illustrative, and the modules, units, etc., described as separate components may or may not be physically separate, that is, they may be located in one place or distributed in multiple places, such as nodes in a system network. Specifically, some or all of the modules and units can be selected according to actual needs to achieve the purpose of the above-described embodiment solutions. Those skilled in the art can understand and implement this without creative effort.

[0168] The above description of the structure, features, and effects of the present invention is based on the embodiments shown in the figures. However, the above are only preferred embodiments of the present invention. It should be noted that the technical features involved in the above embodiments and their preferred methods can be reasonably combined and matched by those skilled in the art to form a variety of equivalent solutions without departing from or changing the design concept and technical effects of the present invention. Therefore, the present invention is not limited to the scope of implementation shown in the figures. Any changes made in accordance with the concept of the present invention, or modifications to equivalent embodiments, that do not exceed the spirit covered by the specification and figures, should be within the protection scope of the present invention.

Claims

1. A text error correction method, characterized in that, include: Receive the text to be corrected; The text to be corrected is subjected to coarse-grained sentiment analysis to obtain a first coarse-grained sentiment classification result, including: performing a first encoding on the text to be corrected to obtain a first encoding sequence, wherein the vector representation of the first position of the first encoding sequence represents the overall semantic information of the text to be corrected; performing sentiment classification on the vector representation of the first position of the first encoding sequence to obtain a first coarse-grained sentiment classification result; performing fine-grained sentiment analysis on phrases representing sentiment in the text to be corrected to obtain a first fine-grained sentiment classification result for the phrases, including: performing a second encoding on the text to be corrected to obtain a second encoding sequence, wherein each position of the phrase in the text to be corrected corresponds to the vector representation of the corresponding position in the second encoding sequence; performing sentiment classification on the vector representations corresponding to the phrases representing sentiment to obtain a first fine-grained sentiment classification result; both the first coarse-grained sentiment classification result and the first fine-grained sentiment classification result include positive sentiment and negative sentiment; Determine whether the first coarse-grained sentiment classification result is consistent with the first fine-grained sentiment classification result, and obtain a consistency detection result; If the consistency detection result is inconsistent, then the phrase is regarded as a phrase to be corrected.

2. The text correction method according to claim 1, characterized in that, Obtaining the consistency detection result specifically includes: Calculate the first similarity between the first coarse-grained sentiment classification result and the first fine-grained sentiment classification result; If the first similarity is greater than the first threshold, the consistency detection result is consistent; otherwise, the consistency detection result is inconsistent.

3. The text correction method according to claim 1, characterized in that, Also includes: The phrase to be corrected is corrected to obtain the corrected text, and the consistency detection result and the corrected text are output.

4. The text correction method according to claim 3, characterized in that, The phrase to be corrected is corrected to obtain the corrected text, specifically including: A third encoding is performed on the phrase to be corrected and all phrases in the knowledge base to obtain a first semantic representation of the phrase to be corrected and a second semantic representation of the phrases in the knowledge base, and a second similarity is calculated between the first semantic representation and the second semantic representation of all phrases in the knowledge base. A fourth encoding is performed on the phrase to be corrected and all phrases in the knowledge base to obtain a first sentiment representation of the phrase to be corrected and a second sentiment representation of the phrases in the knowledge base, and a third similarity is calculated between the first sentiment representation and the second sentiment representation of all phrases in the knowledge base. All second similarities above the second threshold are obtained as fourth similarities, and all third similarities above the third threshold are obtained as fifth similarities. The highest value in the fourth similarities and / or the in-library phrase corresponding to the highest value in the fifth similarities are taken as the corrected phrase. The combination of the corrected phrase and the text to be corrected is used as the corrected text.

5. The text correction method according to any one of claims 1-4, characterized in that, Before coarse-grained and fine-grained sentiment analysis, it also includes: The text to be corrected is segmented into sentences to obtain at least one clause; and, For each clause, coarse-grained sentiment analysis, fine-grained sentiment analysis, consistency sentiment detection, and error correction are performed.

6. The text correction method according to claim 5, characterized in that, The text to be corrected is divided into sentences using transition words and parallel words as the smallest dividing units.

7. The text correction method according to claim 2, characterized in that, The consistency detection results are obtained using a consistency detection model. Training the consistency detection model includes: Coarse-grained sentiment analysis and fine-grained sentiment analysis are performed on the training text to obtain the second coarse-grained sentiment classification result and the second fine-grained sentiment classification result of the phrases representing sentiment in the training text; The vector representations corresponding to all second fine-grained sentiment classification results that are in the same direction as the second coarse-grained sentiment classification results are divided into same-direction vector groups, and the vector representations corresponding to all second fine-grained sentiment classification results that are in the opposite direction to the second coarse-grained sentiment classification results are divided into opposite-direction vector groups. Each first vector representation in the same-direction vector group is combined with all second vector representations in the opposite-direction vector group to form a computational combination; For each calculation combination, the similarity between the first vector representation and the third vector representation corresponding to the second coarse-grained sentiment classification result is calculated as the sixth similarity; and the similarity between the second vector representation and the third vector representation is calculated as the seventh similarity; the difference between the seventh similarity and the sixth similarity is calculated and the sum of the difference and a first preset value is calculated as the first sum, and the larger of the first sum and the second preset value is used as the loss value of the calculation combination. The sum of all calculated combined loss values ​​is used as the loss value of the training text; The model is iteratively trained using the loss values ​​from the training text.

8. A text correction system, characterized in that, It includes a receiving module, a coarse-grained sentiment analysis module, a fine-grained sentiment analysis module, a consistency detection module, and an error correction module; The receiving module is used to receive the text to be corrected. The coarse-grained sentiment analysis module is used to perform coarse-grained sentiment analysis on the text to be corrected and obtain a first coarse-grained sentiment classification result, including: performing a first encoding on the text to be corrected to obtain a first encoding sequence, wherein the vector representation of the first position of the first encoding sequence represents the overall semantic information of the text to be corrected; and performing sentiment classification on the vector representation of the first position of the first encoding sequence to obtain a first coarse-grained sentiment classification result. The fine-grained sentiment analysis module is used to perform fine-grained sentiment analysis on phrases at each position in the text to be corrected, and obtain a first fine-grained sentiment classification result for the phrases. This includes: performing a second encoding on the text to be corrected to obtain a second encoding sequence, where each phrase at each position in the text corresponds to a vector representation of the corresponding position in the second encoding sequence; performing sentiment classification on the vector representations corresponding to the phrases representing sentiment, and obtaining a first fine-grained sentiment classification result; both the first coarse-grained sentiment classification result and the first fine-grained sentiment classification result include positive and negative sentiment. The consistency detection module is used to determine whether the first coarse-grained sentiment classification result is consistent with the first fine-grained sentiment classification result, and to obtain the consistency detection result. The error correction module is used to treat the phrase as a phrase to be corrected when the consistency detection result is inconsistent, correct the phrase to be corrected, obtain the corrected text, and output the consistency detection result and the corrected text.

9. The text correction system according to claim 8, characterized in that, The error correction module includes a semantic similarity calculation module, a sentiment similarity calculation module, a filtering module, and a combination module; The semantic similarity calculation module is used to perform a third encoding on the phrase to be corrected and all phrases in the knowledge base to obtain a first semantic representation of the phrase to be corrected and a second semantic representation of the phrase, and to calculate a second similarity between the first semantic representation and the second semantic representation of all phrases; The sentiment similarity calculation module is used to perform a fourth encoding on the phrase to be corrected and all phrases in the knowledge base to obtain a first sentiment representation of the phrase to be corrected and a second sentiment representation of the phrase, and to calculate a third similarity between the first sentiment representation and the second sentiment representation of all phrases; The filtering module is used to obtain all second similarities above a second threshold as fourth similarities, and to obtain all third similarities above a third threshold as fifth similarities, and to take the phrase corresponding to the highest value in the fourth similarities and / or the highest value in the fifth similarities as corrected phrases. The combination module is used to combine the corrected phrase and the text to be corrected as the corrected text.

10. The text correction system according to any one of claims 8-9, characterized in that, It also includes a sentence segmentation module, which is used to segment the text to be corrected into sentences to obtain at least one clause.

11. A text correction device, characterized in that, include: One or more processors, a memory, and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions that, when executed by the text correction device, cause the text correction device to perform the text correction method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for semantic rules generation and semantic error correction based on mass data, and error correction system implementing the method

    KR1020180113849A

  • Text emotion recognition method and apparatus, electronic device, and computer non-volatile readable storage medium

    WO2020082734A1