CN113449110A - Emotion classification method and device, storage medium and computer equipment - Google Patents
Emotion classification method and device, storage medium and computer equipment Download PDFInfo
- Publication number
- CN113449110A CN113449110A CN202111000019.2A CN202111000019A CN113449110A CN 113449110 A CN113449110 A CN 113449110A CN 202111000019 A CN202111000019 A CN 202111000019A CN 113449110 A CN113449110 A CN 113449110A
- Authority
- CN
- China
- Prior art keywords
- semantic
- information
- syntactic
- graph
- syntax
- 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.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/35—Clustering; Classification
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/951—Indexing; Web crawling techniques
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/205—Parsing
- G06F40/211—Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/30—Semantic analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
Abstract
The invention relates to an emotion classification method, device, storage medium and computer equipment, which is characterized in that a vector representation of an input text is obtained by encoding the input text by utilizing a pre-trained BERT model, syntax information is extracted from a syntax graph generated based on syntax dependence analysis by utilizing a syntax graph convolution network, semantic information is extracted from a weighted semantic similarity graph generated based on a self-attention mechanism by utilizing a semantic graph convolution network, the syntax information and the semantic information are interactively fused by utilizing an exchange module, and the fused syntax information and semantic information are obtained; extracting the syntactic characteristics and semantic characteristics of the target words in the syntactic information and the semantic information based on an attention mechanism; the combined features obtained after the syntactic features and the semantic features are weighted and summed are input into the full-connection layer for emotion classification, emotion polarity information is obtained, and compared with the prior art, the accuracy of a specific emotion target classification task is improved.
Description
Technical Field
The invention relates to the field of natural language processing, in particular to an emotion classification method, device, storage medium and computer equipment.
Background
Emotion classification refers to predicting the emotion polarity (positive, negative, and neutral) to which a particular target word of a sentence corresponds. In recent years, the graph neural network is widely applied to aspect-level emotion analysis with strong performance. The graph convolution-based method can effectively extract syntactic information from the dependency tree,
however, for some sentences lacking obvious syntactic features, the accuracy of the dependency parsing may not be satisfactory. For example, a dependency tree extracted from "has Halloween all put away and fall deco up, partitioning my new PSP." may contain a lot of noise. Second, syntax and semantics interact, both being related and distinct. Therefore, the method based on graph convolution cannot sufficiently analyze the internal rules of sentences to obtain accurate emotion classification information.
Disclosure of Invention
The embodiment of the application provides an emotion classification method, an emotion classification device, a storage medium and computer equipment, which can improve the accuracy of emotion classification. The technical scheme is as follows:
in a first aspect, an embodiment of the present application provides an emotion classification method, including the following steps:
coding an input text by utilizing a pre-trained BERT model to obtain vector representation of each word of the input text;
performing syntactic dependency analysis on the input text to acquire a syntactic dependency relationship of the input text; generating a syntactic graph represented by each vector by taking the vector representation as a graph node and taking the corresponding syntactic dependency represented by the vector representation as an edge;
based on a self-attention mechanism, obtaining a semantic adjacency matrix represented by a vector, and generating a weighted semantic similarity graph;
extracting syntactic information from the syntactic graph by using a syntactic graph convolution network, and extracting semantic information from the weighted semantic similarity graph by using a semantic graph convolution network; interactively fusing the syntax information and the semantic information by using an exchange module to obtain the fused syntax information and semantic information;
extracting the syntactic characteristics and the semantic characteristics of the target words in the syntactic information and the semantic information based on an attention mechanism;
carrying out weighted summation on the syntactic characteristics and the semantic characteristics to obtain joint characteristics;
and inputting the combined features into a full-connection layer for emotion classification to acquire emotion polarity information.
In a second aspect, an embodiment of the present application provides an emotion classification apparatus, including:
the vector representation acquisition module is used for encoding the input text by utilizing a pre-trained BERT model and acquiring the vector representation of each word of the input text;
the syntactic graph obtaining module is used for carrying out syntactic dependency analysis on the input text and obtaining syntactic dependency of the input text; taking vector representation as a graph node, taking the corresponding syntactic dependency relationship represented by the vector as an edge, and acquiring a syntactic graph represented by each vector;
the similarity graph acquisition module is used for acquiring a semantic adjacency matrix represented by the vector based on a self-attention mechanism and generating a weighted semantic similarity graph;
the information acquisition module is used for extracting syntactic information from the syntactic graph by utilizing a syntactic graph convolution network and extracting semantic information from the weighted semantic similarity graph by utilizing a semantic graph convolution network; interactively fusing the syntax information and the semantic information by using an exchange module to obtain the fused syntax information and semantic information;
the feature extraction module is used for extracting the syntactic features and the semantic features of the target words in the syntactic information and the semantic information based on an attention mechanism;
the joint characteristic acquisition module is used for carrying out weighted summation on the syntactic characteristics and the semantic characteristics to acquire joint characteristics;
and the emotion classification acquisition module is used for inputting the combined features into the full-connection layer for emotion classification to acquire emotion polarity information.
In a third aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the emotion classification method as described in any one of the above.
In a fourth aspect, the present application provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable by the processor, and the processor implements the steps of the emotion classification method as described in any one of the above when executing the computer program.
In the embodiment of the application, vector representation of an input text is obtained by coding the input text by using a pre-trained BERT model, syntax information is extracted from a syntax graph generated based on syntax dependence analysis by using a syntax graph convolution network, semantic information is extracted from a weighted semantic similarity graph generated based on a self-attention mechanism by using a semantic graph convolution network, the syntax information and the semantic information are interactively fused by using an exchange module, and the fused syntax information and semantic information are obtained; extracting the syntactic characteristics and semantic characteristics of the target words in the syntactic information and the semantic information based on an attention mechanism; compared with the prior art, the method and the device have the advantages that the syntactic features can be supplemented by the semantic information, the syntactic information and the semantic information are flexibly combined in a dynamic communication mode, and the accuracy of specific emotion target classification tasks is improved.
For a better understanding of location and implementation, the present invention is described in detail below with reference to the accompanying drawings.
Drawings
FIG. 1 is a flow chart of a sentiment classification method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an emotion classification apparatus according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating the masking experiment results using the emotion classification method of the present invention and a conventional emotion classification model in one embodiment;
FIG. 4 is a diagram illustrating the masking test results using the emotion classification method of the present invention and the existing emotion classification model in another embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
It should be understood that the embodiments described are only some embodiments of the present application, and not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without any creative effort belong to the protection scope of the embodiments in the present application.
The terminology used in the embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the embodiments of the present application. As used in the examples of this application and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as utilized herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the application, as detailed in the appended claims. In the description of the present application, it is to be understood that the terms "first," "second," "third," and the like are used merely for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order, nor are the terms "positions" to indicate or imply relative importance. To those of ordinary skill in the art, the above terms may be used in the present application in any particular sense depending on the particular situation.
In addition, in the description of the present application, "a plurality" means two or more unless otherwise specified. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
As shown in fig. 1, an embodiment of the present application provides an emotion classification method, including the following steps:
step S1: coding an input text by utilizing a pre-trained BERT model to obtain vector representation of each word of the input text;
the input text can be text content input by a user at a terminal such as a mobile phone, a computer and the like or other equipment with a text input function.
In one embodiment, the input text may be a social media comment, wherein the social media comment may be collected from a network by using a data capture technology such as a crawler, and the emotion classification method of the present application is used to perform target-specific emotion classification on the input text, so as to obtain emotion polarity information of a target word by a user, and the emotion polarity information feeds back viewpoint tendency and emotion information of the user, and has a wide application prospect in the fields of topic tracking discovery, public opinion tracking, opinion polling, targeted advertisement delivery, after-sale service evaluation, and the like.
The BERT model (Bidirectional Encoder reproduction from transforms) encodes through an input text and outputs vector Representation of each character/word in the text after semantic information is fused. The vector representation may include a text vector characterizing global semantic information of the text and a position vector determining position information of each input word in the text.
In the embodiment of the application, the input text is a text containing target wordsA sentence of length n
Inputting the input text into a BERT model for word coding to obtain a vector representation of each word in the sentenceWherein the vector of the output representsAlso includes a target word subsequence。
Step S2: performing syntactic dependency analysis on the input text to acquire a syntactic dependency relationship of the input text; generating a syntactic graph represented by each vector by taking the vector representation as a graph node and taking the corresponding syntactic dependency represented by the vector representation as an edge;
in one embodiment, the input text is subjected to syntactic dependency parsing by using a Stanford parser, wherein the Stanford parser is an open source syntactic parser based on probability statistics syntactic analysis developed by the Natural language processing group of Stanford university. Specifically, the step of generating a syntax map for each vector representation includes:
a syntax diagram is generated in the following manner:
wherein the content of the first and second substances,in order to be a syntactic graph,for the purpose of a vector representation of the input text,is represented by a vectorThe adjacency matrix of (a);
wherein the content of the first and second substances,the adjacency matrix for graph node i and graph node j,indicating that a dependency exists between graph node i and graph node j.
Step S3: based on a self-attention mechanism, obtaining a semantic adjacency matrix represented by a vector, and generating a weighted semantic similarity graph;
in some cases, the syntactic dependency analysis can introduce a lot of noise, thereby affecting the accuracy of emotion classification. In addition, in many cases, it is difficult to explain the internal rules of the input text only by syntactic dependency analysis, so in the embodiment of the present application, semantic connections between words are constructed by calculating semantic similarities in the input text, a semantic adjacency matrix is supplemented by using an attention mechanism to obtain a weighted semantic similarity map, and syntactic information is supplemented by extracting semantic relationships contained in sentences to improve the accuracy of emotion classification.
The attention mechanism can increase the accuracy of classification by increasing the weight coefficient of important information to focus the model on more important parts. Specifically, the step of generating the weighted semantic similarity graph includes:
mapping the vector representation to K d-dimensional semantic spaces in the following manner;
wherein the content of the first and second substances,for the purpose of a vector representation of the input text,is a vector representation of the kth semantic space,,the corresponding bias vector is represented for the vector of the kth semantic space,the corresponding mapping matrix is represented for the vector of the kth semantic space,is a non-linear activation function;
obtaining semantic adjacency matrixes corresponding to K semantic spaces according to the following modes:
wherein the content of the first and second substances,a semantic adjacency matrix for node i and node j,in order to be a preset threshold value, the threshold value is set,for the vector representation of node i in the kth semantic space,vector representation in the kth semantic space for node j;
acquiring a weighted similarity adjacency matrix according to the following modes:
wherein the content of the first and second substances,for the weighted similarity adjacency matrix for node i and node j,the attention weight coefficients for node i and node j are obtained as follows:
wherein the content of the first and second substances,for the attention weight matrix of the node i,is the attention weight matrix for node j, d is the dimension of the semantic space,is composed ofThe transposed matrix of (2);
acquiring a weighted semantic similarity map according to the following modes:
Mapping the vector representation of each word in the step S1 to K d-dimensional semantic spaces to capture semantic representations in different forms, automatically learning the semantic connection strength between word pairs by using an attention mechanism to obtain semantic adjacency matrixes corresponding to the K semantic spaces, and averaging and summing the semantic adjacency matrixes of the K semantic spaces to obtain a weighted semantic similarity adjacency matrixAnd obtaining a weighted semantic similarity map according to the weighted semantic similarity map。
Step S4: extracting syntactic information from the syntactic graph by using a syntactic graph convolution network, and extracting semantic information from the weighted semantic similarity graph by using a semantic graph convolution network; interactively fusing the syntax information and the semantic information by using an exchange module to obtain the fused syntax information and semantic information;
in one embodiment, the syntactic graph convolution network comprises L layers of convolution layers, and each layer outputs syntax information of L layers respectivelySaid step of extracting syntax information from said syntax map using a syntax map convolutional network, comprising:
syntax information is extracted in the following manner:
wherein the content of the first and second substances,for the non-linear activation function, in the present embodiment,it may be a function of the ReLU,convolution of network for syntax diagramsThe syntax information extracted by the layer is,convolution of network for syntax diagramsThe syntax information extracted by the layer is,is thatThe symmetric normalized adjacency matrix of (a) is,is a syntactic graph convolution networkThe weight matrix of the layer or layers is,is an identity matrix;
the step of extracting semantic information from the weighted semantic similarity graph by using a semantic graph convolution network comprises the following steps:
semantic information is extracted in the following way:
wherein the content of the first and second substances,convolution of network for semantic graphThe semantic information extracted by the layer(s),convolution of network for semantic graphThe semantic information extracted by the layer(s),convolution of network for semantic graphThe weight matrix of the layer or layers is,is thatThe symmetric normalized adjacency matrix of (a).
The exchange module is used for interactively fusing the syntax information extracted by the syntax graph convolution network and the semantic information extracted by the semantic graph convolution network, and the syntax information and the semantic information after exchange and fusion are combined with the mutual influence of syntax and semantics, so that the emotion polarity of a user can be reflected more accurately, and the emotion classification accuracy is improved.
Specifically, the step of acquiring the merged syntax information and semantic information includes:
acquiring the merged syntax information according to the following modes:
wherein the content of the first and second substances,in order to be the syntax information after the merging,convolution of network for semantic graphThe semantic information extracted by the layer(s),for syntactic fusion coefficients, the following is obtained:
wherein the content of the first and second substances,convolution of network for syntax diagramsThe syntax information extracted by the layer is,is composed ofThe transpose matrix of (a) is,in order to syntactically fuse the weight matrices,fusing the bias parameters for syntax;
acquiring the fused semantic information according to the following modes:
wherein the content of the first and second substances,in order to obtain the fused semantic information,for semantic fusion weight coefficients, the following method is used for obtaining:
wherein the content of the first and second substances,is composed ofThe transpose matrix of (a) is,in order to fuse the weight matrix for the semantics,bias parameters are fused for semantics.
Step S5: extracting the syntactic characteristics and the semantic characteristics of the target words in the syntactic information and the semantic information based on an attention mechanism;
the target word can be input into a target in the text to be subjected to emotion analysis, for example, when the input text is a comment, the target word can be food, and emotion polarity information of the target word is obtained by performing emotion analysis on words related to the food in the input text. The syntactic characteristics and the semantic characteristics are fully extracted based on an attention mechanism, the representation of target words and contexts of each level can be fused, and the coding capability of the network is enhanced.
In one embodiment, the step of extracting the syntactic characteristics and semantic characteristics of the target word in the syntactic information and the semantic information based on the attention mechanism specifically includes:
obtaining the output syntactic characteristic weight of each layer of the syntactic graph convolution network according to the following modes:
wherein the content of the first and second substances,convolution of network for syntax diagramsSyntactic characteristic weight of ith node of layer output; wherein the content of the first and second substances,the larger the value isThe characteristics of the layer are more important.For the intermediate parameter, the following method is adopted:
wherein the content of the first and second substances,convolution of network for syntax diagramsSyntactic characteristics of the ith node of the layer output,convolution of network for syntax diagramsSyntactic characteristics of ith node of layer outputThe transposed matrix of (2);
the syntactic characteristics are obtained in the following way:
wherein the content of the first and second substances,for syntactic characteristics of the ith node of a syntactic graph convolutional network,convolution of network for syntax diagramsSyntactic characteristics of the ith node of the layer output. Obtaining the syntactic characteristics of the n nodes of the syntactic graph convolution network according to the mode。
In one embodiment, the syntactic characteristics include a word vector representation of a syntactic target wordWord vector representation in syntactic context. Specifically, a word vector representation of a syntactic target word is obtained in the following manner
Wherein the content of the first and second substances,for a word vector representation of a syntactic target word,for syntactic characteristics of the ith node of a syntactic graph convolutional network,is the average of the pooling functions,
the word vector representation of the syntactic context is obtained in the following way:
wherein the content of the first and second substances,a word vector representation for a syntactic context,
wherein the content of the first and second substances,in order to be a syntactic weight matrix,is composed ofThe transposed matrix of (2).
The semantic features include word vector representations of semantic target wordsWord vector representation in semantic contextWord vector representation of the semantic target wordWord vector representation in semantic contextThe above syntactic feature extraction formula extraction may be referred to, and details are not repeated here.
Step S6: carrying out weighted summation on the syntactic characteristics and the semantic characteristics to obtain joint characteristics;
specifically, the joint features are obtained in the following manner:
wherein the content of the first and second substances,for the sake of the combined features,in order to be a non-linear activation function,in order to be a weight matrix, the weight matrix,as a function of the offset parameter(s),for the first feature, the acquisition is made in the following manner
Wherein the content of the first and second substances,in order to learn the parameters, the user may,for the purpose of the syntactic characteristics,is a semantic feature.
Step S7: and inputting the combined features into a full-connection layer for emotion classification to acquire emotion polarity information.
And inputting the combined features into the full-connection layer to calculate the probability of different emotion polarities so as to acquire emotion polarity information. Specifically, emotion polarity information is acquired in the following manner:
wherein the content of the first and second substances,for the sake of the combined features,is a weight matrix of the fully-connected layer,as a function of the offset parameter(s),is emotion polarity information.
In the embodiment of the application, vector representation of an input text is obtained by coding the input text by using a pre-trained BERT model, syntax information is extracted from a syntax graph generated based on syntax dependence analysis by using a syntax graph convolution network, semantic information is extracted from a weighted semantic similarity graph generated based on a self-attention mechanism by using a semantic graph convolution network, the syntax information and the semantic information are interactively fused by using an exchange module, and the fused syntax information and semantic information are obtained; extracting the syntactic characteristics and semantic characteristics of the target words in the syntactic information and the semantic information based on an attention mechanism; compared with the prior art, the method and the device have the advantages that the syntactic features can be supplemented by the semantic information, the syntactic information and the semantic information are flexibly combined in a dynamic communication mode, the accuracy rate of a specific emotion target classification task is improved, and the method and the device can be suitable for most specific target emotion classification data sets.
As shown in fig. 2, an embodiment of the present application further provides an emotion classification apparatus, including:
the vector representation acquisition module 1 is used for encoding an input text by using a pre-trained BERT model and acquiring the vector representation of each word of the input text;
the syntactic graph obtaining module 2 is used for performing syntactic dependency analysis on the input text to obtain a syntactic dependency relationship of the input text; taking vector representation as a graph node, taking the corresponding syntactic dependency relationship represented by the vector as an edge, and acquiring a syntactic graph represented by each vector;
the similarity graph acquisition module 3 is used for acquiring a semantic adjacency matrix represented by a vector based on a self-attention mechanism and generating a weighted semantic similarity graph;
the information acquisition module 4 is used for extracting syntactic information from the syntactic graph by utilizing a syntactic graph convolution network and extracting semantic information from the weighted semantic similarity graph by utilizing a semantic graph convolution network; interactively fusing the syntax information and the semantic information by using an exchange module to obtain the fused syntax information and semantic information;
the feature extraction module 5 is used for extracting the syntactic features and the semantic features of the target words in the syntactic information and the semantic information based on an attention mechanism;
a joint feature obtaining module 6, configured to perform weighted summation on the syntactic features and the semantic features to obtain joint features;
and the emotion classification acquisition module 7 is used for inputting the combined features into the full-connection layer for emotion classification to acquire emotion polarity information.
It should be noted that, when the emotion classification apparatus provided in the above embodiment executes the emotion classification method, only the division of each function module is illustrated, and in practical applications, the function distribution may be completed by different function modules according to needs, that is, the internal structure of the device is divided into different function modules, so as to complete all or part of the functions described above. In addition, the emotion classification device and the emotion classification method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in detail in the method embodiments and are not described herein again.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is characterized in that: the computer program when executed by a processor performs the steps of the emotion classification method as described in any of the above.
Embodiments of the present application may take the form of a computer program product embodied on one or more storage media including, but not limited to, disk storage, CD-ROM, optical storage, and the like, in which program code is embodied. Computer readable storage media, which include both non-transitory and non-transitory, removable and non-removable media, may implement any method or technology for storage of information. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of the storage medium of the computer include, but are not limited to: phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, may be used to store information that may be accessed by a computing device.
As shown in Table 1, the emotion classification data is obtained by performing emotion classification on data sets such as restaurant, notebook computer, twitter and the like by using the emotion classification method of the present invention and existing emotion classification methods based on semantics (ATAE-LSTM, RAM, MGAN and GCAE) and syntax (LSTM + SynATT, ASGCN, CDT, TD-GAT, BiGCN, R-GA, RepWalk and DGEDT); wherein the accuracy and markov F1 are used as the evaluation indices of the table.
The emotion classification method uses an Adam optimizer optimization network with a learning rate of 1e-3 or 1e-4, sets the learning rate of a BERT model to be 5e-5 or 2e-5, and sets a regularized coefficient of L2 to be 1 e-5. The batch size was set to 32 or 8 and the random discard rate was between 0.1 and 0.6.
Table 1: sentiment classification results
As can be seen from the table, the emotion classification results with higher accuracy can be obtained in the data set. In addition, the invention can well learn the syntactic information and the semantic information on a data set with richer syntactic and semantic information, and the improvement effect is more obvious, such as a data set of a notebook computer.
As shown in fig. 3-4, in an embodiment, a masking experiment is performed by using the emotion classification method of the present invention and an existing emotion classification model (CDT) to obtain a contribution of each word w in a sentence s, wherein the masking experiment calculation method is as follows:
whereinRepresenting the combined features generated by the sentence s (the word w masked),representing the combined features generated by the sentence s (the word w is not masked),if, ifThen the expression w is used to generate the union featureThere was no impact.
As shown in fig. 3, the conventional emotion classification model cannot recognize the viewpoint word 'Great' of 'food' well, but focuses on 'dreadful' erroneously. Similarly, in fig. 4, although the conventional emotion classification model can focus on the opinion word 'loving' of 'psp', it is not sufficiently understood. In the two examples, the emotion classification method can accurately judge which viewpoint word is the most relevant to the aspect word and is less influenced by irrelevant words. Therefore, the method can supplement syntactic characteristics by utilizing semantic information, flexibly combine with the learning syntax and the semantic combined representation through an internal dynamic communication mechanism, can better enhance the analysis capability of the model on sentences compared with the prior work, and improves the accuracy of emotion classification.
The embodiment of the present application further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable by the processor, and when the processor executes the computer program, the processor implements the steps of the emotion classification method according to any one of the above items.
The present invention is not limited to the above-described embodiments, and various modifications and variations of the present invention are intended to be included within the scope of the claims and the equivalent technology of the present invention if they do not depart from the spirit and scope of the present invention.
Claims (10)
1. An emotion classification method, characterized by comprising the steps of:
coding an input text by utilizing a pre-trained BERT model to obtain vector representation of each word of the input text;
performing syntactic dependency analysis on the input text to acquire a syntactic dependency relationship of the input text; generating a syntactic graph represented by each vector by taking the vector representation as a graph node and taking the corresponding syntactic dependency represented by the vector representation as an edge;
based on a self-attention mechanism, obtaining a semantic adjacency matrix represented by a vector, and generating a weighted semantic similarity graph;
extracting syntactic information from the syntactic graph by using a syntactic graph convolution network, and extracting semantic information from the weighted semantic similarity graph by using a semantic graph convolution network; interactively fusing the syntax information and the semantic information by using an exchange module to obtain the fused syntax information and semantic information;
extracting the syntactic characteristics and the semantic characteristics of the target words in the syntactic information and the semantic information based on an attention mechanism;
carrying out weighted summation on the syntactic characteristics and the semantic characteristics to obtain joint characteristics;
and inputting the combined features into a full-connection layer for emotion classification to acquire emotion polarity information.
2. The emotion classification method of claim 1, wherein the step of generating a syntax map for each vector representation comprises:
a syntax diagram is generated in the following manner:
wherein the content of the first and second substances,in order to be a syntactic graph,for the purpose of a vector representation of the input text,is represented by a vectorThe adjacency matrix of (a);
3. The emotion classification method of claim 1, wherein the step of generating a weighted semantic similarity map comprises:
mapping the vector representation to K d-dimensional semantic spaces in the following manner;
wherein the content of the first and second substances,for the purpose of a vector representation of the input text,is a vector representation of the kth semantic space,the corresponding bias vector is represented for the vector of the kth semantic space,the corresponding mapping matrix is represented for the vector of the kth semantic space,is a non-linear activation function;
obtaining semantic adjacency matrixes corresponding to K semantic spaces according to the following modes:
wherein the content of the first and second substances,a semantic adjacency matrix for node i and node j,in order to be a preset threshold value, the threshold value is set,for the vector representation of node i in the kth semantic space,vector representation in the kth semantic space for node j;
acquiring a weighted similarity adjacency matrix according to the following modes:
wherein the content of the first and second substances,for the weighted similarity adjacency matrix for node i and node j,the attention weight coefficients for node i and node j are obtained as follows:
wherein the content of the first and second substances,for the attention weight matrix of the node i,is the attention weight matrix for node j, d is the dimension of the semantic space,is composed ofThe transposed matrix of (2);
acquiring a weighted semantic similarity map according to the following modes:
4. The emotion classification method of claim 1, wherein the step of extracting syntax information from the syntax map using a syntax map convolutional network comprises:
syntax information is extracted in the following manner:
wherein the content of the first and second substances,in order to be a non-linear activation function,convolution of network for syntax diagramsThe syntax information extracted by the layer is,convolution of network for syntax diagramsThe syntax information extracted by the layer is,is thatThe symmetric normalized adjacency matrix of (a) is,is a syntactic graph convolution networkThe weight matrix of the layer or layers is,is a matrix of the units,is represented by a vectorThe adjacency matrix of (a);
the step of extracting semantic information from the weighted semantic similarity graph by using a semantic graph convolution network comprises the following steps:
semantic information is extracted in the following way:
wherein the content of the first and second substances,convolution of network for semantic graphThe semantic information extracted by the layer(s),convolution of network for semantic graphThe semantic information extracted by the layer(s),convolution of network for semantic graphThe weight matrix of the layer or layers is,is thatThe symmetric normalized adjacency matrix of (a) is,is a weighted similarity adjacency matrix.
5. The emotion classification method of claim 4, wherein the step of obtaining the fused syntactic and semantic information comprises:
acquiring the merged syntax information according to the following modes:
wherein the content of the first and second substances,in order to be the syntax information after the merging,convolution of network for semantic graphThe semantic information extracted by the layer(s),for syntactic fusion coefficients, the following is obtained:
wherein the content of the first and second substances,convolution of network for syntax diagramsThe syntax information extracted by the layer is,is composed ofThe transpose matrix of (a) is,in order to syntactically fuse the weight matrices,fusing the bias parameters for syntax;
acquiring the fused semantic information according to the following modes:
wherein the content of the first and second substances,in order to obtain the fused semantic information,for semantic fusion weight coefficients, the following method is used for obtaining:
6. The emotion classification method of claim 1, wherein the step of obtaining the joint features comprises:
the joint features are obtained in the following manner:
wherein the content of the first and second substances,for the sake of the combined features,in order to be a non-linear activation function,in order to be a weight matrix, the weight matrix,as a function of the offset parameter(s),for the first feature, the acquisition is made in the following manner
7. The emotion classification method of claim 1, wherein the step of obtaining emotion polarity information comprises:
obtaining emotion polarity information according to the following modes:
8. An emotion classification apparatus, comprising:
the vector representation acquisition module is used for encoding the input text by utilizing a pre-trained BERT model and acquiring the vector representation of each word of the input text;
the syntactic graph obtaining module is used for carrying out syntactic dependency analysis on the input text and obtaining syntactic dependency of the input text; taking vector representation as a graph node, taking the corresponding syntactic dependency relationship represented by the vector as an edge, and acquiring a syntactic graph represented by each vector;
the similarity graph acquisition module is used for acquiring a semantic adjacency matrix represented by the vector based on a self-attention mechanism and generating a weighted semantic similarity graph;
the information acquisition module is used for extracting syntactic information from the syntactic graph by utilizing a syntactic graph convolution network and extracting semantic information from the weighted semantic similarity graph by utilizing a semantic graph convolution network; interactively fusing the syntax information and the semantic information by using an exchange module to obtain the fused syntax information and semantic information;
the feature extraction module is used for extracting the syntactic features and the semantic features of the target words in the syntactic information and the semantic information based on an attention mechanism;
the joint characteristic acquisition module is used for carrying out weighted summation on the syntactic characteristics and the semantic characteristics to acquire joint characteristics;
and the emotion classification acquisition module is used for inputting the combined features into the full-connection layer for emotion classification to acquire emotion polarity information.
9. A computer-readable storage medium having stored thereon a computer program, characterized in that: the computer program when being executed by a processor realizes the steps of the sentiment classification method according to any one of claims 1 to 7.
10. A computer device, characterized by: comprising a memory, a processor and a computer program stored in the memory and executable by the processor, the processor implementing the steps of the sentiment classification method according to any one of claims 1 to 7 when executing the computer program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111000019.2A CN113449110B (en) | 2021-08-30 | 2021-08-30 | Emotion classification method and device, storage medium and computer equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111000019.2A CN113449110B (en) | 2021-08-30 | 2021-08-30 | Emotion classification method and device, storage medium and computer equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113449110A true CN113449110A (en) | 2021-09-28 |
CN113449110B CN113449110B (en) | 2021-12-07 |
Family
ID=77818967
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111000019.2A Active CN113449110B (en) | 2021-08-30 | 2021-08-30 | Emotion classification method and device, storage medium and computer equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113449110B (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115510226A (en) * | 2022-09-02 | 2022-12-23 | 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) | Emotion classification method based on graph neural network |
CN115712726A (en) * | 2022-11-08 | 2023-02-24 | 华南师范大学 | Emotion analysis method, device and equipment based on bigram embedding |
CN115827878A (en) * | 2023-02-13 | 2023-03-21 | 华南师范大学 | Statement emotion analysis method, device and equipment |
CN116089619A (en) * | 2023-04-06 | 2023-05-09 | 华南师范大学 | Emotion classification method, apparatus, device and storage medium |
CN116304748A (en) * | 2023-05-17 | 2023-06-23 | 成都工业学院 | Text similarity calculation method, system, equipment and medium |
WO2024000956A1 (en) * | 2022-06-30 | 2024-01-04 | 苏州思萃人工智能研究所有限公司 | Aspect sentiment analysis method and model, and medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8700404B1 (en) * | 2005-08-27 | 2014-04-15 | At&T Intellectual Property Ii, L.P. | System and method for using semantic and syntactic graphs for utterance classification |
CN111651973A (en) * | 2020-06-03 | 2020-09-11 | 拾音智能科技有限公司 | Text matching method based on syntax perception |
CN112528672A (en) * | 2020-12-14 | 2021-03-19 | 北京邮电大学 | Aspect-level emotion analysis method and device based on graph convolution neural network |
CN112668319A (en) * | 2020-12-18 | 2021-04-16 | 昆明理工大学 | Vietnamese news event detection method based on Chinese information and Vietnamese statement method guidance |
CN112686056A (en) * | 2021-03-22 | 2021-04-20 | 华南师范大学 | Emotion classification method |
CN112966074A (en) * | 2021-05-17 | 2021-06-15 | 华南师范大学 | Emotion analysis method and device, electronic equipment and storage medium |
-
2021
- 2021-08-30 CN CN202111000019.2A patent/CN113449110B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8700404B1 (en) * | 2005-08-27 | 2014-04-15 | At&T Intellectual Property Ii, L.P. | System and method for using semantic and syntactic graphs for utterance classification |
US20160086601A1 (en) * | 2005-08-27 | 2016-03-24 | At&T Intellectual Property Ii, L.P. | System and method for using semantic and syntactic graphs for utterance classification |
CN111651973A (en) * | 2020-06-03 | 2020-09-11 | 拾音智能科技有限公司 | Text matching method based on syntax perception |
CN112528672A (en) * | 2020-12-14 | 2021-03-19 | 北京邮电大学 | Aspect-level emotion analysis method and device based on graph convolution neural network |
CN112668319A (en) * | 2020-12-18 | 2021-04-16 | 昆明理工大学 | Vietnamese news event detection method based on Chinese information and Vietnamese statement method guidance |
CN112686056A (en) * | 2021-03-22 | 2021-04-20 | 华南师范大学 | Emotion classification method |
CN112966074A (en) * | 2021-05-17 | 2021-06-15 | 华南师范大学 | Emotion analysis method and device, electronic equipment and storage medium |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024000956A1 (en) * | 2022-06-30 | 2024-01-04 | 苏州思萃人工智能研究所有限公司 | Aspect sentiment analysis method and model, and medium |
CN115510226A (en) * | 2022-09-02 | 2022-12-23 | 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) | Emotion classification method based on graph neural network |
CN115510226B (en) * | 2022-09-02 | 2023-11-10 | 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) | Emotion classification method based on graph neural network |
CN115712726A (en) * | 2022-11-08 | 2023-02-24 | 华南师范大学 | Emotion analysis method, device and equipment based on bigram embedding |
CN115712726B (en) * | 2022-11-08 | 2023-09-12 | 华南师范大学 | Emotion analysis method, device and equipment based on double word embedding |
CN115827878A (en) * | 2023-02-13 | 2023-03-21 | 华南师范大学 | Statement emotion analysis method, device and equipment |
CN115827878B (en) * | 2023-02-13 | 2023-06-06 | 华南师范大学 | Sentence emotion analysis method, sentence emotion analysis device and sentence emotion analysis equipment |
CN116089619A (en) * | 2023-04-06 | 2023-05-09 | 华南师范大学 | Emotion classification method, apparatus, device and storage medium |
CN116089619B (en) * | 2023-04-06 | 2023-06-06 | 华南师范大学 | Emotion classification method, apparatus, device and storage medium |
CN116304748A (en) * | 2023-05-17 | 2023-06-23 | 成都工业学院 | Text similarity calculation method, system, equipment and medium |
CN116304748B (en) * | 2023-05-17 | 2023-07-28 | 成都工业学院 | Text similarity calculation method, system, equipment and medium |
Also Published As
Publication number | Publication date |
---|---|
CN113449110B (en) | 2021-12-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113449110B (en) | Emotion classification method and device, storage medium and computer equipment | |
CN108536681B (en) | Intelligent question-answering method, device, equipment and storage medium based on emotion analysis | |
CN112084331A (en) | Text processing method, text processing device, model training method, model training device, computer equipment and storage medium | |
CN109902301B (en) | Deep neural network-based relationship reasoning method, device and equipment | |
CN113627447B (en) | Label identification method, label identification device, computer equipment, storage medium and program product | |
Udandarao et al. | Cobra: Contrastive bi-modal representation algorithm | |
CN112580328A (en) | Event information extraction method and device, storage medium and electronic equipment | |
CN114419642A (en) | Method, device and system for extracting key value pair information in document image | |
CN111259130A (en) | Method and apparatus for providing reply sentence in dialog | |
CN111783903A (en) | Text processing method, text model processing method and device and computer equipment | |
CN113032525A (en) | False news detection method and device, electronic equipment and storage medium | |
CN111597580B (en) | Robot hearing privacy information monitoring processing method | |
CN110633410A (en) | Information processing method and device, storage medium, and electronic device | |
CN115827878B (en) | Sentence emotion analysis method, sentence emotion analysis device and sentence emotion analysis equipment | |
CN114461943B (en) | Deep learning-based multi-source POI semantic matching method and device and storage medium thereof | |
CN116501877A (en) | Multi-mode attention rumor detection method based on causal graph | |
CN113741759B (en) | Comment information display method and device, computer equipment and storage medium | |
CN115357711A (en) | Aspect level emotion analysis method and device, electronic equipment and storage medium | |
CN116150353A (en) | Training method for intention feature extraction model, intention recognition method and related device | |
CN113886547A (en) | Client real-time conversation switching method and device based on artificial intelligence and electronic equipment | |
CN113010772A (en) | Data processing method, related equipment and computer readable storage medium | |
CN115525740A (en) | Method and device for generating dialogue response sentence, electronic equipment and storage medium | |
Yuan et al. | Point-of-Interest Oriented Question Answering with Joint Inference of Semantic Matching and Distance Correlation | |
CN116860952B (en) | RPA intelligent response processing method and system based on artificial intelligence | |
CN111177526B (en) | Network opinion leader identification method and device |
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 |