CN110377915B - Text emotion analysis method and device, storage medium and equipment - Google Patents

Text emotion analysis method and device, storage medium and equipment Download PDF

Info

Publication number
CN110377915B
CN110377915B CN201910678838.9A CN201910678838A CN110377915B CN 110377915 B CN110377915 B CN 110377915B CN 201910678838 A CN201910678838 A CN 201910678838A CN 110377915 B CN110377915 B CN 110377915B
Authority
CN
China
Prior art keywords
vector
text
layer
target
word
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910678838.9A
Other languages
Chinese (zh)
Other versions
CN110377915A (en
Inventor
刘巍
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910678838.9A priority Critical patent/CN110377915B/en
Publication of CN110377915A publication Critical patent/CN110377915A/en
Application granted granted Critical
Publication of CN110377915B publication Critical patent/CN110377915B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates

Abstract

The embodiment of the application discloses a text emotion analysis method, a text emotion analysis device, a text emotion analysis storage medium and text emotion analysis equipment, and belongs to the technical field of computers. The method comprises the following steps: acquiring a text to be analyzed and a target word in the text, wherein the target word represents a target object in the text; generating a first vector set according to first feature vectors of the text, wherein each first vector in the first vector set is extracted from the first feature vectors; generating a second vector set according to second feature vectors of the target words, wherein each second vector in the second vector set is extracted from the second feature vectors; and performing ensemble learning on the first vector set and the second vector set to obtain the emotion polarity of the target word. The method and the device for processing the target words can improve the accuracy of the emotion polarity of the target words.

Description

Text emotion analysis method and device, storage medium and equipment
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a text sentiment analysis method, a text sentiment analysis device, a text sentiment storage medium and text sentiment analysis equipment.
Background
The emotion analysis of the text refers to analyzing the emotion polarity of different target words in the text. Wherein the target word represents a target object in the text. The emotion polarity indicates an emotional tendency, which may include positive emotions, negative emotions, neutral emotions, and the like. For example, if the text is "Good food button dreadful service at which reserve", it can be obtained that the emotion polarity of the target word "food" is a positive emotion, and the emotion polarity of the target word "service" is a negative emotion.
In the related technology, a text and a target word in the text can be input into a machine learning model, and the machine learning model can perform word embedding processing and convolution processing on the text in sequence to obtain a convolution result; performing word embedding processing on the target word to obtain a word vector; and combining the convolution result and the word vector by using a gate control unit (GTRU), and sequentially performing pooling processing and normalization processing on the output result of the gate control unit to obtain the emotion polarity of the target word.
The gate control unit combines the convolution result and the word vector in a near-linear mode, so that feature extraction is simple, correlation between the target word and semantic information is ignored, the output result is mainly determined by the semantic information, influence of the target word on the emotion polarity is ignored, and the emotion polarity of the target word is inaccurate.
Disclosure of Invention
The embodiment of the application provides a text emotion analysis method, a text emotion analysis device, a text emotion storage medium and text emotion analysis equipment, which are used for solving the problem that the emotion polarity of a target word is inaccurate when a convolution result and a word vector are combined through a gate control unit. The technical scheme is as follows:
in one aspect, a method for emotion analysis of a text is provided, where the method includes:
acquiring a text to be analyzed and a target word in the text, wherein the target word represents a target object in the text;
generating a first vector set according to first feature vectors of the text, wherein each first vector in the first vector set is extracted from the first feature vectors;
generating a second vector set according to second feature vectors of the target words, wherein each second vector in the second vector set is extracted from the second feature vectors;
and performing ensemble learning on the first vector set and the second vector set to obtain the emotion polarity of the target word.
In one aspect, an emotion analysis apparatus for text is provided, the apparatus including:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a text to be analyzed and a target word in the text, and the target word represents a target object in the text;
a first generating module, configured to generate a first vector set according to the first feature vectors of the text obtained by the obtaining module, where each first vector in the first vector set is extracted from the first feature vectors;
a second generating module, configured to generate a second vector set according to the second feature vectors of the target word obtained by the obtaining module, where each second vector in the second vector set is extracted from the second feature vectors;
and the ensemble learning module is used for carrying out ensemble learning on the first vector set and the second vector set to obtain the emotion polarity of the target word.
In one aspect, a computer-readable storage medium is provided, in which at least one instruction, at least one program, a set of codes, or a set of instructions is stored, which is loaded and executed by a processor to implement the method for emotion analysis of text as described above.
In one aspect, an emotion analysis device for a text is provided, and the emotion analysis device for the text comprises a processor and a memory, wherein at least one instruction is stored in the memory, and the instruction is loaded and executed by the processor to implement the emotion analysis method for the text.
The technical scheme provided by the embodiment of the application has the beneficial effects that at least:
since each first vector in the first vector set is extracted from the first feature vector of the text, and each second vector in the second vector set is extracted from the second feature vector of the target word, the first vectors can represent semantic information, the second vectors can represent the target word, and the ensemble learning can combine each first vector and each second vector, so that the obtained emotion polarity can comprehensively consider the association between the target word and the semantic information and the influence of the target word on the emotion polarity, and the accuracy of the emotion polarity of the target word is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic diagram of a textual sentiment analysis system according to some exemplary embodiments;
FIG. 2 is a flowchart of a method for emotion analysis of a text according to an embodiment of the present application;
FIG. 3 is a flowchart of a method for emotion analysis of a text according to another embodiment of the present application;
FIG. 4 is a schematic diagram of a model according to another embodiment of the present application;
FIG. 5 is a block diagram illustrating an emotion analysis apparatus for text according to an embodiment of the present application;
fig. 6 is a block diagram showing a structure of a text emotion analyzing apparatus according to still another embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present application more clear, the embodiments of the present application will be further described in detail with reference to the accompanying drawings.
The terms referred to in the present application are explained below.
The target word: the target word represents a target object in the text, which is an object capable of imparting emotion. For example, if the text is a comment that rates the service, taste, and price of a restaurant, the target word may include the service, taste, and price. For another example, if the text is a comment for evaluating the power and fuel consumption of the vehicle, the target word may include the power and fuel consumption.
Emotional polarity: the emotion polarity may include at least one of positive emotion (positive), negative emotion (negative), neutral emotion (neutral), and conflicting emotion (conflict). Where positive emotions can be understood as positive emotions such as "smooth", "happy", etc. Negative emotions may be understood as meaning-less emotions such as "not fluent", "disappointing", and the like. The neutral feeling can be understood as an unappreciated and unappreciated objective feeling, such as "general fluency" and the like. Conflicting emotions may also be referred to as contradictory emotions.
Deep learning: deep learning refers to a machine learning method based on characterization learning of data. The benefit of deep learning is to replace the manual feature acquisition with unsupervised or semi-supervised feature learning and hierarchical feature extraction efficient algorithms.
In recent years, targeted emotion analysis has become one of the research hotspots in the field of natural language processing as a deeper emotion analysis task. Unlike ordinary emotion analysis, specific target emotion analysis needs to analyze the emotion polarity of different target objects in a text, which not only depends on the context information of the text, but also considers the emotion information of different target objects in the text. For example, the text is "Good food button dreadful service at which reserve", the emotion polarity of the target word "food" is a positive emotion, and the emotion polarity of the target word "service" is a negative emotion, so that different target words in the same text may correspond to opposite emotion polarities. In past research, the traditional machine learning method has achieved remarkable success in common emotion analysis tasks, but the traditional machine learning method needs to rely on complicated artificial rules and feature engineering, and different target words in the same text are often predicted to have the same emotion polarity, so that the accuracy of emotion analysis is affected. Therefore, the deep learning method is increasingly applied to the field of natural language processing.
Integrated learning: the ensemble learning is a machine learning method in which a plurality of learners are used for learning, and learning results are integrated by using a certain rule, so that a better learning effect is obtained than that of a single learner.
The following describes an application scenario of the present application.
The method and the device are applied to an application scene for analyzing the emotion polarity of the target word in the text. The text may be an evaluation issued by the user, and the evaluation may be for any article or object, which is not limited in this embodiment. Several evaluations that are frequently published by the user are explained below.
1. When the text is evaluated for a public place such as a restaurant, a casino, a movie theater, a station, a hospital, etc., various aspects of services, facilities, etc. provided by the public place may be evaluated for reference by other users based on emotion analysis.
2. When the text is the evaluation for the product, the goodness of each function of the product can be evaluated according to emotion analysis, so that developers can conveniently select key functions to optimize.
3. When the text is evaluated for movie and television works and literary works, aspects of the works such as plots and movie contents can be evaluated according to emotion analysis so that other users can understand the works.
It is to be noted that the embodiment of the present application may be implemented in a terminal, may also be implemented in a server, and may also be implemented by both the terminal and the server, as shown in fig. 1, the terminal 11 is configured to generate a text and send the text to the server 12, and after performing emotion analysis on the text, the server 12 sends an emotion polarity to the terminal 11 for displaying. Optionally, the terminal 11 and the server 12 are connected through a communication network, which may be a wired network or a wireless network, and this is not limited in this embodiment of the present application.
Illustratively, a model for emotion analysis is stored in the server 12, after a user inputs a text "Good food button great deal service at which source resource" into the terminal 11, the terminal 11 sends the text to the server 12, the server 12 performs emotion analysis on the text through the model to obtain emotion polarities of each target word, and sends the emotion polarities of each target word to the terminal 11 for display.
In the related art, after the convolution result of the text and the word vector of the target word are obtained, the convolution result and the word vector can be combined through a gate control unit. Because the gate control unit is a GTRU, the GTRU comprises a Tanh function and a Relu function, and both the Tanh function and the Relu function are near linear functions, the gate control unit combines a convolution result and a word vector in a near linear mode, so that feature extraction is simple, association between a target word and semantic information is ignored, an output result is mainly determined by the semantic information, influence of the target word on emotion polarity is ignored, and the emotion polarity of the target word is inaccurate.
According to the method and the device, emotion analysis is carried out on the text in a mode of integrated learning plus deep learning, a first vector set corresponding to the text and a second vector set corresponding to the target words are obtained through the deep learning, and then each first vector and each second vector are combined through the integrated learning, so that the obtained emotion polarities can comprehensively consider the association between the target words and semantic information and the influence of the target words on the emotion polarities, and the accuracy of the emotion polarities of the target words is improved.
Referring to fig. 2, a flowchart of a method for emotion analysis of a text according to an embodiment of the present application is shown, where the method for emotion analysis of a text may be applied to the terminal or the server shown in fig. 1. The emotion analysis method of the text comprises the following steps:
step 201, obtaining a text to be analyzed and a target word in the text, where the target word represents a target object in the text.
When emotion analysis is required to be performed on a sentence, the sentence can be used as a text to be analyzed; when emotion analysis needs to be performed on a plurality of sentences, each sentence can be used as a text to be analyzed.
The target words in the text to be analyzed are extracted from the text. The target words can be obtained by inputting texts into the target word extraction model and through the target word extraction model; the text may also be extracted from the text manually, and this embodiment is not limited.
It should be noted that at least one target word may be included in one text. When the text includes a target word, steps 201-204 can be executed to obtain the emotional polarity of the target word; when the text includes at least two target words, one target word may be selected first, step 201-204 is performed to obtain the emotion polarity of the target word, then the next target word is selected, step 201-204 is performed to obtain the emotion polarity of the next target word, and so on, and the cycle is stopped until the emotion polarity of the last target word is obtained.
In step 202, a first vector set is generated according to first feature vectors of text, and each first vector in the first vector set is extracted from the first feature vectors.
In this embodiment, a deep learning method may be used to perform feature extraction on a text to obtain a first feature vector, extract a first vector from the first feature vector, and combine all the first vectors into a first vector set. Wherein the dimension of the first vector is smaller than the dimension of the first feature vector.
Step 203, generating a second vector set according to the second feature vectors of the target words, wherein each second vector in the second vector set is extracted from the second feature vectors.
In this embodiment, a deep learning method may be adopted to perform feature extraction on the target word to obtain a second feature vector, extract a second vector from the second feature vector, and form a second vector set with all the second vectors. Wherein the dimension of the second vector is smaller than the dimension of the second feature vector.
It should be noted that, this embodiment does not limit the execution sequence of steps 202 and 203. That is, step 202 may be performed first, and then step 203 may be performed; step 203 may be executed first, and then step 202 may be executed; steps 202 and 203 may also be performed simultaneously.
Step 204, performing ensemble learning on the first vector set and the second vector set to obtain the emotion polarity of the target word.
In this embodiment, a plurality of processing units for ensemble learning are preset, and after a first vector set and a second vector set are obtained, each first vector in the first vector set and each second vector in the second vector set may be input into each processing unit, and the processing result of each processing unit is processed again according to a preset rule, so as to obtain the emotion polarity of the target word.
For example, if the text is "Good food but great service at that facility," and the text includes the target words "food" and "service," steps 202 to 204 may be performed on the text and the "food" first, and the emotional polarity of the "food" is obtained as a positive emotion; steps 202-204 are then performed for the text and "service" to obtain that the emotion polarity of "service" is a negative emotion.
In summary, according to the method for analyzing emotion of a text provided by the embodiment of the present application, each first vector in the first vector set is extracted from the first feature vector of the text, and each second vector in the second vector set is extracted from the second feature vector of the target word, so that the first vectors may represent semantic information, the second vectors may represent the target word, and the ensemble learning may combine each first vector and each second vector, so that the obtained emotion polarities can comprehensively consider the association between the target word and the semantic information and the influence of the target word on the emotion polarities, thereby improving the accuracy of the emotion polarities of the target word.
Please refer to fig. 3, which shows a flowchart of a method for emotion analyzing a text according to another embodiment of the present application, where the method for emotion analyzing a text can be applied to the terminal or the server shown in fig. 1. The emotion analysis method of the text comprises the following steps:
step 301, obtaining a text to be analyzed and a target word in the text, where the target word represents a target object in the text.
When emotion analysis is required to be performed on a sentence, the sentence can be used as a text to be analyzed; when emotion analysis needs to be performed on a plurality of sentences, each sentence can be used as a text to be analyzed.
The target words in the text to be analyzed are extracted from the text. The target words can be obtained by inputting texts into a target word extraction model and through the target word extraction model; the text may also be extracted from the text manually, and this embodiment is not limited.
It should be noted that at least one target word may be included in one text. When the text includes a target word, steps 302-309 can be executed to obtain the emotion polarity of the target word; when the text includes at least two target words, one target word may be selected first, the steps 302 to 309 are performed to obtain the emotion polarity of the target word, then the next target word is selected, the steps 302 to 309 are performed to obtain the emotion polarity of the next target word, and so on until the emotion polarity of the last target word is obtained, and the cycle is stopped.
In this embodiment, the text and the target word may be processed by a deep learning method, where the text may be processed through steps 302 to 304, and the target word may be processed through steps 305 to 306, which will be described in detail below.
The present embodiment does not limit the order of execution of steps 302-304 and 305-306. That is, steps 302-304 may be performed first, followed by steps 305-306; alternatively, steps 305-306 may be performed first, followed by steps 302-304; steps 302-304 and 305-306 may also be performed simultaneously.
And step 302, performing word embedding processing and convolution processing on the text in sequence to obtain a convolution result.
In this embodiment, a Convolutional Neural Network (CNN) may be used to perform deep learning on a text.
In an alternative embodiment, the convolutional neural network includes a word embedding layer and a convolutional layer, so that the text s may be input into the word embedding layer first, and the word embedding layer performs word embedding processing on the text a to obtain word vectors W of words in the text a s (ii) a Then, the word vector W is used s Inputting the convolution layer, aligning the word vector W through the convolution layer s Performing convolution processing to obtain a convolution result V s
Step 303, converting each matrix in the convolution result into a vector, and connecting all vectors to obtain a first feature vector.
Because the convolution result contains the matrix, each matrix can be connected after being converted into the vector to obtain the first characteristic vector.
There are many ways to convert a matrix into a vector. For example, elements in different rows in the matrix may be connected into a row to obtain a vector with row number 1; alternatively, the elements in different columns in the matrix may be concatenated into one column, resulting in a vector with 1 column.
For ease of understanding, the following description will be made by way of example to convert a matrix into a vector with a number of rows 1. Assume a first matrix of
Figure BDA0002144144800000081
The second matrix is
Figure BDA0002144144800000082
The vector resulting from the conversion of the first matrix is 12 3 4]The vector obtained by converting the second matrix is [5 6 7 8]]The first feature vector is [ 12 3 4 5 6 7 8]]。
Step 304, if the dimension of the first feature vector is n, randomly selecting m first vectors with q dimensions from the first feature vector, and forming a first vector set by the m first vectors, wherein q is less than n.
Wherein n is a positive integer, m is a positive integer, and q is a positive integer less than n.
In this embodiment, a random selection layer may be further provided, and q elements are arbitrarily selected from n elements included in the first feature vector by the random selection layer, and the q elements are combined into one first vector. The positions of the selected q elements may be adjacent or not adjacent, and this embodiment is not limited.
In an alternative embodiment q may be half n, i.e. q = n/2.
For example, if the first feature vector is [ 13 4 5 6 7 ] and q is 4, the obtained first vector may be [ 13 ], [3 4 5 6], [2 4 6], [ 15 6], and so on.
After obtaining the m first vectors, the m first vectors may be grouped into a first vector set R s
Step 305, performing word embedding processing on the target word to obtain a second feature vector.
In this embodiment, canInputting the target word a into a word embedding layer, and performing word embedding processing on the target word a through the word embedding layer to obtain a word vector W of the target word a a
Note that the second feature vector has the same dimension as the first feature vector.
And step 306, if the dimension of the second feature vector is n, randomly selecting m second vectors with q dimensions from the second feature vector, and forming a second vector set by the m second vectors.
In this embodiment, q elements may be arbitrarily selected from n elements included in the second feature vector, and the q elements may be combined into one second vector. The positions of the selected q elements may be adjacent or not adjacent, and this embodiment is not limited.
After m second vectors are obtained, the m second vectors can be combined into a second vector set R a
Step 307, if the first vector set includes p first vectors and the second vector set includes p second vectors, inputting the ith first vector in the first vector set and the jth second vector in the second vector set into k processing units, and selecting a target processing result from the k processing results output by the k processing units.
Wherein p is a positive integer, i and j are both less than or equal to p, and k is a positive integer greater than or equal to 2.
In this embodiment, a Multi-head-bagging-sorting classifier (Multi-head random-sorting classifier) may also be provided, where the Multi-head random-sorting classifier may include k processing units, and each processing unit may be implemented by any network structure, which is not limited in this embodiment.
When the ith first vector and the jth second vector are respectively input into the k processing units, each processing unit outputs a processing result, and one processing result can be selected from the obtained k processing results as a target processing result.
In an alternative embodiment, selecting a target processing result from the k processing results output by the k processing units includes: counting the number of the same processing results in the k processing results output by the k processing units; and taking the most one processing result as a target processing result.
Suppose k is 5, and the processing results output by the 5 processing units are: if the processing result 1, the processing result 2, and the processing result 2 are obtained, the number of the processing results 1 is 1, the number of the processing results 2 is 4, and the processing result 2 is set as the target processing result.
And 308, updating i to i +1, updating j to j +1, and continuing to input the ith first vector in the first vector set and the jth second vector in the second vector set into the k processing units until target processing results corresponding to the pth first vector and the pth second vector are obtained, and then stopping.
If p is 3, the first vector set comprises 3 first vectors, the second vector set comprises 3 second vectors, and the first vector and the first second vector can be processed by k processing units to obtain a first target processing result; processing the first vector and the second vector through k processing units to obtain a second target processing result; processing the first vector and the third second vector through k processing units to obtain a third target processing result; processing the second first vector and the second vector through k processing units to obtain a fourth target processing result; and repeating the steps until the third first vector and the third second vector are processed by the k processing units to obtain a ninth target processing result, and stopping the circulation.
After stopping the loop, all target processing results may be taken as the output of the multi-headed random choice classifier. In general, the output of a multi-headed random choice classifier can be represented as H.
And 309, performing normalization processing on all target processing results to obtain the emotion polarity of the target word.
In this embodiment, a normalization layer may be further provided, and normalization processing may be performed on all target processing results through the normalization layer to obtain the probability that the target word corresponds to each emotion polarity. And finally, taking the emotion polarity with the maximum probability as the emotion polarity of the target word.
Where the normalization layer is a softmax layer, step 309 may be expressed as Y = softmax (H), where H represents the output of the multi-headed random choice classifier and Y represents the emotion polarity of the target word.
For example, if the text is "Good food button fresh service at which source," and the text includes the target words "food" and "service," steps 202-204 may be performed for the text and "food" first, and the emotional polarity of "food" is a positive emotion; steps 202-204 are then performed for the text and "service," and the emotion polarity for "service" is the negative emotion.
In summary, according to the method for analyzing emotion of a text provided by the embodiment of the present application, each first vector in the first vector set is extracted from the first feature vector of the text, and each second vector in the second vector set is extracted from the second feature vector of the target word, so that the first vectors may represent semantic information, the second vectors may represent the target word, and the ensemble learning may combine each first vector and each second vector, so that the obtained emotion polarities can comprehensively consider the association between the target word and the semantic information and the influence of the target word on the emotion polarities, thereby improving the accuracy of the emotion polarities of the target word.
Because the convolutional neural network supports parallel operation, the efficiency of emotion analysis on the text can be improved.
The method may be implemented by a model for emotion analysis of a text, please refer to a structure diagram of the model shown in fig. 4, where the model includes a first Word Embedding layer (Word Embedding), a convolutional layer (volume), a first Random Selector (Random Selector), a second Word Embedding layer (Aspect Embedding), a second Random Selector (Random Selector), a Multi-head Random-based classifier (Multi-head-clustering-classifier), and a normalization layer (Softmax). When the model is used for emotion analysis, a text can be input into a first word embedding layer, the first word embedding layer outputs word vectors of the text to a convolution layer, the convolution layer outputs a first feature vector to a first random selection layer, and the first random selection layer outputs a first vector set to a multi-head random selection classifier; inputting the target word into a second word embedding layer, outputting a second feature vector of the target word to a second random selection layer by the second word embedding layer, and outputting a second vector set to a multi-head random selection classifier by the second random selection layer; the multi-head random selection classifier outputs all target processing results to the normalization layer; the normalization layer outputs the emotional polarity of the target word outward. The Base encoder in fig. 4 is a processing unit in the multi-head random selection classifier.
The AutoEncoder structure used by the model can utilize CNN to replace the traditional LSTM (Long short-term memory), thereby ensuring the interactive complexity between the semantic information and the target information on the premise of improving the parallelism and the training speed, ensuring the capability of capturing the complex relationship between the semantic information and the target information, and fully fusing the semantic information and the target information in the process of disassembling and reconstructing.
The model also needs to be trained before it can be used. When training a model using an SGD (stochastic gradient descent) optimizer, a Learning rate (Learning _ rate) may be set to 1e-3, L2 to 1e-3, and the number of iterations (Epoch) to 10. It should be noted that the learning rate is related to the data set, and the learning rate is exemplified herein as a learning rate based on the Restaurant data set, please refer to the Restaurant data set shown in table one.
Watch 1
Figure BDA0002144144800000111
Table two shows the experimental results of various models on the Restaurant dataset. The model in this embodiment is referred to as MHB-CNN in table two, and the comparison shows that the emotion analysis of the model in this embodiment is most effective.
Watch 2
Figure BDA0002144144800000121
Referring to fig. 5, a block diagram of a text emotion analysis apparatus according to an embodiment of the present application is shown, where the text emotion analysis apparatus can be applied to the terminal or the server shown in fig. 1. The emotion analysis device for the text comprises:
an obtaining module 510, configured to obtain a text to be analyzed and a target word in the text, where the target word represents a target object in the text;
a first generating module 520, configured to generate a first vector set according to the first feature vectors of the text obtained by the obtaining module 510, where each first vector in the first vector set is extracted from the first feature vectors;
a second generating module 530, configured to generate a second vector set according to the second feature vector of the target word obtained by the obtaining module 510, where each second vector in the second vector set is extracted from the second feature vector;
and the ensemble learning module 540 is configured to perform ensemble learning on the first vector set and the second vector set to obtain an emotion polarity of the target word.
In an alternative embodiment, if the first vector set includes p first vectors and the second vector set includes p second vectors, where p is a positive integer, the ensemble learning module 540 is further configured to:
inputting the ith first vector in the first vector set and the jth second vector in the second vector set into k processing units, and selecting a target processing result from k processing results output by the k processing units, wherein i and j are both less than or equal to p, and k is a positive integer greater than or equal to 2;
updating i to i +1, updating j to j +1, and continuing to input the ith first vector in the first vector set and the jth second vector in the second vector set into the k processing units until target processing results corresponding to the pth first vector and the pth second vector are obtained, and then stopping;
and carrying out normalization processing on all target processing results to obtain the emotion polarity of the target words.
In an alternative embodiment, the ensemble learning module 540 is further configured to:
counting the number of the same processing result in the k processing results output by the k processing units;
and taking the processing result with the largest number as a target processing result.
In an alternative embodiment, if the dimension of the first feature vector is n, where n is a positive integer, the first generation module 520 is further configured to:
randomly selecting m first vectors with q dimensions from the first feature vectors, wherein m is a positive integer and q is a positive integer smaller than n;
and forming m first vectors into a first vector set.
In an optional embodiment, if the dimension of the second feature vector is n, the second generating module 530 is further configured to:
randomly selecting m q-dimensional second vectors from the second feature vectors;
and forming m second vectors into a second vector set.
In an alternative embodiment, the first generating module 520 is further configured to:
before generating a first vector set according to a first feature vector of a text, performing word embedding processing and convolution processing on the text in sequence to obtain a convolution result;
converting each matrix in the convolution result into a vector;
and connecting all the vectors to obtain a first characteristic vector.
In an optional embodiment, the second generating module 530 is further configured to:
and performing word embedding processing on the target word to obtain a second feature vector before generating a second vector set according to the second feature vector of the target word.
In summary, according to the emotion analyzing apparatus for text provided by the embodiment of the present application, since each first vector in the first vector set is extracted from the first feature vector of the text, and each second vector in the second vector set is extracted from the second feature vector of the target word, the first vector may represent semantic information, and the second vector may represent the target word, and the ensemble learning may combine each first vector and each second vector, so that the obtained emotion polarity can comprehensively consider the association between the target word and the semantic information and the influence of the target word on the emotion polarity, thereby improving the accuracy of the emotion polarity of the target word.
Because the convolutional neural network supports parallel operation, the efficiency of emotion analysis on the text can be improved.
The application further provides a server, which includes a processor and a memory, where the memory stores at least one instruction, and the at least one instruction is loaded by the processor and executed to implement the emotion analysis method for text provided by the foregoing method embodiments. It should be noted that the server may be a server as provided in fig. 6 below.
Referring to fig. 6, a schematic structural diagram of a server according to an exemplary embodiment of the present application is shown. Specifically, the method comprises the following steps: the server 600 includes a Central Processing Unit (CPU) 601, a system memory 604 including a Random Access Memory (RAM) 602 and a Read Only Memory (ROM) 603, and a system bus 605 connecting the system memory 604 and the central processing unit 601. The server 600 also includes a basic input/output system (I/O system) 606, which facilitates transfer of information between devices within the computer, and a mass storage device 607, which stores an operating system 613, application programs 614, and other program modules 615.
The basic input/output system 606 includes a display 608 for displaying information and an input device 609 such as a mouse, keyboard, etc. for a user to input information. Wherein the display 608 and the input device 609 are connected to the central processing unit 601 through an input output controller 610 connected to the system bus 605. The basic input/output system 606 may also include an input/output controller 610 for receiving and processing input from a number of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, input/output controller 610 also provides output to a display screen, a printer, or other type of output device.
The mass storage device 607 is connected to the central processing unit 601 through a mass storage controller (not shown) connected to the system bus 605. The mass storage device 607 and its associated computer-readable storage media provide non-volatile storage for the server 600. That is, the mass storage device 607 may include a computer-readable storage medium (not shown) such as a hard disk or a CD-ROI drive.
Without loss of generality, the computer-readable storage media may include computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes RAM, ROM, EPROM, EEPROM, flash memory or other solid state memory technology, CD-ROM, DVD, or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that the computer storage media is not limited to the foregoing. The system memory 604 and mass storage device 607 described above may be collectively referred to as memory.
The memory stores one or more programs configured to be executed by the one or more central processing units 601, the one or more programs containing instructions for implementing the sentence encoding or sentence decoding method, and the central processing unit 601 executing the one or more programs implementing the emotion analysis method for text provided by the various method embodiments described above.
The server 600 may also operate as a remote computer connected to a network via a network, such as the internet, in accordance with various embodiments of the present invention. That is, the server 600 may be connected to the network 612 through the network interface unit 611 connected to the system bus 605, or may be connected to other types of networks or remote computer systems (not shown) using the network interface unit 611.
The memory further comprises one or more programs, the one or more programs are stored in the memory, and the one or more programs comprise steps executed by the server for performing the emotion analysis method of the text provided by the embodiment of the invention.
Embodiments of the present application also provide a computer-readable storage medium, in which at least one instruction, at least one program, a set of codes, or a set of instructions is stored, and the at least one instruction, the at least one program, the set of codes, or the set of instructions is loaded and executed by the processor 610 to implement the emotion analysis method for text as described above.
The application also provides a computer program product, which when running on a computer, causes the computer to execute the emotion analysis method of the text provided by the above method embodiments.
One embodiment of the present application provides a computer-readable storage medium having at least one instruction, at least one program, a set of codes, or a set of instructions stored therein, which is loaded and executed by a processor to implement a method for emotion analysis of text as described above.
One embodiment of the present application provides a text emotion analysis device, which includes a processor and a memory, where the memory stores at least one instruction, and the instruction is loaded and executed by the processor to implement the text emotion analysis method as described above.
It should be noted that: in the emotion analysis device for text provided in the above embodiment, only the division of the above functional modules is used for illustration when performing emotion analysis of text, and in practical applications, the above functions may be distributed by different functional modules according to needs, that is, the internal structure of the emotion analysis device for text may be divided into different functional modules to complete all or part of the above described functions. In addition, the emotion analysis device for the text and the emotion analysis method for the text provided by the embodiment belong to the same concept, and specific implementation processes thereof are described in the method embodiment and are not described herein again.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description should not be taken as limiting the embodiments of the present application, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the embodiments of the present application should be included in the scope of the embodiments of the present application.

Claims (10)

1. A method for emotion analysis of a text, the method comprising:
acquiring a text to be analyzed and a target word in the text, wherein the target word represents a target object in the text; performing emotion analysis on the text through a model, wherein the model comprises a first word embedding layer, a convolutional layer, a first random selection layer, a second word embedding layer, a second random selection layer, a multi-head random selection classifier and a normalization layer;
acquiring a first feature vector corresponding to the text through the first word embedding layer and the convolution layer;
acquiring a second feature vector corresponding to the target word through the second word embedding layer;
generating a first vector set according to first feature vectors corresponding to the text through the first random selection layer, wherein each first vector in the first vector set is extracted from the first feature vectors;
generating a second vector set according to a second feature vector corresponding to the target word through the second random selection layer, wherein each second vector in the second vector set is extracted from the second feature vector;
and performing ensemble learning on the first vector set and the second vector set through the multi-head random selection classifier and the normalization layer to obtain the emotion polarity of the target word.
2. The method of claim 1, wherein if the first vector set comprises p first vectors and the second vector set comprises p second vectors, p being a positive integer, the ensemble learning of the first vector set and the second vector set by the multi-headed random choice classifier and the normalization layer to obtain the emotional polarity of the target word comprises:
inputting the ith first vector in the first vector set and the jth second vector in the second vector set into k processing units of the multi-head random selection classifier, and selecting a target processing result from the k processing results output by the k processing units, wherein i and j are both less than or equal to p, and k is a positive integer greater than or equal to 2;
updating i to i +1, updating j to j +1, and continuing to execute the step of inputting the ith first vector in the first vector set and the jth second vector in the second vector set into the k processing units of the multi-head random selection classifier until target processing results corresponding to the pth first vector and the pth second vector are obtained, and then stopping;
and carrying out normalization processing on all target processing results through the normalization layer to obtain the emotion polarity of the target words.
3. The method of claim 2, wherein said selecting a target processing result from the k processing results output by the k processing units comprises:
counting the number of the same processing results in the k processing results output by the k processing units;
and taking the most one processing result as the target processing result.
4. The method according to claim 2 or 3, wherein if the dimension of the first feature vector is n, where n is a positive integer, the generating, by the first random selection layer, a first vector set according to the first feature vector corresponding to the text includes:
randomly selecting m first vectors with q dimensions from the first feature vectors through the first random selection layer, wherein m is a positive integer, and q is a positive integer smaller than n;
and combining m first vectors into the first vector set.
5. The method of claim 4, wherein if the dimension of the second feature vector is n, the generating, by the second random selection layer, a second vector set according to the second feature vector corresponding to the target word comprises:
randomly selecting m q-dimensional second vectors from the second feature vectors through the second random selection layer;
and forming m second vectors into the second vector set.
6. The method of claim 1, wherein obtaining the first feature vector corresponding to the text through the first word embedding layer and the convolutional layer comprises:
performing word embedding processing on the text through the first word embedding layer to obtain a word vector of the text;
performing convolution processing on the word vectors of the text through the convolution layer to obtain a convolution result;
converting each matrix in the convolution results into a vector;
and connecting all the vectors to obtain the first characteristic vector.
7. The method according to claim 1, wherein the obtaining, by the second word embedding layer, a second feature vector corresponding to the target word comprises:
and performing word embedding processing on the target word through the second word embedding layer to obtain the second feature vector.
8. An apparatus for emotion analysis of a text, the apparatus comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a text to be analyzed and a target word in the text, and the target word represents a target object in the text; performing emotion analysis on the text through a model, wherein the model comprises a first word embedding layer, a convolutional layer, a first random selection layer, a second word embedding layer, a second random selection layer, a multi-head random selection classifier and a normalization layer;
the first generation module is used for acquiring a first feature vector corresponding to the text through the first word embedding layer and the convolution layer; generating a first vector set according to first feature vectors corresponding to the text through the first random selection layer, wherein each first vector in the first vector set is extracted from the first feature vectors;
the second generation module is used for acquiring a second feature vector corresponding to the target word through the second word embedding layer; generating a second vector set according to a second feature vector corresponding to the target word through the second random selection layer, wherein each second vector in the second vector set is extracted from the second feature vector;
and the ensemble learning module is used for carrying out ensemble learning on the first vector set and the second vector set through the multi-head random selection classifier and the normalization layer to obtain the emotion polarity of the target word.
9. A computer-readable storage medium, wherein at least one program is stored in the storage medium, and the at least one program is loaded and executed by a processor to implement the method for emotion analysis of a text as claimed in any one of claims 1 to 7.
10. An emotion analysis apparatus for a text, characterized in that, the emotion analysis apparatus for a text comprises a processor and a memory, the memory storing therein at least one instruction, the instruction being loaded and executed by the processor to implement the emotion analysis method for a text according to any one of claims 1 to 7.
CN201910678838.9A 2019-07-25 2019-07-25 Text emotion analysis method and device, storage medium and equipment Active CN110377915B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910678838.9A CN110377915B (en) 2019-07-25 2019-07-25 Text emotion analysis method and device, storage medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910678838.9A CN110377915B (en) 2019-07-25 2019-07-25 Text emotion analysis method and device, storage medium and equipment

Publications (2)

Publication Number Publication Date
CN110377915A CN110377915A (en) 2019-10-25
CN110377915B true CN110377915B (en) 2022-11-29

Family

ID=68256052

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910678838.9A Active CN110377915B (en) 2019-07-25 2019-07-25 Text emotion analysis method and device, storage medium and equipment

Country Status (1)

Country Link
CN (1) CN110377915B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107066553A (en) * 2017-03-24 2017-08-18 北京工业大学 A kind of short text classification method based on convolutional neural networks and random forest
CN107491531A (en) * 2017-08-18 2017-12-19 华南师范大学 Chinese network comment sensibility classification method based on integrated study framework
CN107609009A (en) * 2017-07-26 2018-01-19 北京大学深圳研究院 Text emotion analysis method, device, storage medium and computer equipment
CN108536681A (en) * 2018-04-16 2018-09-14 腾讯科技(深圳)有限公司 Intelligent answer method, apparatus, equipment and storage medium based on sentiment analysis
CN109284389A (en) * 2018-11-29 2019-01-29 北京国信宏数科技有限责任公司 A kind of information processing method of text data, device
CN109710769A (en) * 2019-01-23 2019-05-03 福州大学 A kind of waterborne troops's comment detection system and method based on capsule network
CN109739960A (en) * 2018-12-11 2019-05-10 中科恒运股份有限公司 Sentiment analysis method, sentiment analysis device and the terminal of text
CN109766557A (en) * 2019-01-18 2019-05-17 河北工业大学 A kind of sentiment analysis method, apparatus, storage medium and terminal device
CN109933793A (en) * 2019-03-15 2019-06-25 腾讯科技(深圳)有限公司 Text polarity identification method, apparatus, equipment and readable storage medium storing program for executing

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9141600B2 (en) * 2012-07-12 2015-09-22 Insite Innovations And Properties B.V. Computer arrangement for and computer implemented method of detecting polarity in a message
RU2657173C2 (en) * 2016-07-28 2018-06-08 Общество с ограниченной ответственностью "Аби Продакшн" Sentiment analysis at the level of aspects using methods of machine learning

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107066553A (en) * 2017-03-24 2017-08-18 北京工业大学 A kind of short text classification method based on convolutional neural networks and random forest
CN107609009A (en) * 2017-07-26 2018-01-19 北京大学深圳研究院 Text emotion analysis method, device, storage medium and computer equipment
CN107491531A (en) * 2017-08-18 2017-12-19 华南师范大学 Chinese network comment sensibility classification method based on integrated study framework
CN108536681A (en) * 2018-04-16 2018-09-14 腾讯科技(深圳)有限公司 Intelligent answer method, apparatus, equipment and storage medium based on sentiment analysis
CN109284389A (en) * 2018-11-29 2019-01-29 北京国信宏数科技有限责任公司 A kind of information processing method of text data, device
CN109739960A (en) * 2018-12-11 2019-05-10 中科恒运股份有限公司 Sentiment analysis method, sentiment analysis device and the terminal of text
CN109766557A (en) * 2019-01-18 2019-05-17 河北工业大学 A kind of sentiment analysis method, apparatus, storage medium and terminal device
CN109710769A (en) * 2019-01-23 2019-05-03 福州大学 A kind of waterborne troops's comment detection system and method based on capsule network
CN109933793A (en) * 2019-03-15 2019-06-25 腾讯科技(深圳)有限公司 Text polarity identification method, apparatus, equipment and readable storage medium storing program for executing

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
A Deep Neural Network Model for Target-based Sentiment Analysis;Siyuan Shen等;《IEEE》;20181014;1-7 *
Deep neural network-based classification model for Sentiment Analysis;Donghang Pan等;《arXiv》;20190703;1-6 *
Disentangling Aspect and Opinion Words in Target-based Sentiment Analysis using Lifelong Learning;Shuai Wang等;《arXiv》;20180216;1-7 *
一种用于基于方面情感分析的深度分层网络模型;刘全等;《https://kns.cnki.net/kcms/detail/11.1826.TP.20171129.2026.006.html》;20171129;1-18 *
基于集成学习理论的文本情感分类;方丁等;《计算机系统应用》;20120715;第21卷(第7期);177-121 *

Also Published As

Publication number Publication date
CN110377915A (en) 2019-10-25

Similar Documents

Publication Publication Date Title
CN111291181B (en) Representation learning for input classification via topic sparse self-encoder and entity embedding
US11409945B2 (en) Natural language processing using context-specific word vectors
JP7247441B2 (en) Semantic representation model processing method, device, electronic device, and storage medium
Yu et al. Beyond bilinear: Generalized multimodal factorized high-order pooling for visual question answering
Rothman Transformers for Natural Language Processing: Build, train, and fine-tune deep neural network architectures for NLP with Python, Hugging Face, and OpenAI's GPT-3, ChatGPT, and GPT-4
US20180336193A1 (en) Artificial Intelligence Based Method and Apparatus for Generating Article
CN109840287A (en) A kind of cross-module state information retrieval method neural network based and device
CN112131366A (en) Method, device and storage medium for training text classification model and text classification
JP7431833B2 (en) Language sequence labeling methods, devices, programs and computing equipment
CN110234018B (en) Multimedia content description generation method, training method, device, equipment and medium
CN111985243B (en) Emotion model training method, emotion analysis device and storage medium
CN111666416B (en) Method and device for generating semantic matching model
CN111694937A (en) Interviewing method and device based on artificial intelligence, computer equipment and storage medium
CN111897934A (en) Question and answer pair generation method and device
CN113704460A (en) Text classification method and device, electronic equipment and storage medium
CN111767394A (en) Abstract extraction method and device based on artificial intelligence expert system
Kathuria et al. Real time sentiment analysis on twitter data using deep learning (Keras)
Paaß et al. Foundation Models for Natural Language Processing: Pre-trained Language Models Integrating Media
CN112101042A (en) Text emotion recognition method and device, terminal device and storage medium
CN116796857A (en) LLM model training method, device, equipment and storage medium thereof
Wang et al. SCANET: Improving multimodal representation and fusion with sparse‐and cross‐attention for multimodal sentiment analysis
CN113569068B (en) Descriptive content generation method, visual content encoding and decoding method and device
CN114175018A (en) New word classification technique
CN110377915B (en) Text emotion analysis method and device, storage medium and equipment
US20230281400A1 (en) Systems and Methods for Pretraining Image Processing Models

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant