A method and terminal for automatically generating emotional text

By obtaining the topic keywords of the article and filling them into the social short text template, the problem of low quality of generated text in the existing technology is solved, and high-quality emotional text generation and model training data supplementation are achieved.

CN115017876BActive Publication Date: 2025-09-09XIAMEN MEIYA PICO INFORMATION CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210650394.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-09
Publication Date
2025-09-09
Estimated Expiration
2042-06-09

AI Technical Summary

Technical Problem

Existing technologies require a large amount of high-quality training data sets when generating text, which is costly. This results in low-quality generated text and makes it difficult to effectively apply it on social platforms.

Method used

By obtaining the social short text templates corresponding to the articles to be processed and different emotional tendency categories, the long short-term memory network and seq2seq model are used to extract the topic keywords, and the social short text templates are filled with these keywords to generate emotional text.

Benefits of technology

It achieves high-quality emotional text generation that fits the article topic, is suitable for simulating social networks and other model training, and provides high-quality material resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115017876B_ABST
    Figure CN115017876B_ABST
Patent Text Reader

Abstract

The present invention provides a method and terminal for automatically generating emotional text, which obtains social short text templates corresponding to articles to be processed and different emotional tendency categories; obtains topic keywords based on the articles to be processed; fills the social short text templates with the topic keywords to obtain and output emotional text; the present invention fills the topic keywords obtained from the articles to be processed into the social short text template, so that the automatically generated emotional text is associated with the specific article topic, which is more in line with the natural expression habits of people after reading articles or paragraphs, thereby achieving high-quality emotional text generation. It provides high-quality material resources for building simulated social networks and also provides data supplements for the training of other models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing, and in particular to a method and a terminal for automatically generating emotional text. Background Art

[0002] Existing technologies for text generation primarily employ deep learning methods, which involve compiling massive, high-quality training datasets for training, and then directly generating the final text through model input and output. This places high demands on the data for the training set, exemplified by two difficulties: first, the source data must ensure input and output, maintaining strong connections and output tendencies in terms of content; second, labeling massive amounts of training data requires significant labor costs. Therefore, considering the human and material investment costs, it is difficult to produce a high-quality training dataset. When dataset quality cannot be guaranteed, many existing trained models generate text of lower quality, lacking a strong connection to the article or topic, and thus failing to achieve satisfactory results. Furthermore, low-quality speech information or obviously machine-generated text content is difficult to pass the detection mechanisms of the social platforms on which it is published, and cannot be directly used in practical applications without human intervention. Summary of the Invention

[0003] The technical problem to be solved by the present invention is to provide a method and a terminal for automatically generating emotional text, so as to realize the generation of high-quality text corpus.

[0004] In order to solve the above technical problems, a technical solution adopted by the present invention is:

[0005] A method for automatically generating emotional text, comprising the steps of:

[0006] Obtain the social short text templates corresponding to the articles to be processed and different emotional tendency categories;

[0007] Obtaining topic keywords according to the article to be processed;

[0008] The social short text template is filled in according to the subject keywords to obtain the emotional text and output it.

[0009] In order to solve the above technical problems, another technical solution adopted by the present invention is:

[0010] A terminal for automatically generating emotional text includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:

[0011] Obtain the social short text templates corresponding to the articles to be processed and different emotional tendency categories;

[0012] Obtaining topic keywords according to the article to be processed;

[0013] The social short text template is filled in according to the subject keywords to obtain the emotional text and output it.

[0014] The beneficial effects of the present invention are as follows: taking an article to be processed, training different social short text templates according to different emotional tendency categories, and filling the social short text templates with the theme keywords obtained from the article to be processed, so that the automatically generated emotional text is associated with the specific article topic, more closely matching the natural expression habits of people after reading articles or paragraphs, thereby achieving high-quality emotional text generation. It provides high-quality material resources for building simulated social networks and also provides data supplement for the training of other models. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 A flowchart of a method for automatically generating emotional text according to an embodiment of the present invention;

[0016] Figure 2 This is a schematic structural diagram of a terminal for automatically generating emotional text according to an embodiment of the present invention;

[0017] Figure 3 A flowchart of another method for automatically generating emotional text according to an embodiment of the present invention;

[0018] Figure 4 This is a schematic diagram of the seq2seq article abstract extraction process according to an embodiment of the present invention;

[0019] Figure 5 Schematic diagram of a social short text template generation process according to an embodiment of the present invention.

[0020] Description of labels:

[0021] 1. A terminal for automatically generating emotional text; 2. A processor; 3. A memory. DETAILED DESCRIPTION

[0022] To illustrate the technical content, achieved objectives and effects of the present invention in detail, the following description is given in conjunction with the embodiments and accompanying drawings.

[0023] Please refer to Figure 1 , a method for automatically generating emotional text, comprising the steps of:

[0024] Obtain the social short text templates corresponding to the articles to be processed and different emotional tendency categories;

[0025] Obtaining topic keywords according to the article to be processed;

[0026] The social short text template is filled in according to the subject keywords to obtain the emotional text and output it.

[0027] As can be seen from the above description, the beneficial effects of the present invention are: obtaining an article to be processed, training different social short text templates according to different emotional tendency categories, filling the theme keywords obtained from the article to be processed into the social short text template, and realizing that the automatically generated emotional text is associated with the specific article topic, which is more in line with the natural expression habits of people after reading articles or paragraphs, thereby achieving high-quality emotional text generation. It provides high-quality material resources for building simulated social networks and also provides data supplements for the training of other models.

[0028] Furthermore, obtaining subject keywords based on the article to be processed includes:

[0029] Inputting the article to be processed into a long short-term memory network model to obtain a keyword vector and a semantic vector;

[0030] Performing an attention operation on the keyword vector and the semantic vector to obtain a topic keyword vector;

[0031] A topic keyword is obtained according to the topic keyword vector.

[0032] From the above description, we can see that the article to be processed is passed through the long short-term memory network model (LSTM) to obtain keyword vectors and semantic vectors, and finally the topic keywords are obtained to realize the refinement of the topic of the article to be processed.

[0033] Furthermore, the step of obtaining preset social short text templates corresponding to the article to be processed and different emotional tendency categories includes:

[0034] Get training reviews;

[0035] Calculate the high-frequency word set corresponding to each training comment in the training comments according to the TF-IDF word frequency statistics method;

[0036] Obtaining the emotional tendency category corresponding to each training comment according to the high-frequency word set and the emotional sensitivity table;

[0037] A social short text template corresponding to the emotional tendency category is obtained according to the training comments corresponding to the emotional tendency category.

[0038] From the above description, we can see that when obtaining training comments, we can select texts that are consistent with expressing subjective emotional tendencies, and then train corresponding social short text templates according to different emotional tendency categories to ensure that the final generated emotional text is more in line with natural language.

[0039] Furthermore, obtaining the social short text template corresponding to the emotional tendency category according to the training comments corresponding to the emotional tendency category includes:

[0040] The social short text template is obtained by removing the subject words, prefixes and suffixes in the training comments corresponding to the sentiment tendency category and retaining the subject word vacancies.

[0041] From the above description, we can see that the original keywords, prefixes and suffixes in the training comments are deleted, and the main part expressing the emotional tendency is retained, which facilitates the subsequent filling of content to achieve emotional expression on different topics, and can retain the language habits in natural language to the greatest extent, and fit the text sent by people.

[0042] Furthermore, the social short text template is filled according to the topic keywords to obtain the emotional text and output it, including:

[0043] Fill the subject word gaps in the social short text template according to the subject keywords to obtain the emotional text and output it.

[0044] From the above description, it can be seen that by filling the subject keyword gaps in the social short text template with the subject keywords obtained from the article to be processed, the emotional text corresponding to the article to be processed is generated, thereby realizing the automatic generation of targeted opinion expressions.

[0045] Furthermore, obtaining subject keywords based on the article to be processed further includes:

[0046] Obtaining an article abstract according to the article to be processed;

[0047] The social short text template is filled according to the topic keywords to obtain the emotional text and output it specifically as follows:

[0048] The social short text template is filled in according to the subject keywords, and is aggregated with the article abstract to obtain the emotional text and output it.

[0049] As can be seen from the above description, an article summary is obtained based on the article to be processed, and the article summary is aggregated with the filled social short text template to obtain an emotional text, which fits the habit of people making corresponding summaries when expressing emotions about things, and further improves the quality of the final generated emotional text.

[0050] Furthermore, obtaining an article abstract based on the article to be processed includes:

[0051] The article to be processed is subjected to a seq2seq model to obtain an article summary.

[0052] From the above description, we can see that obtaining the article summary through the seq2seq model can ensure that the article summary accurately reflects the true topic of the article.

[0053] Furthermore, before obtaining an article summary based on the article to be processed through a seq2seq model, the method includes:

[0054] Get training articles;

[0055] Passing the training article through an implication relation classifier in an encoder of the seq2seq model to obtain a first vector and a second vector;

[0056] Combining the first vector and the second vector into a feature vector and performing implication prediction through a classification module;

[0057] An article summary is generated by the decoder of the seq2seq model, and the ratio of the article summary contained in the training article is used as a reward to train the seq2seq model, thereby obtaining a trained seq2seq model.

[0058] From the above description, we can see that adding implication analysis and using the ratio of article summaries implied by the training articles as a reward to train the seq2seq model can further improve the accuracy of the seq2seq model in obtaining article summaries.

[0059] Furthermore, the social short text template is filled according to the subject keywords, and is aggregated with the article abstract to obtain the emotional text and output it, including:

[0060] Determine the syntactic form of the social short text template. If it is a short sentence, fill the social short text template with the subject keywords and concatenate it with the article abstract to obtain an emotional output text.

[0061] If it is a common long sentence, the social short text template is filled in according to the subject keywords, and the article summary is embedded after segmentation by punctuation marks;

[0062] If it is a complex sentence, the social short text template is filled in according to the subject keywords, and the article summary is embedded as a clause.

[0063] From the above description, we can see that by selecting different aggregation methods according to the different syntactic forms of the short text template, the fusion of the article summary and the filled short text template is made more natural, obvious grammatical errors are avoided, and a real simulation effect is achieved.

[0064] Please refer to Figure 2 A terminal for automatically generating emotional text includes a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the computer program, the method for automatically generating emotional text is implemented.

[0065] The above-mentioned method and terminal for automatically generating emotional text of the present invention can be applied to scenarios where emotional text needs to be generated for model training or simulation of real-person speech. It is particularly suitable for supplementing corpus when corpus used for model training is lacking, and for generating corresponding comments for a specific article. The following is an explanation through a specific implementation method.

[0066] Please refer to Figure 1 and Figure 3 , embodiment 1 of the present invention is:

[0067] A method for automatically generating emotional text, comprising the steps of:

[0068] S1. Obtain the social short text templates corresponding to the articles to be processed and different emotional tendency categories;

[0069] S2. Obtain topic keywords based on the article to be processed. Specifically, keywords of the article can be extracted using named entity recognition technology, including:

[0070] S21, inputting the article to be processed into a long short-term memory network model (LSTM) to obtain a keyword vector and a semantic vector;

[0071] S22, performing an attention operation on the keyword vector and the semantic vector to obtain a topic keyword vector;

[0072] S23. Obtain topic keywords based on the topic keyword vector, where the topic keywords include entity nouns and opinion nouns;

[0073] In an optional embodiment, the number of topic keywords is preset. If the number of first topic keywords obtained according to the topic keyword vector exceeds the preset number of topic keywords, keywords that are not entity nouns and non-opinion nouns in the first topic keywords are removed to obtain the topic keywords.

[0074] S24. Obtaining an article abstract based on the article to be processed, including: applying a seq2seq model to the article to be processed to obtain an article abstract, wherein the article abstract reflects the main content or theme of the article; wherein the article abstract extracts the main content or theme of the article;

[0075] There is no restriction on the order between step S4 and steps S21-S23, and they can be executed simultaneously or sequentially;

[0076] S3. Filling the social short text template according to the subject keywords to obtain and output an emotional text, including: filling the social short text template according to the subject keywords, and aggregating it with the article abstract to obtain and output the emotional text. Specifically, determining the syntactic form of the social short text template; if it is a short sentence, filling the social short text template according to the subject keywords, and aggregating it with the article abstract to obtain an emotional output text;

[0077] If it is a common long sentence, the social short text template is filled in according to the subject keywords, and the article summary is embedded after segmentation by punctuation marks;

[0078] If it is a complex sentence, the social short text template is filled according to the subject keywords, and the article summary is embedded as a clause;

[0079] In an optional implementation, S3 further includes: if it is a long sentence, obtaining a preset syntax table to determine the sentence pattern, whether it is an ordinary long sentence or a complex sentence, and embedding the article abstract according to the preset syntax table.

[0080] Please refer to Figure 5 , the second embodiment of the present invention is:

[0081] A method for automatically generating emotional text, which differs from the first embodiment in that, before step S1, it further includes:

[0082] S01. Obtain training comments, where the training comments are texts expressing subjective emotional tendencies;

[0083] S02. Calculate the high-frequency word set corresponding to each training comment in the training comments according to the TF-IDF word frequency statistics method;

[0084] S03, obtaining the emotional tendency category corresponding to each training comment according to the high-frequency word set and the emotional sensitivity table;

[0085] In an optional embodiment, the greeting tendency categories include positive (support), negative (opposition), and neutral;

[0086] S04. Obtaining a social short text template corresponding to the sentiment tendency category according to the training comments corresponding to the sentiment tendency category, including:

[0087] Removing the subject words, prefixes and suffixes in the training comments corresponding to the sentiment tendency category and leaving the subject words blank to obtain the social short text template;

[0088] It can be seen that since the real comments are directly hollowed out, the emotional expression parts are retained and the parts related to the topic and the rest of the indifferent parts are removed, then by filling different topics into the blanks, it is possible to obtain emotional expression sentences on different topics, and they can be as close to the real person's expression as possible;

[0089] Then S3 includes:

[0090] Fill the topic word gaps in the social short text template according to the topic keywords to obtain the emotional text and output it;

[0091] Please refer to Figure 4 , the third embodiment of the present invention is:

[0092] A method for automatically generating emotional text, which differs from the other embodiments in that:

[0093] In step S24, before obtaining the article abstract according to the article to be processed, the following steps are included:

[0094] S211, obtain training articles;

[0095] S212, in the encoder of the seq2seq model, the training article is passed through an implication relationship classifier to obtain a first vector and a second vector; the implication relationship classifier includes a softmax layer; and the encoder has implication awareness;

[0096] S213: Combining the first vector and the second vector into a feature vector and performing entailment prediction via a classification module. Specifically, when training entailment recognition, a bidirectional long short-term memory network is used to encode sentence pairs in the text entailment dataset to obtain u vectors and v vectors, and the two vectors are combined into a feature vector and passed to the classification module for entailment prediction.

[0097] S214. Generate predicted text through the decoder of the seq2seq model, and use the ratio of the predicted text implied by the training text as a reward to train the seq2seq model, thereby obtaining a trained seq2seq model; thus, a summary that can better summarize the original text can be generated.

[0098] Please refer to Figure 2 , the fourth embodiment of the present invention is:

[0099] A terminal 1 for automatically generating emotional text includes a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, each step in Example 1, Example 2, or Example 3 is implemented.

[0100] In summary, the present invention provides a method and terminal for automatically generating emotional texts, which sets corresponding social short text templates for different emotional tendency categories. After receiving the article to be processed, the subject keywords are obtained according to the article to be processed, and the social short text template is filled in according to the subject keywords, and finally the emotional text related to the article to be processed is obtained, which contains the emotional tendency and the content of the article to be processed, has strong pertinence, and can generate a large number of short text corpora that are highly relevant to the article to be processed and have high usability in a short time. The corpus can be used as a bisque resource for building a simulated social network, and can also be organized into a data set as a basis for other models. The training data set is based on the social short text templates obtained by hollowing out and excluding meaningless prefixes and suffixes based on the comments sent by real people. Therefore, it is closer to the real expression of real people. It also classifies the social short text templates according to three directions: positive (support), negative (opposition) and neutral. It is more in line with the different expressions of people under different emotional tendencies and achieves high-simulation personification. At the same time, it sets the syntax corresponding to different sentence patterns and uses different methods to splice the article abstract and the filled social short text template according to the syntax. It can also create complex sentences and avoid semantic incomprehension to the greatest extent, thereby achieving the generation of high-quality text corpus.

[0101] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's description and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for automatically generating emotional text, characterized in that: Including steps: Obtain the social short text templates corresponding to the articles to be processed and different emotional tendency categories; Obtaining subject keywords based on the article to be processed, including: obtaining an article abstract based on the article to be processed; The social short text template is filled according to the subject keywords to obtain and output the emotional text, specifically: the social short text template is filled according to the subject keywords, and is aggregated with the article abstract to obtain and output the emotional text; specifically including: judging the syntactic form of the social short text template, if it is a short sentence, the social short text template is filled according to the subject keywords, and is spliced ​​with the article abstract to obtain the emotional output text; if it is an ordinary long sentence, the social short text template is filled according to the subject keywords, and is embedded in the article abstract after being segmented by punctuation marks; if it is a complex sentence, the social short text template is filled according to the subject keywords, and the article abstract is embedded as a clause.

2. The method for automatically generating emotional text according to claim 1, wherein: The subject keywords obtained according to the article to be processed include: Inputting the article to be processed into a long short-term memory network model to obtain a keyword vector and a semantic vector; Performing an attention operation on the keyword vector and the semantic vector to obtain a topic keyword vector; A topic keyword is obtained according to the topic keyword vector.

3. The method for automatically generating emotional text according to claim 1, wherein: The process of obtaining the social short text templates corresponding to the article to be processed and different sentiment tendency categories includes: Get training reviews; Calculate the high-frequency word set corresponding to each training comment in the training comments according to the TF-IDF word frequency statistics method; Obtaining the emotional tendency category corresponding to each training comment according to the high-frequency word set and the emotional sensitivity table; A social short text template corresponding to the emotional tendency category is obtained according to the training comments corresponding to the emotional tendency category.

4. The method for automatically generating emotional text according to claim 3, wherein: The step of obtaining a social short text template corresponding to the sentiment tendency category according to the training comments corresponding to the sentiment tendency category includes: The social short text template is obtained by removing the subject words, prefixes and suffixes in the training comments corresponding to the sentiment tendency category and retaining the subject word vacancies.

5. The method for automatically generating emotional text according to claim 4, characterized in that: Filling the social short text template according to the topic keywords to obtain the emotional text and output it includes: Fill the subject word gaps in the social short text template according to the subject keywords to obtain the emotional text and output it.

6. The method for automatically generating emotional text according to claim 1, characterized in that: Obtaining an article abstract according to the article to be processed includes: The article to be processed is subjected to a seq2seq model to obtain an article summary.

7. The method for automatically generating emotional text according to claim 6, characterized in that: The step of obtaining an article summary by using a seq2seq model according to the article to be processed includes: Get training articles; Passing the training article through an implication relation classifier in an encoder of the seq2seq model to obtain a first vector and a second vector; Combining the first vector and the second vector into a feature vector and performing implication prediction through a classification module; An article summary is generated by the decoder of the seq2seq model, and the ratio of the article summary contained in the training article is used as a reward to train the seq2seq model, thereby obtaining a trained seq2seq model.

8. A terminal for automatically generating emotional text, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for automatically generating emotional text according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Text processing method and device, equipment and medium

    CN111783468A