CN112183056A - Context-dependent multi-classification emotion analysis method and system based on CNN-BilSTM framework - Google Patents

Context-dependent multi-classification emotion analysis method and system based on CNN-BilSTM framework Download PDF

Info

Publication number
CN112183056A
CN112183056A CN202010838502.7A CN202010838502A CN112183056A CN 112183056 A CN112183056 A CN 112183056A CN 202010838502 A CN202010838502 A CN 202010838502A CN 112183056 A CN112183056 A CN 112183056A
Authority
CN
China
Prior art keywords
emotion
clause
text
classification
layer
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.)
Pending
Application number
CN202010838502.7A
Other languages
Chinese (zh)
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.)
Hefei University of Technology
Original Assignee
Hefei University of Technology
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 Hefei University of Technology filed Critical Hefei University of Technology
Priority to CN202010838502.7A priority Critical patent/CN112183056A/en
Publication of CN112183056A publication Critical patent/CN112183056A/en
Pending legal-status Critical Current

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
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/044Recurrent networks, e.g. Hopfield networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/047Probabilistic or stochastic networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/049Temporal neural networks, e.g. delay elements, oscillating neurons or pulsed inputs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
    • G06Q50/01Social networking

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • General Engineering & Computer Science (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Biophysics (AREA)
  • Molecular Biology (AREA)
  • Biomedical Technology (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Business, Economics & Management (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Probability & Statistics with Applications (AREA)
  • Databases & Information Systems (AREA)
  • Economics (AREA)
  • Human Resources & Organizations (AREA)
  • Marketing (AREA)
  • Primary Health Care (AREA)
  • Strategic Management (AREA)
  • Tourism & Hospitality (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a context-dependent multi-classification emotion analysis method and system based on a CNN-BilSTM framework, and relates to the technical field of text information processing. The method comprises the steps of preprocessing the text comments by acquiring the text comments; carrying out multiple emotion category labeling processing on clauses of the text comments to obtain a training set, a verification set and a test set; and acquiring a multi-classification emotion analysis model based on the context dependence strategy, the training set, the verification set and the test set and based on the emotion analysis model of the CNN-BilSTM frame, and analyzing the emotion category of the text comment to be tested through the multi-classification emotion analysis model. The invention provides a multi-classification emotion analysis model which is constructed based on a context dependence strategy, captures more complex emotion characteristics by fusing context emotion information, can more effectively identify the emotion of each clause in a comment, and improves the accuracy of the multi-classification emotion analysis model, so that the emotion classification of a text comment to be detected can be more accurately analyzed.

Description

Context-dependent multi-classification emotion analysis method and system based on CNN-BilSTM framework
Technical Field
The invention relates to the technical field of text information processing, in particular to a context-dependent multi-classification emotion analysis method and system based on a CNN-BilSTM framework.
Background
With the rapid development of social networks, more and more users have posted text comments about various products on forums, blogs and other websites. Through effective analysis and mining, text reviews can help companies capture customer needs in real time and guide consumers' shopping decisions. Emotion analysis has recently received a great deal of attention as an important text mining technique.
The existing recognition of multiple emotions is called multi-class emotion analysis or multi-class emotion classification. In recent years, some studies on multi-category emotion analysis have been conducted. These studies mainly use machine learning methods such as Support Vector Machines (SVMs) and random forests to identify multiple classes of emotions.
However, the inventors of the present application have found that the existing multi-category emotion classification has certain limitations. First, the specific meaning of emotion in multi-category emotion analysis has not been discussed in depth. Many studies have discussed only three categories of sentiment analysis, including positive, negative and neutral sentiments, or sentiment intensity analysis based on a scale from 1 to 5, where 1 represents a very negative sentiment and 5 represents a very positive sentiment. Secondly, the granularity of multi-class sentiment analysis is not sufficient, and in most of researches on multi-class sentiment analysis, the sentiment of one text comment is recognized as a single sentiment type, or one text comment is marked as a plurality of sentiment labels. The specifically expressed emotion of each clause may be different, so that the emotion cannot be accurately identified, and the accuracy of the conventional multi-category emotion analysis method is low.
Disclosure of Invention
Technical problem to be solved
Aiming at the defects of the prior art, the invention provides a context-dependent multi-classification emotion analysis method and system based on a CNN-BilSTM framework, and solves the technical problem of low accuracy of the conventional multi-class emotion analysis method.
(II) technical scheme
In order to achieve the purpose, the invention is realized by the following technical scheme:
the invention provides a context-dependent multi-classification emotion analysis method based on a CNN-BilSTM framework, which comprises the following steps:
obtaining text comments, and preprocessing the text comments to obtain clauses of the text comments;
carrying out multiple emotion category labeling processing on clauses of the text comments to obtain a training set, a verification set and a test set;
the method comprises the steps of obtaining a multi-classification emotion analysis model based on a context dependence strategy, a training set, a verification set and a test set and based on an emotion analysis model of a CNN-BilSTM frame, analyzing emotion classes of text comments to be tested through the multi-classification emotion analysis model, wherein the multi-classification emotion analysis model structurally comprises a multi-classification emotion analysis model of an analysis layer, an embedding layer, a convolution layer, a pooling layer, a bidirectional LSTM layer and a Softmax layer, and the bidirectional LSTM layer is used for learning text context correlation based on the context dependence strategy.
Preferably, the pretreatment comprises:
deleting the spam text comments;
performing word segmentation processing on the text comments;
clause cutting is carried out on the comment text, and the text comment r is divided into T clauses clause1,clause2,…,clauset,…,clauseT
Preferably, the context-dependent policy includes:
obtaining the emotion category of each clause in the comment text through emotion transfer between clauses in the comment text, wherein the expression is as follows:
Figure BDA0002640550100000031
wherein, clausekDenotes the kth clause, tagkRepresents clauseiOf the emotion category, F2A feature extraction function representing a clause relationship,
Figure BDA0002640550100000032
representing the weight of the features of the ith adjacent clause to the kth clause.
Preferably, the resolution layer includes:
and segmenting the text comment data into clauses based on grammar parsing.
Preferably, the embedding layer is configured to convert the text comment into vector data, specifically:
using the trained word vector model to carry out vectorization representation on each word, and sequentially linking word vectors to obtain a matrix of each clause
Figure BDA0002640550100000033
Wherein the content of the first and second substances,
Figure BDA0002640550100000034
represents MtClausetD is the dimension of the word vector and N is the maximum length of the clause.
The training process of the word vector model is as follows:
and (3) selecting a gensim packet in Python to train a word vector model, and performing repeated iterative training on a large number of text comment corpora to obtain the word vector model in the specific field.
Preferably, the convolutional layer is configured to extract an n-gram syntactic characteristic from a matrix of each clause generated by the embedding layer, where the n-gram syntactic characteristic represents emotion information of each clause, and specifically:
extracting n-gram syntactic characteristics from a matrix of each clause generated from the embedding layer using three convolution kernels of different heights, of the same width, and of the same convolution kernel, by means of a matrix MtAnd filter FlContinuous convolution operation between (1 ≦ L ≦ 3L) can obtain n-gram feature map
Figure BDA0002640550100000041
Where ω ∈ {2,3,4} denotes the filter FlA height of
Figure BDA0002640550100000042
Is derived from the word x by the following formulan:n+-1Generated under the window of (1):
Figure BDA0002640550100000043
wherein the content of the first and second substances,
Figure BDA0002640550100000044
is a convolution operator, WlAnd blRespectively, the weight matrix and the variance of the ith filter, and f is the ReLU function.
Preferably, the pooling layer is used to sequentially stack the L feature maps generated by the three types of convolution kernels in the convolutional layer first into a matrix
Figure BDA0002640550100000045
In (1), as follows:
Figure BDA0002640550100000046
wherein, ω isPRepresenting the height of the P-th type convolution kernel. Then, taking the maximum value of each column to obtain a new feature
Figure BDA0002640550100000047
Figure BDA0002640550100000048
With the max-pooling operation, the final feature vector associated with the class P convolution kernel can be represented as:
Figure BDA0002640550100000049
finally, the final feature vector for the t clause is generated by concatenating the three feature maps associated with the different types of convolution kernels:
Figure BDA00026405501000000410
preferably, the LSTM layer is used to capture long distance dependencies in clauses, and the LSTM network is implemented by introducing a storage unit ctAnd three gates to process the input vector, which can remember important information over multiple time steps, the exact definition of LSTM is as follows:
ft=σ(Wf·[ht-1,gt]+bf)
it=σ(Wi·[ht-1,gt]+bi)
ot=σ(Wo·[ht-1,gt]+bo)
ct=ft⊙ct-1+it⊙tanh(Wc·[ht-1,gt]+bc)
ht=ot⊙tanh(ct)
wherein, Wf,Wi,Wo,WcAnd bf,bi,bo,bcRespectively representing weight matrices and deviations during model training,. indicates element-by-element multiplication,. htRepresents a hidden state and σ is SiThe gmoid function, considering that LSTM can only capture the emotion information of the left clause, therefore, applies Bi-directional LSTM to capture the emotion information of the left and right clauses, Bi-LSTM uses two independent LSTM units, one for the forward direction and one for the reverse direction, the final hidden state of the Bi-LSTM model
Figure BDA0002640550100000051
Hidden state by forward LSTM
Figure BDA0002640550100000052
And hidden state of inverted LSTM
Figure BDA0002640550100000053
The connection composition is as follows:
Figure BDA0002640550100000054
hidden state
Figure BDA0002640550100000055
Is clausetFeature vectors of emotion information across clauses are fused. For ease of understanding, it is denoted as gt',
Figure BDA0002640550100000056
Preferably, the Softmax layer is used for predicting clausetProbability distribution over emotion tags
Figure BDA0002640550100000057
Figure BDA0002640550100000058
Wherein, WqAnd bqRespectively representing the weight matrix and the bias, and Y represents the number of emotion labels, the label with the highest probability value being the clause of the final judgment of the modeltOf a label, formulaAs follows:
Figure BDA0002640550100000061
the labels of all clauses segmented by text comment r can be expressed as:
tagr=(tag1,tag2,…,tagt,…,tagT)。
the invention also provides a context-dependent multi-classification emotion analysis system based on the CNN-BilSTM framework, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the steps of the method when executing the computer program.
(III) advantageous effects
The invention provides a context-dependent multi-classification emotion analysis method and system based on a CNN-BilSTM framework. Compared with the prior art, the method has the following beneficial effects:
the method comprises the steps of preprocessing the text comments by acquiring the text comments; carrying out multiple emotion category labeling processing on clauses of the text comments to obtain a training set, a verification set and a test set; the method comprises the steps of obtaining a multi-classification emotion analysis model based on a context dependence strategy, a training set, a verification set and a test set and based on an emotion analysis model of a CNN-BilSTM frame, analyzing emotion classes of text comments to be tested through the multi-classification emotion analysis model, wherein the multi-classification emotion analysis model structurally comprises a multi-classification emotion analysis model of an analysis layer, an embedding layer, a convolution layer, a pooling layer, a bidirectional LSTM layer and a Softmax layer, and the bidirectional LSTM layer is used for learning text context correlation based on the context dependence strategy. The invention provides a multi-classification emotion analysis model which is constructed based on a context dependence strategy, captures more complex emotion characteristics by fusing context emotion information, can more effectively identify the emotion of each clause in a comment, and improves the accuracy of the multi-classification emotion analysis model, so that the emotion classification of a text comment to be detected can be more accurately analyzed.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a block diagram of a context-dependent multi-classification emotion analysis method based on a CNN-BilSTM framework according to an embodiment of the present invention;
FIG. 2 is a diagram of a parse tree for a comment according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention are clearly and completely described, and it is obvious that the described embodiments are a part of the embodiments of the present invention, but not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the application solves the technical problem of low accuracy of the existing multi-class emotion analysis method by providing the context-dependent multi-class emotion analysis method based on the CNN-BilSTM framework, and realizes accurate analysis of the emotion class of the text comment to be tested.
In order to solve the technical problems, the general idea of the embodiment of the application is as follows:
with the rapid development of social media, mining customer views based on textual comments is crucial to understanding consumer needs. The emotions expressed by customers in product reviews are often diverse, such as worries, satisfaction, cherries, accommodations, and the like. However, the accuracy of the conventional multi-class emotion analysis method is low, so that certain deviation exists between the obtained emotion information and the reality. In the embodiment of the invention, the context-dependent multi-classification emotion analysis method using the CNN-BilSTM framework is provided, the emotion of each clause in the product comment can be effectively identified by fusing context emotion information, and the emotion category of the text comment to be detected can be more accurately analyzed.
In order to better understand the technical solution, the technical solution will be described in detail with reference to the drawings and the specific embodiments.
The embodiment of the invention provides a context-dependent multi-classification emotion analysis method based on a CNN-BilSTM framework, which is executed by a computer and comprises the following steps of S1-S3:
s1, obtaining the text comments, and preprocessing the text comments to obtain clauses of the text comments;
s2, carrying out multiple emotion category labeling processing on clauses of the text comments to obtain a training set, a verification set and a test set;
s3, obtaining a multi-classification emotion analysis model based on an emotion analysis model of a training set, a verification set and a test set and based on a CNN-BilSTM (capacitive neural network-bi-directional long-term memory) frame, analyzing emotion types of the text comments to be tested through the multi-classification emotion analysis model, wherein the multi-classification emotion analysis model structurally comprises an analysis layer, an embedding layer, a convolution layer, a pooling layer, a bidirectional LSTM layer and a Softmax layer, and the bidirectional LSTM layer is used for learning context correlation of the text.
The embodiment of the invention provides a multi-classification emotion analysis model which is constructed based on a context dependence strategy, captures more complex emotion characteristics by fusing context emotion information, can more effectively identify the emotion of each clause in a comment, and improves the accuracy of the multi-classification emotion analysis model, so that the emotion category of a text comment to be tested can be more accurately analyzed.
In an embodiment, S1 obtains the text comment, and preprocesses the text comment to obtain a clause of the text comment. The specific implementation process is as follows:
s101, capturing text comment data. The method comprises the steps of taking a Scapy frame developed by Python as a basis, extracting and analyzing webpage data through XPath and CSS expressions, using a Redis database as a distributed shared crawler queue and a MongoDB database as a data storage library, integrating a Selenium automated testing tool, simultaneously using middleware such as a random User-Agent, an Ali cloud Agent IP and a self-built Agent IP pool, deploying the middleware to a cloud server, and realizing large-scale real-time incremental crawling of product text comment data of a plurality of social media platforms.
And S102, preprocessing data. The crawled data is further processed to obtain high quality and efficient data. The method specifically comprises the following steps:
s102a, removing spam text comments. In order to improve the quality of the data, the spam text comments need to be removed. The spam text comment rejection mainly comprises the following two points:
1) removing according to key words: spam text comments are culled by summarizing some keywords such as words "html", "phone", "delete", etc.
2) And eliminating according to the length of the text comment. Text reviews that are too long or too short in length may be spam text reviews. Therefore, the text comment length is limited to be between 5 and 150, and text comments of other lengths are culled.
S102, 102b, text word segmentation. The embodiment of the invention uses a Chinese word segmentation system ICTCCLAS to realize word segmentation of text comments by Python calling.
And S102, cutting clauses, and 102 c. In the embodiment of the present invention, the clause is a basic unit of analysis. Therefore, a text comment needs to be segmented into a set of clauses for further analysis. The embodiment of the invention uses a Stanford parser to execute grammar parsing on each text, and divides the text comment r into T clauses, namely clause1,clause2,…,clauset,…,clauseT. Each text comment is parsed into a tree in which clauses are labeled as IP or CP. However, there may be embedded relationships between clauses. Thus, the parse tree is traversed recursively to extract leaf clauses that do not contain other IP or CP nodes in their children as basic units. Of a text commentThe syntax parse tree is shown in fig. 2.
In an embodiment, S2, perform multiple emotion category labeling processing on clauses of the text comment, and obtain a training set, a verification set, and a test set. The specific implementation process is as follows:
since the text comment data extracted from the web page is unlabeled, manual labeling is required to obtain training, validation, and test sets that are available to the model. First, the possible emotions expressed by the product text comment data are specified as the following nine types: satisfaction, trust, happiness, containment, neutrality, cherishability, worry, disappointment, anger. The first four belong to positive emotions and the last four to negative emotions, as shown in table 1. Then, part of the text comment data is selected for manual annotation, and each clause of the text comments is annotated as one of the nine emotions. And finally, after the data are labeled, dividing the product text comments into a training set, a verification set and a test set according to the ratio of 6:2: 2.
TABLE 1 detailed description of 9 emotions that may be expressed in product text review
Figure BDA0002640550100000101
Figure BDA0002640550100000111
In one embodiment, S3, a multi-classification emotion analysis model is obtained based on the context-dependent strategy, the training set, the verification set and the test set and based on the emotion analysis model of the CNN-BilSTM framework, and the emotion category of the text comment to be tested is analyzed through the multi-classification emotion analysis model.
It should be noted that, in the embodiment of the present invention, the context-dependent policy refers to the emotional transfer between clauses. Typically, each clause that constitutes a comment expresses only one particular emotion, for example, the text comment R1, which represents a product text comment about an automobile, is composed of three clauses R1 a-R1 c that express satisfied emotion, unfortunately emotion, and disappointed emotion, respectively. Specifically, text commentators first expressed satisfaction with the space of the car and then used the conjunction "however," the emotion translates to a detriment to the interior of the car. Finally, textual commentators change emotion from being prudent to disappointed through an in-depth description of product functionality, including materials and workmanship as an interior feature.
(R1) the vehicle has a large space and is not squeezed at all, (R1.a) and unfortunately the interior of the vehicle, (R1.b) is disappointing both for material and for work. R1.c)
Although clauses may express similar or even opposite emotions, the emotions they express are generally not independent. Typically, they have a transitive relationship. In fact, users often express their opinion of certain products clearly by expressing emotion using short clauses in text reviews. In addition, the user may subconsciously make the clauses coherent at a lexical or semantic level. In other words, the sentiment of these clauses constitutes a process of continuous sentiment expression. For example, in the text review R1, R1 a-R1 c express different emotions, but their combination reflects the overall impression of the product by the text reviewer, providing a continuous emotional expression.
The phenomenon of continuous emotional expression between text comment clauses is referred to herein as emotional communication. From a large number of observations of product text reviews, emotional communication was found to be ubiquitous. Generally, there are three main ways of emotion transfer: turning, deepening and stabilizing.
1) Turning. The turning of emotions refers to a phenomenon in which adjacent clauses express opposite emotions. For example, in the text comment R2, clause R2.a represents positive emotion, and clause R2.b represents negative emotion.
(R2) the car still feels good in comparison to the other (R2.a) but the sound insulation effect is not very good and the noise is a little loud. (R2.c)
2) Deepening. The deepening of the emotion refers to a phenomenon that one clause expresses a stronger emotion than the previous clause. For example, in text comment R3, R3.d contains the word "in particular" for emphasizing a satisfactory emotion.
(R3) my B30 was used almost half a year, and currently there were no minor problems like others, (R3.a) power was abundant, (R3.B) space was also satisfactory, (R3.c) especially it was worth mentioning that cruise at constant speed was quite good, i were to lean on it at high speeds. (R3.d)
3) And (4) stabilizing. The stabilization of emotion refers to the phenomenon that adjacent clauses express similar emotion. For example, all clauses in the text comment R4 represent satisfactory emotions that are relatively stable without major fluctuations.
(R4) the vehicle is very stable to drive, (R4.a) the maneuverability is not good, (R4.b) so far, my vehicle has not lost price, and (R4.c) is very comfortable in mind. (R4.d)
With this description, emotion delivery can be defined as follows:
emotion delivery refers to the phenomenon in which a clause of a text comment deepens and stably expresses a continuous emotion in different ways, such as turning.
Based on the emotion transfer defined above, lexical or semantic links between clauses can be established, and emotion information of all clauses of one text comment can be fused. In this way, richer features of clauses can be extracted, and the sentiment of clauses can also be analyzed more accurately.
Assuming that one text comment is composed of T clauses, the emotion of each clause can be calculated in the following manner without considering emotion delivery:
tagk=Model(F1[clausek])
wherein, clausekDenotes the kth clause, F1Feature extraction function, tag, representing clause emotion informationkRepresents clauseiThe emotion of (1). In this case, features are extracted only from the current clause, and the representation capability is relatively limited.
On the other hand, considering emotion transfer, the emotion of each clause can be calculated in the following manner:
Figure BDA0002640550100000131
wherein, F2A feature extraction function representing a clause relationship,
Figure BDA0002640550100000132
representing the weight of the features of the ith adjacent clause to the kth clause. From the above formula, F1 F2The method is used for representing the existing feature extraction functions, the two representative functions are used for explaining that the manner of feature extraction is increased, richer features can be extracted, and the representation capability is improved.
The specific implementation process of step S3 is as follows:
s301, training the emotion analysis model based on the CNN-BilSTM framework by using the training set obtained in the step S2 to obtain a multi-classification emotion analysis model.
S302, optimizing the multi-classification emotion analysis model by using the verification set and the test set, and improving the generalization capability of the model. The method specifically comprises the following steps:
by minimizing the true probability distribution y and the predicted probability distribution
Figure BDA0002640550100000141
Cross entropy errors between the two types of emotion analysis models are optimized. Considering the problem of sample imbalance in the multi-classification task, a weight is set for each class:
Figure BDA0002640550100000142
wherein, the amountjRepresenting the number of samples in the jth class, given a training set of X training samples, the loss function can be expressed as:
Figure BDA0002640550100000143
wherein, TiIndicating the number of clauses sliced by the ith sample.
And S303, analyzing the emotion types of the text comments to be detected through the optimized multi-classification emotion analysis model. The method specifically comprises the following steps:
the method comprises the steps of inputting text comments to be tested into a multi-classification emotion analysis model, segmenting the text comments to be tested into clause sets through a multi-class emotion analysis model, and then identifying emotion types of all clauses. The enterprise can summarize the emotion category results of a large amount of text comment data through the method to obtain the number of each emotion category, so that the viewpoints of consumers are quantized, and product improvement and innovation are better performed according to the viewpoint information. It should be noted that once the multi-classification emotion analysis model is optimized, the emotion classification of the text comment to be detected can be repeatedly analyzed for multiple times without repeated training, that is, steps S1 to S302 are executed once, and step S303 can be executed for multiple times. Meanwhile, before the text comments to be detected are input into the multi-classification emotion analysis model, only the preprocessing of removing the spam text comments is needed, and the steps of text word segmentation, clause cutting and the like are automatically executed by the classification emotion analysis model.
In the embodiment of the invention, the proposed multi-classification emotion analysis model comprises an analysis layer, an embedding layer, a convolution layer, a pooling layer, a bidirectional LSTM layer and a Softmax layer. First, the multi-classification sentiment analysis model divides a given text comment r into T clauses, namely clause, based on syntactic parsing1,clause2,…,clauset,…,clauseT. Then, at the embedding layer, each word is vectorized by the word vector model. Subsequently, once the word vectors sequentially pass through the convolutional layer and the max-pooling layer, n-gram features for each clause can be extracted. Context relevance is then learned based on bi-directional LSTM and local feature vectors are sequentially integrated in the clauses, thereby constructing a new feature vector for each clause. Finally, once the feature vector of each clause passes through the softmax layer, its emotion prediction can be obtained. The layers of the multi-classification emotion analysis model are described in detail below.
1) And (6) analyzing the layer. The parsing layer segments the text comment data into clauses based on the grammar parsing. The procedure is similar to step S102 c.
2) And (4) embedding the layer.The embedding layer converts the text comments into vector data. First, each word is vectorized using a trained word vector model. Then, by sequentially linking the word vectors, a matrix for each clause can be obtained
Figure BDA0002640550100000151
Wherein represents MtClausetD is the dimension of the word vector and N is the maximum length of the clause. If the length of a certain clause is less than N, some random vectors with normal distribution μ (-1/d,1/d) are filled.
The training process of the word vector model is as follows:
the role of the word vector model is to assign an independent vector to each word in the text, so that the text can be vectorized, and the vectorization is the basic expression of the text in the deep learning-based model. The embodiment of the invention selects and uses a gensim packet in Python to carry out word vector model training, and obtains the word vector model in the specific field by carrying out repeated iterative training on a large number of product text comment corpora.
3) And (4) rolling up the layers. The convolutional layer is used to extract n-gram syntactic features from the matrix of each clause generated by the embedding layer. To extract rich features, embodiments of the present invention apply three types of convolution kernels, having different heights (2, 3, and 4) and the same width d, with L filters for each type of convolution kernel. By means of a matrix MtAnd filter FlContinuous convolution operation between (1 ≦ L ≦ 3L) can obtain n-gram feature map
Figure BDA0002640550100000161
Where ω ∈ {2,3,4} denotes the filter FlOf (c) is measured. In particular, a feature
Figure BDA0002640550100000162
Is derived from the word x in the following wayn:n+-1Generated under the window of (1):
Figure BDA0002640550100000163
wherein the content of the first and second substances,
Figure BDA0002640550100000164
is a convolution operator, WlAnd blRespectively, the weight matrix and the variance of the ith filter, and f is the ReLU function.
4) And (4) a pooling layer. To simplify network complexity and preserve the most important information, the max-pooling layer is used to sub-sample the output of the convolutional layer. In the multi-class emotion analysis model of the embodiment of the present invention, max-1 merging is performed on the feature maps generated by each type of convolution kernel. Specifically, the L signature graphs generated by each type of convolution kernel are first sequentially stacked into a matrix
Figure BDA0002640550100000165
In (1), as follows:
Figure BDA0002640550100000166
wherein, ω isPRepresenting the height of the P-th type convolution kernel. Then, taking the maximum value of each column to obtain a new feature
Figure BDA0002640550100000167
Figure BDA0002640550100000168
With the max-pooling operation, the final feature vector associated with the class P convolution kernel can be represented as:
Figure BDA0002640550100000171
finally, a final feature vector for the t-th clause is generated by concatenating the three feature maps associated with different types of convolution kernels.
Figure BDA0002640550100000172
5) The LSTM layer. In order to learn the emotion information in the clauses into the feature vector of each clause, the LSTM layer learns the text context relevance based on a context-dependent policy. The feature vectors of each clause generated in the previous step are sequentially integrated and transmitted to the LSTM network. LSTM network by introducing a storage unit ctAnd three doors (i.e. forget door f)tInput door itAnd an output gate ot) To process the input vector, the three gates can remember important information over multiple time steps. The precise definition of LSTM is as follows:
ft=σ(Wf·[ht-1,gt]+bf)
it=σ(Wi·[ht-1,gt]+bi)
ot=σ(Wo·[ht-1,gt]+bo)
ct=ft⊙ct-1+it⊙tanh(Wc·[ht-1,gt]+bc)
ht=ot⊙tanh(ct)
wherein, Wf,Wi,Wo,WcAnd bf,bi,bo,bcRespectively representing weight matrices and deviations during model training,. indicates element-by-element multiplication,. htRepresenting a hidden state and sigma is a Sigmoid function. In addition, bi-directional LSTM is applied to capture emotion information for the left and right clauses, considering that LSTM can only capture emotion information for the left clause. The Bi-LSTM uses two independent LSTM units, one for the forward direction and one for the reverse direction. Final hidden states of Bi-LSTM model
Figure BDA0002640550100000181
Hidden state by forward LSTM
Figure BDA0002640550100000182
And hidden state of inverted LSTM
Figure BDA0002640550100000183
And (4) connecting.
Figure BDA0002640550100000184
Hidden state
Figure BDA0002640550100000185
Is clausetFeature vectors of emotion information across clauses are fused. For ease of understanding, it is denoted as gt'。
Figure BDA0002640550100000186
6) Softmax layer. After the LSTM layer, the clause is predicted using the softmax layertProbability distribution over emotion tags
Figure BDA0002640550100000187
Figure BDA0002640550100000188
Wherein, WqAnd bqRespectively, the weight matrix and the bias, and Y represents the number of emotion labels. The label with the highest probability value is the clause of the final judgment of the modeltThe label of (1). The formula is as follows:
Figure BDA0002640550100000189
the labels of all clauses segmented by text comment r can be expressed as:
tagr=(tag1,tag2,…,tagt,…,tagT)
the embodiment of the invention also provides a context-dependent multi-classification emotion analysis system based on the CNN-BilSTM framework, which comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, wherein the steps of the method are realized when the processor executes the computer program.
It can be understood that the above-mentioned system for analyzing multi-category emotion based on context dependency of CNN-BiLSTM framework provided in the embodiment of the present invention corresponds to the above-mentioned method for analyzing multi-category emotion based on context dependency of CNN-BiLSTM framework, and the explanation, examples, and beneficial effects of the relevant contents thereof may refer to the corresponding contents in the method for analyzing multi-category emotion based on context dependency of CNN-BiLSTM framework, and are not described herein again.
In summary, compared with the prior art, the method has the following beneficial effects:
1. the embodiment of the invention provides a multi-classification emotion analysis model which is constructed based on a context dependence strategy, captures more complex emotion characteristics by fusing context emotion information, can more effectively identify the emotion of each clause in a comment, and improves the accuracy of the multi-classification emotion analysis model, so that the emotion category of a text comment to be tested can be more accurately analyzed.
2. The embodiment of the invention can analyze the emotion of the sentence at the clause level to obtain the emotion information with finer granularity, and enterprises can obtain more useful information by mining the emotion with finer granularity, thereby better improving and innovating products.
It should be noted that, through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1.A context-dependent multi-classification emotion analysis method based on a CNN-BilSTM framework is characterized by comprising the following steps:
obtaining text comments, and preprocessing the text comments to obtain clauses of the text comments;
carrying out multiple emotion category labeling processing on clauses of the text comments to obtain a training set, a verification set and a test set;
the method comprises the steps of obtaining a multi-classification emotion analysis model based on a context dependence strategy, a training set, a verification set and a test set and based on an emotion analysis model of a CNN-BilSTM frame, analyzing emotion classes of text comments to be tested through the multi-classification emotion analysis model, wherein the multi-classification emotion analysis model structurally comprises a multi-classification emotion analysis model of an analysis layer, an embedding layer, a convolution layer, a pooling layer, a bidirectional LSTM layer and a Softmax layer, and the bidirectional LSTM layer is used for learning text context correlation based on the context dependence strategy.
2. The CNN-BiLSTM framework based context dependent multi-classification emotion analysis method of claim 1, wherein the preprocessing comprises:
deleting the spam text comments;
performing word segmentation processing on the text comments;
clause cutting is carried out on the comment text, and the text comment r is divided into T clauses clause1,clause2,…,clauset,…,clauseT
3. The CNN-BiLSTM framework based contextually dependent multi-classification sentiment analysis method of claim 2, wherein the contextually dependent policy comprises:
obtaining the emotion category of each clause in the comment text through emotion transfer between clauses in the comment text, wherein the expression is as follows:
Figure FDA0002640550090000021
wherein, clausekDenotes the kth clause, tagkRepresents clauseiOf the emotion category, F2A feature extraction function representing a clause relationship,
Figure FDA0002640550090000022
representing the weight of the features of the ith adjacent clause to the kth clause.
4. The CNN-BiLSTM framework based context dependent multi-classification emotion analysis method of claim 1, wherein the parsing layer comprises:
and segmenting the text comment data into clauses based on grammar parsing.
5. The CNN-BilSTM framework-based context-dependent multi-classification sentiment analysis method of claim 4, wherein the embedding layer is used for converting text comments into vector data, and specifically comprises the following steps:
using the trained word vector model to carry out vectorization representation on each word, and sequentially linking word vectors to obtain a matrix of each clause
Figure FDA0002640550090000023
Wherein the content of the first and second substances,
Figure FDA0002640550090000024
represents MtClausetD is the dimension of the word vector, N is the maximum length of the clause;
the training process of the word vector model is as follows:
and (3) selecting a gensim packet in Python to train a word vector model, and performing repeated iterative training on a large number of text comment corpora to obtain the word vector model in the specific field.
6. The CNN-BiLSTM framework based context dependent multi-classification emotion analysis method of claim 5, wherein the convolutional layer is used for extracting n-gram syntactic features from a matrix of each clause generated by the embedded layer, and the n-gram syntactic features represent emotion information of each clause, and specifically are:
extracting n-gram syntactic characteristics from a matrix of each clause generated from the embedding layer using three convolution kernels of different heights, of the same width, and of the same convolution kernel, by means of a matrix MtAnd filter FlContinuous convolution operation between (1 ≦ L ≦ 3L) can obtain n-gram feature map
Figure FDA0002640550090000031
Where ω ∈ {2,3,4} denotes the filter FlA height of
Figure FDA0002640550090000032
Is derived from the word x by the following formulan:n+-1Generated under the window of (1):
Figure FDA0002640550090000033
wherein the content of the first and second substances,
Figure FDA0002640550090000034
is a convolution operator, WlAnd blRespectively, the weight matrix and the variance of the ith filter, and f is the ReLU function.
7. The CNN-BilSTM framework-based context-dependent multi-class emotion analysis method of claim 6, wherein the pooling layer is used to sequentially stack first the L eigenmaps generated by the three types of convolution kernels in the convolution layer into a matrix
Figure FDA0002640550090000035
In (1), as follows:
Figure FDA0002640550090000036
wherein, ω isPRepresents the height of the P-th type convolution kernel; taking the maximum value of each column to obtain new characteristics
Figure FDA0002640550090000037
Figure FDA0002640550090000038
With the max-pooling operation, the final feature vector associated with the class P convolution kernel can be represented as:
Figure FDA0002640550090000039
generating a final feature vector for the t clause by concatenating three feature maps associated with different types of convolution kernels:
Figure FDA0002640550090000041
8. the CNN-BilSTM framework-based multi-classification emotion analysis method as claimed in claim 7, wherein the LSTM layer is used for capturing long distance dependencies in clauses, and the LSTM network is implemented by introducing a storage unit ctAnd three gates to process the input vector, which can remember important information over multiple time steps, the exact definition of LSTM is as follows:
ft=σ(Wf·[ht-1,gt]+bf)
it=σ(Wi·[ht-1,gt]+bi)
ot=σ(Wo·[ht-1,gt]+bo)
ct=ft⊙ct-1+it⊙tanh(Wc·[ht-1,gt]+bc)
ht=ot⊙tanh(ct)
wherein, Wf,Wi,Wo,WcAnd bf,bi,bo,bcRespectively represent weight matrix and variance during model training, e.g., element by elementMultiplication of htRepresenting hidden states and σ is a Sigmoid function, bidirectional LSTM is applied to capture the emotion information of the left and right clauses, considering that LSTM can only capture the emotion information of the left clause, Bi-LSTM uses two independent LSTM units, one for the forward direction and one for the reverse direction, the final hidden state of the Bi-LSTM model
Figure FDA0002640550090000042
Hidden state by forward LSTM
Figure FDA0002640550090000043
And hidden state of inverted LSTM
Figure FDA0002640550090000044
The connection composition is as follows:
Figure FDA0002640550090000045
hidden state
Figure FDA0002640550090000046
Is clausetThe feature vector of the cross-clause emotion information is fused and is represented as g for easy understandingt',
Figure FDA0002640550090000047
9. The CNN-BiLSTM framework based context dependent multi-classification emotion analysis method of claim 8, wherein the Softmax layer is used for predicting clausetProbability distribution over emotion tags
Figure FDA0002640550090000051
Figure FDA0002640550090000052
Wherein, WqAnd bqRespectively representing the weight matrix and the bias, and Y represents the number of emotion labels, the label with the highest probability value being the clause of the final judgment of the modeltThe formula is as follows:
Figure FDA0002640550090000053
the labels of all clauses segmented by text comment r can be expressed as:
tagr=(tag1,tag2,…,tagt,…,tagT)。
10. a CNN-BiLSTM framework based context-dependent multi-classification sentiment analysis system comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method of any one of claims 1 to 9 when executing the computer program.
CN202010838502.7A 2020-08-19 2020-08-19 Context-dependent multi-classification emotion analysis method and system based on CNN-BilSTM framework Pending CN112183056A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010838502.7A CN112183056A (en) 2020-08-19 2020-08-19 Context-dependent multi-classification emotion analysis method and system based on CNN-BilSTM framework

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010838502.7A CN112183056A (en) 2020-08-19 2020-08-19 Context-dependent multi-classification emotion analysis method and system based on CNN-BilSTM framework

Publications (1)

Publication Number Publication Date
CN112183056A true CN112183056A (en) 2021-01-05

Family

ID=73919439

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010838502.7A Pending CN112183056A (en) 2020-08-19 2020-08-19 Context-dependent multi-classification emotion analysis method and system based on CNN-BilSTM framework

Country Status (1)

Country Link
CN (1) CN112183056A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112950019A (en) * 2021-03-01 2021-06-11 昆明电力交易中心有限责任公司 Electricity selling company evaluation emotion classification method based on combined attention mechanism
CN113076754A (en) * 2021-03-23 2021-07-06 山东师范大学 False comment detection method and system based on knowledge integration
CN113159831A (en) * 2021-03-24 2021-07-23 湖南大学 Comment text sentiment analysis method based on improved capsule network
CN113220893A (en) * 2021-07-09 2021-08-06 北京邮电大学 Product feedback analysis system and method based on emotion analysis
CN113326739A (en) * 2021-05-07 2021-08-31 山东大学 Online learning participation degree evaluation method based on space-time attention network, evaluation system, equipment and storage medium
CN113496123A (en) * 2021-06-17 2021-10-12 三峡大学 Rumor detection method, rumor detection device, electronic equipment and storage medium
CN113609293A (en) * 2021-08-09 2021-11-05 唯品会(广州)软件有限公司 E-commerce comment classification method and device

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112950019A (en) * 2021-03-01 2021-06-11 昆明电力交易中心有限责任公司 Electricity selling company evaluation emotion classification method based on combined attention mechanism
CN112950019B (en) * 2021-03-01 2024-03-29 昆明电力交易中心有限责任公司 Electricity selling company evaluation emotion classification method based on joint attention mechanism
CN113076754A (en) * 2021-03-23 2021-07-06 山东师范大学 False comment detection method and system based on knowledge integration
CN113159831A (en) * 2021-03-24 2021-07-23 湖南大学 Comment text sentiment analysis method based on improved capsule network
CN113326739A (en) * 2021-05-07 2021-08-31 山东大学 Online learning participation degree evaluation method based on space-time attention network, evaluation system, equipment and storage medium
CN113496123A (en) * 2021-06-17 2021-10-12 三峡大学 Rumor detection method, rumor detection device, electronic equipment and storage medium
CN113496123B (en) * 2021-06-17 2023-08-11 三峡大学 Rumor detection method, rumor detection device, electronic equipment and storage medium
CN113220893A (en) * 2021-07-09 2021-08-06 北京邮电大学 Product feedback analysis system and method based on emotion analysis
CN113609293A (en) * 2021-08-09 2021-11-05 唯品会(广州)软件有限公司 E-commerce comment classification method and device
CN113609293B (en) * 2021-08-09 2024-01-30 唯品会(广州)软件有限公司 E-commerce comment classification method and device

Similar Documents

Publication Publication Date Title
CN109543084B (en) Method for establishing detection model of hidden sensitive text facing network social media
CN112183056A (en) Context-dependent multi-classification emotion analysis method and system based on CNN-BilSTM framework
CN110110335B (en) Named entity identification method based on stack model
Shankar et al. An overview and empirical comparison of natural language processing (NLP) models and an introduction to and empirical application of autoencoder models in marketing
US8972408B1 (en) Methods, systems, and articles of manufacture for addressing popular topics in a social sphere
CN108984775B (en) Public opinion monitoring method and system based on commodity comments
CN112650848A (en) Urban railway public opinion information analysis method based on text semantic related passenger evaluation
CN110442728A (en) Sentiment dictionary construction method based on word2vec automobile product field
Haque et al. Opinion mining from bangla and phonetic bangla reviews using vectorization methods
Zhang et al. A hybrid neural network approach for fine-grained emotion classification and computing
CN111782793A (en) Intelligent customer service processing method, system and equipment
Eke et al. The significance of global vectors representation in sarcasm analysis
Rafail et al. Natural language processing
CN111178080A (en) Named entity identification method and system based on structured information
CN113159831A (en) Comment text sentiment analysis method based on improved capsule network
Rajanak et al. Language detection using natural language processing
CN111951079A (en) Credit rating method and device based on knowledge graph and electronic equipment
Phan et al. Applying skip-gram word estimation and SVM-based classification for opinion mining Vietnamese food places text reviews
Naik et al. An adaptable scheme to enhance the sentiment classification of Telugu language
CN115238709A (en) Method, system and equipment for analyzing sentiment of policy announcement network comments
CN111753540B (en) Method and system for collecting text data to perform Natural Language Processing (NLP)
CN114020901A (en) Financial public opinion analysis method combining topic mining and emotion analysis
Rahman et al. ChartSumm: A large scale benchmark for Chart to Text Summarization
Kalaiarasu et al. Sentiment analysis using improved novel convolutional neural network (SNCNN)
CN116992874B (en) Text quotation auditing and tracing method, system, device and storage medium

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