Text Emotion Recognition Method, Device, Computer Equipment and Readable Storage Medium

By setting one-dimensional and two-dimensional emotion groups in the output layer of the emotion classification model and filtering out categories from each emotion group based on feature words, the problem of complex and diverse emotions recognition in the prior art is solved, and the effect of accurately identifying complex text emotions is achieved.

CN114036294BActive Publication Date: 2025-06-27ONE CONNECT SMART TECH CO LTD SHENZHEN
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111306340.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-05
Publication Date
2025-06-27
Estimated Expiration
2041-11-05

AI Technical Summary

Technical Problem

In the prior art, there is only one emotion category based on the maximum probability value and can only be selected to meet the complex and diverse emotions needs, and the various emotion categories selected according to the probability threshold are very likely to contain opposing emotions.

Method used

The output layer using the emotion classification model includes multiple one-dimensional emotion groups and multiple two-dimensional emotion groups. Each one-dimensional emotion group includes an emotion category with no opposing emotions and a miss category. Each two-dimensional emotion group includes two opposing emotions and a miss category. A category is selected from each emotion group based on feature words through the model.

Benefits of technology

The problem of only selecting only the unique emotional categories and possible containing opposing emotions in the prior art is solved, and the complex and diverse text emotions are identified and the screened emotional categories are achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114036294B_ABST
    Figure CN114036294B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of artificial intelligence technology, and specifically discloses a method for text emotion recognition. The method includes: obtaining the text to be recognized and extracting the feature words of the text to be recognized; inputting the extracted feature words into an emotion classification model, wherein the output layer of the emotion classification model includes a plurality of one-dimensional emotion groups and a plurality of two-dimensional emotion groups. Each one-dimensional emotion group includes an emotion category without opposing emotions and a non-hit category, and each two-dimensional emotion group includes two mutually opposing emotion categories and a non-hit category; screening out one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on each feature word through the emotion classification model; when the categories screened out by the emotion classification model include emotion categories, taking all the screened-out emotion categories as the emotions of the text to be recognized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of artificial intelligence, and particularly to a method, device, computer device and computer-readable storage medium for text emotion recognition. Background Art

[0002] In traditional text emotion classification methods, multiple emotion categories are generally predefined in advance, and then a multi-classification method is used to identify text emotions. For example, a single emotion category corresponding to the maximum probability is determined from the predefined emotion categories, or multiple emotion categories that meet the probability threshold are determined from the predefined emotion categories. However, human emotions are complex and diverse. A sentence may express both happiness and liking. The existing technology's solution of selecting only one emotion category based on the maximum probability cannot meet the needs of complex and diverse emotions. In addition, emotions have opposites, such as liking and disgust, happiness and sadness. It is very likely that the multiple emotion categories selected according to the probability threshold contain opposite emotions, which obviously does not conform to the actual situation.

[0003] Regarding the technical problems that the existing technology cannot meet the needs of complex and diverse emotions by selecting only one emotion category based on the maximum probability, and that the multiple emotion categories selected according to the probability threshold are very likely to contain opposite emotions, there is currently no effective solution. Summary of the Invention

[0004] The purpose of the present invention is to provide a method, device, computer device and computer-readable storage medium for text emotion recognition, which can solve the technical problems that the existing technology cannot meet the needs of complex and diverse emotions by selecting only one emotion category based on the maximum probability, and that the multiple emotion categories selected according to the probability threshold are very likely to contain opposite emotions.

[0005] One aspect of the present invention provides a method for text emotion recognition, the method comprising: obtaining a text to be recognized, and extracting feature words of the text to be recognized; inputting the extracted feature words into an emotion classification model, wherein the output layer of the emotion classification model includes multiple one-dimensional emotion groups and multiple two-dimensional emotion groups, each one-dimensional emotion group includes an emotion category without opposite emotions and a non-hit category, and each two-dimensional emotion group includes two mutually opposite emotion categories and a non-hit category; screening out one category from each one-dimensional emotion group of the output layer and one category from each two-dimensional emotion group based on each feature word through the emotion classification model; when the categories screened out by the emotion classification model include emotion categories, taking all the screened-out emotion categories as the emotions of the text to be recognized.

[0006] Optionally, each feature word is received by the word embedding layer of the emotion classification model, and the feature vector of each feature word is output by the word embedding layer; each feature vector is received by the bidirectional LSTM layer of the emotion classification model, and the text vector of the text to be recognized is output by the bidirectional LSTM layer based on each feature vector; the emotion classification model filters out one category from each one-dimensional emotion group and one category from each two-dimensional emotion group of the output layer based on the text vector.

[0007] Optionally, the fully connected layer groups associated with each emotion group in the emotion classification model are determined, where the fully connected layers in each fully connected layer group are respectively associated with one category in the corresponding emotion group, and each fully connected layer is used to represent the category vector of the category associated with the fully connected layer; the text vector is received by the fully connected layer group, and the product of the category vector represented by each fully connected layer in the fully connected layer group and the text vector is calculated, and each obtained product result is recorded as a probability vector, and a probability vector group associated with the fully connected layer group is obtained; the emotion classification model filters out one category from each one-dimensional emotion group and one category from each two-dimensional emotion group of the output layer according to the probability vector group.

[0008] Optionally, each probability vector in the probability vector group is converted into a probability value through the softmax function, and a probability value group is obtained; the emotion classification model determines the emotion group associated with the probability value group; when the determined emotion group is a one-dimensional emotion group, the emotion classification model filters out the maximum probability value from the two probability values included in the probability value group, and filters out the category corresponding to the maximum probability value from the two categories included in the one-dimensional emotion group; when the determined emotion group is a two-dimensional emotion group, the emotion classification model filters out the maximum probability value from the three probability values included in the probability value group, and filters out the category corresponding to the maximum probability value from the three categories included in the two-dimensional emotion group.

[0009] Optionally, when the categories selected by the emotion classification model include emotion categories, all the selected emotion categories are used as the emotion of the text to be recognized, including: when the categories selected by the emotion classification model from each one-dimensional emotion group include emotion categories and the categories selected from each two-dimensional emotion group do not include emotion categories, all the emotion categories selected from each one-dimensional emotion group are used as the emotion of the text to be recognized; or when the categories selected by the emotion classification model from each one-dimensional emotion group do not include emotion categories and the categories selected from each two-dimensional emotion group include emotion categories, all the emotion categories selected from each two-dimensional emotion group are used as the emotion of the text to be recognized; or when the categories selected by the emotion classification model from each one-dimensional emotion group include emotion categories and the categories selected from each two-dimensional emotion group include emotion categories, all the emotion categories selected from each one-dimensional emotion group and each two-dimensional emotion group are used as the emotion of the text to be recognized.

[0010] Another aspect of the present invention provides a text emotion recognition device, the device includes: an extraction module, configured to obtain a text to be recognized and extract feature words of the text to be recognized; an input module, configured to input the extracted feature words into an emotion classification model, wherein the output layer of the emotion classification model includes a plurality of one-dimensional emotion groups and a plurality of two-dimensional emotion groups, each one-dimensional emotion group includes an emotion category without opposing emotions and a non-hit category, and each two-dimensional emotion group includes two opposing emotion categories and a non-hit category; a screening module, configured to screen out one category from each one-dimensional emotion group of the output layer and one category from each two-dimensional emotion group based on each feature word through the emotion classification model; a determination module, configured to, when the categories screened out by the emotion classification model include emotion categories, use all the screened out emotion categories as the emotion of the text to be recognized.

[0011] Optionally, the screening module is specifically configured to: receive each feature word through the word embedding layer of the emotion classification model, and output feature vectors of each feature word through the word embedding layer; receive each feature vector through the bidirectional LSTM layer of the emotion classification model, and output a text vector of the text to be recognized based on each feature vector through the bidirectional LSTM layer; screen out one category from each one-dimensional emotion group of the output layer and one category from each two-dimensional emotion group based on the text vector through the emotion classification model.

[0012] Optionally, when the screening module executes the step of screening out one category from each one-dimensional emotion group in the output layer and screening out one category from each two-dimensional emotion group based on the text vector through the emotion classification model, it is specifically configured to: determine the fully connected layer group associated with each emotion group in the emotion classification model, where each fully connected layer in each fully connected layer group is respectively associated with one category in the corresponding emotion group, and each fully connected layer is used to represent the category vector of the category associated with the fully connected layer; receive the text vector through the fully connected layer group, calculate the product of the category vector represented by each fully connected layer in the fully connected layer group and the text vector, and record each obtained product result as a probability vector to obtain a probability vector group associated with the fully connected layer group; screen out one category from each one-dimensional emotion group in the output layer and screen out one category from each two-dimensional emotion group according to the probability vector group through the emotion classification model.

[0013] Another aspect of the present invention provides a computer device, which includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the computer program, it implements the text emotion recognition method described in any of the above embodiments.

[0014] Another aspect of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the text emotion recognition method described in any of the above embodiments. Further, the computer-readable storage medium may mainly include a program storage area and a data storage area. Among them, the program storage area may store an operating system, application programs required for at least one function, etc.; the data storage area may store data created according to the use of blockchain nodes, etc.

[0015] This embodiment provides a text emotion recognition method. In a pre-trained emotion classification model, emotions are divided into multiple one-dimensional emotion groups and multiple two-dimensional emotion groups. Each one-dimensional emotion group includes an emotion category without opposing emotions and a miss category. Each two-dimensional emotion group includes two opposing emotion categories and a miss category. For the text to be recognized, feature words of the text are extracted and input into the emotion classification model. One category is selected from each one-dimensional emotion group and each two-dimensional emotion group respectively. Finally, the selected emotion categories are determined as the emotion categories of the text, and the selected miss categories are directly not considered. The text emotion determined based on the emotion classification model in this application does not have to be only one emotion, but can be one or more, which solves the problem in the prior art that only one unique emotion category can be selected according to the maximum probability and cannot meet the needs of complex and diverse emotions. At the same time, there must be no opposing emotion categories in the text emotions determined based on the emotion classification model in this application, which solves the technical problem that there are very likely opposing emotions among the multiple emotion categories selected according to the probability threshold. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present invention. Moreover, throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:

[0017] Figure 1 The flowchart of the text emotion recognition method provided in Embodiment 1 of the present invention is shown;

[0018] Figure 2 The block diagram of the text emotion recognition device provided in Embodiment 2 of the present invention is shown;

[0019] Figure 3 The block diagram of the computer device suitable for implementing the text emotion recognition method provided in Embodiment 3 of the present invention is shown; DETAILED DESCRIPTION OF THE EMBODIMENTS

[0020] In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

[0021] It should be noted that in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent in such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of another identical element in the process, method, article or device including the element.

[0022] Embodiment 1

[0023] There are two problems in the prior art: The first problem is that only one unique emotion category can be selected according to the maximum probability, which cannot meet the needs of diverse emotions (human emotions are complex and diverse, and a sentence may express both happiness and liking); the second problem is that although multiple emotion categories can be selected according to the probability threshold, the selected emotion categories may include opposing emotions, which obviously does not conform to the actual situation. To solve these problems in the prior art, this application sets two types of emotion groups: one-dimensional emotion groups and two-dimensional emotion groups. Each one-dimensional emotion group contains an emotion category without opposing emotions and a missed category. Each two-dimensional emotion group contains two emotion categories that are opposing to each other and a missed category. Each time of screening, only one category is selected from each emotion group, and this category may be a missed category or an emotion category. And based on the special setting that the emotion category in the one-dimensional emotion group is an emotion category without opposing emotions and the emotion categories in the two-dimensional emotion group are opposing to each other, the emotion categories selected in this application will definitely not include opposing emotions to each other, and the final emotion result in this application is all the emotion categories selected, thus overcoming the above problems in the prior art. Specifically, Figure 1 The flowchart of the text emotion recognition method provided in Embodiment 1 of the present invention is shown, as Figure 1 shown, the text emotion recognition method includes steps S1 to S4, where:

[0024] Step S1, obtain the text to be recognized, and extract the feature words of the text to be recognized.

[0025] In order to recognize the emotion categories included in the text, it is necessary to preprocess the text. First, remove the punctuation marks in the text, then perform word segmentation on the text to be recognized by means of the Jieba word segmentation algorithm, and then extract the words after the word segmentation operation. For example, if the text to be recognized is "Haha, come on! Students.", after preprocessing, the text is "Haha come on students", and words such as "Haha", "come on" and "students" are extracted, that is, "Haha", "come on" and "students" are the feature words of the text to be recognized "Haha, come on! Students.".

[0026] Step S2: Input the extracted feature words into the emotion classification model. The output layer of the emotion classification model includes multiple one-dimensional emotion groups and multiple two-dimensional emotion groups. Each one-dimensional emotion group includes an emotion category without opposing emotions and a non-hit category. Each two-dimensional emotion group includes two opposing emotion categories and a non-hit category.

[0027] Perform word segmentation on the text, extract the corresponding feature words, and input them into the pre-trained emotion classification model. The emotion classification model identifies the emotion categories contained in the text based on the feature words.

[0028] Specifically, the output layer of the emotion classification model includes multiple one-dimensional emotion groups and multiple two-dimensional emotion groups. Each one-dimensional emotion group includes an emotion category without opposing emotions and a non-hit category. The emotion categories without opposing emotions include, for example, emotions such as gratitude, congratulations, surprise, sympathy, threat, fear, etc. Each two-dimensional emotion group includes two opposing emotion categories and a non-hit category. The two opposing emotion categories include, for example, emotions such as like and dislike, happy and sad, confident and inferior, respect and insult, praise and criticism, agree and refuse, etc.

[0029] Step S3: Through the emotion classification model, select one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on each feature word.

[0030] For example, the one-dimensional emotion group A contains the gratitude emotion category and the non-hit category, and the two-dimensional emotion group B contains two opposing emotion categories, happy and sad, and a non-hit category. Input the feature words contained in the text to be recognized into the emotion classification model, and select one category from the one-dimensional emotion group A and the two-dimensional emotion group B respectively. If the selected categories are both non-hit categories, it indicates that the text does not contain the one-dimensional emotion group A and the two-dimensional emotion group B. If the non-hit category is selected from the one-dimensional emotion group A and the happy category is selected from the two-dimensional emotion group, the emotion of the text is happy. If the gratitude category is selected from the one-dimensional emotion group A and the non-hit category is selected from the two-dimensional emotion group, the emotion of the text is gratitude. If the gratitude emotion category is selected from the one-dimensional emotion group A and the happy category is selected from the two-dimensional emotion group, the emotion of the text is gratitude and happy. Specifically, step S3 includes steps S31 to S33, where:

[0031] Step S31: Receive each feature word through the word embedding layer of the emotion classification model, and output the feature vectors of each feature word through the word embedding layer.

[0032] Step S32: Receive each feature vector through the bidirectional LSTM layer of the emotion classification model, and output the text vector of the text to be recognized based on each feature vector through the bidirectional LSTM layer;

[0033] Step S33: Based on the text vector, select one category from each one-dimensional emotion group of the output layer and one category from each two-dimensional emotion group through the emotion classification model.

[0034] For a computer, it cannot recognize text words directly. Instead, it can only vectorize the text words and abstract the entities into mathematical descriptions. In the embodiment, this transformation can be achieved by using word embedding. The specific process is as follows: Use the trained word vector model to transform each feature word into a feature word vector, such as "1010011…". If each feature word is mapped to a feature word vector of length V, then use W i to represent the 1*V-dimensional feature word vector, where i represents the number of feature words in the text to be recognized.

[0035] Input each feature word vector W i contained in the text into the bidirectional LSTM neural network in sequence to obtain the vector of the entire text (i.e., the text vector). Among them, the bidirectional LSTM neural network can memorize network information. It includes three layers of networks: an input layer, two hidden layers, and an output layer. Each layer of the network is independent, and each feature word vector will be input according to time stamps.

[0036] For example, at time t-1, the feature word vector of "haha" first passes through the input layer and then is saved in the hidden layer; at time t, the feature word vector of "come on" first passes through the input layer and then is saved in the hidden layer. At this moment, in the hidden layer at this time, not only the feature word vector of "come on" but also the feature word vector of "haha" from the previous moment is saved; at time t+1, the feature word vector of "classmates" first passes through the input layer and then is saved in the hidden layer. At this moment, in the hidden layer at this time, not only the feature word vector of "classmates" but also the feature word vectors of the previous moments are included. That is, the current hidden layer contains feature word vectors such as "haha", "come on", and "classmates". In the other hidden layer, information is also passed, but this information is passed from back to front instead of from front to back. Then, at the hidden layer corresponding to time t+1, the feature word vector of "haha" is included; at the hidden layer corresponding to time t, the feature word vectors of "haha" and "come on" are included; at the hidden layer corresponding to time t-1, the feature word vectors of "haha", "come on", and "classmates" are included. Finally, the content in the hidden layer corresponding to the initial moment or the final moment is saved to the output layer, and the function concat encodes the output content to generate the text vector of the entire text.

[0037] Finally, the emotion classification model selects one category from each one-dimensional emotion group and each two-dimensional emotion group respectively based on the text vector of the entire text. Specifically, step S33 includes steps S331 to S333, where:

[0038] Step S331, determine the fully connected layer group associated with each emotion group in the emotion classification model, where each fully connected layer in each fully connected layer group is associated with one category in the corresponding emotion group, and each fully connected layer is used to represent the category vector of the category associated with this fully connected layer;

[0039] Step S332, receive the text vector through the fully connected layer group, and calculate the product of the category vector represented by each fully connected layer in the fully connected layer group and the text vector, and record each obtained product result as a probability vector to obtain a probability vector group associated with the fully connected layer group;

[0040] Step S333, through the emotion classification model, select one category from each one-dimensional emotion group of the output layer and select one category from each two-dimensional emotion group according to the probability vector group.

[0041] Each emotion group is uniquely associated with a fully connected layer group. The number of categories included in each emotion group is the same as the number of fully connected layers included in the fully connected layer group associated with this emotion group. That is, there are two fully connected layers in the fully connected layer group associated with the one-dimensional emotion group, and there are three fully connected layers in the fully connected layer group associated with the two-dimensional emotion group. In this embodiment, each category in each emotion group can be described in the form of a vector through computer language. This vector can be called a category vector, that is, each category has a category vector; and in this embodiment, each fully connected layer is used to represent a category vector, that is, each fully connected layer is associated with the category corresponding to the category vector it represents. Further, input the entire text vector into each fully connected layer group. The fully connected layers included in each fully connected layer group are respectively multiplied by the entire text vector, and each obtained product result is recorded as a probability vector, and finally a probability vector group associated with this fully connected layer group is obtained.

[0042] For example, the one-dimensional emotion group A is associated with a fully connected layer group A 1 , where the emotion category a1 and the missed category a2 in the one-dimensional emotion group A are respectively associated with the fully connected layer A 1 in the fully connected layer group A 11 and A 12 ; the two-dimensional emotion group B is associated with a fully connected layer group B 1 , where the two emotion categories b1 and b2 and the missed category b3 in the one-dimensional emotion group B are respectively associated with the fully connected layer B 1 in the fully connected layer group B 11 , B 12and B 13 Multiply the entire text vector C with the fully connected layer A 11 、A 12 respectively to obtain probability vectors CA 1 、CA 2 corresponding to the two categories, that is, the probability vector group associated with the fully connected layer group A 1 is CA 1 、CA 2 ; Multiply the entire text vector C with the fully connected layer B 11 、B 12 and B 13 respectively to obtain probability vectors CB 1 、CB 2 and CB 3 corresponding to the three categories, that is, the probability vector group associated with the fully connected layer group B 1 is CB 1 、CB 2 and CB 3 .

[0043] Finally, the emotion classification model selects one category from each one-dimensional emotion group and each two-dimensional emotion group based on the probability vector group. Specifically, step S333 includes steps S3331 to S3334, where:

[0044] Step S3331, convert each probability vector in the probability vector group into a probability value through the softmax function to obtain a probability value group;

[0045] Step S3332, determine the emotion group associated with the probability value group through the emotion classification model;

[0046] Step S3333, when the determined emotion group is a one-dimensional emotion group, select the maximum probability value from the two probability values included in the probability value group, and select the category corresponding to the maximum probability value from the two categories included in this one-dimensional emotion group;

[0047] Step S3334, when the determined emotion group is a two-dimensional emotion group, select the maximum probability value from the three probability values included in the probability value group, and select the category corresponding to the maximum probability value from the three categories included in this two-dimensional emotion group.

[0048] Convert the obtained probability vector group into a probability value group through the softmax function. When the determined emotion group is a one-dimensional emotion group, select the maximum probability value from the two probability values included in the probability value group, and select the category corresponding to the maximum probability value from the two categories included in the one-dimensional emotion group; when the determined emotion group is a two-dimensional emotion group, select the maximum probability value from the three probability values included in the probability value group, and select the category corresponding to the maximum probability value from the three categories included in the two-dimensional emotion group.

[0049] For example: In the one-dimensional emotion group A, the probability vector groups corresponding to the two categories are CA 1 、CA 2 , and the probability value group obtained through the softmax function is CA 1 、 CA 2 . If CA 1 has the largest probability value, then select from the one-dimensional emotion group A CA 1 The corresponding category is the emotion category a1; in the two-dimensional emotion group B, the probability vectors CB corresponding to the three categories 1 、CB 2 and CB 3 , and the probability value group obtained through the softmax function is CB 1 、 CB 2 and CB 3 . If CB 1 has the largest probability value, then select from the two-dimensional emotion group B CB 1 The corresponding category is the emotion category b1.

[0050] Step S4, when the categories selected by the emotion classification model include emotion categories, use all the selected emotion categories as the emotions of the text to be recognized.

[0051] Specifically, step S4 includes:

[0052] When the categories selected from each one-dimensional emotion group by the emotion classification model include emotion categories, and the categories selected from each two-dimensional emotion group do not include emotion categories, use all the emotion categories selected from the one-dimensional emotion group as the emotions of the text to be recognized; or

[0053] When the categories selected from each one-dimensional emotion group by the emotion classification model do not include emotion categories, and the categories selected from each two-dimensional emotion group include emotion categories, use all the emotion categories selected from the two-dimensional emotion group as the emotions of the text to be recognized; or

[0054] When the categories selected from each one - dimensional emotion group by the emotion classification model include emotion categories, and the categories selected from each two - dimensional emotion group include emotion categories, all the emotion categories selected from the one - dimensional emotion group and the two - dimensional emotion group are used as the emotions of the text to be recognized.

[0055] Judge whether the category corresponding to the maximum probability value in the one - dimensional emotion group and / or the two - dimensional emotion group is an emotion category. If it is an emotion category, all the determined emotion categories are used as the emotion categories of the text to be recognized.

[0056] This embodiment provides a text emotion recognition method. In a pre - trained emotion classification model, emotions are divided into multiple one - dimensional emotion groups and multiple two - dimensional emotion groups. Each one - dimensional emotion group includes an emotion category without an opposing emotion and a non - hit category. Each two - dimensional emotion group includes two opposing emotion categories and a non - hit category. For the text to be recognized, the feature words of the text are extracted and input into the emotion classification model. One category is selected from each one - dimensional emotion group and each two - dimensional emotion group respectively. Finally, the selected emotion categories are determined as the emotion categories of the text, and the non - hit categories selected are directly not considered. The text emotion determined based on the emotion classification model in this application does not have to be only one emotion, but can be one or more, which solves the problem in the prior art that only one emotion category can be selected according to the maximum probability value and cannot meet the requirements of complex and diverse emotions. At the same time, the text emotions determined based on the emotion classification model in this application will definitely not include emotion categories with opposing relationships, which solves the technical problem that among the multiple emotion categories selected according to the probability threshold, there is a high probability of including opposing emotions.

[0057] Embodiment Two

[0058] Embodiment Two of the present invention further provides a text emotion recognition device. This text emotion recognition device corresponds to the text emotion recognition method provided in Embodiment One above. The corresponding technical features and technical effects are not elaborated in this embodiment, and the relevant parts can refer to Embodiment One above. Specifically, Figure 2 shows the block diagram of the text emotion recognition device provided in Embodiment Two of the present invention. As Figure 2 shown, the text emotion recognition device 200 includes an extraction module 201, an input module 202, a screening module 203, and a determination module 204, where:

[0059] The extraction module 201 is used to obtain the text to be recognized and extract the feature words of the text to be recognized;

[0060] An input module 202 for inputting the extracted feature words into an emotion classification model, wherein the output layer of the emotion classification model includes a plurality of one-dimensional emotion groups and a plurality of two-dimensional emotion groups, each one-dimensional emotion group includes an emotion category without an opposing emotion and a non-hit category, and each two-dimensional emotion group includes two opposing emotion categories and a non-hit category;

[0061] A screening module 203 for screening out one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on each feature word through the emotion classification model;

[0062] A determination module 204 for, when the categories screened out through the emotion classification model include emotion categories, using all the screened-out emotion categories as the emotions of the text to be recognized.

[0063] Optionally, the screening module is specifically configured to: receive each feature word through the word embedding layer of the emotion classification model, and output a feature vector of each feature word through the word embedding layer; receive each feature vector through the bidirectional LSTM layer of the emotion classification model, and output a text vector of the text to be recognized based on each feature vector through the bidirectional LSTM layer; screen out one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on the text vector through the emotion classification model.

[0064] Optionally, when the screening module executes the step of screening out one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on the text vector through the emotion classification model, it is specifically configured to: determine a fully connected layer group associated with each emotion group in the emotion classification model, wherein each fully connected layer in each fully connected layer group is respectively associated with a category in the corresponding emotion group, and each fully connected layer is used to represent a category vector of the category associated with the fully connected layer; receive the text vector through the fully connected layer group, calculate the product of the category vector represented by each fully connected layer in the fully connected layer group and the text vector, record each obtained product result as a probability vector, and obtain a probability vector group associated with the fully connected layer group; screen out one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group according to the probability vector group through the emotion classification model.

[0065] Optionally, when the screening module executes the step of screening out one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group according to the probability vector group through the emotion classification model, it is specifically configured to: convert each probability vector in the probability vector group into a probability value through the softmax function to obtain a probability value group; determine the emotion group associated with the probability value group through the emotion classification model; when the determined emotion group is a one-dimensional emotion group, screen out the maximum probability value from the two probability values included in the probability value group through the emotion classification model, and screen out the category corresponding to the maximum probability value from the two categories included in the one-dimensional emotion group; when the determined emotion group is a two-dimensional emotion group, screen out the maximum probability value from the three probability values included in the probability value group through the emotion classification model, and screen out the category corresponding to the maximum probability value from the three categories included in the two-dimensional emotion group.

[0066] Optionally, the determining module is specifically configured to: when the categories screened out from each one-dimensional emotion group through the emotion classification model include emotion categories, and the categories screened out from each two-dimensional emotion group do not include emotion categories, use all the emotion categories screened out from the one-dimensional emotion groups as the emotions of the text to be recognized; or when the categories screened out from each one-dimensional emotion group through the emotion classification model do not include emotion categories, and the categories screened out from each two-dimensional emotion group include emotion categories, use all the emotion categories screened out from the two-dimensional emotion groups as the emotions of the text to be recognized; or when the categories screened out from each one-dimensional emotion group through the emotion classification model include emotion categories, and the categories screened out from each two-dimensional emotion group include emotion categories, use all the emotion categories screened out from the one-dimensional emotion groups and the two-dimensional emotion groups as the emotions of the text to be recognized.

[0067] Embodiment III

[0068] Figure 3 The block diagram of the computer device suitable for implementing the text emotion recognition method provided in Embodiment III of the present invention is shown. In this embodiment, the computer device 300 may be a smart phone, a tablet computer, a notebook computer, a desktop computer, a rack server, a blade server, a tower server or a cabinet server (including an independent server or a server cluster composed of multiple servers) that executes a program. As Figure 3 shown, the computer device 300 of this embodiment at least includes, but is not limited to: a memory 301, a processor 302, and a network interface 303 that can communicate with each other through a system bus. It should be noted that, Figure 3Only computer device 300 with components 301 - 303 is shown, but it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively.

[0069] In this embodiment, the memory 303 includes at least one type of computer-readable storage medium. The readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 301 can be an internal storage unit of the computer device 300, such as the hard disk or memory of the computer device 300. In other embodiments, the memory 301 can also be an external storage device of the computer device 300, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. equipped on the computer device 300. Of course, the memory 301 can also include both the internal storage unit and the external storage device of the computer device 300. In this embodiment, the memory 301 is generally used to store the operating system and various application software installed on the computer device 300, such as the program code of the text emotion recognition method, etc.

[0070] In some embodiments, the processor 302 can be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chips. The processor 302 is generally used to control the overall operation of the computer device 300. For example, it performs control and processing related to data interaction or communication with the computer device 300, etc. In this embodiment, the processor 302 is used to run the program code of the steps of the text emotion recognition method stored in the memory 301.

[0071] In this embodiment, the text emotion recognition method stored in the memory 301 can also be divided into one or more program modules and executed by one or more processors (in this embodiment, the processor 302) to complete the present invention.

[0072] The network interface 303 may include a wireless network interface or a wired network interface, which is generally used to establish a communication link between the computer device 300 and other computer devices. For example, the network interface 303 is used to connect the computer device 300 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 300 and the external terminal. The network may be a wireless or wired network such as an enterprise intranet (Intranet), the Internet, the Global System of Mobile communication (GSM for short), Wideband Code Division Multiple Access (WCDMA for short), 4G network, 5G network, Bluetooth, Wi-Fi, etc.

[0073] Embodiment 4

[0074] Embodiment 4 of the present invention also provides a computer-readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, server, App application store, etc., on which a computer program is stored, and when the computer program is executed by a processor, the steps of the text emotion recognition method are implemented.

[0075] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the embodiments of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. Optionally, they can be implemented by program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order than here, or they can be separately made into individual integrated circuit modules, or multiple modules or steps among them can be made into a single integrated circuit module to implement. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.

[0076] It should be noted that the serial numbers of the embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0077] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general-purpose hardware platform. Of course, they can also be implemented by hardware, but in many cases, the former is a better implementation method.

[0078] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be similarly included in the patent protection scope of the present invention.

Claims

1. A text emotion recognition method, characterized in that, The method includes: Obtain the text to be recognized, and extract the feature words of the text to be recognized; Input the extracted feature words into an emotion classification model, wherein the output layer of the emotion classification model includes a plurality of one-dimensional emotion groups and a plurality of two-dimensional emotion groups, each one-dimensional emotion group includes an emotion category without opposing emotions and a non-hit category, and each two-dimensional emotion group includes two mutually opposing emotion categories and a non-hit category; Through the emotion classification model, select one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on each feature word; wherein, each time of selection, select only one category from each emotion group, and this category is the non-hit category or the emotion category; When the categories selected by the emotion classification model include emotion categories, use all the selected emotion categories as the emotions of the text to be recognized.

2. The method according to claim 1, wherein The step of selecting one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on each feature word through the emotion classification model includes: Receive each feature word through the word embedding layer of the emotion classification model, and output the feature vector of each feature word through the word embedding layer; Receive each feature vector through the bidirectional LSTM layer of the emotion classification model, and output the text vector of the text to be recognized based on each feature vector through the bidirectional LSTM layer; Through the emotion classification model, select one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on the text vector.

3. The method according to claim 2, characterized in that, The step of selecting one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on the text vector through the emotion classification model includes: Determine the fully connected layer group associated with each emotion group in the emotion classification model, wherein the fully connected layers in each fully connected layer group are respectively associated with one category in the corresponding emotion group, and each fully connected layer is used to represent the category vector of the category associated with this fully connected layer; Receive the text vector through the fully connected layer group, and calculate the product of the category vector represented by each fully connected layer in the fully connected layer group and the text vector, and record each obtained product result as a probability vector to obtain a probability vector group associated with the fully connected layer group; Through the emotion classification model, select one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group according to the probability vector group.

4. The method according to claim 3, characterized in that, The step of selecting one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group according to the probability vector group through the emotion classification model includes: Convert each probability vector in the probability vector group into a probability value through the softmax function to obtain a probability value group; Through the emotion classification model, determine the emotion group associated with the probability value group; When the determined emotion group is a one-dimensional emotion group, the emotion classification model is used to screen out the maximum probability value from the two probability values included in the probability value group, and screen out the category corresponding to the maximum probability value from the two categories included in the one-dimensional emotion group; When the determined emotion group is a two-dimensional emotion group, the emotion classification model is used to screen out the maximum probability value from the three probability values included in the probability value group, and screen out the category corresponding to the maximum probability value from the three categories included in the two-dimensional emotion group.

5. The method according to claim 1, wherein When the categories screened out by the emotion classification model include emotion categories, all the screened-out emotion categories are used as the emotions of the text to be recognized, including: When the categories screened out from each one-dimensional emotion group by the emotion classification model include emotion categories, and the categories screened out from each two-dimensional emotion group do not include emotion categories, all the emotion categories screened out from each one-dimensional emotion group are used as the emotions of the text to be recognized; or When the categories screened out from each one-dimensional emotion group by the emotion classification model do not include emotion categories, and the categories screened out from each two-dimensional emotion group include emotion categories, all the emotion categories screened out from each two-dimensional emotion group are used as the emotions of the text to be recognized; or When the categories screened out from each one-dimensional emotion group by the emotion classification model include emotion categories, and the categories screened out from each two-dimensional emotion group include emotion categories, all the emotion categories screened out from each one-dimensional emotion group and each two-dimensional emotion group are used as the emotions of the text to be recognized.

6. A text emotion recognition device, characterized in that, The device includes: An extraction module, configured to obtain the text to be recognized and extract the feature words of the text to be recognized; An input module, configured to input the extracted feature words into an emotion classification model, where the output layer of the emotion classification model includes a plurality of one-dimensional emotion groups and a plurality of two-dimensional emotion groups, each one-dimensional emotion group includes an emotion category without opposing emotions and a non-hit category, and each two-dimensional emotion group includes two opposing emotion categories and a non-hit category; A screening module, configured to screen out one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on each feature word through the emotion classification model; where, each time of screening, only one category is screened out from each emotion group, and this category is a non-hit category or an emotion category; A determination module, configured to, when the categories screened out by the emotion classification model include emotion categories, use all the screened-out emotion categories as the emotions of the text to be recognized.

7. The device according to claim 6, characterized in that, The screening module is specifically configured to: Receive each feature word through the word embedding layer of the emotion classification model, and output the feature vectors of each feature word through the word embedding layer; Receive each feature vector through the bidirectional LSTM layer of the emotion classification model, and output the text vector of the text to be recognized based on each feature vector through the bidirectional LSTM layer; The emotion classification model is used to select one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on the text vector.

8. The device according to claim 7, characterized in that When the screening module executes the step of selecting one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group based on the text vector through the emotion classification model, it is specifically configured to: Determine the fully connected layer group associated with each emotion group in the emotion classification model, where each fully connected layer in the fully connected layer group is respectively associated with one category in the corresponding emotion group, and each fully connected layer is used to represent the category vector of the category associated with the fully connected layer; Receive the text vector through the fully connected layer group, calculate the product of the category vector represented by each fully connected layer in the fully connected layer group and the text vector, record each obtained product result as a probability vector, and obtain a probability vector group associated with the fully connected layer group; The emotion classification model is used to select one category from each one-dimensional emotion group in the output layer and one category from each two-dimensional emotion group according to the probability vector group.

9. A computer device, the computer device comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 5 when executing the computer program.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program implements the method according to any one of claims 1 to 5 when executed by the processor.

Citation Information

Patent Citations

  • Audio data processing method and device, medium and computing device

    CN108986843A

  • Text analysis method and device, computer device and computer storage medium

    CN110427610A