Text emotion observation method, computer device and storage medium
By annotating sample texts and building a knowledge base of emotional events, and using observation matrices and neural networks to adjust the emotional vectors, the problem of different groups of people expressing emotions differently in texts is solved, and more accurate emotion prediction is achieved.
Patent Information
- Application Number
- CN202211742286.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2042-12-30
AI Technical Summary
Existing technologies fail to effectively consider the different emotional expressions of different people towards the same text in text sentiment analysis, resulting in inaccurate emotional results.
By annotating sample texts, building an emotional event knowledge base, adjusting the emotional vector using observation matrices and neural networks, considering the differences between different groups of people, and using deep learning models and psychological theories for emotional calculation.
It improves the accuracy of text emotion prediction, solves the difference between personal and group emotions, and realizes the quantification and accurate analysis of emotions.
Smart Images

Figure CN116010599B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of psychological emotion observation, and in particular relates to a text emotion observation method, computer equipment and storage medium. Background Art
[0002] With the development of the Internet, online text communication is also increasing. Emotional analysis of these text speeches can obtain valuable information. In the prior art, it is usually implemented in the following way: 1. In the patent with publication number CN113849646A and invention name A method for text sentiment analysis, the general semantic matrix, structural semantic matrix, and sentence initialization representation are input into the graph convolutional neural network, cross network and activation function to obtain the general semantic syntactic representation and structural semantic syntactic representation of the sentence, and then the target structural semantic syntactic representation and target general semantic syntactic representation are calculated by combining the general semantic hidden representation and structural semantic hidden representation of the sentence respectively. The target general semantic syntactic representation and target structural semantic syntactic representation are spliced and non-attribute words are shielded to obtain the attribute word feature representation of each word in the sentence, and then the attention weight of each word in the sentence is calculated based on the word embedding representation and the attention weight of each word, and the sentence sentiment polarity is output based on the word embedding representation and the attention weight of each word. 2. In the patent with publication number CN111475640A and invention name "Text emotion recognition method and device based on emotion summary", an emotion summary is generated based on the text to be recognized; and the generated emotion summary is provided to the text emotion recognition model to perform text emotion recognition. 3. In the patent with publication number CN113849646A and invention name "A text emotion analysis method", a global vector and a word conversion vector are used to respectively vectorize and train the target text to obtain a first text vector matrix and a second text vector matrix of the target text, where the target text is the text to be emotion analyzed; a dual-path attention mechanism is used to respectively extract key feature information from the first text vector matrix and the second text vector matrix, and enhance and fuse the features thereof; an activation function is used to classify the first text vector matrix and the first text vector matrix after feature fusion to obtain the emotion analysis result of the target text.
[0003] Since emotions are very subjective, the same text can express different emotions for different people. Existing technologies do not take this factor into account, resulting in inaccurate emotional results. Summary of the Invention
[0004] In order to overcome the above technical defects, the present invention provides a text emotion observation method, a computer device and a storage medium, which can effectively improve the accuracy of text emotion prediction.
[0005] In order to solve the above problems, the present invention adopts the following solutions:
[0006] A text emotion observation method comprises the following steps:
[0007] Annotate sample text;
[0008] Construct a sentiment vector calculation model and calculate the sentiment vector of the sample text based on the annotations;
[0009] Construct an emotional event knowledge base of sample texts using sample texts and emotional vectors;
[0010] The observation model and observation matrix are used to calculate the sentiment vector of the text to be observed based on the sentiment event knowledge base.
[0011] As a further improvement of the present invention, the labeling of the sample text includes: labeling the sample text with emotion direction, emotion polarity, emotion category, and emotion intensity, wherein the emotion direction, the emotion polarity, and the emotion category all include several types of emotions.
[0012] As a further improvement of the present invention, the step of calculating the sentiment vector of the sample text according to the annotation includes:
[0013] Extract the sample text and divide it into: event part, cognitive part and emotional description part;
[0014] Based on the annotations, the sentiment vectors of the event part, cognitive part and sentiment description part are calculated.
[0015] As a further improvement of the present invention, the step of constructing an emotional event knowledge base of the sample text using the sample text and the emotion vector includes:
[0016] The event part, the cognitive part, the emotion description part, and the emotion vector form a key-value pair to construct the emotion event knowledge base.
[0017] As a further improvement of the present invention, the step of calculating the sentiment vector of the text to be observed by using the observation model and the observation matrix based on the sentiment event knowledge base includes:
[0018] Retrieve sample texts that are identical or similar to the text to be observed from the emotional event knowledge base;
[0019] The observation model is used to calculate the preliminary sentiment vector of the text to be observed;
[0020] The observation matrix is used to adjust the preliminary sentiment vector to obtain the sentiment vector of the text to be observed.
[0021] As a further improvement of the present invention, the present invention further includes the step of constructing the observation matrix:
[0022] Modeling the observation matrix using matrices or neural networks;
[0023] When the observation matrix is used to adjust the preliminary emotion vector, the activation function in the neural network structure is non-zero.
[0024] As a further improvement of the present invention, the present invention further includes the step of constructing the observation matrix:
[0025] Divide the labeled population into several labeled groups;
[0026] For the sample text, classify it into the corresponding annotation group according to the annotation population;
[0027] Calculate the sentiment vector of the text in the same annotated group and obtain the statistical calculation result of the difference between the sentiment vector of the sample text in a certain annotated group and the result output by the observation model;
[0028] The step of adjusting the preliminary emotion vector using the observation matrix includes:
[0029] Multiply the observation matrix with the preliminary sentiment vector.
[0030] As a further improvement of the present invention, the step of constructing an emotional event knowledge base of the sample text using the sample text and the emotion vector further includes:
[0031] Based on the theory of cognitive behavioral therapy, the sample text is expanded and the event part, cognitive part, emotional description part and emotional vector that constitute the key-value pair are combined to construct the emotional event knowledge base;
[0032] According to the interpretation methods of emotions in other psychological theories, the sample text is expanded, and the emotional event knowledge base is constructed with the event part, cognitive part, emotional description part and emotional vector that constitute the key-value pair.
[0033] The present invention also provides a computer device, including a processor and a memory, wherein the memory stores program code, and the processor executes the program code to perform the above-mentioned text emotion observation method.
[0034] The present invention also includes a computer-readable storage medium, characterized in that the computer-readable storage medium stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the above-mentioned text emotion observation method.
[0035] Compared with existing technologies, this invention achieves the following technical benefits: It pre-annotates sample texts to quantify their sentiment. Based on sufficient annotated data, it constructs a sentiment event knowledge base, which is then used for calculations to quantify the sentiment of all unknown texts. This fundamentally addresses the problem of significant sentiment variation across texts. Furthermore, it constructs an observation matrix and adjusts the sentiment vector, addressing the issues of personalized, highly variable, and demographically diverse sentiment. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings, wherein:
[0037] Figure 1 This is a flowchart of the text emotion observation method described in Example 1;
[0038] Figure 2 Another flow chart of the text emotion observation method described in Example 1;
[0039] Figure 3 This is a schematic diagram of the structure of the computer device described in Example 3. DETAILED DESCRIPTION
[0040] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0041] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0042] The terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed or inherent to such process, method, article, or apparatus.
[0043] Example 1
[0044] This embodiment provides a text emotion observation method, such as Figure 1 and Figure 2 As shown, the steps include:
[0045] S1. Label the sample text, including the following: emotional direction, emotional polarity, emotional category, and emotional intensity. Emotional direction, emotional polarity, and emotional category all include several types of emotions. The labeled text has a definition for the text length, and texts of different lengths are labeled according to a certain proportion. Among them, in emotional direction, emotions towards oneself are inward, emotions towards the outside world are outward, and no direction is neutral; in emotional polarity, positive is positive emotion, negative is negative emotion, and neutral is no emotion; in emotional categories, they are positive, sad, angry, fearful, surprised, disgusted, and neutral; in emotional intensity, you can refer to the psychological definition of emotional labeling, 0-10 intensity, and different intensity labeling definitions. You can also choose 0-100, different values can be normalized and mapped, or you can choose odd-numbered quantitative standards such as 0, 3, 5, 7, and 9.
[0046] In order to improve the diversity of sample text annotation, different groups of people need to be selected to annotate the sample text during annotation. The annotated population and situational distribution design requirements should be met, and the population should be defined from different perspectives such as age, occupation, geographic location, education level, gender, industry, family, psychologist, friends, and experts.
[0047] When collecting annotated sample texts, acceptance criteria are established to obtain qualified sample texts. For example, the acceptance criteria are: samples with a consistency of emotion types greater than or equal to (n+1) / 2 are selected as qualified samples, where n is the number of annotators and n is an odd number greater than or equal to 5.
[0048] For the same sample text, its sentiment intensity can be calculated using the following methods: median, maximum value, average value, logistic regression and other modeling methods.
[0049] The main sentences and clauses in the sample text must be annotated. The process of annotating the sample text is as follows:
[0050] Example 1:
[0051] {
[0052] 'sentences': [
[0054] {
[0055] 'id':14******************************,
[0056] 'content':'Everyone says you should live with your anxiety symptoms and not wait until you're better before doing anything else, but I really don't know how to persevere or how to get through these remaining difficult months.'
[0057] 'polarity':'negative',
[0058] 'sentiment':'sad',
[0059] 'intensity':8,
[0060] 'orientation':'inside',
[0061] 'clause':[
[0062] {
[0063] 'content':'But I really don't know how to persevere and how to get through these remaining difficult months',
[0064] 'polarity':'negative',
[0065] 'orientation':'inside',
[0066] 'sentiment':'sad',
[0067] 'intensity':8
[0068] },
[0069] {
[0070] 'content':'But I really don't know how to persevere and how to get through these difficult remaining months', 'polarity':'negative',
[0071] 'orientation':'inside',
[0072] 'sentiment':'fear',
[0073] 'intensity':7
[0074] } ]
[0076] },
[0077] {
[0078] } ]
[0080] }
[0081] Example 2:
[0082] {
[0083] "id":123****************************,
[0084] "content":"1. Going out for fun. 2. Visiting family. 3. Irregular holidays.", "polarity": "negative",
[0085] "sentiment": "disgust",
[0086] "intensity": "3",
[0087] "orientation": "in",
[0088] "clause":
[0089] {
[0090] "content": "Going out for fun",
[0091] "sentiment": "positive emotion",
[0092] "polarity": "positive", `
[0093] "orientation": "middle",
[0094] "intensity": "2"
[0095] },
[0096] {
[0097] "content": "Visiting family",
[0098] "sentiment": "positive emotion",
[0099] "polarity": "positive",
[0100] "orientation": "out",
[0101] "intensity": "2" `
[0102] },
[0103] {
[0104] "content": "Irregular holidays",
[0105] "sentiment": "disgust",
[0106] "polarity": "negative",
[0107] "orientation": "out",
[0108] "intensity":"3"
[0109] } ]
[0111] }
[0112] S2. Construct a sentiment intensity calculation model and calculate the sentiment vector of the sample text based on the annotation. For example, the sentiment intensity calculation model used in this embodiment is a deep learning model. For details, please refer to the prior art. Step S2 specifically includes the following steps:
[0113] S21. Extract the sample text and divide it into: event part, cognitive part and emotional description part.
[0114] S22. According to the annotation, f(event, emotion, cognition) = e emotion vector, calculate the emotion vector of the event part, the cognition part and the emotion description part. For example: (event, emotion) e, (cognition, emotion) e, (cognition, event) e, event e, cognition e, emotion e. According to the annotation, the emotion vector e can be determined. The positive and negative can be quantified in the form of [0,1,2]. The internal and external emotions are [0,1,2]. Sadness, surprise and disgust emotions are quantified in the form of basis vectors. Positive is [1,0,0,0,0,0,0], sadness is [1,0,0,0,0,0]
[0115] Different emotion categories form the basis vector space [0, 1, 0, 0, 0, 0], with a total of 9 dimensions. The first dimension is polarity, the second is direction, and the next seven dimensions are emotion categories. Given a certain amount of data, the deep learning model can solve for f(event, emotion, cognition), f(event, cognition), f(event, emotion), f(emotion, cognition), f(event), f(emotion), and f(cognition).
[0116] S3. Construct an emotional event knowledge base of the sample text with the sample text and the emotional vector. The specific method adopted is: the event part, the cognitive part, the emotional description part, and the emotional vector form a key-value pair to construct the emotional event knowledge base. At the same time, according to the theory of cognitive behavioral therapy (CBT), the sentence structure is further expanded. The sentence can also introduce a state part, a behavior part, a motivation part, and a result part to assist in the expansion and reduction of the intensity of the emotion, thereby improving the sample text and constructing the emotional event knowledge base with the event part, the cognitive part, the emotional description part, and the emotional vector that constitute the key-value pair; or according to the interpretation method of emotions in other psychological theories (such as positive psychology), the sample text is expanded and constructed with the event part, the cognitive part, the emotional description part, and the emotional vector that constitute the key-value pair to construct the emotional event knowledge base.
[0117] S4. Using the observation model and observation matrix, and based on the emotional event knowledge base, calculate the sentiment vector of the observed text. For example, if I hate calling parents [1,1,0,0,0,0,0,3,0], and the teacher's observation vector is [1,1,0,0,0,0,0,1.5,0], we can see that teachers' dislike for this text has decreased. This difference is adjusted using the observation matrix.
[0118] Considering that different semantic parts evoke different emotions and intensities in different people, this embodiment constructs the observation matrix from the perspective of a psychological observer. Ordinary emotions focus on sadness, anger, disgust, and fear, while psychology focuses on anxiety, depression, and anger. Corresponding emotion mapping is required, and the observation matrix is constructed using linear modeling:
[0119] First, the annotation population is divided into several annotation groups; the annotation population is divided according to different group characteristics, such as age, aesthetics, common hobbies, common experiences, common views, and common emotional tendencies; then, the sample texts are clustered into corresponding annotation groups according to the annotation population; finally, the sentiment vector is calculated for the texts in the same annotation group to obtain the sentiment vector of the sample text in a certain annotation group after the observation matrix. The sentiment vector obtained by the general population without the observation matrix calculation and the sentiment vector of the sample text in a certain annotation group after the observation matrix calculation are calculated, and finally the observation matrix is obtained. The observation matrix example is as follows:
[0120] Observation Matrix
[0121] The measurement matrix can be applied to different groups of people to correct their sentiment vectors. It can also be generalized to individuals. This requires sufficient prior knowledge to construct the individual's measurement matrix. To improve the accuracy of the measurement matrix, the nonlinear modeling of the neural network layer can be used. The noise matrix can then be used to select Gaussian noise, uniformly distributed noise, Gaussian mixture noise, exponential noise, and other noise models.
[0122] When the observation matrix adopts the linear modeling method, the observation matrix is multiplied by the preliminary emotion vector to make adjustments.
[0123] In addition, the measurement matrix can also be modeled using nonlinear modeling methods, such as using a fully connected neural network with an activation function to implement the measurement matrix modeling. Other neural network structures such as GRU and LSTM can also be used for implementation, or a combination of various neural network structures can be used for implementation. When the measurement matrix is modeled using a nonlinear modeling method, the activation function in the neural network structure is non-zero.
[0124] A deep neural network is used, with the preliminary emotion vector as the input of the network and the final emotion vector as the output of the network, such as a fully connected network model.
[0125] Next, step S4 is further explained in conjunction with a specific implementation method:
[0126] Enter the text to be observed: I will call parents twice next week
[0127] S41. Search the emotional event knowledge base and prepare the same or similar sample texts:
[0128] Known text
[0129] I hate calling parents [1,1,0,0,0,0,0,3,0]. In this emotion vector, each digit represents: emotion direction, emotion polarity, emotion type (positive, angry, surprised, fearful, sad, disgusted, neutral).
[0130] My parents were called. [0,1,0,0,0,2,0,4,0]
[0131] When I was young, I was often called to the parents' office. [0,1,0,0,0,3,0,3,0]
[0132] S42. Based on the above known text, the event extraction part is used to extract the event of calling parents and calculate the sentiment vector. The event extraction can be a deep learning model. For details about deep learning models, please refer to the prior art. Since f is known, the e of the extracted event can be calculated. The calculation result is:
[0133] Call parents [2,1,0,0,0,3,0,3,0]
[0134] S43. After the emotional type and intensity of the event are constructed, they will be triggered by different events in practice, thus changing. Therefore, it is necessary to use the observation matrix to further adjust the semantics. After the adjustment, the result is:
[0135] Next week I was called twice to be the parent [0,1,0,0,0,3.5,0,3.5,0]
[0136] In summary, this invention achieves sentiment quantification of sample texts by pre-annotating them. Based on sufficient annotated data, it constructs a sentiment event knowledge base, which is then used for calculations to quantify the sentiment of all unknown texts. This fundamentally addresses the problem of significant sentiment variation among texts. Simultaneously, an observation matrix is constructed and sentiment vectors are adjusted, addressing the issues of personalized, highly variable, and demographically diverse sentiment.
[0137] Example 2
[0138] This embodiment provides a computer device, such as Figure 3 As shown, the computer device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to implement the text emotion observation method of Example 1.
[0139] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0140] The memory can be used to store the computer program or module, and the processor realizes the various functions of the auxiliary terminal device based on mirror neuron therapy by running or executing the computer program or module stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created based on the use of the mobile phone (such as audio data, a phone book, etc.). In addition, the memory can include a high-speed random access memory and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage device.
[0141] Example 3
[0142] This embodiment provides a computer-readable storage medium, which stores at least one instruction, at least one program, code set or instruction set. The at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the text emotion observation method of Example 1.
[0143] Storage media can include physical devices used to store information, typically digitizing information and then storing it in electrical, magnetic, or optical media. Examples include devices that use electrical energy to store information, such as various types of memory, such as RAM and ROM; devices that use magnetic energy to store information, such as hard drives, floppy disks, magnetic tapes, magnetic core memories, bubble memories, and USB flash drives; and devices that use optical energy to store information, such as CDs and DVDs. Of course, there are other types of readable storage media, such as quantum memory and graphene memory.
[0144] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A text emotion observation method, characterized in that: Including steps: Annotate sample text; Construct a sentiment vector calculation model and calculate the sentiment vector of the sample text based on the annotations; Construct an emotional event knowledge base of sample texts using sample texts and emotional vectors; Using the observation model and observation matrix, and based on the emotional event knowledge base, the sentiment vector of the text to be observed is calculated; The step of calculating the sentiment vector of the text to be observed by using the observation model and the observation matrix and based on the sentiment event knowledge base includes: Retrieve sample texts that are identical or similar to the text to be observed from the emotional event knowledge base; The observation model is used to calculate the preliminary sentiment vector of the text to be observed; The observation matrix is used to adjust the preliminary sentiment vector to obtain the sentiment vector of the text to be observed; When the observation matrix is used to adjust the preliminary emotion vector, the activation function in the neural network structure is non-zero.
2. The text emotion observation method according to claim 1, characterized in that The labeling of the sample text includes labeling the sample text with emotion direction, emotion polarity, emotion category, and emotion intensity, wherein the emotion direction, the emotion polarity, and the emotion category all include several emotion types.
3. The text emotion observation method according to claim 1, characterized in that: The step of calculating the sentiment vector of the sample text according to the annotation includes: Extract the sample text and divide it into: event part, cognitive part and emotional description part; Based on the annotations, the sentiment vectors of the event part, cognitive part and sentiment description part are calculated.
4. The text emotion observation method according to claim 3, characterized in that: The step of constructing an emotional event knowledge base of the sample text using the sample text and the emotional vector includes: The event part, the cognitive part, the emotion description part, and the emotion vector form a key-value pair to construct the emotion event knowledge base.
5. The text emotion observation method according to any one of claims 1 to 4, characterized in that: It also includes the steps of constructing the observation matrix: The observation matrix is modeled using a matrix or a neural network.
6. The text emotion observation method according to any one of claims 1 to 4, characterized in that: Alternatively, the steps of constructing the observation matrix include: Divide the labeled population into several labeled groups; For the sample text, classify it into the corresponding annotation group according to the annotation population; Calculate the sentiment vector of the text in the same annotated group and obtain the statistical calculation result of the difference between the sentiment vector of the sample text in a certain annotated group and the result output by the observation model; The step of adjusting the preliminary emotion vector using the observation matrix includes: Multiply the observation matrix with the preliminary sentiment vector.
7. The text emotion observation method according to claim 2, characterized in that: The step of constructing an emotional event knowledge base of the sample text using the sample text and the emotional vector also includes: Based on the theory of cognitive behavioral therapy, the sample text is expanded and the event part, cognitive part, emotional description part and emotional vector that constitute the key-value pair are combined to construct the emotional event knowledge base; According to the interpretation methods of emotions in other psychological theories, the sample text is expanded, and the emotional event knowledge base is constructed with the event part, cognitive part, emotional description part and emotional vector that constitute the key-value pair.
8. A computer device, characterized in that: The method comprises a processor and a storage, wherein program code is stored in the storage, and the processor executes the program code to execute the text emotion observation method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that The readable storage medium stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to implement the text emotion observation method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Text emotion recognition method and device based on emotion abstracts
CN111475640A
Text sentiment analysis method
CN113849646A
Method and system for extracting text semantic data based on implicit sentiment word analysis
CN112329472A
Method for Fine-Grained Affective States Understanding and Prediction
US20200250278A1