Text processing method and device, electronic equipment and storage medium
By extracting contextual information and combining user needs, large language models are used for text error correction, which solves the accuracy problem of traditional methods in processing new words, slang and terminology in specific fields, and achieves higher error correction accuracy and flexibility. .
Patent Information
- Application Number
- CN202410875229.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-30
- Publication Date
- 2024-10-15
AI Technical Summary
Traditional document error correction methods are not very accurate when faced with new words, slang or terminology in specific fields, and are difficult to cope with language evolution and contextual changes, resulting in a decrease in error correction accuracy.
By obtaining the semantics of the text to be processed, extracting contextual information and combining the user's error correction needs, a large language model is used for error correction processing, and error correction prompt text is generated to improve error correction accuracy and flexibility.
It improves the accuracy and flexibility of text error correction, makes text expression more accurate and smooth, and can adjust context more finely to adapt to language changes.
Smart Images

Figure CN118780288A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of natural language processing and artificial intelligence, and in particular to a text processing method, device, electronic device and storage medium. Background Art
[0002] In the field of traditional document error correction, error correction methods mainly rely on word library matching or sequence tagging technology. These traditional methods, whether they are compared through a huge word library or identified using complex sequence tagging rules, are based on pre-defined knowledge or patterns to perform error correction tasks. However, with the continuous evolution of language and the dynamic changes in context, this static and fixed error correction method has gradually revealed its limitations. Specifically, the traditional word library error correction method mainly identifies and replaces incorrect words by comparing with pre-defined correct words. However, when faced with new words, slang or terms in specific fields, it often seems powerless because these words may not be included in the word library. Similarly, sequence tagging rules are also designed based on historical data and linguists' understanding of language structure. Although they can identify and correct grammatical errors to a certain extent, they are difficult to cope with flexible and changeable contexts and expressions. Precisely because these methods are based on fixed knowledge and patterns, their error correction accuracy is often greatly reduced when faced with changing contexts. For example, with the emergence of Internet slang and popular words, traditional error correction methods are difficult to accurately identify these emerging expressions, and may even misjudge them as errors. Therefore, the error correction accuracy of traditional document error correction methods is not high. Summary of the invention
[0003] The embodiment of the present invention provides a text processing method, which aims to solve the problem of low error correction accuracy in existing document error correction methods. The context information is extracted by using the semantics to be processed, and the context information is used as error correction auxiliary information for the text to be processed. The context information and the user's error correction requirements are comprehensively used to improve the accuracy and flexibility of text error correction. At the same time, the text can be adjusted more finely according to the context, making the text expression more accurate and fluent.
[0004] In a first aspect, an embodiment of the present invention provides a text processing method, the method comprising the following steps:
[0005] Obtain the text to be processed and the error correction requirements;
[0006] Determining at least one type of context information of the text to be processed according to the semantics of the text to be processed;
[0007] Generate an error correction prompt text based on the text to be processed, the error correction requirement and at least one type of context information;
[0008] The error correction prompt text is input into a large language model for error correction processing, and the target text is obtained through the output of the large language model.
[0009] Optionally, determining at least one type of context information of the text to be processed according to the semantics of the text to be processed includes:
[0010] Extracting context words from the text to be processed to obtain context word distribution of the text to be processed;
[0011] Based on the context word distribution, the text to be processed is segmented to obtain at least one segmented text;
[0012] Determining at least one context information of the segmented text according to the semantics of the segmented text;
[0013] At least one type of context information of the text to be processed is determined according to at least one context of the segmented text.
[0014] Optionally, the segmenting of the text to be processed based on the context word distribution to obtain at least one segmented text includes:
[0015] Determining the text distance between two adjacent context words according to the context word distribution;
[0016] If the text distance between the two adjacent context words is greater than or equal to a preset text distance threshold, a segmentation point is determined between the two adjacent context words, and the to-be-processed text is segmented based on the segmentation point to obtain at least two segmented texts;
[0017] If the text distance between the two adjacent context words is less than a preset text distance threshold, the text to be processed is segmented based on the first context word and the last context word to obtain a segmented text.
[0018] Optionally, if the text distance between the two adjacent context words is greater than or equal to a preset text distance threshold, a segmentation point is determined between the two adjacent context words, and the to-be-processed text is segmented based on the segmentation point to obtain at least two segmented texts, including:
[0019] In the two adjacent context words, a first segmentation point is determined according to the contextual semantics of the preceding context word, and a second segmentation point is determined according to the contextual semantics of the succeeding context word;
[0020] If the first segmentation point is before the second segmentation point, segmenting the text to be processed based on the first segmentation point and the second segmentation point to obtain at least two segmented texts;
[0021] If the first segmentation point is after the second segmentation point, a third segmentation point is determined between the first segmentation point and the second segmentation point, and the text to be processed is segmented based on the third segmentation point to obtain at least two segmented texts.
[0022] Optionally, determining at least one context information of the segmented text according to the semantics of the segmented text includes:
[0023] Extracting semantic features of the segmented text;
[0024] The semantic features are subjected to context classification processing to obtain at least one context information of the segmented text.
[0025] Optionally, generating an error correction prompt text based on the text to be processed, the error correction requirement, and at least one type of context information includes:
[0026] If the context information of the text to be processed is a type of context information, then based on the text to be processed, the error correction requirement and the type of context information, generate an error correction prompt text;
[0027] If the context information of the text to be processed is multiple types of context information, obtaining at least one segmented text corresponding to each type of context information;
[0028] Based on at least one segmented text corresponding to each type of the context information, generate an error correction subtext corresponding to each type of the context information, wherein each type of the context information corresponds to one error correction subtext;
[0029] Based on the text to be processed, the error correction requirement and one error correction sub-text corresponding to each type of context information, an error correction prompt text is generated.
[0030] Optionally, generating an error correction subtext corresponding to each type of the context information based on at least one segmented text corresponding to each type of the context information includes:
[0031] For a type of the context information, if it corresponds to only one segmented text, the segmented text is determined as an error correction sub-text corresponding to the type of the context information;
[0032] If it corresponds to multiple segmented texts, sort the multiple segmented texts;
[0033] Performing summary generation processing on two adjacent segmented texts to obtain a summary text between the two adjacent segmented texts;
[0034] Based on the summary text between the two adjacent segmented texts, splicing the two adjacent segmented texts;
[0035] After the splicing is completed, a correction sub-text corresponding to each type of context information is obtained.
[0036] In a second aspect, an embodiment of the present invention further provides a text processing device, the text processing device comprising:
[0037] The acquisition module is used to obtain the text to be processed and the error correction requirements;
[0038] A first processing module, configured to determine at least one type of context information of the text to be processed according to the semantics of the text to be processed;
[0039] A second processing module, configured to generate an error correction prompt text based on the text to be processed, the error correction requirement and at least one type of context information;
[0040] The third processing module is used to input the error correction prompt text into the large language model for error correction processing, and obtain the target text through the output of the large language model.
[0041] In a third aspect, an embodiment of the present invention 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 the steps of the text processing method provided in the embodiment of the present invention when executing the computer program.
[0042] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the text processing method provided in the embodiment of the invention are implemented.
[0043] In the embodiment of the present invention, the text to be processed and the error correction requirements are obtained; at least one type of context information of the text to be processed is determined according to the semantics of the text to be processed; based on the text to be processed, the error correction requirements and at least one type of context information, an error correction prompt text is generated; the error correction prompt text is input into the large language model for error correction processing, and the target text is obtained through the output of the large language model. The context information is extracted using the semantics to be processed, and the context information is used as the error correction auxiliary information of the text to be processed. The context information and the user's error correction requirements are comprehensively used to improve the accuracy and flexibility of text error correction. At the same time, the text can be adjusted more finely according to the context to make the text expression more accurate and fluent. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0045] Figure 1 is a flowchart of a text processing method provided by an embodiment of the present invention;
[0046] Figure 2 is a structural schematic diagram of a text processing device provided in an embodiment of the present invention;
[0047] Figure 3 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] like Figure 1 As shown, Figure 1 is a flowchart of a text processing method provided by an embodiment of the present invention, comprising:
[0050] 101. Obtain the text to be processed and the error correction requirements.
[0051] In an embodiment of the present invention, the above-mentioned text processing method can be applied to a text processing platform or application program for implementing text processing. The above-mentioned text processing platform can be built based on a server or a distributed server. The above-mentioned text processing platform is deployed with functional applications supporting text processing such as text processing applications, large language models or interfaces of large language models. The above-mentioned text processing application can call the large language model through an interface to perform text processing. The above-mentioned text processing is text error correction processing, which is mainly used to correct erroneous sentences in the text to be processed.
[0052] The above-mentioned text processing platform is communicatively connected with the user terminal, and the user can upload a text processing request through the user terminal. The above-mentioned text processing request may include the pending text that the user needs to process and the error correction requirements of the user's intention. The above-mentioned pending text is the text that the user needs to correct. The above-mentioned error correction requirements may include error correction type, error correction content, error correction method, etc. For example, the above-mentioned error correction type may be network language correction, dialect correction, basic error correction, etc., the above-mentioned error correction content may be "change 'xx' to 'yy'", "change 'network language' to 'formal language'", etc., and the above-mentioned error correction method may be replacement, annotation, marking, etc.
[0053] The above error correction requirements may be one or more. If there are multiple error correction requirements, the multiple error correction requirements may be sorted in a default order.
[0054] 102. Determine at least one type of context information of the text to be processed based on the semantics of the text to be processed.
[0055] In an embodiment of the present invention, after obtaining the text to be processed, semantic features can be extracted from the text to be processed through a semantic extraction tool (such as a transformer model, an LSTM model, etc.), and the semantic features can be contextually classified to obtain a context classification result, which includes at least one type of context information. The context classification result is determined as the context information of the text to be processed, and at least one type of context information of the text to be processed is obtained.
[0056] In a possible embodiment, the text to be processed can be analyzed at the lexical level to identify key words, phrases and their mutual relations. Through syntactic analysis, the structure of sentences in the text to be processed, such as subject, predicate, object, attributive, adverbial, complement, etc., is determined, so as to have a deeper understanding of the semantic structure in the text to be processed. Context association and sentiment analysis are performed on the basis of lexical analysis and syntactic analysis. The contextual relationship in the text to be processed is analyzed through context association, and the actual meaning of rhetoric devices such as pronouns, metaphors and metaphors is identified and understood. The sentiment tendency of the text to be processed, such as positive, negative or neutral, is judged through sentiment analysis, so as to assist in determining the context and emotional background of the text. Theme identification and scene restoration are performed on the basis of context association and sentiment analysis. Keywords and sentences in the text to be processed are identified through theme identification, and the theme of the text to be processed is identified. By trying to restore the scene or situation described in the text to be processed, including time, place, character relationship, etc., the context is understood more comprehensively. Common sense reasoning and domain knowledge matching are performed on the basis of theme identification and scene restoration. Through common sense reasoning, combined with common sense and general knowledge, the information in the text to be processed is reasoned and supplemented to enrich the contextual information of the text to be processed. According to the subject of the text to be processed, the field to which the text to be processed belongs is determined, and the knowledge of the field to which the text to be processed belongs is matched to understand the context more accurately. After common sense reasoning and field knowledge matching, the final context information is determined as at least one type of context information of the text to be processed.
[0057] 103. Generate an error correction prompt text based on the text to be processed, the error correction requirement, and at least one type of context information.
[0058] In an embodiment of the present invention, text correction can be achieved through a large language model. The above-mentioned large language model can be a dedicated large language model or an existing open source large language model. The embodiment of the present invention does not limit the specific large language model in accordance with laws and regulations.
[0059] The text to be processed, the error correction requirement and at least one type of context information can be filled into a preset error correction prompt template to obtain the error correction prompt text. Alternatively, a generative text model can be used. Specifically, the pre-prepared text to be processed, the error correction requirement and at least one type of context information are used as sample data, and the pre-prepared error correction prompt text is used as the label of the sample data. A generative text model for outputting the error correction prompt text is trained by a supervised training method. After the training is completed, a trained generative text model is obtained. The text to be processed, the error correction requirement and at least one type of context information are input into the trained generative text model, and the error correction prompt text is output by the trained generative text model.
[0060] 104. Input the error correction prompt text into the large language model for error correction processing, and obtain the target text through the output of the large language model.
[0061] In an embodiment of the present invention, after obtaining the error correction prompt text, the error correction prompt text is used to guide the large language model to perform error correction processing on the text to be processed, so that the large language model can perform more detailed error correction on the text to be processed according to the error correction requirements and context information.
[0062] The text output by the large language model is used as the target text.
[0063] In a possible embodiment, the target text may include error correction marks or annotations. After obtaining the target text, the target text may be returned to the user terminal for display, and the user may confirm the target text displayed by the user terminal.
[0064] In the embodiment of the present invention, the text to be processed and the error correction requirements are obtained; at least one type of context information of the text to be processed is determined according to the semantics of the text to be processed; based on the text to be processed, the error correction requirements and at least one type of context information, an error correction prompt text is generated; the error correction prompt text is input into the large language model for error correction processing, and the target text is obtained through the output of the large language model. The context information is extracted using the semantics to be processed, and the context information is used as the error correction auxiliary information of the text to be processed. The context information and the user's error correction requirements are comprehensively used to improve the accuracy and flexibility of text error correction. At the same time, the text can be adjusted more finely according to the context to make the text expression more accurate and fluent.
[0065] It should be noted that the text processing method provided in the embodiment of the present invention can be applied to electronic devices such as mobile phones, tablets, computers, servers, etc. that can perform text processing.
[0066] It is understandable that in the specific implementation of this application, text data, user data and other related data are involved. When the embodiments in this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data, as well as the training, deployment and calling of large language models, must comply with relevant laws, regulations and standards of relevant countries and regions.
[0067] Optionally, in the step of determining at least one type of contextual information of the text to be processed based on the semantics of the text to be processed, contextual words can be extracted from the text to be processed to obtain the contextual word distribution of the text to be processed; based on the contextual word distribution, the text to be processed is segmented to obtain at least one segmented text; according to the semantics of the segmented text, at least one contextual information of the segmented text is determined; according to at least one context of the segmented text, at least one type of contextual information of the text to be processed is determined.
[0068] In an embodiment of the present invention, the context words may include geographical words, humanities words, domain words, etc. The context words may reflect the scene, emotion, theme, etc. described in the text to be processed. The text to be processed includes at least a plurality of context words, and the plurality of context words are distributed in different text positions in the text to be processed.
[0069] The context words and the text positions of the context words in the text to be processed can be extracted from the text to be processed by a word extraction tool or algorithm, thereby obtaining the distribution of the context words in the text to be processed.
[0070] After obtaining the distribution of context words, the text to be processed can be segmented according to the distribution of the context words.
[0071] In a possible embodiment, the principle of segmentation is based on the relevance and closeness between context words. First, the context words are sorted in order according to the text position. If the distance between two adjacent context words is close, it means that the context relevance between the adjacent context words is high and they can be divided into the same paragraph; on the contrary, if the distance is far, it may mean a change in context and segmentation should be performed. By segmenting the text to be processed according to the distribution of context words, the text to be processed can be split into several segmented texts with relatively independent contexts, which facilitates a more detailed analysis of the context information of each segmented text later, thereby improving the accuracy of the context information.
[0072] After obtaining the segmented texts, a semantic analysis is performed on each segmented text to determine the contextual information corresponding to each segmented text. Specifically, this can be achieved through natural language processing technology or machine learning algorithms. Specifically, the semantic features of each segmented text can be extracted through word vectors, topic models and other methods, and then context classification is performed based on the semantic features. For example, a segmented text describes content related to "Northeastern dialect", while another segmented text may involve content in the field of "Silicon Valley Technology". After classification processing based on the semantic features of the segmented texts, at least one contextual information corresponding to each segmented text can be obtained.
[0073] After obtaining at least one context information corresponding to each segmented text, the overall context information of the text to be processed is comprehensively determined according to the context information of each segmented text. It should be noted that, since a text may contain multiple segmented texts, that is, contain context information corresponding to multiple segmented texts, it is necessary to integrate and summarize these context information. Specifically, if the context information corresponding to multiple segmented texts is of the same category, the context information of the category to which the context information corresponding to the multiple segmented texts belongs is determined as the context information of the text to be processed. If the context information corresponding to multiple segmented texts is not of the same category, the frequency and importance of the context information of each segmented text can be counted, and then the context information with high frequency of occurrence or great importance is selected as the main context of the text to be processed. At the same time, other minor context information can also be retained to provide a more comprehensive text description. Obtain at least one category of context information of the text to be processed, and provide a more accurate context background for subsequent text error correction.
[0074] Optionally, in the step of segmenting the processed text based on the distribution of context words to obtain at least one segmented text, the text distance between two adjacent context words can be determined according to the distribution of context words; if the text distance between two adjacent context words is greater than or equal to a preset text distance threshold, a segmentation point is determined between the two adjacent context words, and the processed text is segmented based on the segmentation point to obtain at least two segmented texts; if the text distance between two adjacent context words is less than the preset text distance threshold, the processed text is segmented based on the first context word and the last context word to obtain a segmented text.
[0075] In an embodiment of the present invention, after obtaining the context word distribution of the text to be processed, the text distance between two adjacent context words can be calculated according to the text positions of the two adjacent context words in the text to be processed. The above text distance can be understood as the number of characters or words between the positions where the two context words appear in the text to be processed. By calculating the text distance between two adjacent context words, the closeness between the two adjacent context words is determined, and then it is decided whether to set a segmentation point between the two adjacent context words.
[0076] The text distance between two adjacent context words is compared with a preset text distance threshold. This threshold is set based on experience or actual needs and is used to determine whether the two adjacent context words are far enough apart so that the text content to which the two adjacent context words belong can be regarded as an independent text content. If the text distance between two adjacent context words is greater than or equal to the text distance threshold, it means that the content between the two adjacent context words is relatively independent, and a segmentation point can be set between the two adjacent context words. After the segmentation point is determined between the two adjacent context words, the segmentation point is used as the basis for dividing the text paragraphs. According to the above segmentation points, the text to be processed is divided into at least two segmented texts. Each segmented text contains a set of closely related context words (at least one context word), which can implicitly represent the content or theme of a specific part of the text to be processed.
[0077] If the text distance between two adjacent context words is less than the preset text distance threshold, it means that the two adjacent context words are closely connected in the text, and it is difficult to separate the content between the two adjacent context words into independent segments. In this case, you can choose to segment the entire text to be processed based on the first context word and the last context word, so as to obtain a larger segmented text. This ensures that closely related context words will not be mistakenly segmented into different segmented texts, maintaining the coherence and integrity of the segmented text.
[0078] According to the distribution of context words and the text distance between context words, the text to be processed is segmented reasonably, so that segmented text with relatively independent context can be obtained, thereby improving the accuracy of context information.
[0079] Optionally, if the text distance between two adjacent context words is greater than or equal to a preset text distance threshold, a segmentation point is determined between the two adjacent context words, and the text to be processed is segmented based on the segmentation point to obtain at least two segmented texts. In the step, a first segmentation point can be determined in the two adjacent context words according to the contextual semantics of the preceding context word, and a second segmentation point can be determined according to the contextual semantics of the succeeding context word; if the first segmentation point is before the second segmentation point, the text to be processed is segmented based on the first segmentation point and the second segmentation point to obtain at least two segmented texts; if the first segmentation point is after the second segmentation point, a third segmentation point is determined between the first segmentation point and the second segmentation point, and the text to be processed is segmented based on the third segmentation point to obtain at least two segmented texts.
[0080] In an embodiment of the present invention, when the text distance between two adjacent context words is greater than or equal to a preset text distance threshold, a segmentation point may be determined between the two context words, and the text to be processed may be segmented according to the segmentation point.
[0081] Specifically, the first segmentation point can be determined according to the contextual semantics of the prior context word. In the text to be processed, the text content before and after the prior context word is determined, and a semantic breakpoint is found (generally speaking, the semantic breakpoint is most likely a context turning point). The breakpoint is used as the first segmentation point, and the text content before the first segmentation point is divided into a segmented text, so that the segmented text remains semantically complete and coherent. Similarly, the second segmentation point can be determined according to the contextual semantics of the subsequent context word, and the text content after the second segmentation point is divided into a segmented text, so that the segmented text remains semantically complete and coherent.
[0082] In a possible embodiment, it should be noted that the text position of the first segmentation point may be after the text position of the second segmentation point, which will cause the two segmented texts to have part of the same text content, causing confusion and intersection of contexts. Therefore, in order to avoid the same text content between the segmented texts, after determining the first segmentation point and the second segmentation point, it is necessary to compare the positional relationship between the first segmentation point and the second segmentation point. If the first segmentation point is before the second segmentation point, this means that the influence range of the preceding context words does not overlap with the influence range of the following context words, i.e., the two segmented texts after segmentation do not have part of the same text content. In this case, the processed text can be directly segmented based on the first segmentation point and the second segmentation point, thereby obtaining at least two segmented texts.
[0083] If the first segmentation point is after the second segmentation point, this indicates that there is an overlap between the influence range of the previous context word and the influence range of the subsequent context word. In order to avoid the same text content between the segmented texts, a new segmentation point, namely the third segmentation point, can be determined between the first segmentation point and the second segmentation point. The selection plan of the above-mentioned third segmentation point is to balance the influence ranges of the two context words as much as possible to ensure that the two segmented texts after segmentation are still semantically coherent and complete. The above-mentioned third segmentation point can be the end or beginning of the paragraph closest to the middle position between the first segmentation point and the second segmentation point.
[0084] After the third segmentation point is determined, the text to be processed can be segmented based on the third segmentation point. This ensures that each segmented text reflects the semantic scope of its internal context words as much as possible, while avoiding context confusion and overlap. In this way, we can obtain at least two semantically relatively independent segmented texts.
[0085] By carefully determining the segmentation points and comparing the positional relationships of each segmentation point, we can ensure that each segmented text accurately reflects the semantic scope of its internal context words, avoid confusion and overlap of contexts, and provide a more accurate basis for subsequent text analysis and error correction processing.
[0086] Optionally, in the step of determining at least one context information of the segmented text according to the semantics of the segmented text, semantic features of the segmented text may be extracted; and context classification processing may be performed on the semantic features to obtain at least one context information of the segmented text.
[0087] In the embodiment of the present invention, key semantic features can be extracted from the segmented text through natural language processing technologies such as keyword extraction, topic modeling, sentiment analysis, etc. The semantic features can imply the core meaning and theme of the segmented text and can serve as the basis for subsequent context classification.
[0088] After the semantic features are extracted, the semantic features can be subjected to context classification processing. The semantic features can be divided into different context categories according to a specific classification method such as a support vector machine (SVM) or a convolutional neural network (CNN).
[0089] After the above-mentioned context classification processing, the context classification result of each segmented text is obtained, and the context classification result is determined as the context information of the corresponding segmented text. The context classification result may include at least one context information, that is, the context information of the segmented text is at least one.
[0090] By extracting the semantic features of the segmented text and performing context classification processing on the semantic features, the context information of each segmented text can be accurately determined, thereby improving the accuracy of the context information of the text to be processed.
[0091] Optionally, in the step of generating an error correction prompt text based on the text to be processed, the error correction requirement and at least one type of context information, if the context information of the text to be processed is one type of context information, then the error correction prompt text can be generated based on the text to be processed, the error correction requirement and the one type of context information; if the context information of the text to be processed is multiple types of context information, then at least one segmented text corresponding to each type of context information is obtained; based on at least one segmented text corresponding to each type of context information, an error correction sub-text corresponding to each type of context information is generated, and each type of context information corresponds to one error correction sub-text; based on the text to be processed, the error correction requirement and an error correction sub-text corresponding to each type of context information, the error correction prompt text is generated.
[0092] In an embodiment of the present invention, if there is only one type of context information of the text to be processed, the error correction prompt text can be directly generated based on this type of context information, the text to be processed itself, and the error correction requirements. Through the error correction prompt text, after clarifying the context information of the text to be processed, the errors that may exist in the text in the corresponding context can be accurately pointed out according to the context information, and modification prompts that conform to the corresponding context can be given. For example, if the context is academic, the error correction prompt text will prompt the large language model to use more formal and professional vocabulary and expressions to correct the error correction target.
[0093] When the context information of the text to be processed contains multiple categories, the situation will be more complicated. The large language model needs to identify the errors in the corresponding contexts in different contexts and correct them according to the corresponding contexts. Therefore, considering that different contexts may appear in different parts of the text to be processed, at least one segmented text corresponding to each type of context information can be obtained, and based on the segmented text corresponding to each type of context information, a correction sub-text corresponding to each type of context information is generated. It can be understood that for each context part of the text, a correction prompt for the context can be given, which can ensure that the correction prompt text is more accurate.
[0094] After the error correction subtexts corresponding to each type of context information are generated, these subtexts can be combined with the text to be processed and the error correction requirements to generate the final error correction prompt text. The generation method can refer to the specific embodiment of step 103.
[0095] By considering single-category and multi-category contextual information of the text to be processed, more specific and relevant error correction prompts can be provided, so that the large language model can more effectively modify and improve the text to be processed.
[0096] Optionally, in the step of generating an error correction sub-text corresponding to each type of context information based on at least one segmented text corresponding to each type of context information, for a type of context information, if it corresponds to only one segmented text, the segmented text may be determined as an error correction sub-text corresponding to the type of context information; if it corresponds to multiple segmented texts, the multiple segmented texts may be sorted; summary generation processing may be performed on two adjacent segmented texts to obtain a summary text between the two adjacent segmented texts; based on the summary text between the two adjacent segmented texts, the two adjacent segmented texts may be spliced; after the splicing is completed, an error correction sub-text corresponding to each type of context information may be obtained.
[0097] In an embodiment of the present invention, when the context information of the text to be processed contains multiple categories, for a certain category of context information, if this category of context information corresponds to only one segmented text, then the segmented text can be directly determined as an error correction sub-text corresponding to this category of context information without the need for additional processing.
[0098] When a certain type of context information corresponds to multiple segmented texts, the multiple segmented texts can be sorted to ensure that the multiple segmented texts are in a time sequence. The basis for the sorting can be the order in which the multiple segmented texts appear in the original text.
[0099] After sorting the multiple segmented texts, summary generation processing is performed on two adjacent segmented texts. The summary text can summarize the core contents of the two adjacent segmented texts, thereby maintaining the semantic coherence between the two adjacent segmented texts.
[0100] The summary text between each adjacent segmented text splices two adjacent segmented texts, and then merges multiple segmented texts into a coherent error correction sub-text, so that the above error correction sub-text can fully reflect the text content under this type of context information.
[0101] When all the segmented texts are processed and spliced in the above manner, a correction subtext corresponding to each type of context information can be obtained. This correction subtext not only contains all the key content under this type of context information, but also maintains the coherence and integrity of the text, which facilitates the subsequent correction processing.
[0102] According to the segmented text corresponding to each type of contextual information, a correction sub-text can be generated that can comprehensively reflect the content of this type of contextual information. Through sorting, summary generation, and splicing, multiple segmented texts can be effectively integrated into a coherent correction sub-text, thereby improving the correction accuracy of the correction prompt text.
[0103] like Figure 2 As shown, an embodiment of the present invention further provides a text processing device, comprising:
[0104] An acquisition module 201 is used to acquire the text to be processed and the error correction requirements;
[0105] A first processing module 202 is used to determine at least one type of context information of the text to be processed according to the semantics of the text to be processed;
[0106] The second processing module 203 is used to generate an error correction prompt text based on the text to be processed, the error correction requirement and at least one type of context information;
[0107] The third processing module 204 is used to input the error correction prompt text into the large language model for error correction processing, and obtain the target text through the output of the large language model.
[0108] Optionally, the first processing module 202 is also used to extract context words from the text to be processed to obtain the context word distribution of the text to be processed; based on the context word distribution, segment the text to be processed to obtain at least one segmented text; according to the semantics of the segmented text, determine at least one context information of the segmented text; according to at least one context of the segmented text, determine at least one type of context information of the text to be processed.
[0109] Optionally, the first processing module 202 is also used to determine the text distance between two adjacent context words according to the context word distribution; if the text distance between the two adjacent context words is greater than or equal to a preset text distance threshold, a segmentation point is determined between the two adjacent context words, and the text to be processed is segmented based on the segmentation point to obtain at least two segmented texts; if the text distance between the two adjacent context words is less than a preset text distance threshold, the text to be processed is segmented based on the first context word and the last context word to obtain a segmented text.
[0110] Optionally, the first processing module 202 is also used to determine a first segmentation point according to the contextual semantics of the preceding context word, and to determine a second segmentation point according to the contextual semantics of the succeeding context word, among the two adjacent context words; if the first segmentation point is before the second segmentation point, then segmenting the text to be processed based on the first segmentation point and the second segmentation point to obtain at least two segmented texts; if the first segmentation point is after the second segmentation point, then determining a third segmentation point between the first segmentation point and the second segmentation point, then segmenting the text to be processed based on the third segmentation point to obtain at least two segmented texts.
[0111] Optionally, the first processing module 202 is further configured to extract semantic features of the segmented text; and perform context classification processing on the semantic features to obtain at least one context information of the segmented text.
[0112] Optionally, the second processing module 203 is also used to generate an error correction prompt text based on the text to be processed, the error correction requirement and the one type of context information if the context information of the text to be processed is one type of context information; if the context information of the text to be processed is multiple types of context information, then obtain at least one segmented text corresponding to each type of context information; based on at least one segmented text corresponding to each type of context information, generate an error correction sub-text corresponding to each type of context information, and each type of context information corresponds to one error correction sub-text; based on the text to be processed, the error correction requirement and one error correction sub-text corresponding to each type of context information, generate an error correction prompt text.
[0113] Optionally, the second processing module 203 is also used for, for a type of the context information, if it corresponds to only one segmented text, determining the segmented text as an error correction sub-text corresponding to a type of the context information; if it corresponds to multiple segmented texts, sorting the multiple segmented texts; performing summary generation processing on two adjacent segmented texts to obtain a summary text between the two adjacent segmented texts; splicing the two adjacent segmented texts based on the summary text between the two adjacent segmented texts; after the splicing is completed, obtaining an error correction sub-text corresponding to each type of the context information.
[0114] It should be noted that the text processing apparatus provided in the embodiment of the present invention can be applied to devices such as smart phones, computers, servers, etc. that can perform text processing methods.
[0115] The text processing device provided in the embodiment of the present invention can implement each process implemented by the regional retention method in the above method embodiment and can achieve the same beneficial effect. To avoid repetition, it will not be described here.
[0116] like Figure 3 As shown, an embodiment of the present invention further provides an electronic device, characterized in that it includes a processor, and the processor can execute any one of the above-mentioned text processing methods.
[0117] Specifically, it includes a processor 301 and a memory 302, and a computer program for executing the text processing method which is stored in the memory 302 and can be run on the processor 301, wherein:
[0118] The processor 301 runs the computer program of the text processing method stored in the memory 302 to perform the following steps:
[0119] Obtain the text to be processed and the error correction requirements;
[0120] Determining at least one type of context information of the text to be processed according to the semantics of the text to be processed;
[0121] Generate an error correction prompt text based on the text to be processed, the error correction requirement and at least one type of context information;
[0122] The error correction prompt text is input into a large language model for error correction processing, and the target text is obtained through the output of the large language model.
[0123] Optionally, the determining, according to the semantics of the text to be processed, of at least one type of context information of the text to be processed performed by the processor 301 includes:
[0124] Extracting context words from the text to be processed to obtain context word distribution of the text to be processed;
[0125] Based on the context word distribution, the text to be processed is segmented to obtain at least one segmented text;
[0126] Determining at least one context information of the segmented text according to the semantics of the segmented text;
[0127] At least one type of context information of the text to be processed is determined according to at least one context of the segmented text.
[0128] Optionally, the processor 301 performs segmentation processing on the text to be processed based on the context word distribution to obtain at least one segmented text, including:
[0129] Determining the text distance between two adjacent context words according to the context word distribution;
[0130] If the text distance between the two adjacent context words is greater than or equal to a preset text distance threshold, a segmentation point is determined between the two adjacent context words, and the to-be-processed text is segmented based on the segmentation point to obtain at least two segmented texts;
[0131] If the text distance between the two adjacent context words is less than a preset text distance threshold, the text to be processed is segmented based on the first context word and the last context word to obtain a segmented text.
[0132] Optionally, if the text distance between the two adjacent context words is greater than or equal to a preset text distance threshold, the processor 301 determines a segmentation point between the two adjacent context words, and performs segmentation processing on the text to be processed based on the segmentation point to obtain at least two segmented texts, including:
[0133] In the two adjacent context words, a first segmentation point is determined according to the contextual semantics of the preceding context word, and a second segmentation point is determined according to the contextual semantics of the succeeding context word;
[0134] If the first segmentation point is before the second segmentation point, the text to be processed is segmented based on the first segmentation point and the second segmentation point to obtain at least two segmented texts.
[0135] If the first segmentation point is after the second segmentation point, a third segmentation point is determined between the first segmentation point and the second segmentation point, and the text to be processed is segmented based on the third segmentation point to obtain at least two segmented texts.
[0136] Optionally, the determining, according to the semantics of the segmented text, at least one context information of the segmented text performed by the processor 301 includes:
[0137] Extracting semantic features of the segmented text;
[0138] The semantic features are subjected to context classification processing to obtain at least one context information of the segmented text.
[0139] Optionally, the processor 301 generates an error correction prompt text based on the text to be processed, the error correction requirement, and at least one type of context information, including:
[0140] If the context information of the text to be processed is a type of context information, then based on the text to be processed, the error correction requirement and the type of context information, generate an error correction prompt text;
[0141] If the context information of the text to be processed is multiple types of context information, obtaining at least one segmented text corresponding to each type of context information;
[0142] Based on at least one segmented text corresponding to each type of the context information, generate an error correction subtext corresponding to each type of the context information, wherein each type of the context information corresponds to one error correction subtext;
[0143] Based on the text to be processed, the error correction requirement and one error correction sub-text corresponding to each type of context information, an error correction prompt text is generated.
[0144] Optionally, the processor 301 generates an error correction subtext corresponding to each type of the context information based on at least one segmented text corresponding to each type of the context information, including:
[0145] For a type of the context information, if it corresponds to only one segmented text, the segmented text is determined as an error correction sub-text corresponding to the type of the context information;
[0146] If it corresponds to multiple segmented texts, sort the multiple segmented texts;
[0147] Performing summary generation processing on two adjacent segmented texts to obtain a summary text between the two adjacent segmented texts;
[0148] Based on the summary text between the two adjacent segmented texts, splicing the two adjacent segmented texts;
[0149] After the splicing is completed, a correction sub-text corresponding to each type of context information is obtained.
[0150] It should be noted that the electronic device provided in the embodiment of the present invention can be applied to devices such as smart phones, computers, servers, etc. that can perform text processing methods.
[0151] The electronic device provided in the embodiment of the present invention can implement each process implemented by the regional retention method in the above method embodiment and can achieve the same beneficial effect. To avoid repetition, it will not be described here.
[0152] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the text processing method provided by the embodiment of the present invention are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0153] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the above-mentioned computer program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the above-mentioned computer-readable storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0154] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.
Claims
1. A text processing method, characterized in that: The method comprises the following steps: Obtain the text to be processed and the error correction requirements; Determining at least one type of context information of the text to be processed according to the semantics of the text to be processed; Generate an error correction prompt text based on the text to be processed, the error correction requirement and at least one type of context information; The error correction prompt text is input into a large language model for error correction processing, and the target text is obtained through the output of the large language model.
2. The text processing method according to claim 1, characterized in that: The step of determining at least one type of context information of the text to be processed according to the semantics of the text to be processed includes: Extracting context words from the text to be processed to obtain context word distribution of the text to be processed; Based on the context word distribution, the text to be processed is segmented to obtain at least one segmented text; Determining at least one context information of the segmented text according to the semantics of the segmented text; At least one type of context information of the text to be processed is determined according to at least one context of the segmented text.
3. The text processing method according to claim 2, characterized in that: The step of segmenting the text to be processed based on the context word distribution to obtain at least one segmented text includes: Determining the text distance between two adjacent context words according to the context word distribution; If the text distance between the two adjacent context words is greater than or equal to a preset text distance threshold, a segmentation point is determined between the two adjacent context words, and the to-be-processed text is segmented based on the segmentation point to obtain at least two segmented texts; If the text distance between the two adjacent context words is less than a preset text distance threshold, the text to be processed is segmented based on the first context word and the last context word to obtain a segmented text.
4. The text processing method according to claim 3, characterized in that: If the text distance between the two adjacent context words is greater than or equal to a preset text distance threshold, a segmentation point is determined between the two adjacent context words, and the to-be-processed text is segmented based on the segmentation point to obtain at least two segmented texts, including: In the two adjacent context words, a first segmentation point is determined according to the contextual semantics of the preceding context word, and a second segmentation point is determined according to the contextual semantics of the succeeding context word; If the first segmentation point is before the second segmentation point, segmenting the text to be processed based on the first segmentation point and the second segmentation point to obtain at least two segmented texts; If the first segmentation point is after the second segmentation point, a third segmentation point is determined between the first segmentation point and the second segmentation point, and the text to be processed is segmented based on the third segmentation point to obtain at least two segmented texts.
5. The text processing method according to any one of claims 2 to 4, characterized in that: The determining, according to the semantics of the segmented text, at least one context information of the segmented text comprises: Extracting semantic features of the segmented text; The semantic features are subjected to context classification processing to obtain at least one context information of the segmented text.
6. The text processing method according to claim 5, characterized in that: The generating of the error correction prompt text based on the text to be processed, the error correction requirement and at least one type of the context information includes: If the context information of the text to be processed is a type of context information, then based on the text to be processed, the error correction requirement and the type of context information, generate an error correction prompt text; If the context information of the text to be processed is multiple types of context information, obtaining at least one segmented text corresponding to each type of context information; Based on at least one segmented text corresponding to each type of the context information, generate an error correction subtext corresponding to each type of the context information, wherein each type of the context information corresponds to one error correction subtext; Based on the text to be processed, the error correction requirement and one error correction sub-text corresponding to each type of context information, an error correction prompt text is generated.
7. The text processing method according to claim 6, characterized in that: The generating an error correction subtext corresponding to each type of the context information based on at least one segmented text corresponding to each type of the context information comprises: For a type of the context information, if it corresponds to only one segmented text, the segmented text is determined as an error correction sub-text corresponding to the type of the context information; If it corresponds to multiple segmented texts, sort the multiple segmented texts; Performing summary generation processing on two adjacent segmented texts to obtain a summary text between the two adjacent segmented texts; Based on the summary text between the two adjacent segmented texts, splicing the two adjacent segmented texts; After the splicing is completed, a correction sub-text corresponding to each type of context information is obtained.
8. A text processing device, characterized in that: The text processing device comprises: The acquisition module is used to obtain the text to be processed and the error correction requirements; A first processing module, configured to determine at least one type of context information of the text to be processed according to the semantics of the text to be processed; A second processing module, configured to generate an error correction prompt text based on the text to be processed, the error correction requirement and at least one type of context information; The third processing module is used to input the error correction prompt text into the large language model for error correction processing, and obtain the target text through the output of the large language model.
9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the text processing method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the text processing method according to any one of claims 1 to 7 are implemented.
