A method, apparatus, and device for Chinese text error correction based on context fusion thinking chain.
By combining multi-granularity feature fusion and chain-like reasoning, the problems of insufficient feature fusion and unexplainable error correction process in Chinese text correction technology are solved, improving the accuracy and interpretability of Chinese text correction, especially the ability to handle complex error types, thus enhancing the practicality of the system.
Patent Information
- Application Number
- CN202510456241.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-11
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2045-04-11
AI Technical Summary
Existing Chinese text correction technologies suffer from insufficient feature fusion, unexplainable error correction processes, weak ability to handle complex errors, and inadequate utilization of Chinese language characteristics, resulting in low accuracy and limited practicality.
This paper adopts a context-based fusion thinking chain approach, which integrates character-level and word-level features through a multi-granularity feature fusion mechanism and combines chain-like thinking reasoning to generate an error correction process. By using the innovative combination of multi-granularity feature fusion and thinking chain reasoning, the accuracy and interpretability of Chinese text error correction are improved.
It significantly improves the accuracy of Chinese text error correction, especially in handling complex error types, and provides clear error correction criteria, enhancing system transparency and user experience.
Smart Images

Figure CN120449866B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a method, apparatus and device for Chinese text error correction based on context fusion thinking chain. Background Technology
[0002] Chinese text correction is a fundamental technology in the field of natural language processing. Its goal is to automatically detect and correct various error types in text, including spelling errors, similar-looking character errors, similar-sounding character errors, idiom errors, and grammatical errors. Due to the complexity of the Chinese language, such as the large number of similar-looking and homophonous characters, and the flexibility of its grammatical structure, Chinese text correction technology faces numerous challenges.
[0003] In related technologies, traditional Chinese text correction methods are mainly based on rule matching, n-gram language models, or statistical machine learning methods. These methods perform well in handling simple spelling errors or fixed-pattern errors, but have significant limitations in handling complex context-related errors. With the development of deep learning technology, neural network-based text correction methods have made significant progress. Currently, mainstream methods typically use pre-trained language models, such as BERT (Bidirectional Encoder Representations from Transformers) and RoBERTa (Robustly optimized BERT approach), as a foundation to build a detection-correction pipeline model, that is, first detecting the error location, and then predicting the correct character.
[0004] However, the following technical problems still need to be solved:
[0005] First, there is insufficient integration of character-level and word-level features. Existing methods mostly use single-granularity (usually character-level) feature representations, lacking comprehensive consideration of multi-granularity language units (characters, words, phrases), resulting in insufficient understanding of contextual semantics, especially with low accuracy when dealing with semantically related errors.
[0006] Second, there is a lack of interpretable error correction reasoning processes. Current deep learning models typically operate as "black boxes," failing to provide clear error correction criteria and reasoning processes. This makes it difficult for users to understand and verify the rationality of the error correction results, limiting their application value in professional scenarios such as education and editing.
[0007] Third, the ability to handle complex error types is limited. Existing methods perform well in handling simple spelling errors, but their accuracy in identifying and correcting complex error types such as idiom errors, grammatical errors, and semantic inconsistencies is not high, making it difficult to meet the needs of practical applications.
[0008] Fourth, there is a lack of in-depth utilization of the characteristics of the Chinese language. The unique characteristics of the Chinese language (such as the connection between form, sound, and meaning, and fixed collocations in idioms) have not been fully reflected and utilized in the model design, resulting in insufficient generalization ability and robustness of the model.
[0009] In summary, there is an urgent need for a text correction technology that can fully utilize multi-granularity feature fusion, possess interpretable reasoning capabilities, effectively handle complex error types, and deeply leverage the characteristics of the Chinese language, in order to improve the accuracy, interpretability, and practicality of Chinese text correction. Summary of the Invention
[0010] This application provides a Chinese text error correction method, apparatus, and device based on context-fusion thinking chain to solve the problems of insufficient feature fusion, unexplainable error correction process, weak ability to handle complex errors, and insufficient utilization of Chinese language characteristics in existing Chinese text error correction technologies. By enhancing text feature representation through a context-aware multi-granularity feature fusion mechanism and combining chain-like thinking reasoning to generate an error correction analysis process, the accuracy and interpretability of Chinese text error correction are effectively improved.
[0011] The first aspect of this application provides a Chinese text error correction method based on context fusion thought chain, including the following steps:
[0012] Obtain the Chinese text data to be corrected, and perform feature encoding on the Chinese text data to be corrected to obtain an initial context representation;
[0013] Based on the initial context representation, character-level features of the Chinese text data to be corrected are extracted, and word segmentation is performed on the Chinese text data to be corrected. Word-level features of the Chinese text data to be corrected are extracted, and the character-level features and word-level features are fused to generate a fused context representation. The fused context representation is then enhanced to obtain an enhanced context representation.
[0014] Based on the enhanced context representation, at least one erroneous character in the Chinese text data to be corrected is identified, and the error type corresponding to each erroneous character is determined;
[0015] Based on each error character and the error type corresponding to each error character, a chain-like reasoning process is generated;
[0016] Based on the thought chain reasoning process and the enhanced context representation, each erroneous character is corrected to obtain the corrected text and the thought chain error correction basis corresponding to the corrected text.
[0017] According to one embodiment of this application, the step of fusing the character-level features and the word-level features to generate a fused context representation includes:
[0018] The character-level features are mapped to a preset feature space, and the word-level features are also mapped to the preset feature space. Based on a preset linear interpolation strategy, the mapped word-level features and the mapped character-level features are time-aligned to obtain the aligned word-level features.
[0019] Calculate the feature fusion weights of the mapped character-level features and the aligned word-level features, and perform weighted fusion of the mapped character-level features and the aligned word-level features based on the feature fusion weights to obtain the fused context representation.
[0020] According to one embodiment of this application, the step of generating a chain-like reasoning process based on the error type corresponding to each error character includes:
[0021] Obtain the context information of each erroneous character, and infer the cause of error for each erroneous character based on the context information of each erroneous character;
[0022] Based on the error type corresponding to each error character and the context information of each error character, determine the error type complexity and context complexity corresponding to each error character;
[0023] The target thought chain template is determined based on the error type complexity corresponding to each error character and the context complexity.
[0024] Based on the context information of each erroneous character, the predicted correction candidates, and the cause of each erroneous character, the target thinking chain template is filled in to generate the chain-like thinking reasoning process.
[0025] According to one embodiment of this application, correcting each erroneous character to obtain corrected text includes:
[0026] Based on the enhanced context representation, each erroneous character is mapped to a preset vocabulary space to obtain the character prediction probability distribution of each erroneous character, and the preset number of characters with the highest probability from the character distribution probability are selected as the first candidate correction item;
[0027] A second candidate correction term is generated from the thought chain reasoning process, and a candidate correction set is obtained based on the first candidate correction term and the second candidate correction term;
[0028] Based on a pre-set language knowledge base, the rationality score of each candidate in the candidate correction set is calculated;
[0029] Based on the character prediction probability distribution of each erroneous character and the rationality score of each candidate, at least one target correction character is determined;
[0030] The corrected text is generated by replacing each erroneous character with at least one target correction character.
[0031] According to one embodiment of this application, the error type includes at least one of spelling errors, similar-looking character errors, similar-sounding character errors, idiom errors, grammatical errors, punctuation errors, and semantic inconsistencies.
[0032] According to the Chinese text correction method based on context fusion and thought chain in this application, the Chinese text data to be corrected is feature-encoded, multi-granularity feature fusion is performed, and context representation is enhanced. The location of erroneous characters is detected and the error type is determined based on the enhanced context representation. An error analysis process is dynamically generated. The error is corrected by combining the thought chain reasoning process, generating corrected text and corresponding thought chain correction basis. Thus, through the innovative combination of multi-granularity feature fusion and thought chain reasoning, not only is the accuracy of Chinese text correction improved, especially in handling complex error types, but the interpretability of the correction process is also achieved, providing users with clear and understandable correction basis, significantly improving the practicality and user experience of the correction system.
[0033] A second aspect of this application provides a Chinese text correction device based on context fusion thought chain, comprising:
[0034] The acquisition module is used to acquire the Chinese text data to be corrected and to perform feature encoding on the Chinese text data to be corrected to obtain an initial context representation;
[0035] The processing module is used to extract character-level features of the Chinese text data to be corrected based on the initial context representation, perform word segmentation on the Chinese text data to be corrected, extract word-level features of the Chinese text data to be corrected, fuse the character-level features and the word-level features to generate a fused context representation, and enhance the fused context representation to obtain an enhanced context representation.
[0036] The identification module is used to identify at least one erroneous character in the Chinese text data to be corrected based on the enhanced context representation, and to determine the error type corresponding to each erroneous character;
[0037] The generation module is used to generate a chain-like reasoning process based on each error character and the error type corresponding to each error character;
[0038] The correction module is used to correct each erroneous character based on the thought chain reasoning process and the enhanced context representation, so as to obtain the corrected text and the thought chain error correction basis corresponding to the corrected text.
[0039] According to one embodiment of this application, the processing module is configured to:
[0040] The character-level features are mapped to a preset feature space, and the word-level features are also mapped to the preset feature space. Based on a preset linear interpolation strategy, the mapped word-level features and the mapped character-level features are time-aligned to obtain the aligned word-level features.
[0041] Calculate the feature fusion weights of the mapped character-level features and the aligned word-level features, and perform weighted fusion of the mapped character-level features and the aligned word-level features based on the feature fusion weights to obtain the fused context representation.
[0042] According to one embodiment of this application, the generation module is configured to:
[0043] Obtain the context information of each erroneous character, and infer the cause of error for each erroneous character based on the context information of each erroneous character;
[0044] Based on the error type corresponding to each error character and the context information of each error character, determine the error type complexity and context complexity corresponding to each error character;
[0045] The target thought chain template is determined based on the error type complexity corresponding to each error character and the context complexity.
[0046] Based on the context information of each erroneous character, the predicted correction candidates, and the cause of each erroneous character, the target thinking chain template is filled in to generate the chain-like thinking reasoning process.
[0047] According to one embodiment of this application, the correction module is configured to:
[0048] Based on the enhanced context representation, each erroneous character is mapped to a preset vocabulary space to obtain the character prediction probability distribution of each erroneous character, and the preset number of characters with the highest probability from the character distribution probability are selected as the first candidate correction item;
[0049] A second candidate correction term is generated from the thought chain reasoning process, and a candidate correction set is obtained based on the first candidate correction term and the second candidate correction term;
[0050] Based on a pre-set language knowledge base, the rationality score of each candidate in the candidate correction set is calculated;
[0051] Based on the character prediction probability distribution of each erroneous character and the rationality score of each candidate, at least one target correction character is determined;
[0052] The corrected text is generated by replacing each erroneous character with at least one target correction character.
[0053] According to one embodiment of this application, the error type includes at least one of spelling errors, similar-looking character errors, similar-sounding character errors, idiom errors, grammatical errors, punctuation errors, and semantic inconsistencies.
[0054] According to embodiments of this application, the Chinese text correction device based on context fusion and thought chain performs feature encoding on the Chinese text data to be corrected, performs multi-granularity feature fusion, and enhances the context representation. Based on the enhanced context representation, it detects the position of erroneous characters and determines the error type; dynamically generates an error analysis process; and corrects the error by combining the thought chain reasoning process, generating corrected text and corresponding thought chain correction basis. Thus, through the innovative combination of multi-granularity feature fusion and thought chain reasoning, it not only improves the accuracy of Chinese text correction, especially in handling complex error types, but also achieves interpretability of the correction process, providing users with clear and understandable correction basis, significantly enhancing the practicality and user experience of the correction system.
[0055] A third aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the Chinese text correction method based on context fusion thought chain as described in the above embodiments.
[0056] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the Chinese text error correction method based on context fusion thought chain as described in the above embodiments.
[0057] A fifth aspect of this application provides a computer program product, including a computer program executed by a processor to implement the Chinese text error correction method based on context fusion thought chain as described in the above embodiments.
[0058] Compared with the prior art, the technical solution provided by this invention has the following beneficial effects:
[0059] (1) Through the multi-granularity feature fusion mechanism, character-level features and word-level features are effectively integrated, which enhances the model’s ability to understand text semantics, especially for context-related errors with higher recognition accuracy;
[0060] (2) A chain-like reasoning generation module is introduced to provide an interpretable reasoning process for the error correction results, which enhances the transparency and credibility of the system and makes it easier for users to understand and verify the rationality of the error correction results.
[0061] (3) Based on the multi-level thinking chain template and error complexity assessment mechanism, different analysis strategies are adopted for different types of errors, which significantly improves the system's ability to handle complex error types (such as idiom errors, grammatical errors, etc.).
[0062] (4) A rich language knowledge base was constructed, making deep use of the form, sound and meaning characteristics of the Chinese language, and combining the advantages of deep learning and symbolic knowledge to enhance the model's error correction accuracy and generalization ability.
[0063] (5) By using a multi-task joint learning framework and a contrastive learning mechanism, the training process of the model is optimized, and the model’s ability to adapt to unseen error types and contexts is improved.
[0064] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0065] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0066] Figure 1 This is a flowchart of a Chinese text error correction method based on context fusion thought chain provided according to an embodiment of this application;
[0067] Figure 2 This is a schematic diagram of the structure of a chain-like reasoning generation module according to an embodiment of this application;
[0068] Figure 3 This is a schematic diagram of a Chinese text error correction method based on context fusion thought chain according to an embodiment of this application;
[0069] Figure 4 This is a diagram illustrating the architecture of a context-fusion thought chain-based Chinese text correction system according to an embodiment of this application.
[0070] Figure 5 This is a schematic diagram of the structure of a multi-granularity feature fusion module according to an embodiment of this application;
[0071] Figure 6 This is a schematic diagram of the web interface and result display of a Chinese text correction system according to an embodiment of this application;
[0072] Figure 7 This is a block diagram of a Chinese text correction device based on a context-fusion thought chain according to an embodiment of this application;
[0073] Figure 8 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0074] The embodiments of this application are described in detail below. Examples of the 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 intended to explain this application, and should not be construed as limiting this application.
[0075] The following description, with reference to the accompanying drawings, describes a Chinese text correction method, apparatus, and device based on context fusion and thought chain, according to embodiments of this application. Addressing the problems mentioned in the background art regarding insufficient feature fusion, uninterpretable correction process, weak ability to handle complex errors, and insufficient utilization of Chinese language characteristics in Chinese text correction technologies, this application provides a Chinese text correction method based on context fusion and thought chain. In this method, the Chinese text data to be corrected is feature-encoded, multi-granularity feature fusion is performed, and context representation is enhanced. The location of erroneous characters is detected and the error type is determined based on the enhanced context representation. An error analysis process is dynamically generated. The error is corrected by combining the thought chain reasoning process, generating corrected text and corresponding thought chain correction basis. Thus, through the innovative combination of multi-granularity feature fusion and thought chain reasoning, not only is the accuracy of Chinese text correction improved, especially in handling complex error types, but the interpretability of the correction process is also achieved, providing users with clear and understandable correction basis, significantly improving the practicality and user experience of the correction system.
[0076] Specifically, Figure 1 This is a flowchart illustrating a Chinese text correction method based on context fusion thinking chain, provided for an embodiment of this application.
[0077] It should be noted that the Chinese text correction method based on context-fusion thinking chain provided in this embodiment of the invention can be applied to various text correction scenarios, including online document editing, intelligent input methods, and intelligent writing assistance systems. This method can effectively detect and correct various types of errors in Chinese text, such as spelling errors, similar-looking character errors, similar-sounding character errors, idiom errors, and grammatical errors, while providing clear and explainable correction criteria, significantly improving user experience and text quality.
[0078] Understandably, Chain-of-Thought (CoT) refers to a structured reasoning process that simulates the step-by-step analysis process humans use when thinking about problems, making the reasoning process more transparent and interpretable. Context Fusion (CF), on the other hand, refers to the organic fusion of linguistic unit features at different granularities (such as character-level and word-level) to enhance the semantic understanding of text representation. This invention combines Chain-of-Thought reasoning with Context Fusion technology to construct a highly efficient and accurate Chinese text error correction solution.
[0079] like Figure 1 As shown, this Chinese text correction method based on context fusion thinking chain includes the following steps:
[0080] In step S101, the Chinese text data to be corrected is obtained, and feature encoding is performed on the Chinese text data to be corrected to obtain an initial context representation.
[0081] Specifically, the system receives Chinese text input by the user or retrieves Chinese text data to be corrected from sources such as files and databases. The Chinese text data to be corrected can be a single sentence, paragraph, or a complete document. The system supports multiple input methods, including direct input, file upload, or API (Application Programming Interface) calls.
[0082] In some embodiments, the system receives user text input from input devices (such as keyboards, touchscreens, etc.) or reads text files specified by the user. The system can also be designed to receive text data transmitted by other applications through API interfaces, enabling system integration. For batch processing scenarios, the system can receive and process multiple text fragments at once, meeting the needs of large-scale text correction; and performs preprocessing during the input stage, removing special characters or formatting tags and extracting plain text content for subsequent processing.
[0083] Furthermore, a pre-trained Chinese language model is used to encode features of the Chinese text data to be corrected. In a preferred embodiment, MacBERT can be used as the base encoder. This model is a BERT variant specifically optimized for Chinese corpora and performs excellently on various Chinese natural language processing tasks. In practice, the system segments the Chinese text sequence to be corrected into words and inputs it into the pre-trained language model, obtaining the hidden state representation of the last layer of the model as the initial context representation.
[0084] It should be noted that the initial context representation is a high-dimensional vector, typically with dimensions of 768 or 1024, containing rich semantic, syntactic, and contextual information. These vector representations provide the basic features for subsequent error detection and correction processes.
[0085] In some embodiments, the system may select pre-trained models of different sizes, such as lightweight ALBERT-Chinese, medium-sized MacBERT-base, and large-scale RoBERTa-large, depending on actual computing resource constraints, to achieve a balance between performance and efficiency. No specific limitations are made here.
[0086] In step S102, based on the initial context representation, character-level features of the Chinese text data to be corrected are extracted, and word segmentation is performed on the Chinese text data to be corrected to extract word-level features. The character-level features and word-level features are fused to generate a fused context representation, and the fused context representation is enhanced to obtain an enhanced context representation.
[0087] Furthermore, in some embodiments, character-level features and word-level features are fused to generate a fused context representation, including: mapping character-level features to a preset feature space and mapping word-level features to a preset feature space, and aligning the mapped word-level features with the mapped character-level features in time sequence based on a preset linear interpolation strategy to obtain aligned word-level features; calculating the feature fusion weights of the mapped character-level features and the aligned word-level features, and performing weighted fusion of the mapped character-level features and the aligned word-level features based on the feature fusion weights to obtain a fused context representation.
[0088] Specifically, the system first extracts features through two processing flows: character-level and word-level. The character-level flow splits the original Chinese text to be corrected into character sequences, and then extracts character-level features using a pre-trained character encoder. Correspondingly, the word-level flow first uses a word segmentation tool (such as jieba) to segment the text into word sequences, and then extracts word-level features using a word encoder.
[0089] For example, for the input text "We need to improve work efficiency", the character flow will process it into a character sequence of ['I', 'we', 'need', 'to', 'improve', 'do', 'work', 'efficiency', 'rate'], while the word flow will obtain a word sequence of ['we', 'need', 'improve', 'work', 'efficiency'] after word segmentation.
[0090] Next, through their respective feature mapping layers, the system projects character-level features and word-level features onto a unified preset feature space to ensure that the dimensions of the two types of features are consistent, which facilitates subsequent fusion operations.
[0091] Since word-level sequences are usually shorter than character-level sequences (a word may contain multiple characters), feature alignment is required. In a preferred embodiment, the system adopts a word-to-character linear interpolation mechanism to map word-level features to the corresponding character positions. For example, for the word "工作" (work), its word-level features will be mapped to the positions of the characters "工" (work) and "作" (do) respectively.
[0092] After feature alignment, the system calculates the fusion weights through a fusion gate network. Specifically, first, the character-level features and the aligned word-level features are concatenated and input into a fully connected layer, and then the sigmoid activation function is applied to obtain the fusion weight values within the range of 0-1. This weight determines the relative importance of the character-level features and the word-level features in the final representation, assigns different importance to the character-level and word-level features for different text positions, thereby generating a richer fusion-type context representation, which can capture both character-level details and word-level semantic information.
[0093] It can be understood that the fusion weights are calculated dynamically and there will be different weight values for characters at different positions. For example, for positions where character-similar error is likely to occur, the system may assign higher weights to the character-level features; while for positions where idiom errors may exist, the system may be more inclined to the word-level features.
[0094] Finally, the system performs a weighted combination of the character-level features and the word-level features based on the calculated fusion weights, and applies residual connection and layer normalization to obtain the final fusion-type context representation. The residual connection ensures the retention of the original information, while the layer normalization helps with training stability and convergence speed.
[0095] The advantage of the multi-granularity feature fusion in the embodiments of this application is that: the character-level features capture the fine-grained information at the character level, which is beneficial for identifying spelling errors, character-similar errors, etc.; the word-level features provide more macroscopic semantic unit information, which helps to understand the context and collocation relationship of words, and is particularly important for identifying complex errors such as idiom errors and semantic incoherence. By fusing these two different-granularity features, the system can more comprehensively understand the text content and improve the accuracy of error detection and correction.
[0096] Furthermore, a context-aware attention mechanism is applied to enhance the fusion-type context representation. Specifically, the system adopts a multi-head self-attention mechanism to capture the long-range dependencies between different positions in the sequence.
[0097] In one embodiment, the multi-head attention layer constructed in this application includes eight attention heads: semantic association head, syntactic structure head, word co-occurrence head, topic consistency head, entity relation head, contextual coherence head, grammatical dependency head, and discourse cohesion head. Each head performs independent attention calculations for different linguistic features of the text, and then the results are merged. Specifically, the semantic association head focuses on capturing semantic relevance, the syntactic structure head focuses on structural dependencies in the syntactic tree, the word co-occurrence head identifies common collocation patterns, the topic consistency head maintains topic coherence, the entity relation head tracks relationships between entities, the contextual coherence head maintains paragraph logic, the grammatical dependency head marks grammatical relations, and the discourse cohesion head handles long-distance referential relationships. The attention calculation process first maps the input features to a query vector (Q), a key vector (K), and a value vector (V). Then, the dot product of the query vector Q and the key vector K is calculated. After scaling and softmax normalization, attention weights are obtained. Finally, these weights are used to perform a weighted summation of the value vector V.
[0098] For example, for long sentences containing grammatical errors, such as "His new invention has made a great contribution to the development of science and technology" (where "contribution" should be "gain"), the system can establish a long-distance association between "invention" and "contribution" through a multi-head attention mechanism, which helps to identify "contribution" as an incorrect word. Specifically, the semantic association head identifies common collocations between "make" and "contribute," the grammatical dependency head marks the inconsistency of "contribution" in verb-object structures, and the entity relation head focuses on semantic mismatches between "invention" as the subject and "contribution" as the object.
[0099] To enhance positional awareness, the system adds positional encoding to the input features. In implementation, fixed positional encoding generated by sine and cosine functions can be used, or learnable positional embeddings can be employed. Positional information is crucial for correctly understanding the relative positions of elements in a text sequence, especially for handling word order errors.
[0100] Furthermore, the output of the attention layer undergoes a projection transformation through a fully connected layer to adjust the feature dimensions, then is added to the original input features (residual connection), and finally normalized using an application layer to obtain an enhanced contextual representation. This context-enhanced representation can better capture long-distance dependencies and complex semantic structures in the text.
[0101] Therefore, the core advantage of the context-aware attention mechanism in this application is its ability to capture long-distance dependencies in text, especially for handling grammatical and semantic errors spanning multiple characters or words. Through this mechanism, the system can enhance the context of the representation at each position in the text, making it contain richer contextual semantic information.
[0102] In step S103, based on the enhanced context representation, at least one error character in the Chinese text data to be corrected is identified, and the error type corresponding to each error character is determined.
[0103] Among them, in some embodiments, the error types include at least one of spelling mistakes, similar-shaped character mistakes, similar-sounding character mistakes, idiom mistakes, grammar mistakes, punctuation mistakes, and semantic incoherence.
[0104] Specifically, based on the enhanced context representation, the error detection module identifies the positions of error characters in the text. Error detection adopts a sequence annotation mode, and each character position is classified into two categories (0 indicates correct, 1 indicates incorrect).
[0105] Specifically, the enhanced context representation is input into the fully connected layer to obtain the logits of binary classification, and then converted into a probability distribution through the softmax function. If the error probability at a certain position exceeds the preset threshold (the default is 0.5), it is determined that there is an error at that position.
[0106] In an optimized embodiment, the system can dynamically adjust the detection threshold according to the requirements of different application scenarios. For example, for applications that require high accuracy, the preset threshold can be increased to 0.7 or higher; while for scenarios that pursue high recall rate, the preset threshold can be reduced to 0.3 or lower.
[0107] Furthermore, for the detected error positions, the specific error type is determined through the error type classification module. Error type classification is a multi-classification problem, and the system inputs the enhanced context representation into another classification head to predict the specific error type.
[0108] In one embodiment, the system supports the following 8 error types:
[0109] Spelling mistake: General writing of wrong characters, such as writing "tomorrow" as "明填";
[0110] Similar-shaped character mistake: Confusion caused by similar glyphs, such as writing "已经" as "己经";
[0111] Similar-sounding character mistake: Confusion caused by similar pronunciations, such as writing "起来" as "气来";
[0112] Idiom mistake: Improper use of idioms, such as writing "无动于衷" as "无动于忠";
[0113] Grammar mistake: Improper grammar structure, such as the misuse of "的", "地", and "得";
[0114] Punctuation mistake: Improper use of punctuation marks, such as the misuse of commas and periods;
[0115] Semantic incoherence: The sentence expression is not smooth or the semantics are contradictory;
[0116] Other errors: Other errors not categorized into the above types.
[0117] It should be noted that the determination of the error type is crucial for generating targeted thought chain reasoning in the future, and different types of errors require different analysis strategies and correction methods.
[0118] In step S104, a chain-like reasoning process is generated based on each error character and the error type corresponding to each error character.
[0119] Furthermore, in some embodiments, a chain-like reasoning process is generated based on the error type corresponding to each error character, including: obtaining the context information of each error character and inferring the error cause of each error character based on the context information of each error character; determining the error type complexity and context complexity corresponding to each error character based on the error type and context information of each error character; determining the target thinking chain template based on the error type complexity and context complexity corresponding to each error character; and filling the target thinking chain template based on the context information of each error character, predicted correction candidates, and the error cause of each error character to generate a chain-like reasoning process.
[0120] In one specific embodiment, the chain-like reasoning generation module first obtains error character, position, and type information, and then combines the language knowledge base and context information to generate a structured reasoning process.
[0121] The structure of the chain-like reasoning generation module is as follows: Figure 2 As shown, it includes: a language knowledge base, which includes a knowledge base of similar-looking characters, a knowledge base of similar-sounding characters, an idiom dictionary, a word collocation dictionary, and a professional terminology dictionary; an error analysis component, which infers the cause and type of error based on the language knowledge base and contextual features; a thought chain template library, which includes multi-level thought chain templates, which are divided into basic templates and advanced templates according to error type and complexity; dynamically selecting appropriate thought chain templates based on error type and error complexity; and filling the selected thought chain templates with reasoning steps based on the error context, error characters, correction characters, and inferred error causes to generate a thought chain error correction basis.
[0122] For example, the language knowledge base includes multiple sub-knowledge bases, including a knowledge base for similar-looking characters, a knowledge base for similar-sounding characters, an idiom dictionary, a word collocation dictionary, and a professional terminology dictionary, etc. These knowledge bases provide the necessary linguistic knowledge support for reasoning in the thought chain.
[0123] The methods for constructing a language knowledge base include:
[0124] Build a knowledge base of similar - shaped Chinese characters, collect pairs of Chinese characters with similar glyphs, and calculate the glyph similarity;
[0125] Build a knowledge base of homophonous Chinese characters, and collect Chinese characters with similar pronunciations grouped by pinyin or phonetic notations;
[0126] Build an idiom dictionary, collect common idioms and their meanings, usages, and error - prone forms;
[0127] Build a collocation dictionary of words, and record the correct collocation relationships of common words;
[0128] Build a dictionary of technical terms, collect technical terms in various fields and their standard spellings;
[0129] The language knowledge base is used for error type inference, thinking - chain generation, and providing correction candidates.
[0130] For example, the knowledge base of similar - shaped Chinese characters records pairs of Chinese characters with similar shapes, such as "已 (yǐ)" and "己 (jǐ)", "土 (tǔ)" and "士 (shì)", etc.; the knowledge base of homophonous Chinese characters records Chinese characters with similar pronunciations, such as "的 (de)", "地 (dì)", "得 (děi)", etc.; the idiom dictionary includes common idioms and their meanings, usages, and common error forms.
[0131] Based on the error type and the context information of each error character, first, perform an error complexity assessment. The complexity assessment considers two factors: error - type complexity (idiom errors and grammar errors usually have higher complexity) and context complexity (sentence length, structural complexity, etc.).
[0132] Among them, the error complexity is determined through the following steps:
[0133] First, analyze the error type, and determine idiom errors, grammar errors, and semantic - incoherence errors as high - complexity errors;
[0134] Second, analyze the structural complexity of the error context, including sentence length, the number of punctuation marks, and the depth of nested structures;
[0135] Third, comprehensively consider the error type and context complexity to determine the complexity level of the error;
[0136] Finally, the thinking - chain reasoning generation module selects a basic template or an advanced template according to the determined error complexity level.
[0137] Specifically, according to the evaluated complexity, select a suitable target thinking - chain template from the thinking - chain template library. In one embodiment, the template library includes two types: basic templates and advanced templates. The basic templates have a relatively simple structure and are suitable for spelling errors, similar - shaped / homophonous Chinese character errors, etc.; the advanced templates include more detailed analysis steps and are suitable for complex error types such as idiom errors and grammar errors.
[0138] Fill in the selected target thought chain template based on the error context, error characters, corrected characters, and inferred error reasons to generate a complete thought chain reasoning process. The thought chain usually includes links such as error phenomenon description, context analysis, reason inference, candidate solution generation, final selection, and reasons.
[0139] It should be noted that for different types of errors, the thought chain template has different structures:
[0140] For spelling errors, the thought chain template includes context analysis, listing of candidate correct characters, and reasons for the final selection; for near - shape character errors, the thought chain template includes analysis of glyph similarity, explanation of confusing parts, and reasons for the correct selection; for near - sound character errors, the thought chain template includes analysis of pronunciation similarity, explanation of semantic differences, and reasons for the correct selection; for idiom errors, the thought chain template includes idiom recognition, comparison with similar idioms, explanation of idiom meanings, and reasons for the correct selection; for grammar errors, the thought chain template includes grammar rule explanation, error analysis, and correct expression forms; for semantic incoherence errors, the thought chain template includes broader context semantic analysis, reasons for incoherence, and semantic explanation after modification.
[0141] Exemplarily, for the near - shape character error "提搞工作效率" (should be "提高工作效率"), the thought chain generated by the system may be:
[0142] "Analysis detected a near - shape character error: the character '搞' at the position
[0143] ↓ Analyze the context and semantics
[0144] The context indicates that here it needs to express the meaning of "enhancing work efficiency"
[0145] ↓ Consider possible correct options
[0146] Based on the context and semantics, possible correct characters are: 高, 升, 增
[0147] ↓ Determine the best choice
[0148] The most suitable one should be '高'
[0149] ↓ Verify the result
[0150] After changing '搞' to '高', the sentence becomes "我们需要提高工作效率" (We need to improve work efficiency), which meets the semantic requirements
[0151] Conclusion: The character '搞' at this position is a near - shape character error and should use '高' because '提高' is the correct collocation of words, meaning to enhance or increase.
[0152] In step S105, each erroneous character is corrected according to the thought chain reasoning process and the enhanced context representation, resulting in the corrected text and the thought chain error correction basis corresponding to the corrected text.
[0153] Further, in some embodiments, each erroneous character is corrected to obtain corrected text, including: mapping each erroneous character to a preset vocabulary space based on enhanced contextual representation to obtain the character prediction probability distribution of each erroneous character, and selecting a preset number of characters with the highest probability from the character distribution probability as first candidate correction items; generating second candidate correction items from the thought chain reasoning process, and obtaining a candidate correction set based on the first and second candidate correction items; calculating the rationality score of each candidate item in the candidate correction set based on a preset language knowledge base; determining at least one target correction character based on the character prediction probability distribution of each erroneous character and the rationality score of each candidate item; and replacing each erroneous character with the at least one target correction character to generate corrected text.
[0154] Specifically, combining the thought chain reasoning process with enhanced contextual representation, a correction prediction module performs final correction on detected errors. First, based on the enhanced contextual representation, a fully connected layer maps the features of each error location to the vocabulary space, obtaining the character prediction probability distribution for each error location. The top K characters with the highest probabilities from this distribution are selected as the first candidate correction terms. Simultaneously, a second candidate correction term is extracted from the thought chain reasoning process; the two are merged to form a complete candidate correction set.
[0155] In one embodiment, a reasonableness score is calculated for each candidate in the candidate set based on a language knowledge base. Reasonableness assessment considers multiple factors, including semantic fluency, collocation habits, and word frequency. For example, for idiom errors, the system prioritizes characters in the corresponding positions of the correct idiom; for errors involving similar-looking or similar-sounding characters, the system considers the semantic matching degree between the candidate character and the context.
[0156] Furthermore, by combining the probability distribution of characters and the reasonableness score, the optimal corrective character is selected to replace the erroneous characters in the original text, generating the corrected text. Finally, the corrected text and the corresponding thought chain error correction basis are output to help users understand the error correction process and its basis.
[0157] Furthermore, the Chinese text correction method based on context fusion thought chain in this application embodiment also includes constructing a multi-task joint loss function, specifically including:
[0158] Error detection loss is calculated using the cross-entropy loss function to determine the difference between the error detection result and the true label.
[0159] Error type classification loss is calculated using the cross-entropy loss function to determine the difference between the predicted error type and the actual error type.
[0160] The prediction loss is corrected by calculating the difference between the corrected character prediction and the true corrected character using the cross-entropy loss function;
[0161] The thought chain generation loss is calculated by using the mean squared error loss function to determine the difference between the thought chain encoding representation and the target representation.
[0162] By comparing the learning loss, the contrast relationship between the incorrect text representation and the correct text representation is calculated using cosine similarity.
[0163] Therefore, by comprehensively weighting the various losses, a multi-task joint loss function is constructed for end-to-end model training.
[0164] Furthermore, the steps for calculating the contrastive learning loss include: extracting feature representations of erroneous positions in the erroneous text as anchor samples; extracting feature representations of the same positions in the corresponding correct text as positive samples; extracting feature representations of other positions or other texts in the batch as negative samples; calculating the cosine similarity between anchor samples and positive samples, and the cosine similarity between anchor samples and each negative sample; adjusting the similarity distribution based on the temperature parameter to construct the contrastive learning objective function; maximizing the similarity between anchor samples and positive samples while minimizing the similarity between anchor samples and negative samples.
[0165] To facilitate a clearer and more intuitive understanding of the context-fusion-based Chinese text error correction method proposed in this application, the following section combines... Figure 3 Taking the execution of a context-fusion-based Chinese text correction method on a terminal as an example, this paper introduces the context-fusion-based Chinese text correction method provided in this embodiment of the invention. For details, please refer to... Figure 3 , Figure 3 This diagram illustrates a flowchart of a Chinese text correction method based on context fusion thought chain provided by an embodiment of the present invention. The method includes the following steps:
[0166] S301, Obtain the Chinese text data to be corrected.
[0167] S302, Based on the pre-trained Chinese language model, feature encoding is performed on the Chinese text to be corrected to obtain the initial context representation of the text sequence.
[0168] S303, Perform multi-granularity feature fusion, which fuses the character-level features of the text sequence with the word-level features obtained through word segmentation to generate a fused context representation.
[0169] S304, The context-aware attention mechanism is applied to enhance the fused context representation, capture long-distance dependencies, and generate an enhanced context representation.
[0170] S305, based on the enhanced context representation, the error detection module performs binary classification on each character position in the text, identifies the position of the erroneous character, and outputs the error detection result.
[0171] S306, for each identified error character position, the error type is determined by the error type classification module.
[0172] S307: For each detected error, the chain-based reasoning generation module dynamically generates a chain-based reasoning process based on the error type, error context, and language knowledge base.
[0173] S308, combining the thought chain reasoning process with the enhanced context representation, the correction prediction module corrects each detected error, generating the corrected text and the corresponding thought chain error correction basis.
[0174] The following describes the Chinese text correction system based on context fusion thinking chain, which is part of the Chinese text correction method based on context fusion thinking chain according to the embodiments of this application.
[0175] Specifically, this context-fusion-based Chinese text correction system, based on the core technology of this invention—namely, the context-fusion-based Chinese text correction method—realizes a complete processing flow from text input to error detection, analysis, and correction, providing users with high-precision, interpretable Chinese text correction services. For example... Figure 4 As shown, the system adopts a layered architecture design, with each functional layer working closely together to form a highly efficient error correction pipeline. The system mainly includes the following core modules:
[0176] The input layer receives various forms of text to be corrected, supporting single-text input, batch processing, and file import. It also performs text encoding standardization and preprocessing to provide standardized input for subsequent processing. The encoding layer integrates a pre-trained language model, word segmentation module, and feature encoding unit, converting the input text into a high-dimensional semantic representation and constructing an initial feature space. The core processing layer is the key technical implementation area of the system, containing two core functional units: multi-granularity feature fusion and context-aware attention. It generates enhanced contextual representations through dynamic fusion of word-level features and long-distance dependency modeling. The error handling layer performs precise error localization and classification, identifying various types of errors in the text through binary classification detection and multi-classification analysis. The knowledge base layer provides external knowledge support for the system, integrating various language knowledge resources and thought chain templates to provide necessary evidence for the reasoning process. The output layer is responsible for result presentation and user interaction, providing various forms of error correction result display and interface services.
[0177] The structure of the multi-granularity feature fusion module is as follows: Figure 5 As shown, character-level features are mapped to the feature space through a character-level feature projection layer; word-level features are mapped to the same feature space as character-level features through a word-level feature projection layer; temporal alignment of word-level features to character-level features is achieved through linear interpolation or attention mechanisms; feature fusion weights of character-level features and aligned word-level features are calculated; feature fusion weights are obtained through a gating mechanism based on concatenated features; based on the feature fusion weights, character-level features and aligned word-level features are weighted and fused to obtain a fused context representation; residual connections and layer normalization are applied to the fused context representation to ensure feature stability.
[0178] Furthermore, the context-aware attention mechanism includes: constructing a multi-head self-attention layer, which contains multiple attention heads, each of which independently calculates the attention weights between the query vector, key vector, and value vector; adding positional encoding to the text sequence to incorporate positional information; projecting the output of the multi-head self-attention layer through a fully connected layer; applying residual connections to add the projected features to the original input features; and applying layer normalization to the added features to improve feature stability, thereby obtaining an enhanced contextual representation.
[0179] To achieve practical deployment and user-friendly interaction of the system, this invention designs a complete interface interaction and user experience flow. For example... Figure 6As shown, the system provides an intuitive and user-friendly web interface, facilitating text correction and result viewing. The interface design is clearly divided into sections with a logical layout, including a text input area, parameter setting area, result display area, and thought chain analysis area. Users can submit text to be corrected in the input area, adjust detection thresholds and thought chain generation options in the parameter area, and the system processes the data in real time. Errors and corrections are highlighted in the results area, and a structured error analysis process is displayed in the thought chain area, allowing users to clearly understand the basis and reasoning logic for correction.
[0180] The system implements a standardized RESTful API interface design, supporting single-text error correction and batch processing functions, facilitating integration with third-party applications. The interface uses JSON format for data exchange, and the response content includes complete information such as the original text, correction results, error list, and thought process analysis, meeting the system integration needs of different scenarios.
[0181] In practical applications, this system can be widely used in various scenarios. In the field of intelligent writing assistance, the system can be integrated into online document editors to provide users with real-time error correction suggestions and error analysis; in the field of education, the system can serve as a teaching aid for Chinese writing, helping students improve their writing quality and language comprehension; in the fields of professional publishing and content production, the system can significantly improve the efficiency and quality of text proofreading and reduce the cost of manual proofreading.
[0182] The system implementation of this invention adopts a modular design, with each functional unit connected through standardized interfaces, providing excellent scalability and flexibility. The system can be configured and adjusted according to actual application needs, supporting deployments of different scales and scenarios, from lightweight deployments for personal use to high-concurrency cluster deployments for enterprise applications, meeting the performance requirements of various application scenarios.
[0183] Through the implementation of the above system, this invention achieves three core technological breakthroughs in the field of Chinese text correction technology: First, the multi-granularity feature fusion mechanism realizes the dynamic integration and enhancement of word-level semantic features, significantly improving the detection capability of complex semantic errors; second, the context-aware attention mechanism effectively captures long-distance dependencies, enhancing the system's accuracy in understanding grammatical structures and contexts; finally, the chain-thinking reasoning technology provides a clear and traceable analytical path for the error correction process, breaking through the "black box" limitations of traditional error correction systems and making the error correction results highly interpretable and credible. These technological innovations work synergistically to construct a Chinese text correction solution with theoretical depth and practical value.
[0184] Through the above description of the embodiments, those skilled in the art can clearly understand that the various embodiments of the present invention can be implemented by means of software or by dedicated hardware design. The technical solution of the present invention, through innovative interdisciplinary integration, organically combines deep neural network technology with symbolic reasoning systems, achieving an excellent balance between language processing accuracy and system interpretability, and providing a new theoretical perspective and practical path for the development of language artificial intelligence technology.
[0185] According to the Chinese text correction method based on context fusion and thought chain in this application, the Chinese text data to be corrected is feature-encoded, multi-granularity feature fusion is performed, and context representation is enhanced. The location of erroneous characters is detected and the error type is determined based on the enhanced context representation. An error analysis process is dynamically generated. The error is corrected by combining the thought chain reasoning process, generating corrected text and corresponding thought chain correction basis. Thus, through the innovative combination of multi-granularity feature fusion and thought chain reasoning, not only is the accuracy of Chinese text correction improved, especially in handling complex error types, but the interpretability of the correction process is also achieved, providing users with clear and understandable correction basis, significantly improving the practicality and user experience of the correction system.
[0186] Next, referring to the accompanying drawings, a Chinese text correction device based on context fusion thought chain proposed according to an embodiment of this application is described.
[0187] Figure 7 This is a block diagram of a Chinese text correction device based on context fusion thought chain according to an embodiment of this application.
[0188] like Figure 7 As shown, the Chinese text correction device 10 based on context fusion thinking chain includes: acquisition module 100, processing module 200, recognition module 300, generation module 400 and correction module 500.
[0189] The system comprises the following modules: an acquisition module 100, which acquires the Chinese text data to be corrected and performs feature encoding on the data to obtain an initial context representation; a processing module 200, which extracts character-level features from the Chinese text data to be corrected based on the initial context representation, performs word segmentation on the data, extracts word-level features, fuses the character-level and word-level features to generate a fused context representation, and enhances the fused context representation to obtain an enhanced context representation; an identification module 300, which identifies at least one erroneous character in the Chinese text data to be corrected based on the enhanced context representation and determines the error type corresponding to each erroneous character; a generation module 400, which generates a chain-like reasoning process based on each erroneous character and its corresponding error type; and a correction module 500, which corrects each erroneous character based on the chain-like reasoning process and the enhanced context representation to obtain the corrected text and the corresponding chain-like reasoning basis for the correction.
[0190] Further, in some embodiments, the processing module 200 is configured to: map character-level features to a preset feature space, map word-level features to a preset feature space, and align the mapped word-level features with the mapped character-level features in time based on a preset linear interpolation strategy to obtain aligned word-level features; calculate the feature fusion weights of the mapped character-level features and the aligned word-level features, and perform weighted fusion of the mapped character-level features and the aligned word-level features based on the feature fusion weights to obtain a fused context representation.
[0191] Furthermore, in some embodiments, the generation module 400 is configured to: obtain context information of each error character, and infer the error cause of each error character based on the context information of each error character; determine the error type complexity and context complexity corresponding to each error character according to the error type corresponding to each error character and the context information of each error character; determine the target thinking chain template according to the error type complexity and context complexity corresponding to each error character; and fill the target thinking chain template according to the context information of each error character, the predicted correction candidates, and the error cause of each error character to generate a chain-like thinking reasoning process.
[0192] Further, in some embodiments, the correction module 500 is configured to: map each erroneous character to a preset vocabulary space based on enhanced contextual representation, obtain the character prediction probability distribution of each erroneous character, and select the preset number of characters with the highest probability from the character distribution probability as first candidate correction items; generate second candidate correction items from the thought chain reasoning process, and obtain a candidate correction set based on the first and second candidate correction items; calculate the rationality score of each candidate item in the candidate correction set based on a preset language knowledge base; determine at least one target correction character based on the character prediction probability distribution of each erroneous character and the rationality score of each candidate item; and replace each erroneous character with the at least one target correction character to generate corrected text.
[0193] Furthermore, in some embodiments, the error types include at least one of spelling errors, similar-looking character errors, similar-sounding character errors, idiom errors, grammatical errors, punctuation errors, and semantic inconsistencies.
[0194] It should be noted that the foregoing explanation of the Chinese text correction method based on context fusion mind chain also applies to the Chinese text correction device based on context fusion mind chain in this embodiment, and will not be repeated here.
[0195] According to embodiments of this application, the Chinese text correction device based on context fusion and thought chain performs feature encoding on the Chinese text data to be corrected, performs multi-granularity feature fusion, and enhances the context representation. Based on the enhanced context representation, it detects the position of erroneous characters and determines the error type; dynamically generates an error analysis process; and corrects the error by combining the thought chain reasoning process, generating corrected text and corresponding thought chain correction basis. Thus, through the innovative combination of multi-granularity feature fusion and thought chain reasoning, it not only improves the accuracy of Chinese text correction, especially in handling complex error types, but also achieves interpretability of the correction process, providing users with clear and understandable correction basis, significantly enhancing the practicality and user experience of the correction system.
[0196] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include:
[0197] The memory 801, the processor 802, and the computer program stored on the memory 801 and capable of running on the processor 802.
[0198] When the processor 802 executes the program, it implements the Chinese text error correction method based on context fusion thinking chain provided in the above embodiments.
[0199] Furthermore, electronic devices also include:
[0200] Communication interface 803 is used for communication between memory 801 and processor 802.
[0201] The memory 801 is used to store computer programs that can run on the processor 802.
[0202] The memory 801 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0203] If the memory 801, processor 802, and communication interface 803 are implemented independently, then the communication interface 803, memory 801, and processor 802 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0204] Optionally, in a specific implementation, if the memory 801, processor 802, and communication interface 803 are integrated on a single chip, then the memory 801, processor 802, and communication interface 803 can communicate with each other through an internal interface.
[0205] The processor 802 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0206] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described Chinese text error correction method based on context fusion thought chain.
[0207] This application also provides a computer program product, including a computer program that is executed by a processor to implement the above-described Chinese text correction method based on context fusion thought chain.
[0208] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0209] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0210] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A Chinese text error correction method based on context fusion thinking chain, characterized in that, The method comprises the following steps: obtaining Chinese text data to be corrected, and performing feature coding on the Chinese text data to be corrected to obtain an initial context representation; based on the initial context representation, extracting word-level features of the Chinese text data to be corrected, and performing word segmentation processing on the Chinese text data to be corrected to extract word-level features, fusing the word-level features and the word-level features, generating a fused context representation, and enhancing the fused context representation to obtain an enhanced context representation; based on the enhanced context representation, identifying at least one error character in the Chinese text data to be corrected, and determining the error type corresponding to each error character; According to the chain thought reasoning process and the enhanced context representation, the error character is corrected, and the corrected text and the thought chain correction basis corresponding to the corrected text are obtained; According to the error type corresponding to each error character, the chain thought reasoning process is generated, which includes: obtaining the context information of each error character, and based on the context information of each error character, the error reason of each error character is inferred; According to the error type corresponding to each error character and the context information of each error character, the error type complexity and context complexity corresponding to each error character are determined; According to the error type complexity corresponding to each error character and the context complexity, a target thought chain template is determined; according to the context information of each error character, the predicted correction candidate and the error reason of each error character, the target thought chain template is filled, and the chain thought reasoning process is generated; The error character is corrected to obtain the corrected text, which includes: based on the enhanced context representation, mapping each error character to a preset word table space to obtain a character prediction probability distribution of each error character, and selecting the highest probability of a preset character as a first candidate correction item from the character prediction probability distribution; The second candidate correction item is generated from the chain thought reasoning process, and the first candidate correction item and the second candidate correction item are obtained according to the first candidate correction item and the second candidate correction item to obtain a candidate correction set; Based on the preset language knowledge base, the rationality score of each candidate item in the candidate correction set is calculated; According to the character prediction probability distribution of each error character and the rationality score of each candidate item, at least one target correction character is determined; The at least one target correction character is used to replace the error character to generate the corrected text. The word-level features and the word-level features are fused to generate a fused context representation, which includes:
2. The method according to claim 1, wherein, map the word-level features to the preset feature space, and map the character-level features to the preset feature space, and based on a preset linear interpolation strategy, align the mapped word-level features and the mapped character-level features in time sequence to obtain aligned word-level features; calculate feature fusion weights of the mapped character-level features and the aligned word-level features, and based on the feature fusion weights, perform weighted fusion on the mapped character-level features and the aligned word-level features to obtain the fusion-type context representation.
3. The method according to claim 1, wherein, The error types include at least one of spelling errors, homograph errors, homophone errors, idiom errors, grammar errors, punctuation errors, and semantic errors.
4. A Chinese text error correction device based on context fusion thinking chain, characterized in that, The method comprises: an acquisition module configured to acquire Chinese text data to be corrected, and perform feature encoding on the Chinese text data to be corrected to obtain an initial context representation; a processing module configured to extract character-level features of the Chinese text data to be corrected based on the initial context representation, perform word segmentation processing on the Chinese text data to be corrected to extract word-level features of the Chinese text data to be corrected, fuse the character-level features and the word-level features to generate a fusion-type context representation, and enhance the fusion-type context representation to obtain an enhanced context representation; an identification module configured to identify at least one error character in the Chinese text data to be corrected based on the enhanced context representation, and determine an error type corresponding to each error character; a generation module configured to generate a chain-of-thought reasoning process according to each error character and the error type corresponding to each error character; a correction module configured to correct each error character according to the chain-of-thought reasoning process and the enhanced context representation to obtain corrected text and a thought chain correction basis corresponding to the corrected text; The generation module is configured to: acquire context information of each error character, and infer an error cause of each error character based on the context information of each error character; determine an error type complexity and a context complexity corresponding to each error character according to the error type corresponding to each error character and the context information of each error character; determine a target thought chain template according to the error type complexity corresponding to each error character and the context complexity; and fill the target thought chain template according to the context information of each error character, a predicted correction candidate, and the error cause of each error character to generate the chain-of-thought reasoning process. The correction module is configured to: based on the enhanced context representation, map each error character to a preset vocabulary space, obtain a character prediction probability distribution of each error character, and select a preset number of characters with the highest probabilities from the character prediction probability distribution as first candidate correction items; generate second candidate correction items from the chain-of-thought reasoning process, obtain a candidate correction set according to the first candidate correction items and the second candidate correction items, calculate a rationality score of each candidate item in the candidate correction set based on a preset language knowledge base, determine at least one target correction character according to the character prediction probability distribution of each error character and the rationality score of each candidate item, and replace each error character with the at least one target correction character to generate the corrected text.
5. The Chinese text correction device based on context fusion thinking chain according to claim 4, characterized in that, The processing module is configured to: map the word-level features to a preset feature space and map the character-level features to the preset feature space, and based on a preset linear interpolation strategy, align the mapped word-level features and the mapped character-level features in time sequence to obtain aligned word-level features; calculate feature fusion weights of the mapped character-level features and the aligned word-level features, and based on the feature fusion weights, perform weighted fusion on the mapped character-level features and the aligned word-level features to obtain the fusion context representation.
6. An electronic device, comprising: It comprises: a memory, a processor, and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to implement the Chinese text correction method based on context fusion chain-of-thought as claimed in any one of claims 1-3.
7. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the Chinese text correction method based on context fusion chain-of-thought as claimed in any one of claims 1-3.
8. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the Chinese text correction method based on context fusion chain-of-thought as claimed in any one of claims 1-3.
Citation Information
Patent Citations
Text error correction method, system and equipment and storage medium
CN116822464A
Chinese spelling error correction method
CN118278394A