Text processing method and device, electronic equipment and readable storage medium
By preprocessing and rule detection of the target text, and using a rhetorical question generation model to generate rhetorical questions, the problem that electronic devices cannot accurately determine the rhetorical question format is solved, and fast and efficient text input is achieved.
Patent Information
- Application Number
- CN202211476650.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-23
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2042-11-23
AI Technical Summary
Electronic devices cannot accurately determine the rhetorical question form corresponding to the text, causing users to waste time when changing declarative sentences into rhetorical questions, thus reducing text input efficiency.
By acquiring the target text, performing preprocessing and rhetorical question rule detection, and using a pre-trained rhetorical question generation model to generate corresponding rhetorical questions, including the application of a rhetorical question rule library and a deep learning model.
Generate rhetorical questions quickly and accurately, saving text input time and improving text input efficiency.
Smart Images

Figure CN115759009B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a text processing method, apparatus, electronic device, and readable storage medium. Background Technology
[0002] Currently, with the development of computer technology, electronic devices such as terminals or servers have the ability to translate and semantically recognize text input by users.
[0003] However, in related technologies, electronic devices cannot accurately determine the rhetorical question form corresponding to the text. Therefore, when a user wants to change text from a declarative sentence to a rhetorical question, it wastes text input time, thus reducing the efficiency of text input. Summary of the Invention
[0004] In view of this, embodiments of this application provide a text processing method, apparatus, electronic device, and readable storage medium to quickly and accurately determine the rhetorical question corresponding to the target text, thereby saving text input time and improving text input efficiency.
[0005] Firstly, a text processing method is provided, the method comprising:
[0006] Get the target text.
[0007] The target text is subjected to rhetorical question rule detection, and the rule detection result is determined.
[0008] In response to the rule detection result being passed, a rhetorical question corresponding to the target text is generated based on the pre-trained rhetorical question generation model and the target text.
[0009] In some embodiments, performing rhetorical question rule detection on the target text and determining the rule detection result includes:
[0010] The target text is preprocessed to determine the words and sentence structure information within the target text.
[0011] Based on the words in the target text, the sentence structure information of the target text, and the pre-set rhetorical question rule base, the target text is subjected to rhetorical question rule detection, and the rule detection result is determined. The rhetorical question rule base includes at least predetermined words and predetermined sentence structures.
[0012] In some embodiments, performing rhetorical question rule detection on the target text and determining the rule detection result includes:
[0013] The target text is input into a pre-trained rule detection model to determine the rule detection result output by the rule detection model.
[0014] In some embodiments, the method further includes:
[0015] Obtain a first training set, which includes at least a first training sample and a first sample label corresponding to the first training sample, wherein the first sample label includes at least the rule detection result corresponding to the first training sample.
[0016] The first training sample is input into the rule detection model to determine the output result of the rule detection model.
[0017] The rule detection model is trained based on the output of the rule detection model and the label of the first sample.
[0018] In some embodiments, performing rhetorical question rule detection on the target text and determining the rule detection result includes:
[0019] The target text is input into the rhetorical question generation model to determine the rule detection result based on the rhetorical question generation model.
[0020] In some embodiments, the method further includes:
[0021] Obtain a second training set, which includes at least a second training sample and a second sample label corresponding to the second training sample, wherein the second sample label includes at least a rhetorical question corresponding to the second training sample.
[0022] The second training sample is input into the rhetorical question generation model to determine the output of the rhetorical question generation model.
[0023] The rhetorical question generation model is trained based on the output of the rhetorical question generation model and the second sample label.
[0024] In some embodiments, the rhetorical question generation model is a bidirectional autoregressive transformer model.
[0025] Secondly, a text processing apparatus is provided, the apparatus comprising:
[0026] The target text acquisition module is configured to acquire the target text.
[0027] The rule detection module is configured to perform rhetorical question rule detection on the target text and determine the rule detection result.
[0028] The rhetorical question generation module is configured to generate a rhetorical question corresponding to the target text in response to the rule detection result being passed, based on the pre-trained rhetorical question generation model and the target text.
[0029] In some embodiments, the rule detection module is specifically configured to perform:
[0030] The target text is preprocessed to determine the words and sentence structure information within the target text.
[0031] Based on the words in the target text, the sentence structure information of the target text, and the pre-set rhetorical question rule base, the target text is subjected to rhetorical question rule detection, and the rule detection result is determined. The rhetorical question rule base includes at least predetermined words and predetermined sentence structures.
[0032] In some embodiments, the rule detection module is specifically configured to perform:
[0033] The target text is input into a pre-trained rule detection model to determine the rule detection result output by the rule detection model.
[0034] In some embodiments, the apparatus further includes:
[0035] The first acquisition module is configured to acquire a first training set, the first training set including at least a first training sample and a first sample label corresponding to the first training sample, the first sample label including at least a rule detection result corresponding to the first training sample.
[0036] The first determining module is configured to input the first training sample into the rule detection model and determine the output result of the rule detection model.
[0037] The first training module is configured to train the rule detection model based on the output of the rule detection model and the label of the first sample.
[0038] In some embodiments, the rule detection module is specifically configured to perform:
[0039] The target text is input into the rhetorical question generation model to determine the rule detection result based on the rhetorical question generation model.
[0040] In some embodiments, the apparatus further includes:
[0041] The second acquisition module is configured to acquire a second training set, the second training set including at least a second training sample and a second sample label corresponding to the second training sample, the second sample label including at least a rhetorical question corresponding to the second training sample.
[0042] The second determining module is configured to input the second training sample into the rhetorical question generation model and determine the output result of the rhetorical question generation model.
[0043] The second training module is configured to train the rhetorical question generation model based on the output of the rhetorical question generation model and the second sample label.
[0044] In some embodiments, the rhetorical question generation model is a bidirectional autoregressive transformer model.
[0045] Thirdly, embodiments of this application provide an electronic device, including a memory and a processor, wherein the memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method as described in the first aspect.
[0046] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer program instructions thereon, which, when executed by a processor, implement the method described in the first aspect.
[0047] In this embodiment, the target text can be acquired and subjected to rhetorical question rule detection to determine whether the target text is suitable for generating a rhetorical question. Further, if the rhetorical question rule detection result is passed, this embodiment can generate a rhetorical question corresponding to the target text based on a pre-trained rhetorical question generation model and the target text. Specifically, since this embodiment first determines whether the target text is suitable for generating a rhetorical question through rhetorical question rule detection during the generation process, and further generates the corresponding rhetorical question using the rhetorical question generation model when the target text is found to be suitable, this embodiment can quickly generate the corresponding rhetorical question for suitable text, thereby saving text input time and improving text input efficiency. Attached Figure Description
[0048] The above and other objects, features and advantages of the present application will become clearer from the following description of embodiments of the present application with reference to the accompanying drawings, in which:
[0049] Figure 1 This is a flowchart illustrating the text processing method according to an embodiment of this application;
[0050] Figure 2 This is a flowchart of the text processing method according to an embodiment of this application;
[0051] Figure 3 This is a flowchart of another text processing method according to an embodiment of this application;
[0052] Figure 4 This is a flowchart of another text processing method according to an embodiment of this application;
[0053] Figure 5This is a flowchart of another text processing method according to an embodiment of this application;
[0054] Figure 6 This is a flowchart of another text processing method according to an embodiment of this application;
[0055] Figure 7 This is a schematic diagram of the structure of the text processing device according to an embodiment of this application;
[0056] Figure 8 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0057] The present application is described below based on embodiments, but it is not limited to these embodiments. In the detailed description of the present application below, certain specific details are described in detail. Those skilled in the art can fully understand the present application without these details. To avoid obscuring the substance of the present application, well-known methods, processes, flows, elements, and circuits are not described in detail.
[0058] Furthermore, those skilled in the art should understand that the accompanying drawings provided herein are for illustrative purposes only and are not necessarily drawn to scale.
[0059] Unless the context explicitly requires it, words such as "including" or "contains" in the instruction manual should be interpreted as including rather than exclusive or exhaustive; that is, meaning "including but not limited to".
[0060] In the description of this application, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this application, unless otherwise stated, "a plurality of" means two or more.
[0061] In text-based dialogue, rhetorical questions use an interrogative sentence structure to express a positive viewpoint. Rhetorical questions have a stronger tone than regular declarative sentences, and are more likely to provoke thought and reflection. In other words, rhetorical questions are a rhetorical device, a sentence structure that can be used to express strong emotions. Compared to declarative sentences, users can use rhetorical questions to strongly express their demands, feelings, and the key points of their expression.
[0062] In related technologies, electronic devices cannot accurately determine the rhetorical question form corresponding to text. Therefore, users currently can only obtain the corresponding rhetorical question form by manually inputting it. For example, in related technologies, when a user inputs text in the form of a declarative sentence and wants to change it into text in the form of a rhetorical question, the user needs to delete the text in the declarative form and re-enter the text in the form of the rhetorical question. This wastes text input time and reduces the efficiency of text input.
[0063] To address the aforementioned problems, this application provides a text processing method to accurately determine the rhetorical question corresponding to the target text, thereby improving the efficiency of text input. Specifically, this text processing method can be applied to electronic devices, where the electronic device can be a terminal or a server. The terminal can be a smartphone, tablet computer, or personal computer (PC), etc., and the server can be a single server, a server cluster configured in a distributed manner, or a cloud server.
[0064] like Figure 1 As shown, user 11 can input target text 12 through external input devices such as a mouse or keyboard, or through the input unit of electronic device 13 itself (such as a keyboard or touch screen). Correspondingly, electronic device 13 can receive target text 12 and perform rhetorical question rule detection on target text 12 based on the aforementioned text processing method. Further, if the rhetorical question rule detection result is passed, electronic device 13 can generate a rhetorical question 14 corresponding to target text 12 based on a pre-trained rhetorical question generation model and target text 12. Specifically, in the process of generating rhetorical question 14, this embodiment first determines whether target text 12 is suitable for generating a rhetorical question through rhetorical question rule detection. When it is detected that target text 12 is suitable for generating a rhetorical question, this embodiment further generates the rhetorical question 14 corresponding to target text 12 through the rhetorical question generation model. Therefore, through this embodiment, corresponding rhetorical questions can be quickly generated for suitable text, thereby saving text input time and improving text input efficiency.
[0065] Furthermore, such as Figure 2 As shown, the above text processing method may include the following steps:
[0066] In step S110, the target text is obtained.
[0067] The target text may include multiple characters, words, and sentences.
[0068] In one optional implementation, after obtaining the target text, the present application embodiment can preprocess the target text to improve the efficiency of text processing.
[0069] The preprocessing may include noise filtering, text segmentation, space detection, and symbol detection. Specifically, the target text may contain meaningless text noise such as garbled characters. In this case, the embodiments of this application can identify and delete the aforementioned text noise, thereby preserving the valid information in the target text.
[0070] In cases where the target text includes multiple sentences, embodiments of this application can further divide the target text into sentence-level segments based on punctuation marks in the target text, so as to mark, record and return the sentence set corresponding to the target text, thereby enabling further individual rhetorical question rule detection for each sentence in the sentence set.
[0071] This application embodiment can also perform word recognition on the target text, thereby dividing the target text or its various sentences into word-level segments to label, record, and return the word set corresponding to the target text. Further, based on this word set, this application embodiment determines the part of speech and meaning of each word, and then, based on the part of speech and meaning of each word, determines the sentence structure of the target text and whether the target text contains strong modal particles. In the subsequent rhetorical question rule detection process, the rule detection result is determined based on the aforementioned sentence structure and modal particles.
[0072] This application embodiment can also perform space detection or symbol detection on the target text, thereby recording or deleting spaces or invalid symbols in the target text.
[0073] Therefore, by preprocessing the target text, this application embodiment can remove noise from the target text, segment the target text, and detect spaces or symbols in the target text, thereby improving the efficiency of subsequent rhetorical question rule detection and rhetorical question generation.
[0074] In step S120, the target text is subjected to rhetorical question rule detection, and the rule detection result is determined.
[0075] The rhetorical question rule detection is used to determine whether the target text can be converted into a rhetorical question. In practical applications, declarative sentences and exclamatory sentences can be converted into rhetorical questions. For example, "You should go to [place name]." can be converted into "Shouldn't you go to [place name]?", and "The weather is nice today!" can be converted into "Is the weather bad today?". Conversely, since interrogative sentences are used to express questions rather than statements, they cannot be converted into rhetorical questions.
[0076] Therefore, the embodiments of this application can use rhetorical question rules to determine whether the target text can be converted into a rhetorical question, thereby filtering out text that cannot be converted into a rhetorical question, avoiding invalid text processing, and improving the efficiency of text processing.
[0077] In one optional implementation, embodiments of this application can perform rhetorical question rule detection on the target text based on a pre-set rhetorical question rule base. Specifically, for example... Figure 3 As shown, step S120 above may include the following steps:
[0078] In step S121, the target text is preprocessed to determine the words and sentence structure information in the target text.
[0079] The preprocessing includes at least word segmentation. By segmenting the target text, this embodiment can determine each word in the target text, the part of speech (noun, verb) of each word, and the punctuation marks in the target text. Furthermore, this embodiment can determine the structure of the target text (e.g., noun-verb-noun structure) based on the part of speech of each word and the punctuation marks in the target text, and determine the sentence structure information of the target text based on the structure and punctuation marks in the target text. This sentence structure information is used to characterize the sentence structure to which the target text belongs.
[0080] In step S122, based on the words in the target text, the sentence structure information of the target text, and the pre-set rhetorical question rule base, the target text is subjected to rhetorical question rule detection, and the rule detection result is determined.
[0081] Among them, the rhetorical question rule base includes at least predetermined words and predetermined sentence patterns.
[0082] In this embodiment, a rhetorical question rule base can be constructed based on the definition of rhetorical questions in Chinese and the characteristics of rhetorical question patterns. For example, this embodiment can define a strongly worded declarative sentence as a sentence that can generate a rhetorical question. That is, in this case, the predetermined sentence patterns in the rhetorical question rule base can be declarative sentences, and the predetermined words can be one or more pre-set interjections. As another example, this embodiment can also define an exclamatory sentence as a sentence that can generate a rhetorical question. That is, in this case, the predetermined sentence patterns in the rhetorical question rule base can be exclamatory sentences, and the predetermined words can be one or more pre-set interjections.
[0083] It should be noted that, in practical applications, the predetermined sentence patterns in the embodiments of this application may simultaneously include declarative sentence patterns, exclamatory sentence patterns, and other applicable sentence patterns. Furthermore, the rhetorical question rule base may also include predetermined punctuation marks (such as periods and exclamation marks) to more accurately filter the target text.
[0084] Therefore, through the embodiments of this application, it is possible to detect whether the target text contains predetermined words and sentence patterns based on a rhetorical question rule base to determine whether the target text is suitable for generating rhetorical questions. Furthermore, if the target text contains predetermined words and sentence patterns, it indicates that the target text can generate rhetorical questions. In this case, the embodiments of this application can generate corresponding rhetorical questions based on the target text. Specifically, in the process of generating rhetorical questions, the embodiments of this application first use rhetorical question rules to determine whether the target text is suitable for generating rhetorical questions. When it is detected that the target text is suitable for generating rhetorical questions, the embodiments of this application further use a rhetorical question generation model to generate the rhetorical question corresponding to the target text. Therefore, through the embodiments of this application, corresponding rhetorical questions can be quickly generated for suitable text, thereby saving text input time and improving text input efficiency.
[0085] In an optional implementation, embodiments of this application can perform rhetorical question rule detection on the target text based on a pre-trained rule detection model. Specifically, step S120 above may include the following steps:
[0086] In step S123, the target text is input into the pre-trained rule detection model to determine the rule detection result output by the rule detection model.
[0087] The rule detection model can be a deep learning model. By training the deep learning model, it can determine whether the target text is suitable for generating a rhetorical question. In other words, in this embodiment, the target text can be input into a pre-trained rule detection model, which can output a corresponding result label based on the target text. This result label can be either "can generate a rhetorical question" or "cannot generate a rhetorical question." This result label is the rule detection result.
[0088] Furthermore, embodiments of this application can train the rule detection model based on the first training set, specifically, as follows: Figure 4 As shown, the process may include the following steps:
[0089] In step S210, the first training set is obtained.
[0090] The first training set includes at least a first training sample and a first sample label corresponding to the first training sample. The first sample label includes at least the rule detection result corresponding to the first training sample. The first training sample may include multiple characters, words, and sentences. The first sample label may be the rule detection result corresponding to the first training sample that indicates "can generate a rhetorical question" or "cannot generate a rhetorical question".
[0091] In step S220, the first training sample is input into the rule detection model to determine the output result of the rule detection model.
[0092] In step S230, the rule detection model is trained based on the output of the rule detection model and the label of the first sample.
[0093] In this embodiment of the application, after determining the output result of the rule detection model, a loss function can be determined based on the loss between the output result and the first sample label, and the model parameters of the rule detection model can be adjusted according to the loss function until the rule detection model converges, thereby completing the training of the rule detection model.
[0094] Therefore, through the embodiments of this application, a pre-trained rule detection model can be used to detect whether the target text is suitable for generating rhetorical questions. Furthermore, if the rule detection result for the target text is "passed," it indicates that the target text can generate rhetorical questions. In this case, the embodiments of this application can generate corresponding rhetorical questions based on the target text. Specifically, in the process of generating rhetorical questions, the embodiments of this application first determine whether the target text is suitable for generating rhetorical questions through rhetorical question rule detection. When it is detected that the target text is suitable for generating rhetorical questions, the embodiments of this application further generate the corresponding rhetorical questions for the target text through a rhetorical question generation model. Therefore, through the embodiments of this application, corresponding rhetorical questions can be quickly generated for suitable text, thereby saving text input time and improving text input efficiency.
[0095] In step S130, in response to the rule detection result being passed, a rhetorical question is generated based on the pre-trained rhetorical question generation model and the target text.
[0096] The rhetorical question generation model can be a deep learning model. By training the deep learning model, it can fully utilize the information in the target text to generate corresponding rhetorical questions based on the input target text. In other words, the rhetorical question generation model in this application can save users the process of manually modifying the target text into rhetorical questions, thereby saving text input time and improving text input efficiency.
[0097] Therefore, in this embodiment, the target text can be obtained and rhetorical question rule detection can be performed on the target text to determine whether the target text is suitable for generating rhetorical questions. Further, if the rhetorical question rule detection result is passed, this embodiment can generate the rhetorical question corresponding to the target text based on a pre-trained rhetorical question generation model and the target text. Specifically, in the process of generating rhetorical questions, this embodiment first determines whether the target text is suitable for generating rhetorical questions through rhetorical question rule detection. When it is detected that the target text is suitable for generating rhetorical questions, this embodiment further generates the rhetorical question corresponding to the target text through the rhetorical question generation model. Therefore, through this embodiment, corresponding rhetorical questions can be quickly generated for suitable text, thereby saving text input time and improving text input efficiency.
[0098] In one optional implementation, the rhetorical question generation model can be a bidirectional and auto-regressive transformer (BART) model, where the BART model is a pre-trained language model using the overall structure of the Transformer model. This embodiment uses the BART pre-trained model as the basic framework for the rhetorical question generation model. By combining the bidirectional and auto-regressive characteristics of the BART model, the model can fully utilize contextual information to generate rhetorical questions more fluently, improving the accuracy of the rhetorical questions compared to the target text.
[0099] In one optional implementation, embodiments of this application can train the rhetorical question generation model based on a second training set, specifically, as follows: Figure 5 As shown, the process may include the following steps:
[0100] In step S310, the second training set is obtained.
[0101] The second training set includes at least the second training sample and the second sample label corresponding to the second training sample, and the second sample label includes at least the rhetorical question corresponding to the second training sample.
[0102] In step S320, the second training sample is input into the rhetorical question generation model to determine the output result of the rhetorical question generation model.
[0103] In step S330, the rhetorical question generation model is trained based on the output of the rhetorical question generation model and the second sample label.
[0104] In this embodiment of the application, after determining the output of the rhetorical question generation model, a loss function can be determined based on the loss between the output and the second sample label, and the model parameters of the rhetorical question generation model can be adjusted according to the loss function until the rhetorical question generation model converges, thereby completing the training of the rhetorical question generation model.
[0105] Therefore, through the embodiments of this application, a pre-trained rule detection model can be used to detect whether the target text is suitable for generating a rhetorical question. Furthermore, if the rule detection result of the target text is "passed," it indicates that the target text can generate a rhetorical question. In this case, the embodiments of this application can generate the rhetorical question corresponding to the target text based on a pre-trained rhetorical question generation model. Specifically, in the process of generating a rhetorical question, the embodiments of this application first determine whether the target text is suitable for generating a rhetorical question through rhetorical question rule detection. When it is detected that the target text is suitable for generating a rhetorical question, the embodiments of this application further generate the rhetorical question corresponding to the target text through the rhetorical question generation model. Therefore, through the embodiments of this application, corresponding rhetorical questions can be quickly generated for suitable text, thereby saving text input time and improving text input efficiency.
[0106] In one alternative implementation, since both the process of detecting rhetorical question rules and generating rhetorical questions can be implemented using a deep learning model, the embodiments of this application can implement the detection of rhetorical question rules and the generation of rhetorical questions using a single deep learning model, thereby improving the efficiency of text processing.
[0107] Specifically, step S120 above may include the following steps:
[0108] In step S124, the target text is input into the rhetorical question generation model to determine the rule detection result based on the rhetorical question generation model.
[0109] In other words, the embodiments of this application can both detect rhetorical question rules in the target text using a rhetorical question generation model, and generate rhetorical questions corresponding to the target text using a rhetorical question generation model.
[0110] It should be noted that if the embodiments of this application use a rhetorical question generation model to perform rhetorical question rule detection on the target text, the rhetorical question generation model can directly perform rhetorical question rule detection on the target text after receiving the target text, and directly generate the rhetorical question corresponding to the target text based on the rule detection results. During this process, the rule detection results can be output or not.
[0111] For example, such as Figure 6 As shown, embodiments of this application may include the following steps:
[0112] In step S61, the target text is obtained.
[0113] In step S62, the target text is subjected to rhetorical question rule detection based on the rhetorical question generation model, and the rule detection result is determined. If the rule detection result is successful, step S63 is executed; if the rule detection result is unsuccessful, step S64 is executed.
[0114] In this embodiment, rhetorical question rule detection can be performed based on a rhetorical question generation model. This embodiment can train the rhetorical question generation model based on steps S310-S330 described above. In this case, the second sample label in the second training set can include the rhetorical question corresponding to the second training sample and the second training sample itself.
[0115] In other words, in this embodiment of the application, if the rhetorical question generation model outputs the rhetorical question corresponding to the target text after obtaining the target text, it indicates that the result of the rhetorical question generation model in the rhetorical question rule detection is "passed"; if the rhetorical question generation model outputs the target text after obtaining the target text, it indicates that the result of the rhetorical question generation model in the rhetorical question rule detection is "failed".
[0116] In step S63, a rhetorical question is generated based on the rhetorical question generation model to correspond to the target text.
[0117] In step S64, the target text is retained.
[0118] In step S65, the rhetorical question generated by the rhetorical question generation model is output.
[0119] In step S66, the target text is output.
[0120] Through the embodiments of this application, rhetorical question rules can be detected in the target text based on the rhetorical question generation model, and rhetorical questions corresponding to the target text can also be generated based on the rhetorical question generation model. Therefore, the embodiments of this application can realize both rhetorical question rule detection and rhetorical question generation through a single model, thereby improving the efficiency of text processing.
[0121] Furthermore, in the process of generating rhetorical questions, this embodiment first uses rhetorical question rules to determine whether the target text is suitable for generating rhetorical questions. When the target text is found to be suitable for generating rhetorical questions, this embodiment further uses a rhetorical question generation model to generate the corresponding rhetorical question for the target text. Therefore, through this embodiment, corresponding rhetorical questions can be quickly generated for suitable text, thereby saving text input time and improving text input efficiency.
[0122] Based on the same technical concept, embodiments of this application also provide a text processing device, such as... Figure 7 As shown, the device includes: a target text acquisition module 71, a rule detection module 72, and a rhetorical question generation module 73.
[0123] The target text acquisition module 71 is configured to acquire the target text.
[0124] The rule detection module 72 is configured to perform rhetorical question rule detection on the target text and determine the rule detection result.
[0125] The rhetorical question generation module 73 is configured to generate a rhetorical question corresponding to the target text in response to the rule detection result being passed, based on the pre-trained rhetorical question generation model and the target text.
[0126] In some embodiments, the rule detection module 72 is specifically configured to perform:
[0127] The target text is preprocessed to determine the words and sentence structure information within the target text.
[0128] Based on the words in the target text, the sentence structure information of the target text, and the pre-set rhetorical question rule base, the target text is subjected to rhetorical question rule detection, and the rule detection result is determined. The rhetorical question rule base includes at least predetermined words and predetermined sentence structures.
[0129] In some embodiments, the rule detection module 72 is specifically configured to perform:
[0130] The target text is input into a pre-trained rule detection model to determine the rule detection result output by the rule detection model.
[0131] In some embodiments, the apparatus further includes:
[0132] The first acquisition module is configured to acquire a first training set, the first training set including at least a first training sample and a first sample label corresponding to the first training sample, the first sample label including at least a rule detection result corresponding to the first training sample.
[0133] The first determining module is configured to input the first training sample into the rule detection model and determine the output result of the rule detection model.
[0134] The first training module is configured to train the rule detection model based on the output of the rule detection model and the label of the first sample.
[0135] In some embodiments, the rule detection module 72 is specifically configured to perform:
[0136] The target text is input into the rhetorical question generation model to determine the rule detection result based on the rhetorical question generation model.
[0137] In some embodiments, the apparatus further includes:
[0138] The second acquisition module is configured to acquire a second training set, the second training set including at least a second training sample and a second sample label corresponding to the second training sample, the second sample label including at least a rhetorical question corresponding to the second training sample.
[0139] The second determining module is configured to input the second training sample into the rhetorical question generation model and determine the output result of the rhetorical question generation model.
[0140] The second training module is configured to train the rhetorical question generation model based on the output of the rhetorical question generation model and the second sample label.
[0141] In some embodiments, the rhetorical question generation model is a bidirectional autoregressive transformer model.
[0142] In this embodiment, the target text can be acquired and subjected to rhetorical question rule detection to determine whether the target text is suitable for generating a rhetorical question. Further, if the rhetorical question rule detection result is passed, this embodiment can generate a rhetorical question corresponding to the target text based on a pre-trained rhetorical question generation model and the target text. Specifically, since this embodiment first determines whether the target text is suitable for generating a rhetorical question through rhetorical question rule detection during the generation process, and further generates the corresponding rhetorical question using the rhetorical question generation model when the target text is found to be suitable, this embodiment can quickly generate the corresponding rhetorical question for suitable text, thereby saving text input time and improving text input efficiency.
[0143] Figure 8 This is a schematic diagram of an electronic device according to an embodiment of this application. For example... Figure 8 As shown, Figure 8The illustrated electronic device is a general address lookup device, comprising a general computer hardware architecture, including at least a processor 81 and a memory 82. The processor 81 and memory 82 are connected via a bus 83. The memory 82 is adapted to store instructions or programs executable by the processor 81. The processor 81 can be a standalone microprocessor or a collection of one or more microprocessors. Thus, the processor 81 executes the instructions stored in the memory 82, thereby performing the method flow described in the embodiments of this application as above to process data and control other devices. The bus 83 connects the aforementioned components together, and also connects these components to a display controller 84, a display device, and an input / output (I / O) device 85. The input / output (I / O) device 85 can be a mouse, keyboard, modem, network interface, touch input device, motion-sensing input device, printer, and other devices known in the art. Typically, the input / output device 85 is connected to the system via an input / output (I / O) controller 86.
[0144] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus (devices), or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0145] This application is described with reference to flowchart illustrations of methods, apparatus (devices), and computer program products according to embodiments of this application. It should be understood that each step in the flowchart can be implemented by computer program instructions.
[0146] These computer program instructions may be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including an instruction means, the implementation process of which is described in the instruction means. Figure 1 The function specified in one or more processes.
[0147] These computer program instructions may also be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing device, produce instructions for implementing processes. Figure 1 A device for a function specified in one or more processes.
[0148] Another embodiment of this application relates to a non-volatile storage medium for storing a computer-readable program for use by a computer to execute some or all of the above-described method embodiments.
[0149] That is, those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program specifying the relevant hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0150] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A text processing method, characterized in that, The method includes: Get the target text; The target text is subjected to rhetorical question rule detection to determine the rule detection result. The rhetorical question rule detection is used to determine whether the target text is a predetermined sentence structure that can be converted into a rhetorical question. The predetermined sentence structure includes at least a declarative sentence structure or an exclamatory sentence structure. In response to the rule detection result being passed, a rhetorical question corresponding to the target text is generated based on the pre-trained rhetorical question generation model and the target text; The step of performing rhetorical question rule detection on the target text and determining the rule detection result includes: The target text is preprocessed to determine the words and sentence structure information within it; and Based on the words in the target text, the sentence structure information of the target text, and the pre-set rhetorical question rule library, the target text is subjected to rhetorical question rule detection, and the rule detection result is determined. The rhetorical question rule library includes at least predetermined words and predetermined sentence structures, and the predetermined words are one or more pre-set interjections. The step of performing rhetorical question rule detection on the target text and determining the rule detection result further includes: The target text is input into the rhetorical question generation model to determine the rule detection result based on the rhetorical question generation model; The method further includes: Obtain a second training set, which includes at least a second training sample and a second sample label corresponding to the second training sample, wherein the second sample label includes at least a rhetorical question corresponding to the second training sample. The second training sample is input into the rhetorical question generation model to determine the output of the rhetorical question generation model; and The rhetorical question generation model is trained based on the output of the rhetorical question generation model and the second sample label.
2. The method according to claim 1, characterized in that, The step of performing rhetorical question rule detection on the target text and determining the rule detection result further includes: The target text is input into a pre-trained rule detection model to determine the rule detection result output by the rule detection model.
3. The method according to claim 2, characterized in that, The method further includes: Obtain a first training set, the first training set including at least a first training sample and a first sample label corresponding to the first training sample, the first sample label including at least the rule detection result corresponding to the first training sample; The first training sample is input into the rule detection model, and the output result of the rule detection model is determined; and The rule detection model is trained based on the output of the rule detection model and the label of the first sample.
4. The method according to claim 1, characterized in that, The rhetorical question generation model is a bidirectional autoregressive transformer model.
5. A text processing device, characterized in that, The device includes: The target text acquisition module is configured to acquire the target text. The rule detection module is configured to perform rhetorical question rule detection on the target text, determine the rule detection result, and the rhetorical question rule detection is used to determine whether the target text is a predetermined sentence structure that can be converted into a rhetorical question, wherein the predetermined sentence structure includes at least a declarative sentence structure or an exclamatory sentence structure; and The rhetorical question generation module is configured to generate a rhetorical question corresponding to the target text in response to the rule detection result being passed, based on the pre-trained rhetorical question generation model and the target text. The rule detection module is configured as follows: The target text is preprocessed to determine the words and sentence structure information within it; and Based on the words in the target text, the sentence structure information of the target text, and the pre-set rhetorical question rule library, the target text is subjected to rhetorical question rule detection, and the rule detection result is determined. The rhetorical question rule library includes at least predetermined words and predetermined sentence structures, and the predetermined words are one or more pre-set interjections. The rule detection module is also configured to: The target text is input into the rhetorical question generation model to determine the rule detection result based on the rhetorical question generation model; The apparatus further includes, when training the rhetorical question generation model: The second acquisition module is configured to acquire a second training set, the second training set including at least a second training sample and a second sample label corresponding to the second training sample, the second sample label including at least a rhetorical question corresponding to the second training sample; The second determining module is configured to input the second training sample into the rhetorical question generation model and determine the output result of the rhetorical question generation model. The second training module is configured to train the rhetorical question generation model based on the output of the rhetorical question generation model and the second sample label.
6. An electronic device comprising a memory and a processor, characterized in that, The memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method as described in any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method of any one of claims 1-4.
Citation Information
Patent Citations
Text processing method, device and equipment and storage medium
CN111814451A
Input method and device and device for input
CN114510154A