Text emotion recognition model training method and text emotion recognition method

Through training memory and generalized emotional identification models, the emotional identification model in existing technology is difficult to take into account the problem of memory and generalization, and realize the efficient and accurate identification of different emotional expression forms.

CN119337183APending Publication Date: 2025-01-21CHINA MOBILE ONLINE SERVICES CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411500919.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-01-21

AI Technical Summary

Technical Problem

The prior art is difficult to take into account the memory and generalization of text emotion recognition models at the same time, resulting in insufficient accuracy and adaptability of emotion recognition in practical applications.

Method used

By obtaining the sample emotion recognition data set and the sample emotion classification label set, memory-based and generalized emotion recognition models are trained respectively. The memory model emphasizes the memory of known emotional features through the FM model, and the generalization model improves the recognition ability of complex emotional expressions through the BERT model.

Benefits of technology

The text emotion recognition model achieves efficient and accurate recognition in different emotional expression forms, has both memory and generalization capabilities, and improves the accuracy and adaptability of emotion recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119337183A_ABST
    Figure CN119337183A_ABST
Patent Text Reader

Abstract

The invention provides a training method of a text emotion recognition model and a text emotion recognition method, and relates to the technical field of natural language processing. The method comprises the steps of training a first preset model based on a sample emotion recognition data set and a sample emotion classification label set, and determining a memory type emotion recognition model; determining a sample balance emotion recognition data set from the sample emotion recognition data set based on the sample emotion classification tag set; determining a generalization type emotion recognition model based on the sample balance emotion recognition data set and the balance emotion classification label set; and determining a text emotion recognition model based on the memory type emotion recognition model and the generalization type emotion recognition model. According to the method, the problem that an emotion recognition method in the prior art is difficult to give consideration to memorability and generalization at the same time can be solved, and efficient and accurate recognition of different forms of text emotion expressions is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a training method for a text emotion recognition model and a text emotion recognition method. Background Art

[0002] With the continuous growth of the number of Internet users, public opinion information on social media and other digital platforms has shown explosive growth. Users express their opinions and share their experiences through various platforms. The emotional tendency of this information will affect public opinion, and then have a profound impact on corporate image and social events. How to quickly and accurately identify emotional information in massive texts has become an important topic in the field of data analysis and public opinion monitoring. Existing technologies mainly rely on two methods in emotion recognition: keyword-based dictionary matching method and deep learning-based model training method. The dictionary matching method relies on an artificially accumulated keyword library to identify text emotions through rule matching. This method has a strong memory ability and can accurately capture known feature words, but when faced with new vocabulary and complex contexts, its generalization ability is insufficient and it is difficult to adapt to the ever-changing user language expressions. On the other hand, deep learning models have strong generalization ability and can automatically learn diverse features in data, but due to their weak memory for specific rare features, they often cannot accurately identify low-frequency but important emotional information.

[0003] Therefore, it is difficult for existing emotion recognition methods to take into account both memorability and generalization at the same time, resulting in insufficient accuracy and adaptability of emotion recognition in practical applications. There is an urgent need for a method that can take into account both memorability and generalization at the same time to improve the efficiency and accuracy of text emotion recognition. Summary of the invention

[0004] The present invention provides a text emotion recognition model training method and a text emotion recognition method, so as to solve the defect that the emotion recognition method in the prior art is difficult to take into account both memorability and generalization at the same time, resulting in insufficient accuracy and adaptability of emotion recognition in practical applications.

[0005] The present invention provides a training method for a text emotion recognition model, comprising: Obtain a sample emotion recognition data set and a sample emotion classification label set, wherein each emotion label in the sample emotion classification label set corresponds one-to-one to each sample emotion recognition data in the sample emotion recognition data set; the emotion labels in the sample emotion classification label set are divided into positive emotion labels and negative emotion labels; Based on the sample emotion recognition data set and the sample emotion classification label set, training a first preset model to determine a memory-based emotion recognition model; Based on the sample emotion classification label set, determining a sample balanced emotion recognition data set from the sample emotion recognition data set, wherein the number of sample emotion recognition data representing positive emotion labels in the sample balanced emotion recognition data set is the same as the number of sample emotion recognition data representing negative emotion labels; Based on the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set, training a second preset model to determine a generalized emotion recognition model; Based on the memory-type emotion recognition model and the generalized emotion recognition model, a text emotion recognition model is determined.

[0006] According to a text emotion recognition model training method provided by the present invention, after obtaining a sample emotion recognition data set and a sample emotion classification label set, the method further includes: The sample emotion recognition data set is input into a classification model to obtain a classification result output by the classification model; the classification result is used to determine the text type of each sample emotion recognition data in the sample emotion recognition data set, and the text type includes a short review text or a media text; Based on the classification result, the sample emotion recognition dataset is determined as a short review text emotion recognition dataset or a media text emotion recognition dataset; If the sample emotion recognition data set is a short review text emotion recognition data set, the text emotion recognition model is determined as a short review text emotion recognition model; If the sample emotion recognition data set is a media text emotion recognition data set, the text emotion recognition model is determined to be a media text emotion recognition model.

[0007] According to a text emotion recognition model training method provided by the present invention, the first preset model is trained based on the sample emotion recognition data set and the sample emotion classification label set to determine the memory-type emotion recognition model, including: Determine the matching results of the emotion keywords of each sample emotion recognition data in the sample emotion recognition data set and each preset emotion word in the preset emotion word set; each preset emotion word in the preset emotion word set is provided with a weight; Determine the emotion score of the emotion keyword of each piece of the sample emotion recognition data based on the matching result and the weight of each preset emotion word in the preset emotion word set; Convert the emotion score of the emotion keyword of each piece of sample emotion recognition data into a vector representation to determine a sample emotion recognition data vector set; wherein each emotion recognition data vector in the sample emotion recognition data vector set corresponds one-to-one to each piece of sample emotion recognition data in the sample emotion recognition data set; Based on the sample emotion recognition data vector set and the sample emotion classification label set, a first preset model is trained to determine a memory-type emotion recognition model.

[0008] According to a text emotion recognition model training method provided by the present invention, the sample emotion recognition data set and the sample emotion classification label set are determined based on the following method: Acquire a first emotion recognition data set, and determine a first emotion classification label set based on a collection source attribute of each emotion recognition data in the first emotion recognition data set; the collection source attribute is a basis for determining an emotion label corresponding to the emotion recognition data; Acquire a second emotion recognition data set, and perform semantic sequence segmentation on each emotion recognition data in the second emotion recognition data set to obtain a second emotion recognition data sequence set; Determine the total emotion score of each emotion recognition data sequence in the second emotion recognition data sequence set based on the matching results between the semantic units in each emotion recognition data sequence in the second emotion recognition data sequence set and the preset emotion words in the preset emotion word set; Determine a second emotion classification label set based on the total emotion score of each emotion recognition data sequence in the second emotion recognition data sequence set; The total emotion score of each emotion recognition data sequence in the second emotion recognition data sequence set is compared with the preset emotion threshold range respectively, and based on the comparison result, a third emotion recognition data sequence set is determined, and the second emotion classification label set is determined as the third emotion classification label set; each emotion label in the third emotion classification label set corresponds to each emotion recognition data sequence in the third emotion recognition data sequence set one by one; Deleting a semantic unit in each emotion recognition data sequence of the third emotion recognition data sequence set that matches the same semantic unit as each preset emotion word in the preset emotion word set, to determine a third emotion recognition data set; Based on the first emotion recognition data set and the third emotion recognition data set, a sample emotion recognition data set is determined; based on the first emotion classification label set and the third emotion classification label set, a sample emotion classification label set is determined.

[0009] The present invention also provides a text emotion recognition method, comprising: Inputting the text to be recognized into a text emotion recognition model to obtain an emotion recognition result output by the text emotion recognition model; Wherein, the text emotion recognition model is trained based on the training method of the text emotion recognition model as mentioned above.

[0010] According to a text emotion recognition method provided by the present invention, the text emotion recognition model includes a short review text emotion recognition model or a media text emotion recognition model, and the text to be recognized is input into the text emotion recognition model to obtain the emotion recognition result output by the text emotion recognition model, including: Input the text to be recognized into a classification model to obtain a classification result output by the classification model; the classification result is used to determine the text type of the text to be recognized, and the text type includes a short review text or a media text; If the text type of the to-be-recognized text is a short review text, the to-be-recognized text is input into the short review text emotion recognition model to obtain a short review text emotion recognition result output by the short review text emotion recognition model; If the text type of the text to be recognized is media text, the text to be recognized is input into the media text emotion recognition model to obtain a media text emotion recognition result output by the media text emotion recognition model.

[0011] The present invention also provides a text emotion recognition device, comprising: A training data acquisition module, which is used to acquire a sample emotion recognition data set and a sample emotion classification label set, wherein each emotion label in the sample emotion classification label set corresponds one-to-one to each sample emotion recognition data in the sample emotion recognition data set; the emotion labels in the sample emotion classification label set are divided into positive emotion labels and negative emotion labels; A memory-type emotion recognition model training module, which is used to train a first preset model based on the sample emotion recognition data set and the sample emotion classification label set to determine a memory-type emotion recognition model; A balanced data acquisition module, which is used to determine a sample balanced emotion recognition data set from the sample emotion recognition data set based on the sample emotion classification label set, wherein the number of sample emotion recognition data representing positive emotion labels in the sample balanced emotion recognition data set is the same as the number of sample emotion recognition data representing negative emotion labels; A generalized emotion model training module, which is used to train a second preset model based on the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set to determine a generalized emotion recognition model; The text emotion recognition model determination module is used to determine the text emotion recognition model based on the memory-type emotion recognition model and the generalization-type emotion recognition model.

[0012] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the training method for a text emotion recognition model as described in any one of the above items is implemented; or, when the processor executes the computer program, the text emotion recognition method as described in any one of the above items is implemented.

[0013] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for training a text emotion recognition model as described in any one of the above items; or, when the computer program is executed by a processor, implements a method for text emotion recognition as described in any one of the above items.

[0014] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements a training method for a text emotion recognition model as described in any one of the above; or, when executed by a processor, implements a text emotion recognition method as described in any one of the above.

[0015] The training method of the text emotion recognition model and the text emotion recognition method provided by the present invention obtain a sample emotion recognition data set and a sample emotion classification label set, wherein each emotion label in the sample emotion classification label set corresponds one-to-one to each sample emotion recognition data in the sample emotion recognition data set; the emotion labels in the sample emotion classification label set are divided into positive emotion labels and negative emotion labels; based on the sample emotion recognition data set and the sample emotion classification label set, a first preset model is trained to determine a memory-type emotion recognition model; based on the sample emotion classification label set, a sample balanced emotion recognition data set is determined from the sample emotion recognition data set, wherein the number of sample emotion recognition data representing positive emotion labels in the sample balanced emotion recognition data set is the same as the number of sample emotion recognition data representing negative emotion labels; based on the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set, a second preset model is trained to determine a generalized emotion recognition model emotion recognition model; based on the memory-type emotion recognition model and the generalized emotion recognition model, a text emotion recognition model is determined; the present invention uses a sample emotion recognition data set and a sample emotion classification label set to use a first preset model for training, focusing on improving the model's memory ability for known emotion features, ensuring the trained memory-type emotion recognition model's emotion recognition accuracy for news, traditional media and other texts; by using a sample balanced emotion recognition data set and a balanced emotion classification label set to train the second preset model, its generalization ability is improved, so that the trained generalized emotion recognition model can focus on the recognition of complex and diverse emotional expressions, especially in dynamic texts such as social media and short reviews, and can effectively respond to emerging vocabulary and semantic changes, and improve generalization performance; after completing the training of the memory-type emotion recognition model and the generalized emotion recognition model, the advantages of the two are combined to form a text emotion recognition model with both memory and generalization capabilities, so as to achieve efficient and accurate recognition of different text emotion expressions. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0017] Figure 1 It is a flowchart of the training method of the text emotion recognition model provided by the present invention.

[0018] Figure 2 It is a schematic diagram of the training data acquisition process of the training method of the text emotion recognition model provided by the present invention.

[0019] Figure 3 It is a flow chart of the text emotion recognition method provided by the present invention.

[0020] Figure 4 It is a structural schematic diagram of the training device of the text emotion recognition model provided by the present invention.

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

[0022] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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.

[0023] In the field of text emotion recognition, the existing technology has realized emotion classification methods based on machine learning and deep learning models, which can effectively identify the emotional tendency of text in specific scenarios. However, after in-depth research and experiments, the applicant found that there is a key problem in the existing emotion recognition technology, that is, when faced with different types of text data, it is impossible to take into account the memory and generalization of the model at the same time. Specifically, the emotion recognition models in the existing technology are either good at processing texts with fixed or known emotional expressions, showing good memory ability, but poor recognition effect when faced with uncommon or complex emotional expressions; or they have strong generalization ability and can cope with diverse emotional expressions, but sacrifice the memory ability of common emotional vocabulary and fixed structures, resulting in a decrease in recognition accuracy.

[0024] The applicant further discovered that although the existing technology has partially solved some emotion recognition problems, it still has shortcomings. For example, the existing memory-based model can perform well in structured texts such as traditional media and news articles, and can accurately identify clear emotional tendencies. However, when faced with texts such as short reviews and social media, the memory-based model cannot adapt due to the flexible and changeable language usage of these texts, and the recognition accuracy is low. On the other hand, the generalized model can better cope with these complex emotional expressions, but when dealing with fixed emotional vocabulary and structured emotional expressions, the recognition accuracy is not enough, especially in the memory and recognition of known emotional features. Through an in-depth analysis of the existing technology, the applicant found that there is currently a lack of an emotion recognition method that can accurately remember known emotional features and adapt to complex and changeable emotional expressions. The existing single model is difficult to meet both requirements at the same time, resulting in insufficient overall accuracy and adaptability of emotion recognition. Therefore, there is an urgent need for an innovative solution that can combine the advantages of memory-based and generalized emotion recognition models to achieve efficient and accurate recognition of different emotional expressions.

[0025] In view of the above problems, the present invention proposes the following embodiments.

[0026] Figure 1 It is a flowchart of the training method of the text emotion recognition model provided by the present invention, such as Figure 1 As shown, the training process includes the following steps: Step 110, obtaining a sample emotion recognition data set and a sample emotion classification label set, wherein each emotion label in the sample emotion classification label set corresponds one-to-one to each sample emotion recognition data in the sample emotion recognition data set; the emotion labels in the sample emotion classification label set are divided into positive emotion labels and negative emotion labels.

[0027] Here, the sample emotion recognition dataset is a collection containing a large number of sample emotion recognition data. Specifically, each sample emotion recognition data refers to a text, which belongs to the object to be recognized. These texts can come from different sources such as social media, comments, news, etc., representing a wide range of emotional expressions. Each text is assigned an emotion label to mark the emotional tendency of the text. These emotion labels form a sample emotion classification label set; emotion labels are usually divided into positive emotion labels and negative emotion labels. For example, a positive comment will be labeled with positive emotion, while a negative comment will be labeled with negative emotion.

[0028] It should be noted that each emotion recognition sample data corresponds to a unique emotion label. This means that each text has been clearly labeled with its emotion category. This correspondence ensures that the model can correctly associate the text content with the emotional tendency, so that the characteristics of different emotions can be learned during training.

[0029] Step 120: Based on the sample emotion recognition data set and the sample emotion classification label set, a first preset model is trained to determine a memory-based emotion recognition model.

[0030] It should be noted that the first preset model refers to the Wide side model, and the first preset model uses the FM model to implement the function. Specifically, the Wide side model uses the FM model to remember the feature rules related to the sentiment label. The FM model is very good at processing discrete variables, especially in sentiment recognition tasks. It can identify potential patterns related to sentiment labels by modeling high-order interactions of features. When training the Wide side model, you are actually training an FM model. The Wide side model is trained using a set of sample sentiment recognition data vectors and corresponding sentiment labels, so that the FM model can learn and remember the characteristics of specific emotions. Since the FM model can process discrete variables and remember the interactions of features, the Wide side model can better capture the sentiment-related features in the sentiment dictionary, thereby enhancing the accuracy of recognition.

[0031] The Wide side model focuses on memory, which makes it perform well in recognizing features it has seen, but may have poor generalization ability for new features. Therefore, the Wide side model needs to be used in conjunction with the Deep side model to achieve a balance between feature memory and generalization ability.

[0032] For example, the Wide side model focuses on memorization, which makes it perform well in recognizing seen features, but may have weak generalization capabilities for new features. Therefore, the Wide side model needs to be used in conjunction with the Deep side model to achieve a balance between feature memory and generalization capabilities. In summary, the Wide side model is built based on the FM model, aiming to improve the accuracy and efficiency of emotion recognition by capturing and remembering the relationship between features. The FM model provides the Wide side model with powerful feature interaction capabilities and memorization, enabling it to perform better when handling emotion recognition tasks.

[0033] In one embodiment, the first preset model, i.e., the Wide-side model, adopts a factorization machine (FM) model; the FM model is particularly good at processing discrete variables, and therefore the first preset model is trained using a sample emotion recognition data vector set obtained by vectorizing the sample emotion recognition data set and a corresponding sample emotion classification label set; specifically, each vector in the sample emotion recognition data vector set corresponds one-to-one to each emotion label in the sample emotion classification label set, and this one-to-one correspondence ensures that during the training process, the model can accurately learn the connection between each emotion label and its corresponding feature; further, by training the first preset model, a memory-type emotion recognition model is finally determined, and by utilizing the powerful memory capacity of the FM model, the recognition accuracy in emotion classification tasks can be significantly improved, especially when processing specific emotion vocabulary, the FM model can effectively capture the rules of emotion features, thereby improving the overall performance of the model.

[0034] For details on how to determine the sample emotion recognition data vector set, please refer to the following embodiments, which will not be elaborated here.

[0035] Step 130, based on the sample emotion classification label set, determine a sample balanced emotion recognition data set from the sample emotion recognition data set, wherein the number of sample emotion recognition data representing positive emotion labels in the sample balanced emotion recognition data set is the same as the number of sample emotion recognition data representing negative emotion labels.

[0036] Exemplarily, in the process of generating a sample balanced emotion recognition data set, firstly, based on the sample emotion classification label set, each sample emotion recognition data is selected from the sample emotion recognition data set, and it is ensured that the emotion label of each sample emotion recognition data corresponds to its corresponding emotion recognition data one by one. In other words, the emotion recognition data and the emotion label always maintain a matching relationship. Further, in order to construct a sample balanced emotion recognition data set, for a certain emotion label, some emotion words are deleted from the corresponding sample emotion recognition data to generate a new data sample. At this time, this new data sample still maintains the same emotion label correspondence as the original sample; by repeating the above process, similar processing is performed on different samples to generate multiple data samples; finally, it is ensured that the number of data samples corresponding to the generated positive emotion labels is equal to the number of data samples corresponding to the negative emotion labels, thereby forming a balanced sample emotion recognition data set. This balanced emotion recognition data set can effectively reduce the impact of category imbalance on model training and improve the recognition accuracy and robustness of the model.

[0037] Specifically, for example, delete some emotional words from the sample emotion recognition data corresponding to the positive emotion label A to obtain a new data sample a; delete some emotional words from the sample emotion recognition data corresponding to the negative emotion label B to obtain a new data sample b. Repeat this operation to obtain a sample balanced emotion recognition data set. At this time, the number of sample emotion recognition data with positive emotion labels in the sample balanced emotion recognition data set is the same as the number of sample emotion recognition data representing negative emotion labels.

[0038] Step 140: Based on the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set, a second preset model is trained to determine a generalized emotion recognition model.

[0039] Exemplarily, the second preset model refers to the Deep side model, which is a part used to improve the generalization of the emotion recognition model. Generalization refers to the ability of the model to maintain a high classification accuracy when facing unseen and new emotional expressions. In this method, the Deep side uses the BERT (Bidirectional Encoder Representation Model) model for deep semantic feature extraction and learning. Since the BERT model has strong semantic understanding capabilities, especially the ability to capture contextual information, it is very suitable for processing sentiment classification tasks. In this process, the Deep side model relies on BERT as its deep learning foundation, and enhances its generalization ability in Chinese text through the Whole Word Masking model. As an improved version of BERT, the Whole Word Masking model performs better when processing Chinese text because it can more accurately process the vocabulary structure in the Chinese language through the whole word masking technology, improving the model's understanding of emotional expression.

[0040] Here, a generalized emotion recognition model is obtained based on the Deep side model training. The Deep side model focuses on generalization ability, processes data through a complex network structure, and captures deep features in the data.

[0041] It should be noted that when the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set are input into the Deep side model for training, since the Wide side model needs to be jointly trained with the Deep side model to obtain the optimal parameters, there is no need for a linear classifier to output the result. The specific joint training steps can be referred to the following embodiments, which will not be described in detail here.

[0042] Step 150: Determine a text emotion recognition model based on the memory-based emotion recognition model and the generalized emotion recognition model.

[0043] Here, the memory-based emotion recognition model is trained based on the Wide-side model, which is good at remembering specific patterns and emotion keywords that have been observed. For example, it can efficiently capture and remember known emotion words and their associations in the emotion dictionary. This makes it perform well when dealing with tasks with known emotion rules.

[0044] Here, the generalized emotion recognition model is trained based on the Deep side model, which has strong generalization ability. This means that it can not only recognize the emotion patterns in the training data, but also make accurate judgments in unseen emotion words or sentence structures, and has stronger transfer learning ability.

[0045] It should be noted that by combining the memory model on the Wide side and the generalization model on the Deep side, the text emotion recognition model can process both known and unknown emotion patterns. The Wide side model is good at memorizing known emotion words and patterns, and can show high accuracy when facing texts with fixed emotion rules; while the Deep side model is good at understanding complex contexts, especially when dealing with unseen sentence structures or vocabulary, and can effectively reason, thereby achieving accurate analysis of novel or ambiguous emotion expressions.

[0046] For example, the outputs of the wide side model and the deep side model are weighted and summed, and then trained through a unified logical loss function. Specifically, the wide side model is mainly good at memorizing and processing historical rules, while the deep side model captures complex contexts and new emotional patterns through deep learning. The purpose of joint training is to let the two models work together, combining their respective advantages, and finally obtain a text emotion recognition model that can process different types of data at the same time. Among them, the loss function formula is: ; This formula describes the probability that the model predicts label Y=1 for a given input X, where Y is a binary classification label. is the sigmoid function, It is used to convert the original feature x into a format suitable for model processing. b is the bias term. is the weight vector of the Wide side model, Is used for the final activation function The loss function combines the outputs of the wide-side model and the deep-side model, weights the predictions of the two, and calculates the final classification probability through the Sigmoid function. The goal of the logistic loss function is to adjust the weights of the wide-side model and the deep-side model by minimizing the classification error, so that the model can predict different sentiment labels more accurately.

[0047] The training method of the text emotion recognition model provided by the embodiment of the present invention uses a first preset model for training through a sample emotion recognition data set and a sample emotion classification label set, focusing on improving the model's memory ability for known emotion features, ensuring the emotion recognition accuracy of the trained memory-type emotion recognition model for news, traditional media and other texts; by training the second preset model with a sample balanced emotion recognition data set and a balanced emotion classification label set, its generalization ability is improved, so that the trained generalized emotion recognition model can focus on the recognition of complex and diversified emotion expressions, especially in dynamic texts such as social media and short reviews, and can effectively respond to emerging vocabulary and semantic changes, and improve generalization performance; after completing the training of the memory-type emotion recognition model and the generalized emotion recognition model, the advantages of the two are combined to form a text emotion recognition model with both memory and generalization capabilities, so as to achieve efficient and accurate recognition of different forms of emotion expression.

[0048] Based on any of the above embodiments, in the method, after obtaining the sample emotion recognition data set and the sample emotion classification label set, the method further includes: The sample emotion recognition data set is input into a classification model to obtain a classification result output by the classification model; the classification result is used to determine the text type of each sample emotion recognition data in the sample emotion recognition data set, and the text type includes a short review text or a media text; Based on the classification result, the sample emotion recognition dataset is determined as a short review text emotion recognition dataset or a media text emotion recognition dataset; If the sample emotion recognition data set is a short review text emotion recognition data set, the text emotion recognition model is determined as a short review text emotion recognition model; If the sample emotion recognition data set is a media text emotion recognition data set, the text emotion recognition model is determined to be a media text emotion recognition model.

[0049] In one embodiment, the sample emotion recognition data set needs to be classified by a classification model, so as to determine the sample emotion recognition data set as a short review text emotion recognition data set or a media text emotion recognition data set according to the classification result.

[0050] Specifically, the classification model can analyze the features of the text and output the corresponding classification results. The classification results usually include short review text and media text; if the text is classified as a short review text, it will be input into a short review text sentiment recognition model designed specifically for short reviews. The short review text sentiment recognition model will extract sentiment keywords and sentiment tendencies in the text to output the short review text sentiment recognition results; if the text is classified as a media text, it will be input into a media text sentiment recognition model for media text to output the media text sentiment recognition results. The design of the media text sentiment recognition model takes into account the characteristics of media texts and may adopt more complex feature extraction methods to capture the emotional information in the text.

[0051] Here, the short review text sentiment recognition dataset refers to the short reviews posted by users on e-commerce platforms, social media, etc. These reviews are usually short and direct, and can reflect the user's immediate feelings about the product or service.

[0052] Here, the media text emotion recognition dataset includes text data from news, commentary articles, or other forms of media content. Such texts are usually more formal and contain longer narratives and analyses. According to the selected dataset and, if the short comment text emotion recognition dataset and its corresponding label set are used, the generated emotion recognition model is called the short comment text emotion recognition model. Conversely, if the media text emotion recognition dataset and its label set are used, the generated model is called the media text emotion recognition model.

[0053] Specifically, user reviews are more colloquial and casual, containing a large number of Internet buzzwords and informal expressions, creating a relaxed and free communication atmosphere. User reviews usually focus more on expressing personal feelings and opinions; user reviews are more direct and emotionally vivid in emotional expression, and can quickly convey users' true thoughts and emotions. Traditional media tend to use formal and rigorous language, focus on logic and factual accuracy, and avoid using Internet buzzwords and informal expressions in order to maintain their professionalism and authority; traditional media are usually more restrained in emotional expression, emphasizing more facts and objective analysis, and may not be as direct or obvious as user reviews. Due to the significant differences in language style and structural characteristics mentioned above, traditional media and user reviews show different needs and characteristics in emotion recognition. This means that different emotion recognition models need to be trained for traditional media and user reviews respectively in order to better adapt to their respective text characteristics. This will ensure the accuracy and effectiveness of emotion recognition. By training specifically for each text type, the model can learn and understand the unique emotional expression of each text more deeply, thereby improving the quality and adaptability of emotion recognition.

[0054] The training method of the text emotion recognition model provided by the embodiment of the present invention significantly improves the accuracy and adaptability of emotion recognition by training the emotion recognition models of short review text and media text separately. Since the language of short review text is more colloquial and the structure is free, while media text tends to be formal and logical, targeted model training enables each model to focus on specific text features, thereby effectively capturing emotional information. In addition, this separate training strategy improves the training efficiency of the model, reduces unnecessary information interference, and facilitates subsequent optimization and maintenance. This method not only improves the performance of emotion recognition, but also enhances the user experience, so that the system can better meet the user's needs for emotional feedback.

[0055] Based on any of the above embodiments, in the method, training a first preset model based on the sample emotion recognition data set and the sample emotion classification label set to determine a memory-based emotion recognition model includes: Determine the matching results of the emotion keywords of each sample emotion recognition data in the sample emotion recognition data set and each preset emotion word in the preset emotion word set; each preset emotion word in the preset emotion word set is provided with a weight; Determine the emotion score of the emotion keyword of each piece of the sample emotion recognition data based on the matching result and the weight of each preset emotion word in the preset emotion word set; Convert the emotion score of the emotion keyword of each piece of sample emotion recognition data into a vector representation to determine a sample emotion recognition data vector set; wherein each emotion recognition data vector in the sample emotion recognition data vector set corresponds one-to-one to each piece of sample emotion recognition data in the sample emotion recognition data set; Based on the sample emotion recognition data vector set and the sample emotion classification label set, a first preset model is trained to determine a memory-type emotion recognition model.

[0056] Here, the core is to convert the sample emotion recognition dataset into a sample emotion recognition data vector set. This process usually involves converting text samples into numerical formats so that machine learning models can process and analyze them. Through the above vectorization process, a set of multiple vectors is finally obtained, each vector represents the characteristics of a text sample, and this vector set can be used for subsequent model training and emotion recognition.

[0057] Here, the preset sentiment word set is a set of sentiment words defined in advance, and each word is assigned a corresponding weight. The sentiment score is a value calculated based on the matching results of sentiment keywords and preset sentiment words and their weights, reflecting the degree of sentiment tendency of the text.

[0058] In one embodiment, emotional keywords of each sample emotion recognition data are extracted from a sample emotion recognition data set, and these keywords are matched with each preset emotion word in a preset emotion word set. This matching process helps to identify the emotional information in the sample, ensuring that the emotional tendency of the text can be accurately reflected; further, in the preset emotion word set, each emotion word has a corresponding weight, and these weights reflect the importance or influence of different emotion words. By analyzing the matching results and weights, a sentiment score can be calculated for the emotion keyword of each sample emotion recognition data; further, the obtained emotion score is converted into a vector representation, thereby forming a sample emotion recognition data vector set. This process represents the text data in a numerical form, so that the machine learning model can process it; in the sample emotion recognition data vector set, each emotion recognition data vector corresponds one-to-one with each data in the original sample emotion recognition data set, ensuring the accuracy and traceability of the data.

[0059] Exemplarily, there are two data sources for the preset sentiment word set. The first is compiled through an open source sentiment dictionary; the second is a self-built dictionary. When constructing a preset sentiment word set, in addition to considering the positive and negative labels of each word, it is also necessary to assign weights to the words. First, the default weight of the words in the open source sentiment dictionary is set to 1, indicating its relative basic importance. Secondly, the weight of the words in the self-built dictionary is usually higher, reflecting its importance in a specific business environment, and the weight value is set according to business accumulation. For example, the weight of a word may be 10 or 6. When fusing the words from the two data sources, the weights of the same words need to be accumulated to form a comprehensive preset sentiment word set. Specifically, for example, if word A and word B both appear in the open source sentiment dictionary, the weights of word A and word B in the open source sentiment dictionary are both 1; for example, if word A and word B both appear in the self-built dictionary, the weight of word A in the self-built dictionary is 10 and the weight of word B in the self-built dictionary is 6 according to their importance in the business; when the open source sentiment dictionary and the self-built dictionary are merged, the final weight of word A in the preset sentiment word set is 11, and the final weight of word B in the preset sentiment word set is 7. Through the above steps, the final constructed sentiment dictionary will contain each word and its corresponding weight, forming a complete sentiment dictionary.

[0060] Exemplarily, the sentiment score of the sentiment keyword of each sample sentiment recognition data can be determined based on the following method: First, each sample sentiment recognition data is segmented and the words that are not in the positive and negative dictionaries are deleted. Further, the text is segmented and stop words are removed, and the sentiment score of the sentiment keyword in each data is calculated based on the following formula: ; in, Words to express The sentiment score, Indicates the frequency of the word in the data. Indicates the weight of the word in the sentiment dictionary, label is the sentiment label of the word, positive is 1, negative is -1. For example, the sentence consists of words A, B, C and D, that is, "ABDCBA". At this time, assuming that word A is a word with a negative sentiment label and D is a word with a positive sentiment label, the weight of word A in the preset sentiment word set is 11, and the weight of word D in the preset sentiment word set is 3; then based on the formula, it can be calculated that the sentiment score of word A is ; The sentiment score of word D is .

[0061] Exemplarily, vector conversion can be performed in the following manner: the factorization machine (FM) model is good at processing discrete variables, so the score of each word can be discretized. First, the sentiment score is divided into 6 intervals (-∞,-30], (-30,-10], (-10,0], (0, 10], (10, 25], (25, +∞]; each word is converted into a six-dimensional vector according to the score. For example: the score of word A is -22, which belongs to the interval (-30,-10], so the vector of word A is represented as "0,1,0,0,0,0"; the score of word D is 3, which belongs to the interval (0, 10], so the vector of word D is represented as "0,0,0,1,0,0". Further, the discretized word vectors are spliced ​​in order.

[0062] The training method of the text emotion recognition model provided by the embodiment of the present invention can more accurately reflect the emotion intensity of different keywords by using the weights of preset emotion words, and effectively distinguish positive and negative emotion tendencies; secondly, after the emotion score is converted into a vector, it is convenient for the model to efficiently process the emotion information in subsequent training and reasoning, ensuring that the feature vector of each emotion recognition data corresponds one-to-one with the original text emotion, thereby enhancing the accuracy and robustness of emotion classification. This method of combining dictionary weights and vectorization processing provides the model with refined input features and improves the overall emotion recognition effect.

[0063] like Figure 2 As shown, Figure 2 The process of obtaining training data, namely the process of obtaining sample emotion recognition datasets and sample emotion classification label sets, is demonstrated.

[0064] Based on any of the above embodiments, in this method, the sample emotion recognition data set and the sample emotion classification label set are determined based on the following method: Acquire a first emotion recognition data set, and determine a first emotion classification label set based on a collection source attribute of each emotion recognition data in the first emotion recognition data set; the collection source attribute is a basis for determining an emotion label corresponding to the emotion recognition data; Acquire a second emotion recognition data set, and perform semantic sequence segmentation on each emotion recognition data in the second emotion recognition data set to obtain a second emotion recognition data sequence set; Determine the total emotion score of each emotion recognition data sequence in the second emotion recognition data sequence set based on the matching results between the semantic units in each emotion recognition data sequence in the second emotion recognition data sequence set and the preset emotion words in the preset emotion word set; Determine a second emotion classification label set based on the total emotion score of each emotion recognition data sequence in the second emotion recognition data sequence set; The total emotion score of each emotion recognition data sequence in the second emotion recognition data sequence set is compared with the preset emotion threshold range respectively, and based on the comparison result, a third emotion recognition data sequence set is determined, and the second emotion classification label set is determined as the third emotion classification label set; each emotion label in the third emotion classification label set corresponds to each emotion recognition data sequence in the third emotion recognition data sequence set one by one; Deleting a semantic unit in each emotion recognition data sequence of the third emotion recognition data sequence set that matches the same semantic unit as each preset emotion word in the preset emotion word set, to determine a third emotion recognition data set; Based on the first emotion recognition data set and the third emotion recognition data set, a sample emotion recognition data set is determined; based on the first emotion classification label set and the third emotion classification label set, a sample emotion classification label set is determined.

[0065] It should be noted that after obtaining the first emotion recognition data set and the second emotion recognition data set, data preprocessing is required; specifically, data preprocessing includes data filtering, data cleaning, and data format normalization. Data filtering includes filtering content that is not related to the target field, such as advertisements or text data that is not related to the industry; and cleaning up duplicate content and junk information in the data to ensure that the retained content has analytical value; in addition, data that may contain sensitive information or violate laws and regulations needs to be eliminated to ensure the legality and compliance of the data. Data cleaning includes preliminary format processing of text data, removing HTML tags, special characters, extra spaces, and irrelevant information outside the text; as well as processing spelling errors and grammatical problems in the text, and adjusting the text format to ensure the accuracy and consistency of the data. Data format normalization includes, for shorter data, extending the text length to a preset fixed value by padding with 0, that is, adding enough "0" characters at the end of the text until the length requirement is met; for ultra-long texts, in order to avoid the loss of semantic information caused by direct truncation, the TextRank (text ranking algorithm) algorithm is used to extract the summary information of the text. The TextRank algorithm builds a graph model based on the similarity of text slices, iteratively calculates the ranking score of each node, and finally selects the node with the higher score as the summary of the text, retaining the most representative content.

[0066] Here, the source attribute of the collection refers to the source characteristics of the sentiment data, which can help infer the positive or negative tendency of the sentiment. For example, for short review data, the category of the sentiment can be judged according to the source of the comment, and the first sentiment classification label set can be generated based on these attributes. More specifically, in some complaint platforms, because they essentially provide complaint and appeal services for users, user feedback data in the platform can usually be directly judged as negative sentiment. This type of data represents the user's negative experience and is suitable for being labeled as a negative sentiment label. In addition to complaint platforms, sentiment labels can also be labeled through data sources with a rating system. For example, user comment data on an e-commerce website can directly infer sentiment tendencies based on user ratings.

[0067] In one embodiment, the second emotion recognition data set is segmented into semantic sequences, each emotion recognition data is converted into multiple semantic units, and matched with a preset emotion word set, and the total emotion score of each data is calculated; the total emotion score represents the overall emotion intensity of the data, and the emotion tendency is derived by comparing the weights of the emotion words; further, based on these total scores, a second emotion classification label set is generated.

[0068] For example, each piece of data in the second emotion recognition dataset D Perform semantic unit segmentation, and each piece of data after segmentation Transformed into a sequence of semantic units, denoted as ,in , is the nth semantic unit generated after segmentation; the purpose of this semantic unit segmentation is to ensure that each semantic unit after segmentation has a high degree of semantic integrity and fluency. Match with the preset sentiment word set to judge each semantic sequence Whether the semantic unit in appears in the preset sentiment word set, as shown in the formula: ;in , Representing Semantic Sequence The number of occurrences of the semantic unit in h is expressed as: ; If the semantic unit appears in the preset sentiment word set, 1 is returned, and if the semantic unit does not appear in the preset sentiment word set, 0 is returned. To ensure the significance of the subsequent MASK operation, at least two semantic units in each data sequence must hit positive and negative words. Therefore, semantic sequences with a hit value less than 2 must be eliminated.

[0069] In one embodiment, the total emotion score of each emotion recognition data sequence in the second emotion recognition data sequence set is compared with a preset emotion threshold range, emotion data that meets the threshold condition is screened out, a third emotion recognition data sequence set is generated, and the second emotion classification label set is determined as the third emotion classification label set. This process ensures that only data whose emotion intensity meets the set standard will be retained to improve the accuracy of classification.

[0070] Specifically, each piece of emotion recognition data that meets the threshold condition has its corresponding emotion classification label in the second emotion classification label set; through the screening process, these qualified data and their corresponding emotion labels are retained, thereby forming a third emotion recognition data sequence set and its corresponding third emotion classification label set.

[0071] In one embodiment, a semantic unit that matches the same as each preset emotion word in the preset emotion word set is deleted in each emotion recognition data sequence of the third emotion recognition data sequence set to determine the third emotion recognition data set; and the third emotion recognition data set at this time inherits the third emotion classification label set corresponding to the third emotion recognition data sequence set, that is, each emotion recognition data in the third emotion recognition data set corresponds one-to-one to each emotion label in the third emotion classification label set.

[0072] It should be noted that in emotion recognition data, some semantic units may appear multiple times in different emotion data, and the emotional tendency of these keywords is obvious. The model will rely heavily on these keywords to make emotional judgments during training. In this case, the model may tend to "memorize" these words instead of judging the emotional tendency based on the context as a whole, which will cause the model to perform poorly on unseen emotional data or data with different emotional expressions, resulting in overfitting. By deleting these semantic units that match the same preset emotional words, the model can be forced to pay more attention to the remaining semantic information. The model will have to infer the emotional tendency based on the remaining contextual information instead of relying on the direct match of the emotional words. This processing method can help the model learn to better understand complex semantic structures and improve its ability to recognize emotions in different contexts. Deleting semantic units is actually "blurring" the direct clues of emotional expression, allowing the model to learn to make reasonable judgments when the emotional expression is not obvious or the emotional words are missing. The model trained in this way can more accurately perform emotion recognition when faced with new and unseen emotional expressions, and show better generalization ability.

[0073] The training method of the text emotion recognition model provided by the embodiment of the present invention is based on the first emotion recognition data set and the third emotion recognition data set, and determines that the sample emotion recognition data set can improve data diversity. The first emotion recognition data set and the third emotion recognition data set are each derived from different data processing methods. The emotion classification of the first emotion recognition data set is usually based on the data collection source attribute, while the third emotion recognition data set is constructed by screening the total emotion score and deleting specific emotion words. Combining the two helps to obtain more extensive and more diverse training data, so that the model can be exposed to different forms of emotion expression and enhance the learning effect of the model.

[0074] Furthermore, by deleting some sentiment words, the third sentiment recognition dataset can train the model to rely on contextual information for sentiment recognition in the absence of explicit sentiment words. Combining it with the first sentiment recognition dataset can help the model learn how to judge sentiment in the presence of clear sentiment words, and make reasonable sentiment classification when the sentiment expression is vague, thereby improving the model's generalization ability in different scenarios.

[0075] Furthermore, the first sentiment classification label set and the third sentiment classification label set come from different annotation methods, respectively. The first sentiment classification label set is based on the source attributes of the collection, while the third sentiment classification label set is based on the comparison of the total sentiment score and the threshold. By combining the two label sets to determine the final sample sentiment classification label set, the model can be more robust when facing different sources of sentiment and expressions, and reduce the deviation that may be caused by a single annotation method. In addition, the sentiment classification in the first sentiment recognition dataset is usually clearer, and the sentiment keywords are obvious, which helps to improve the classification accuracy of the model. The third sentiment recognition dataset deletes some sentiment words and relies more on contextual information to judge sentiment, which helps to improve the recall rate of the model. By combining the two types of datasets, a better balance can be achieved between precision and recall.

[0076] In general, combining the first emotion recognition dataset with the third emotion recognition dataset, as well as the first emotion classification label set with the third emotion classification label set, can effectively improve the data diversity and the generalization ability of the model, enhance the robustness of the model, and achieve a balance between precision and recall, thereby improving the overall performance of the emotion classification model.

[0077] Based on any of the above embodiments, in the text emotion recognition method, it includes: Inputting the text to be recognized into a text emotion recognition model to obtain an emotion recognition result output by the text emotion recognition model; Wherein, the text emotion recognition model is trained based on the training method of the text emotion recognition model described above.

[0078] In the text emotion recognition method provided by the embodiment of the present invention, the text to be recognized is input into a text emotion recognition model based on a wide-side model and a deep-side model, and the emotion recognition result is generated by the model. This model utilizes the memory ability of the wide-side model and can effectively capture the clear feature interaction relationship in the text, such as the keywords in the sentiment dictionary and their sentiment scores. At the same time, the deep-side model improves the generalization ability of complex semantics through deep learning, ensuring that the model can understand more complex contexts and multi-dimensional emotional expressions. Through the joint training of the wide side and the deep side, the model has both memory and generalization, achieving the effect of improving accuracy and stability in complex text sentiment analysis scenarios.

[0079] like Figure 3 As shown, Figure 3 A flow chart of the text emotion recognition method provided by the present invention is shown.

[0080] Based on any of the above embodiments, in the text emotion recognition method, the text emotion recognition model includes a short review text emotion recognition model or a media text emotion recognition model, and the text to be recognized is input into the text emotion recognition model to obtain the emotion recognition result output by the text emotion recognition model, including: Input the text to be recognized into a classification model to obtain a classification result output by the classification model corresponding to the text to be recognized; the classification result is used to determine the text type of the text to be recognized, and the text type includes a short review text or a media text; If the text type of the to-be-recognized text is a short review text, the to-be-recognized text is input into the short review text emotion recognition model to obtain a short review text emotion recognition result output by the short review text emotion recognition model; If the text type of the text to be recognized is media text, the text to be recognized is input into the media text emotion recognition model to obtain a media text emotion recognition result output by the media text emotion recognition model.

[0081] In one embodiment, the text to be recognized is input into a pre-trained classification model to determine its text type. The classification model can analyze the features of the text and output the corresponding classification results. The classification results usually include short review text and media text; if the text is classified as a short review text, it is input into a short review text emotion recognition model specially designed for short reviews. The short review text emotion recognition model will extract emotional keywords and emotional tendencies in the text to output the short review text emotion recognition results; if the text is classified as a media text, it is input into a media text emotion recognition model for media text to output the media text emotion recognition results. The design of the media text emotion recognition model takes into account the characteristics of media texts, and may adopt more complex feature extraction methods to capture emotional information in the text.

[0082] The text emotion recognition method provided by the embodiment of the present invention can select the most appropriate emotion recognition algorithm for processing by pre-classifying the text to be recognized. The classification and recognition process ensures the best adaptation to different text types, thereby improving the accuracy of emotion recognition; further, there are differences in the emotional expression of different text types. Through the application of targeted models, the risk of misclassification and misjudgment of emotions can be effectively reduced, and the efficiency of the overall system can be improved; further, the design of the method provided by the present invention enables the system to adapt to diverse data inputs, whether it is short reviews or media texts, they can be effectively analyzed through corresponding models, and have a wide range of applications.

[0083] Based on any of the above embodiments, in this method, the classification model is determined based on the following method: Based on the sample emotion recognition text and the classification result label corresponding to the sample emotion recognition text, the FastText preset model is trained to determine the classification model.

[0084] Here, sample emotion recognition text refers to text data that has been annotated and clearly indicates the emotional tendency. These texts are the basis for model training and directly affect the classification effect of the model. The classification result label is the result of annotating the emotional tendency of each sample emotion recognition text, usually including different emotional categories, such as positive, negative, and neutral. The FastText preset model is a text classification and representation learning model that can effectively process text data, generate high-quality word vectors, and be used for text classification tasks. Its core advantage lies in its fast and accurate text processing capabilities.

[0085] For example, first, training data is obtained from preprocessed data and the data is preliminarily classified. Then, the FastText algorithm is used to train the data to build an efficient and accurate classification model. Finally, the classification model is applied to new input data to achieve automatic classification and labeling. This process effectively improves the efficiency and accuracy of data processing and ensures the reliability of sentiment analysis.

[0086] The text emotion recognition method provided by the embodiment of the present invention uses a large amount of labeled data for training, so that the model has strong generalization ability and can accurately recognize different types of text; secondly, the FastText algorithm has high computing efficiency when processing relatively simple classification tasks, ensuring rapid response; finally, the establishment of the model provides a solid foundation for subsequent emotion analysis, enhances the accuracy and reliability of emotion recognition, and thus improves the overall efficiency of data processing.

[0087] The text emotion recognition device provided by the present invention is described below. The text emotion recognition device described below and the text emotion recognition method described above can be referenced to each other.

[0088] Figure 4 A structural diagram of a training device for a text emotion recognition model provided by the present invention, such as Figure 4 As shown, the training device of the text emotion recognition model includes: A training data acquisition module 410 is used to acquire a sample emotion recognition data set and a sample emotion classification label set, wherein each emotion label in the sample emotion classification label set corresponds one-to-one to each sample emotion recognition data in the sample emotion recognition data set; and the emotion labels in the sample emotion classification label set are divided into positive emotion labels and negative emotion labels; A memory-type emotion recognition model training module 420, which is used to train a first preset model based on the sample emotion recognition data set and the sample emotion classification label set to determine a memory-type emotion recognition model; A balanced data acquisition module 430, which is used to determine a sample balanced emotion recognition data set from the sample emotion recognition data set based on the sample emotion classification label set, wherein the number of sample emotion recognition data representing positive emotion labels in the sample balanced emotion recognition data set is the same as the number of sample emotion recognition data representing negative emotion labels; A generalized emotion model training module 440, which is used to train a second preset model based on the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set to determine a generalized emotion recognition model; The text emotion recognition model determination module 450 is used to determine the text emotion recognition model based on the memory-type emotion recognition model and the generalization-type emotion recognition model.

[0089] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530 and a communications bus 540, wherein the processor 510, the communications interface 520 and the memory 530 communicate with each other via the communications bus 540. The processor 510 may call the logic instructions in the memory 530 to execute a training method for a text emotion recognition model, the method comprising: obtaining a sample emotion recognition data set and a sample emotion classification label set, wherein each emotion label in the sample emotion classification label set corresponds one-to-one to each sample emotion recognition data in the sample emotion recognition data set; the emotion labels in the sample emotion classification label set are divided into positive emotion labels and negative emotion labels; based on the sample emotion recognition data set and the sample emotion classification label set, a first preset model is trained to determine a memory-type emotion recognition model; based on the sample emotion classification label set, a sample balanced emotion recognition data set is determined from the sample emotion recognition data set, wherein the sample balanced emotion recognition data set The number of sample emotion recognition data representing positive emotion labels is the same as the number of sample emotion recognition data representing negative emotion labels; based on the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set, a second preset model is trained to determine a generalized emotion recognition model; based on the memory-type emotion recognition model and the generalized emotion recognition model, a text emotion recognition model is determined; or, a text emotion recognition method is executed, the method comprising: inputting the text to be recognized into the text emotion recognition model to obtain an emotion recognition result output by the text emotion recognition model; wherein the text emotion recognition model is trained based on the training method of the text emotion recognition model as described in any of the above items.

[0090] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0091] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the training method of the text emotion recognition model provided by the above-mentioned methods, and the method includes: obtaining a sample emotion recognition data set and a sample emotion classification label set, wherein each emotion label in the sample emotion classification label set corresponds one-to-one to each sample emotion recognition data in the sample emotion recognition data set; the emotion labels in the sample emotion classification label set are divided into positive emotion labels and negative emotion labels; based on the sample emotion recognition data set and the sample emotion classification label set, a first preset model is trained to determine a memory-type emotion recognition model; based on ... A sample balanced emotion recognition data set is determined in the data set, wherein the number of sample emotion recognition data representing positive emotion labels in the sample balanced emotion recognition data set is the same as the number of sample emotion recognition data representing negative emotion labels; based on the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set, a second preset model is trained to determine a generalized emotion recognition model; based on the memory-type emotion recognition model and the generalized emotion recognition model, a text emotion recognition model is determined; or, a text emotion recognition method is executed, the method comprising: inputting a text to be recognized into the text emotion recognition model to obtain an emotion recognition result output by the text emotion recognition model; wherein the text emotion recognition model is trained based on the training method of the text emotion recognition model as described in any of the above items.

[0092] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a training method for a text emotion recognition model provided by the above-mentioned methods, the method comprising: obtaining a sample emotion recognition data set and a sample emotion classification label set, wherein each emotion label in the sample emotion classification label set corresponds one-to-one to each sample emotion recognition data in the sample emotion recognition data set; the emotion labels in the sample emotion classification label set are divided into positive emotion labels and negative emotion labels; based on the sample emotion recognition data set and the sample emotion classification label set, a first preset model is trained to determine a memory-type emotion recognition model; based on the sample emotion classification label set, a sample balanced emotion recognition is determined from the sample emotion recognition data set. A sample balanced emotion recognition data set is prepared, wherein the number of sample emotion recognition data representing positive emotion labels in the sample balanced emotion recognition data set is the same as the number of sample emotion recognition data representing negative emotion labels; based on the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set, a second preset model is trained to determine a generalized emotion recognition model; based on the memory-type emotion recognition model and the generalized emotion recognition model, a text emotion recognition model is determined; or, a text emotion recognition method is executed, which method comprises: inputting a text to be recognized into the text emotion recognition model to obtain an emotion recognition result output by the text emotion recognition model; wherein the text emotion recognition model is trained based on the training method of the text emotion recognition model as described in any one of the above items.

[0093] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0094] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

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

Claims

1. A training method for a text emotion recognition model, characterized in that: include: Obtain a sample emotion recognition data set and a sample emotion classification label set, wherein each emotion label in the sample emotion classification label set corresponds one-to-one to each sample emotion recognition data in the sample emotion recognition data set; the emotion labels in the sample emotion classification label set are divided into positive emotion labels and negative emotion labels; Based on the sample emotion recognition data set and the sample emotion classification label set, training a first preset model to determine a memory-based emotion recognition model; Based on the sample emotion classification label set, determining a sample balanced emotion recognition data set from the sample emotion recognition data set, wherein the number of sample emotion recognition data representing positive emotion labels in the sample balanced emotion recognition data set is the same as the number of sample emotion recognition data representing negative emotion labels; Based on the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set, training a second preset model to determine a generalized emotion recognition model; Based on the memory-type emotion recognition model and the generalized emotion recognition model, a text emotion recognition model is determined.

2. The training method of the text emotion recognition model according to claim 1, characterized in that: After obtaining the sample emotion recognition data set and the sample emotion classification label set, the method further includes: The sample emotion recognition data set is input into a classification model to obtain a classification result output by the classification model; the classification result is used to determine the text type of each sample emotion recognition data in the sample emotion recognition data set, and the text type includes a short review text or a media text; Based on the classification result, the sample emotion recognition dataset is determined as a short review text emotion recognition dataset or a media text emotion recognition dataset; If the sample emotion recognition data set is a short review text emotion recognition data set, the text emotion recognition model is determined as a short review text emotion recognition model; If the sample emotion recognition data set is a media text emotion recognition data set, the text emotion recognition model is determined to be a media text emotion recognition model.

3. The training method of the text emotion recognition model according to claim 2, characterized in that: The step of training a first preset model based on the sample emotion recognition data set and the sample emotion classification label set to determine a memory-based emotion recognition model includes: Determine the matching results of the emotion keywords of each sample emotion recognition data in the sample emotion recognition data set and each preset emotion word in the preset emotion word set; each preset emotion word in the preset emotion word set is provided with a weight; Determine the emotion score of the emotion keyword of each piece of the sample emotion recognition data based on the matching result and the weight of each preset emotion word in the preset emotion word set; Convert the emotion score of the emotion keyword of each piece of sample emotion recognition data into a vector representation to determine a sample emotion recognition data vector set; wherein each emotion recognition data vector in the sample emotion recognition data vector set corresponds one-to-one to each piece of sample emotion recognition data in the sample emotion recognition data set; Based on the sample emotion recognition data vector set and the sample emotion classification label set, a first preset model is trained to determine a memory-type emotion recognition model.

4. The training method of the text emotion recognition model according to claim 3 is characterized in that: The sample emotion recognition dataset and the sample emotion classification label set are determined based on the following method: Acquire a first emotion recognition data set, and determine a first emotion classification label set based on a collection source attribute of each emotion recognition data in the first emotion recognition data set; the collection source attribute is a basis for determining an emotion label corresponding to the emotion recognition data; Acquire a second emotion recognition data set, and perform semantic sequence segmentation on each emotion recognition data in the second emotion recognition data set to obtain a second emotion recognition data sequence set; Determine the total emotion score of each emotion recognition data sequence in the second emotion recognition data sequence set based on the matching results between the semantic units in each emotion recognition data sequence in the second emotion recognition data sequence set and the preset emotion words in the preset emotion word set; Determine a second emotion classification label set based on the total emotion score of each emotion recognition data sequence in the second emotion recognition data sequence set; The total emotion score of each emotion recognition data sequence in the second emotion recognition data sequence set is compared with the preset emotion threshold range respectively, and based on the comparison result, a third emotion recognition data sequence set is determined, and the second emotion classification label set is determined as the third emotion classification label set; each emotion label in the third emotion classification label set corresponds to each emotion recognition data sequence in the third emotion recognition data sequence set one by one; Deleting a semantic unit in each emotion recognition data sequence of the third emotion recognition data sequence set that matches the same semantic unit as each preset emotion word in the preset emotion word set, to determine a third emotion recognition data set; Determine a sample emotion recognition dataset based on the first emotion recognition dataset and the third emotion recognition dataset; Based on the first sentiment classification label set and the third sentiment classification label set, a sample sentiment classification label set is determined.

5. A text emotion recognition method, characterized in that: include: Inputting the text to be recognized into a text emotion recognition model to obtain an emotion recognition result output by the text emotion recognition model; The text emotion recognition model is trained based on the text emotion recognition model training method according to any one of claims 1 to 4.

6. The text emotion recognition method according to claim 5, characterized in that: The text emotion recognition model includes a short review text emotion recognition model or a media text emotion recognition model. The text to be recognized is input into the text emotion recognition model to obtain an emotion recognition result output by the text emotion recognition model, including: Input the text to be recognized into a classification model to obtain a classification result output by the classification model; the classification result is used to determine the text type of the text to be recognized, and the text type includes a short review text or a media text; If the text type of the to-be-recognized text is a short review text, the to-be-recognized text is input into the short review text emotion recognition model to obtain a short review text emotion recognition result output by the short review text emotion recognition model; If the text type of the text to be recognized is media text, the text to be recognized is input into the media text emotion recognition model to obtain a media text emotion recognition result output by the media text emotion recognition model.

7. A training device for a text emotion recognition model, characterized in that: include: A training data acquisition module, which is used to acquire a sample emotion recognition data set and a sample emotion classification label set, wherein each emotion label in the sample emotion classification label set corresponds one-to-one to each sample emotion recognition data in the sample emotion recognition data set; the emotion labels in the sample emotion classification label set are divided into positive emotion labels and negative emotion labels; A memory-type emotion recognition model training module, which is used to train a first preset model based on the sample emotion recognition data set and the sample emotion classification label set to determine a memory-type emotion recognition model; A balanced data acquisition module, which is used to determine a sample balanced emotion recognition data set from the sample emotion recognition data set based on the sample emotion classification label set, wherein the number of sample emotion recognition data representing positive emotion labels in the sample balanced emotion recognition data set is the same as the number of sample emotion recognition data representing negative emotion labels; A generalized emotion model training module, which is used to train a second preset model based on the sample balanced emotion recognition data set and the balanced emotion classification label set corresponding to the sample balanced emotion recognition data set to determine a generalized emotion recognition model; The text emotion recognition model determination module is used to determine the text emotion recognition model based on the memory-type emotion recognition model and the generalization-type emotion recognition model.

8. An electronic device 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 training method of the text emotion recognition model as described in any one of claims 1 to 4 is implemented; or, when the processor executes the computer program, the text emotion recognition method as described in any one of claims 5 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the training method of the text emotion recognition model as described in any one of claims 1 to 4; or, when the computer program is executed by a processor, it implements the text emotion recognition method as described in any one of claims 5 to 6.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the training method of the text emotion recognition model as described in any one of claims 1 to 4; or, when the computer program is executed by a processor, it implements the text emotion recognition method as described in any one of claims 5 to 6.