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

By identifying and segmenting text semantic boundaries, semantic analysis combined with domain knowledge base, and dynamically adjusting error correction paths, the problems of multi-error type interleaving and insufficient adaptability of dynamic contexts in the existing technology are solved, and coordinated detection and correction of text error correction technology in high-risk fields are realized.

CN120336535BActive Publication Date: 2025-08-29北京观微科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510806686.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-17
Publication Date
2025-08-29
Estimated Expiration
2045-06-17

AI Technical Summary

Technical Problem

In the face of the problems of multi-error type interleaving, insufficient adaptability of dynamic contexts and difficulty in integrating domain-specific knowledge, especially in high-risk fields such as medical and law, it is difficult to achieve coordinated detection and correction of grammatical, semantic, and logical errors.

Method used

By obtaining the text to be corrected for semantic boundary recognition, dividing it into multiple clauses and assigning the sequence ID, semantic analysis is performed in combination with the target domain knowledge base, identifying the error type, and adjusting the error correction path through dynamic strategy optimization to generate error correction results containing error location, type and correction suggestions.

Benefits of technology

It realizes collaborative error detection and correction in the context of multiple error types interleaving and dynamic contexts, improves the industry-oriented implementation capabilities of error correction technology, and ensures collaborative correction of text grammar, semantics and logic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120336535B_ABST
    Figure CN120336535B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention relate to the field of natural language processing technology and provide a text error correction method, device, electronic device, and storage medium. The method comprises: obtaining a target text to be corrected and performing semantic boundary recognition to obtain all semantic boundaries; then dividing the target text into multiple clauses, assigning IDs according to the order in which each clause appears, and generating structured data with sequence IDs; inputting the structured data into a language model, and calling the target domain knowledge base corresponding to the target text as a constraint condition to perform semantic parsing and identify the error type; adjusting the error correction path based on the error type and then re-identifying the error information, wherein the error information includes error content, error type, and error location; and reorganizing multiple clauses based on the sequence ID and error content, error type, and error location to generate an error correction result including the error location, error type, and correction suggestions. Thus, the coordinated detection and correction of grammatical, semantic, and logical errors is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] As a core technology in natural language processing, text error correction plays an irreplaceable role in improving information accuracy and ensuring text standardization. With the acceleration of digitization, the volume of text data in scenarios such as legal documents, academic literature, and medical records is growing exponentially. Errors in text can lead to semantic ambiguity and even misjudgments (e.g., miswritten medical records leading to diagnostic bias).

[0003] Traditional error correction methods primarily rely on explicit rule bases (such as regular expression matching) or static language models (such as n-grams). While these methods can address basic grammatical errors, their recognition rate for deeper logical errors (such as incorrect terminology and cross-sentence reference errors) is less than 40%. While deep learning technologies (such as Seq2Seq models and Transformers) have significantly improved error correction accuracy in recent years, they still face bottlenecks in complex semantic reasoning, dynamic context adaptation, and the coordinated handling of multiple error types.

[0004] Current text intelligent error correction technology faces three challenges. First, the problem of multiple error types being intertwined is significant. For example, grammatical errors, semantic contradictions, and logical fallacies often coexist in the same text, and the requirements of grammatical standardization and semantic rationality must be met at the same time. Secondly, the dynamic context adaptability is insufficient, and existing models find it difficult to adjust the reasoning path in real time according to the context, resulting in semantic gaps when processing long texts. In addition, the integration of domain-specific knowledge is difficult. For example, the professional terms used in medical records, updates to sensitive word libraries, etc. require the construction of targeted error correction strategies based on domain knowledge. These problems jointly restrict the effectiveness of traditional methods in complex scenarios, especially in high-risk fields such as medicine and law, where minor errors may lead to serious consequences. Summary of the Invention

[0005] The present invention provides a text error correction method, device, electronic device and storage medium to address the defects of existing text error correction technology in the problems of multiple error types interweaving, dynamic context adaptability and domain-specific knowledge integration, realize the coordinated detection and correction of grammatical, semantic and logical errors, effectively respond to dynamic context challenges, and provide a solution for the industry-wide implementation of text intelligent error correction technology.

[0006] The present invention provides a text error correction method, comprising:

[0007] Obtain the target text to be corrected;

[0008] Performing semantic boundary recognition on the target text to obtain all semantic boundaries of the target text;

[0009] Based on all the semantic boundaries, the target text is divided into a plurality of clauses, and an ID is assigned to each clause according to the order in which each clause appears in the target text, thereby generating structured data with a sequence ID;

[0010] Inputting the structured data of each clause into the language model, and calling the target domain knowledge base corresponding to the target text as a constraint condition to perform semantic parsing on the structured data, and identifying the error type in the structured data;

[0011] adjusting an error correction path based on the error type, and re-identifying error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type, and error location;

[0012] The plurality of clauses are reorganized based on the sequence ID and the error content, error type and error position to generate an error correction result including the error position, error type and correction suggestion.

[0013] In one possible implementation, the method further includes:

[0014] Performing a confidence score on each error message in the error correction result;

[0015] Based on the confidence score, error information integration is performed for each error type in the error correction result, wherein the error information integration includes streamlining error prompts and filtering error information with a confidence score lower than a threshold.

[0016] In one possible implementation, the method further includes:

[0017] Identify punctuation marks of the target text using a semantic boundary recognition algorithm;

[0018] Segmenting the target text into a plurality of first short sentences based on the punctuation marks;

[0019] Semantic features of the plurality of first short sentences are identified, and semantic boundaries are identified based on the semantic features to obtain all semantic boundaries of the target text.

[0020] In one possible implementation, the method further includes:

[0021] Based on all the semantic boundaries, segmenting the target text into a plurality of second short sentences;

[0022] Extracting a semantic embedding vector of each second short sentence, and calculating the cosine similarity of adjacent second short sentences based on the semantic embedding vector;

[0023] Determining whether there is a dependency relationship between the second short sentence pairs whose cosine similarity is greater than a threshold;

[0024] If it is determined that there is a dependency relationship between the second short sentence pairs, the second short sentence pairs are combined into independent clauses to obtain a plurality of clauses into which the target text is segmented.

[0025] In one possible implementation, the method further includes:

[0026] Through the preset model inference service engine, an inference task is generated based on each clause, and each inference task corresponds to a thread;

[0027] Multi-threaded parallel processing is performed based on processor occupancy.

[0028] In one possible implementation, the method further includes:

[0029] Input the structured data of each clause into the language model and obtain the semantic vector of each clause through model encoding;

[0030] Retrieving the corresponding knowledge semantic vector in the target domain knowledge base corresponding to the target text based on the semantic vector of each clause;

[0031] Comparing the similarity between the semantic vector of each clause and the knowledge semantic vector to determine the knowledge item most relevant to each clause;

[0032] The knowledge items are used as constraints to perform semantic parsing on the structured data of each clause, and the error types in the structured data are identified.

[0033] In one possible implementation, the method further includes:

[0034] If there are multiple error messages in each error type, arranging the multiple error messages in descending order based on the confidence scores from high to low;

[0035] In each error type, the target error information with the highest confidence is retained;

[0036] Generate correction suggestions for the target error information retained in each error type.

[0037] The present invention also provides a text error correction device, comprising the following modules:

[0038] An acquisition module is used to obtain the target text to be corrected;

[0039] A boundary recognition module is used to perform semantic boundary recognition on the target text to obtain all semantic boundaries of the target text;

[0040] a text segmentation module, configured to segment the target text into a plurality of clauses based on all semantic boundaries, and assign an ID to each clause according to the order in which each clause appears in the target text, thereby generating structured data with sequence IDs;

[0041] An error identification module is used to input the structured data of each clause into the language model, and use the target domain knowledge base corresponding to the target text as a constraint to perform semantic analysis on the structured data and identify the error type in the structured data;

[0042] The error identification module is further configured to adjust an error correction path based on the error type, and re-identify error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type, and error location;

[0043] The error correction module is configured to reorganize the plurality of clauses based on the sequence ID and the error content, error type, and error position, and generate an error correction result including the error position, error type, and correction suggestion.

[0044] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-described text error correction methods when executing the computer program.

[0045] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which implements any of the above-described text error correction methods when executed by a processor.

[0046] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned text error correction methods.

[0047] The text error correction method, device, electronic device and storage medium provided by the present invention obtain a target text to be corrected; perform semantic boundary recognition on the target text to obtain all semantic boundaries of the target text; based on all semantic boundaries, divide the target text into multiple clauses, and assign an ID to each clause according to the order in which each clause appears in the target text, generating structured data with a sequence ID; input the structured data of each clause into a language model, and call the target domain knowledge base corresponding to the target text as a constraint condition to perform semantic analysis on the structured data and identify the error type in the structured data; adjust the error correction path based on the error type, and re-identify the error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type and error location; reorganize the multiple clauses based on the sequence ID and the error content, error type and error location to generate an error correction result including the error location, error type and correction suggestion. Compared with the existing text error correction technology that performs poorly in the problems of multiple error types interweaving, dynamic context adaptability and domain-specific knowledge integration, this solution uses the text preprocessing layer to standardize the input text cleaning and semantic unit division, and then combines the domain knowledge base and dynamic path optimization algorithm in the reasoning error correction layer to realize multi-dimensional error detection and correction. Finally, the error correction results are integrated through the result integration layer and a structured report is generated according to priority, realizing the coordinated correction of grammatical, semantic and logical errors, and providing a solution for the industry implementation of text error correction technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0049] Figure 1 This is one of the flow charts of the text error correction method provided by the present invention.

[0050] Figure 2 This is the second flow chart of the text error correction method provided by the present invention.

[0051] Figure 3 This is a schematic diagram of error correction categories supported by the text error correction method provided by the present invention.

[0052] Figure 4 This is a text error correction architecture diagram based on implicit thinking chain verification and dynamic reasoning path optimization provided by the present invention.

[0053] Figure 5 It is a structural schematic diagram of the text error correction device provided by the present invention.

[0054] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0055] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0056] To facilitate understanding of the embodiments of the present invention, specific embodiments will be further explained below with reference to the accompanying drawings. The embodiments do not limit the embodiments of the present invention.

[0057] Figure 1 This is one of the flow charts of the text error correction method provided by the present invention, such as Figure 1 As shown, the method includes the following:

[0058] S11. Obtain the target text to be corrected.

[0059] The embodiments of the present invention provide a text error correction method to address the problems of low efficiency in collaborative correction of multiple error types and difficulty in maintaining semantic coherence in complex text scenarios.

[0060] Specifically, the initial text to be corrected is first obtained, and then text noise is eliminated through operations such as traditional-simplified conversion, full-width and half-width unification, and special character filtering. Special characters and irrelevant symbols (for example, HTML tags) are filtered out to obtain the standardized target text.

[0061] S12: Perform semantic boundary recognition on the target text to obtain all semantic boundaries of the target text.

[0062] The target text is semantically identified based on a semantic boundary recognition algorithm (for example, a sentence segmentation model that integrates punctuation rules and a pre-trained language model) to obtain all the semantic boundaries of the target text.

[0063] S13. Based on all the semantic boundaries, the target text is divided into multiple clauses, and an ID is assigned to each clause according to the order in which each clause appears in the target text, thereby generating structured data with a sequence ID.

[0064] Long texts are segmented into independent clauses based on semantic boundaries, and adjacent clauses with strong dependencies are merged based on logical relevance analysis. The segmented clauses are assigned unique sequence IDs and then encapsulated into structured data units containing the sequence IDs and their original position information. This design ensures the efficiency of parallel reasoning while avoiding the semantic gaps caused by traditional sentence segmentation methods by preserving semantic relevance, providing high-quality input units for the subsequent construction of implicit thought chains.

[0065] S14: input the structured data of each clause into the language model, and call the target domain knowledge base corresponding to the target text as a constraint condition to perform semantic analysis on the structured data, and identify the error type in the structured data.

[0066] Utilize pre-trained language models to perform deep semantic analysis of text, build logical reasoning chains based on custom knowledge bases, perform semantic analysis of structured data, and identify errors within structured data. This can be combined with specialized terminology from specific knowledge domains. For example, when correcting non-standard medical terminology, the corresponding knowledge domain is medicine.

[0067] S15: Adjust the error correction path based on the error type, and re-identify error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type, and error location.

[0068] The error correction path is adaptively selected based on the error type and contextual features. If the initial judgment result shows that the text does not involve a certain type of error, the system will adaptively adjust the error correction path and skip checking for that type of error, thereby alleviating the problem of excessive error correction and improving the processing efficiency of the entire system. For example, if the model determines that the text does not involve professional terminology, or only involves general expressions, the system will not initiate the check process for knowledge errors and will invest more resources in areas where errors may exist. In this way, the dynamic strategy optimization module achieves efficient resource utilization and improved system performance while ensuring error correction accuracy.

[0069] Furthermore, based on the adjusted error correction path, error information corresponding to the error type determined above in the structured data is re-identified, wherein the error information includes error content, error type, and error location. The error location can be determined by the sequence ID.

[0070] S16. Reorganize the multiple clauses based on the sequence ID and the error content, error type, and error position, and generate an error correction result including the error position, error type, and correction suggestion.

[0071] Clauses are reassembled according to sequence IDs to generate structured results containing error locations, types, and correction suggestions. Priority and content filtering are determined through a confidence scoring mechanism.

[0072] The confidence scoring mechanism assesses the confidence of each error by comprehensively considering factors such as the severity of the error type, the degree of matching of the error description, and the consistency of the context. Furthermore, the confidence score and error details can be used to personalize the display of structured results. For example, errors can be sorted by error type and severity, and duplicate errors and those with low scores can be filtered out.

[0073] Finally, the result integration module will sort the filtered and sorted correction results in descending order of error hazard level, and provide correction suggestions, original text snippets, and confidence star ratings for each error, presenting them to users in a clear and structured manner.

[0074] The text error correction method provided by the present invention obtains a target text to be corrected; performs semantic boundary recognition on the target text to obtain all semantic boundaries of the target text; based on all semantic boundaries, divides the target text into multiple clauses, and assigns an ID to each clause according to the order in which each clause appears in the target text, generating structured data with a sequence ID; inputs the structured data of each clause into a language model, and calls the target domain knowledge base corresponding to the target text as a constraint condition to perform semantic parsing on the structured data, and identify the error type in the structured data; adjusts the error correction path based on the error type, and re-identifies the error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type and error position; reorganizes the multiple clauses based on the sequence ID and the error content, error type and error position, and generates an error correction result including the error position, error type and correction suggestion. Compared with the existing text error correction technology that performs poorly in the problems of multiple error types interweaving, dynamic context adaptability and domain-specific knowledge integration, this method uses the text preprocessing layer to standardize the input text cleaning and semantic unit division, and then combines the domain knowledge base and dynamic path optimization algorithm in the reasoning error correction layer to realize multi-dimensional error detection and correction. Finally, the error correction results are integrated through the result integration layer and a structured report is generated according to priority, realizing the coordinated correction of grammatical, semantic and logical errors, and providing a solution for the industry implementation of text error correction technology.

[0075] Figure 2 This is the second flow chart of the text error correction method provided by the present invention, such as Figure 2 As shown, the method includes the following:

[0076] S21 , obtaining a target text to be corrected, and identifying punctuation marks in the target text using a semantic boundary recognition algorithm.

[0077] S22 . Segment the target text into a plurality of first short sentences based on the punctuation marks, identify semantic features of the plurality of first short sentences, and identify semantic boundaries based on the semantic features to obtain all semantic boundaries of the target text.

[0078] The embodiments of the present invention provide a text error correction method to address the problems of low efficiency in collaborative correction of multiple error types and difficulty in maintaining semantic coherence in complex text scenarios.

[0079] Specific, combined Figure 4 The provided text error correction architecture diagram based on implicit thinking chain verification and dynamic reasoning path optimization is explained in detail. The text error correction architecture implemented by the present invention consists of a text preprocessing layer, a reasoning error correction layer and a result integration layer. In the text preprocessing layer, the original text is processed by the text preprocessing module and the multi-granularity slicing module in turn to form a structured sentence subset, which is dynamically thread pool scheduled in the parallel reasoning module. Entering the reasoning error correction layer, the content after parallel reasoning is first injected with real-time constraints by the implicit thinking chain construction module combined with the domain knowledge base, and then processed by the dynamic strategy optimization module to generate a preliminary parsing result. Finally, in the result integration layer, the preliminary parsing results are successively subjected to confidence scoring and custom filtering to eliminate redundant information such as low confidence, and output the final accurate error correction result.

[0080] Specifically, standardized cleaning is performed through the text preprocessing module to provide high-quality input for subsequent error correction. First, irrelevant symbols such as HTML tags are filtered out, and regular expressions are used to directly remove tags to avoid interference with semantic analysis. Next, the character-level processing stage begins: when traversing each character, if a full-width number is found, it is converted to a half-width number using ASCII code offset to ensure a uniform number format. For half-width English, numbers, and special symbols (such as @#¥!%, etc.), they are filtered out as required rather than retained. This step achieves quick judgment by maintaining a set of special characters.

[0081] Punctuation processing is a key step: half-width punctuation (such as !@#$%^& ()) is converted to full-width characters, while retaining half-width commas (e.g., 1,000) and dashes (e.g., 2023-03-28) in the value. The implementation determines whether to convert the punctuation mark by checking whether the characters before and after it are digits. For example, when encountering a comma, the operator checks whether the characters before and after it are digits. If so, the character is kept in half-width format; otherwise, it is converted to full-width. This strategy balances formatting standardization with numerical readability.

[0082] The OpenCC tool is used to convert Traditional Chinese text into Simplified Chinese. A try-except block is used to catch exceptions during the conversion process, ensuring stable operation even when encountering unsupported characters. After character processing, consecutive whitespace characters (including line breaks and tabs) are merged, and regular expressions are used to replace multiple spaces with a single space. Redundant spaces are also removed from the beginning and end of the text.

[0083] To meet the need for uniform number formats, we've added a thousands separator processing feature. For example, when encountering a value like 1,000, commas are removed through regular expression matching, resulting in a unified format of 1000. This optimization ensures the consistency of values ​​in subsequent processing and avoids logical errors caused by formatting differences. The entire preprocessing process, through multi-stage filtering and rule verification, effectively eliminates text noise, providing a reliable foundation for subsequent implicit thought chain construction and dynamic reasoning.

[0084] Furthermore, the multi-granularity slicing module, centered on semantic boundary identification and logical relevance analysis, combines both rules and models to achieve intelligent text segmentation and merging. First, a BERT-based sentence segmentation model performs preliminary text segmentation. Based on punctuation rules, this model optimizes segmentation boundaries by learning contextual semantic features (such as logical connectives like "therefore" and "however") to obtain the full semantic boundaries of the target text. For example, when a causal relationship is detected between the clause before a comma and the following sentence, the complete semantic unit is prioritized.

[0085] S23. Based on all the semantic boundaries, segment the target text into a plurality of second short sentences, extract a semantic embedding vector of each second short sentence, and calculate the cosine similarity of adjacent second short sentences based on the semantic embedding vector.

[0086] S24. Determine whether there is a dependency relationship between the second short sentence pairs whose cosine similarity is greater than a threshold. If it is determined that there is a dependency relationship between the second short sentence pairs, merge the second short sentence pairs into independent clauses to obtain the multiple clauses into which the target text is segmented.

[0087] Based on all semantic boundaries, the logical relevance analysis phase begins. Sentence-BERT is used to generate a semantic embedding vector for each second sentence, and the cosine similarity of adjacent second sentences is calculated. For second sentence pairs with a similarity above a threshold (e.g., 0.85), dependency syntactic analysis is performed to determine whether a strong dependency exists. For example, if the subject of clause B is the object of clause A, this is considered a strong association, triggering a merge operation.

[0088] A dynamic threshold adjustment mechanism is introduced for complex text scenarios. In legal documents, since legal clauses often contain multi-layered nested structures, the threshold can be raised to 0.9 to retain more complete semantic units; while in ordinary text, the threshold can be lowered to 0.8 to improve segmentation flexibility.

[0089] S25. Assign an ID to each clause according to the order in which each clause appears in the target text, and generate structured data with a sequence ID.

[0090] Ultimately, the sliced ​​clauses are encapsulated as structured data units containing sequence IDs and original position information. This design not only ensures the efficiency of parallel reasoning, but also avoids the semantic gaps caused by traditional clause segmentation by preserving semantic relevance, providing high-quality input units for the subsequent construction of implicit thought chains.

[0091] S26. Input the structured data of each clause into the language model and obtain the semantic vector of each clause through model encoding.

[0092] In the embodiment of the present invention, a preset model inference service engine is used to generate an inference task based on each clause, and each inference task corresponds to a thread; multi-threaded parallel processing is performed based on the processor occupancy.

[0093] Specifically, the parallel inference module, based on VLLM management of large language models (LLMs), leverages VLLM's acceleration mechanism to deliver efficient and stable parallel processing using GPU resources. VLLM employs PagedAttention technology to store the key-value cache required for attention calculations in pages, effectively reducing GPU memory fragmentation and significantly improving memory utilization. Leveraging this VLLM feature, the module can process more inference tasks on a single GPU, thereby enhancing overall parallel processing capabilities.

[0094] Regarding task scheduling, the module builds a dynamic thread pool scheduling algorithm based on VLLM's asynchronous inference interface. Each thread in the thread pool corresponds to an independent inference task, which is then submitted to the VLLM's inference engine for processing. The module monitors GPU memory usage in real time. When memory usage exceeds a preset threshold (for example, 90%), the system automatically reduces the number of concurrent threads and places new inference tasks in the task queue. Furthermore, to avoid the overhead of frequent thread creation and destruction, the module maintains a certain number of idle threads so that they can be quickly reactivated once memory resources are freed up.

[0095] To ensure system stability under high load, the module has designed a comprehensive exception handling mechanism. During the inference process, if a clause's inference task times out or fails, the system will assess the situation based on the VLLM's error feedback, automatically reduce the number of concurrent threads, and re-queue the task. If failure persists after multiple retries, the system will log a detailed error message, including task information, error type, and time of occurrence. The clause will then be skipped and other tasks will be processed, preventing single points of failure from impacting the entire inference process.

[0096] Furthermore, the structured data of each clause is input into the language model and encoded by the model to obtain the semantic vector of each clause.

[0097] S27. Retrieve the corresponding knowledge semantic vector in the target domain knowledge base corresponding to the target text based on the semantic vector of each clause.

[0098] S28. Compare the similarity between the semantic vector of each clause and the knowledge semantic vector, and determine the knowledge item most relevant to each clause.

[0099] In the implicit thinking chain construction module, when using pre-trained language models for deep semantic analysis, the model is fine-tuned based on the characteristics of different domains to better adapt to the text semantic understanding needs of specific fields. At the same time, when combining specific domain knowledge bases to build logical reasoning chains, the content of the knowledge base is updated and maintained in real time based on updates to industry regulations and fluctuations in public opinion, thereby ensuring the accuracy and effectiveness of the logical reasoning chain.

[0100] Specifically, in the construction of the logical reasoning chain, a retrieval enhancement architecture is adopted. The clause is encoded by the model to obtain the semantic vector , input it into the (Facebook AI Similarity Search, FAISS) vector database for retrieval. Assume that there is domain knowledge items, and the vector corresponding to each item is , by calculating the semantic vector and Similarity To determine the most relevant knowledge items. The commonly used similarity calculation method is cosine similarity:

[0101]

[0102] Sort by similarity and select the first The most relevant knowledge items form a knowledge set , are added to the original clause as additional context. These knowledge items are like adding more background information to the original clause, enriching the original clause's information. The original clause has limited information. When adding relevant knowledge items as context, the model can better understand the clause's semantics. When building a logical reasoning chain, this supplementary contextual knowledge can serve as a basis for reasoning. Rich contextual knowledge can help the model avoid incorrect reasoning. If the model only has the original clause, it may make incorrect associations or inferences due to insufficient information. However, additional contextual knowledge can provide correct guidance.

[0103] The domain knowledge base maintains real-time performance through an asynchronous update mechanism. For a specific domain knowledge base, an incremental update scheme is implemented. Taking the legal document database as an example, assuming that the original database stores a collection of legal documents: , the newly acquired legal text set is , calculate the hash value of each text through the SimHash algorithm , by comparing the Hamming distance of the hash values To detect text changes, when it exceeds a certain threshold, the text is considered to have changed, and only the changed part is synchronized to the vector database to reduce the update cost.

[0104] S29. Using the knowledge item as a constraint condition, perform semantic parsing on the structured data of each clause to identify the error type in the structured data.

[0105] S210: Adjust an error correction path based on the error type, and re-identify error information in the structured data based on the adjusted error correction path.

[0106] S211: Reorganize the multiple clauses based on the sequence ID and the error content, error type, and error position, and generate an error correction result including the error position, error type, and correction suggestion.

[0107] The dynamic strategy optimization module, as the core component of the text intelligent error correction system, consists of two key parts: fine-tuning the model for accurate error category judgment, and path selection based on preliminary judgment results to alleviate excessive error correction.

[0108] During the model fine-tuning phase, the module uses LoRA (Low-Rank Adaptation) technology to efficiently adapt the pre-trained large language model (LLM). The backbone parameters that are classified as frozen and trainable low-rank matrix parameters . Assume that the weight matrix of the model is , after LoRA adjustment becomes , and its calculation formula is:

[0109]

[0110] in, Is the shape of The low-rank matrix, Is the shape of The low-rank matrix, is the rank of the low-rank matrix, is the dimension of the original weight matrix. In this way, the number of trainable parameters is greatly reduced, significantly reducing the memory requirements.

[0111] During the training process, a special loss function is designed to make the model better adapt to the semantic understanding requirements of text in a specific knowledge domain. Taking cross-sentence logical error recognition as an example, assuming that the input text contains clauses, each clause The corresponding true label is , the model prediction result is , using the triplet loss function (Triplet Loss) to optimize the model:

[0112]

[0113] in, is the anchor sample, is a positive sample, is a negative sample, is a distance metric function (such as Euclidean distance), is a boundary parameter. This loss function forces the model to learn the logical relationships between different clauses, improving its ability to identify problems such as time contradictions and knowledge errors. By continuously adjusting the parameters of the trainable low-rank matrix, the model reaches the optimal value under this loss function, enabling it to accurately identify possible error categories in the text.

[0114] After the above fine-tuning, the model can make a preliminary error classification judgment on the input text. Figure 3This is the error correction type supported by the embodiment of the present invention. Another part of the dynamic strategy optimization module will use this preliminary judgment result as the basis for path selection. If the preliminary judgment result shows that the text does not involve a certain type of error, the system will adaptively adjust the error correction path and skip the inspection module for this type of error, thereby alleviating the problem of excessive error correction and improving the processing efficiency of the entire system. For example, if the model determines that the text does not involve professional terminology, or only involves conventional expressions, the system will not start the inspection process for knowledge errors and will invest more resources in areas where errors may exist. In this way, the dynamic strategy optimization module achieves efficient resource utilization and improved system performance while ensuring the accuracy of error correction.

[0115] S212: Perform a confidence score on each error message in the error correction result.

[0116] S213: Integrate error information for each error type in the error correction result based on the confidence score.

[0117] The result integration module, the final output hub of the intelligent text correction system, efficiently presents structured correction results through sequence reorganization, confidence assessment, and dynamic filtering. After receiving the correction request results for each clause initiated during the parallel reasoning phase, this module constructs an ordered data structure based on the clause sequence IDs and integrates the results of these parallel requests in the original text order.

[0118] In terms of confidence assessment, the module uses a specially designed confidence scoring model to score each error item. The model uses a hierarchical weighted algorithm, and its core formula is:

[0119]

[0120] in, The error harm level weight. For example, if a time error seriously affects the accuracy of the content, the harm level will be higher, such as 4. To describe the matching weight, we use a domain-specific fine-tuned large language model (LLM) to calculate the matching degree between the error description and the actual text; The contextual consistency weight is used to verify the logical coherence of the correction suggestion with the surrounding context through dependency syntactic analysis. Hazard(e), Match(d), and Contexd(c) are all set to a 5-point scale. Hazard(e) represents the current error level score, taking the error category as input. The highest score of 5 indicates the most significant error. A preset error list ranks the error categories. Match(d) represents the current description consistency score, taking the error category, error location, error correction content, and error suggestion as input. It evaluates the consistency of the four. Because model generation is unstable, mismatches between the four may occur. The highest score of 5 indicates that the four descriptions are consistent. Contexd(c) represents the coherence of the correction result in the original text. It takes the correction content and context as input. It evaluates whether the current correction result is abrupt in the original text. The highest score of 5 indicates that it is consistent with the original text.

[0121] The confidence rating scale is set on a 1-5 point scale, with 3 and above being considered credible errors and 5 indicating a high confidence level of serious errors that must be corrected.

[0122] In the dynamic filtering phase, the system supports multi-dimensional filtering strategies. For repeatedly pointed out errors, a location-based clustering algorithm is used: first, the errors are grouped according to the location where the error occurred (clause ID and text offset), for example, multiple error descriptions within the same clause are grouped together; then, within each cluster group, they are sorted in descending order by confidence score, retaining only the error description with the highest confidence. This method ensures that the most credible suggestions are retained among different error descriptions in the same location, avoiding redundant prompts. In specific scenarios, regular expressions are also used to automatically block correction suggestions involving sensitive information. Errors with a confidence score below 3 are automatically ignored through a threshold filtering mechanism.

[0123] Finally, the result integration module will sort the filtered and sorted correction results in descending order of error hazard level, and provide correction suggestions, original text snippets, and confidence star ratings for each error, presenting them to users in a clear and structured manner.

[0124] The core of the embodiment of the present invention lies in the collaborative architecture of implicit thinking chain verification and dynamic reasoning path optimization. First, the long text is decomposed into logically related clause units according to semantic boundaries through multi-granularity slicing technology, while retaining the strong correlation between adjacent clauses to avoid semantic fragmentation, forming a structured processing unit; then a dynamic thread scheduling mechanism is used to perform parallel reasoning on the sliced ​​clauses, and the concurrency is adjusted by real-time monitoring of the system resource usage status, thereby improving the processing efficiency while ensuring the depth of semantic analysis, and introducing a task retry mechanism to ensure the stability of reasoning. At the semantic parsing layer, the system uses a domain-adapted pre-trained language model to deeply encode the text, and combines it with a real-time updated standard terminology library, sensitive word library and other specific domain knowledge bases to construct a logical reasoning chain containing specific domain knowledge constraints, thereby accurately capturing deep problems such as non-standard professional expressions and cross-sentence reference errors.

[0125] The dynamic strategy optimization module, serving as the system's decision-making hub, adaptively adjusts the error correction path based on error type (e.g., grammatical errors, knowledge errors) and contextual features. For example, if the initial judgment is that the content does not involve a certain type of error, the error correction path will be adaptively adjusted to mitigate over-correction and improve overall efficiency. Finally, the result integration module reorganizes the clauses into their original sequence and generates a structured report containing the error location, type, and correction suggestions. Errors are prioritized based on confidence scores to ensure that high-risk errors are presented first.

[0126] The innovation of the embodiment of the present invention lies in the deep integration of "dynamic reasoning driven by domain knowledge" and "multi-dimensional semantic collaborative verification". By combining implicit thinking chain modeling with adaptive error correction strategies, the system not only solves the semantic fault problem of static models in long text processing, but also realizes the collaborative correction of grammatical, semantic and logical errors. Its technical value lies in providing an error correction paradigm that takes into account both efficiency and accuracy for high-risk areas. Through a real-time updated knowledge base and a dynamic path optimization mechanism, it can effectively respond to dynamic contextual challenges such as industry standard updates and social public opinion fluctuations, and provide innovative solutions for the industrial implementation of text intelligent error correction technology.

[0127] The text error correction device provided by the present invention is described below. The text error correction device described below and the text error correction method described above can be referenced to each other.

[0128] Figure 5 This is a schematic diagram of the structure of the text error correction device provided by the present invention, which specifically includes:

[0129] The acquisition module 501 is used to acquire the target text to be corrected. Detailed descriptions can be found in the corresponding descriptions of the above method embodiments, which will not be repeated here.

[0130] The boundary recognition module 502 is used to perform semantic boundary recognition on the target text to obtain all semantic boundaries of the target text. Detailed descriptions can be found in the corresponding descriptions of the above method embodiments, which will not be repeated here.

[0131] The text segmentation module 503 is configured to segment the target text into multiple clauses based on all semantic boundaries, assign an ID to each clause according to the order in which it appears in the target text, and generate structured data with sequence IDs. For detailed descriptions, please refer to the corresponding descriptions of the above method embodiments and will not be repeated here.

[0132] Error identification module 504 is configured to input the structured data of each clause into a language model and perform semantic parsing on the structured data using the target domain knowledge base corresponding to the target text as constraints to identify the types of errors in the structured data. For detailed descriptions, please refer to the corresponding descriptions of the above method embodiments and will not be repeated here.

[0133] The error identification module 504 is further configured to adjust an error correction path based on the error type and re-identify error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type, and error location. For detailed descriptions, please refer to the corresponding descriptions of the above method embodiments and will not be repeated here.

[0134] The error correction module 505 is configured to reorganize the plurality of clauses based on the sequence ID and the error content, error type, and error location, and generate an error correction result including the error location, error type, and correction suggestions. For detailed description, please refer to the corresponding description of the above method embodiment, which will not be repeated here.

[0135] Figure 6 An example of a physical structure diagram of an electronic device is shown below. Figure 6As shown, the electronic device may include: a processor 810 , a communication interface 820 , a memory 830 and a communication bus 840 , wherein the processor 810 , the communication interface 820 and the memory 830 communicate with each other via the communication bus 840 . The processor 810 can call the logic instructions in the memory 830 to execute a text correction method, which includes: obtaining a target text to be corrected; performing semantic boundary recognition on the target text to obtain all semantic boundaries of the target text; based on all semantic boundaries, dividing the target text into multiple clauses, and assigning an ID to each clause according to the order in which each clause appears in the target text, generating structured data with a sequence ID; inputting the structured data of each clause into a language model, and calling the target domain knowledge base corresponding to the target text as a constraint condition to perform semantic parsing on the structured data, and identifying the error type in the structured data; adjusting the error correction path based on the error type, and re-identifying the error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type and error location; reorganizing the multiple clauses based on the sequence ID and the error content, error type and error location, and generating an error correction result including the error location, error type and correction suggestion.

[0136] Furthermore, the logic instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product, stored in a storage medium, includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.

[0137] On the other hand, the present invention also provides a computer program product, comprising a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the text correction method provided by the above methods, the method comprising: obtaining a target text to be corrected; performing semantic boundary recognition on the target text to obtain all semantic boundaries of the target text; based on all semantic boundaries, dividing the target text into multiple clauses, and assigning an ID to each clause according to the order in which each clause appears in the target text, thereby generating structured data with a sequence ID; inputting the structured data of each clause into a language model, and calling a target domain knowledge base corresponding to the target text as a constraint condition to perform semantic parsing on the structured data to identify the error type in the structured data; adjusting an error correction path based on the error type, and re-identifying error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type, and error location; and reorganizing the multiple clauses based on the sequence ID and the error content, error type, and error location to generate an error correction result including the error location, error type, and correction suggestion.

[0138] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the text correction method provided by the above-mentioned methods, the method comprising: obtaining a target text to be corrected; performing semantic boundary recognition on the target text to obtain all semantic boundaries of the target text; based on all semantic boundaries, dividing the target text into multiple clauses, and assigning an ID to each clause according to the order in which each clause appears in the target text, thereby generating structured data with a sequence ID; inputting the structured data of each clause into a language model, and calling the target domain knowledge base corresponding to the target text as a constraint condition to perform semantic parsing on the structured data, and identifying the error type in the structured data; adjusting the error correction path based on the error type, and re-identifying the error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type and error location; reorganizing the multiple clauses based on the sequence ID and the error content, error type and error location, and generating an error correction result including the error location, error type and correction suggestion.

[0139] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0140] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.

[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A text error correction method, characterized in that: include: Obtain the target text to be corrected; Performing semantic boundary recognition on the target text to obtain all semantic boundaries of the target text; Based on all the semantic boundaries, the target text is divided into a plurality of clauses, and an ID is assigned to each clause according to the order in which each clause appears in the target text, thereby generating structured data with a sequence ID; Inputting the structured data of each clause into the language model, and calling the target domain knowledge base corresponding to the target text as a constraint condition to perform semantic parsing on the structured data, and identifying the error type in the structured data; Inputting the structured data of each clause into the language model, and using the target domain knowledge base corresponding to the target text as a constraint to perform semantic parsing on the structured data, and identifying the error type in the structured data, includes: Input the structured data of each clause into the language model and obtain the semantic vector of each clause through model encoding; Retrieving the corresponding knowledge semantic vector in the target domain knowledge base corresponding to the target text based on the semantic vector of each clause; Comparing the similarity between the semantic vector of each clause and the knowledge semantic vector to determine the knowledge item most relevant to each clause; Using the knowledge item as a constraint condition, semantically parsing the structured data of each clause to identify error types in the structured data; adjusting an error correction path based on the error type, and re-identifying error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type, and error location; The plurality of clauses are reorganized based on the sequence ID and the error content, error type and error position to generate an error correction result including the error position, error type and correction suggestion.

2. The method according to claim 1, characterized in that The method further comprises: Performing a confidence score on each error message in the error correction result; Based on the confidence score, error information integration is performed for each error type in the error correction result, wherein the error information integration includes streamlining error prompts and filtering error information with a confidence score lower than a threshold.

3. The method according to claim 1, characterized in that The performing semantic boundary recognition on the target text to obtain all semantic boundaries of the target text includes: Identify punctuation marks of the target text using a semantic boundary recognition algorithm; Segmenting the target text into a plurality of first short sentences based on the punctuation marks; Semantic features of the plurality of first short sentences are identified, and semantic boundaries are identified based on the semantic features to obtain all semantic boundaries of the target text.

4. The method according to claim 3, characterized in that The step of segmenting the target text into a plurality of clauses based on all the semantic boundaries comprises: Based on all the semantic boundaries, segmenting the target text into a plurality of second short sentences; Extracting a semantic embedding vector of each second short sentence, and calculating the cosine similarity of adjacent second short sentences based on the semantic embedding vector; Determining whether there is a dependency relationship between the second short sentence pairs whose cosine similarity is greater than a threshold; If it is determined that there is a dependency relationship between the second short sentence pairs, the second short sentence pairs are combined into independent clauses to obtain a plurality of clauses into which the target text is segmented.

5. The method according to claim 1, characterized in that The method further comprises: Through the preset model inference service engine, an inference task is generated based on each clause, and each inference task corresponds to a thread; Multi-threaded parallel processing is performed based on processor occupancy.

6. The method according to claim 2, characterized in that The integrating error information for each error type in the error correction result based on the confidence score includes: If there are multiple error messages in each error type, arranging the multiple error messages in descending order based on the confidence scores from high to low; In each error type, the target error information with the highest confidence is retained; Generate correction suggestions for the target error information retained in each error type.

7. A text error correction device, characterized in that: include: An acquisition module is used to obtain the target text to be corrected; A boundary recognition module is used to perform semantic boundary recognition on the target text to obtain all semantic boundaries of the target text; a text segmentation module, configured to segment the target text into a plurality of clauses based on all semantic boundaries, and assign an ID to each clause according to the order in which each clause appears in the target text, thereby generating structured data with sequence IDs; An error identification module is used to input the structured data of each clause into the language model, and use the target domain knowledge base corresponding to the target text as a constraint to perform semantic analysis on the structured data and identify the error type in the structured data; The method of inputting the structured data of each clause into the language model, and calling the target domain knowledge base corresponding to the target text as a constraint condition to perform semantic parsing on the structured data, and identifying the error type in the structured data, includes: inputting the structured data of each clause into the language model to obtain the semantic vector of each clause through model encoding; retrieving the corresponding knowledge semantic vector in the target domain knowledge base corresponding to the target text based on the semantic vector of each clause; comparing the similarity between the semantic vector of each clause and the knowledge semantic vector to determine the knowledge item most relevant to each clause; and using the knowledge item as a constraint condition to perform semantic parsing on the structured data of each clause, and identifying the error type in the structured data; The error identification module is further configured to adjust an error correction path based on the error type, and re-identify error information in the structured data based on the adjusted error correction path, wherein the error information includes error content, error type, and error location; The error correction module is configured to reorganize the plurality of clauses based on the sequence ID and the error content, error type, and error position, and generate an error correction result including the error position, error type, and correction suggestion.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the text error correction method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the text error correction method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Remote consultation record text error correction method based on natural language processing

    CN110110334A

  • Medical text error correction method and device, storage medium and electronic equipment

    CN115048937A