Comment sentiment analysis method and system based on knowledge graph and interactive graph convolution
By combining knowledge graphs and interactive graph convolutional networks in aspect-level sentiment analysis, using sub-graph generation and multi-head attention mechanisms, the existing models are solved in information loss and noise problems, and the accuracy of emotion classification is improved, especially in In the case of small data volume and irregular sentences.
Patent Information
- Application Number
- CN202210182675.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-02-25
AI Technical Summary
The existing aspect-level sentiment analysis model has information loss and noise problems when utilizing knowledge graphs and syntactic dependencies, resulting in low accuracy in sentiment classification, especially when the data volume is small and the sentences are not standardized.
Using a deep learning network model based on knowledge graph and interactive graph convolution, the sub-graph generation strategy, position weighting, relational attention mechanism, graph convolution network and multi-head attention mechanism are extracted through sub-graph generation strategy, position weighting, relationship attention mechanism, graph convolution network and multi-head attention mechanism, combined with syntactic dependency and external knowledge, comment sentences are extracted The graph convolution represents vectors and performs gating fusion to enhance the accuracy of emotion classification.
It improves the accuracy of emotion classification, effectively utilizes the knowledge graph and syntactic dependence relationship, reduces the impact of noise, and improves the performance of the model in short text and multi-faceted sentiment analysis.
Smart Images

Figure CN114492459B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing, and specifically relates to a comment sentiment analysis method and system based on knowledge graph and interactive graph convolution. Background Art
[0002] Sentiment Analysis (SA), also known as opinion mining, is a basic task in the field of Natural Language Processing (NLP). The basic goal of this task is to mine the sentiment information in a given text and analyze its sentiment polarity. This task is divided into document-level sentiment analysis, sentence-level sentiment analysis, and aspect-level sentiment analysis according to different classification granularities. Traditional document-level or sentence-level sentiment analysis models can only analyze the entire document or sentence to identify its sentiment polarity. With the rapid development of the Internet, a large number of comment texts have emerged on online social media platforms and online shopping platforms. Most of these texts have the characteristics of being short, multifaceted, and non-standard. When a comment sentence has multiple aspects and the sentiment polarity of each aspect is different, these document-level or sentence-level sentiment analysis models are obviously unable to correctly interpret the sentiment information therein. Therefore, the more fine-grained aspect-level sentiment analysis has gradually become the mainstream of current research. Aspect-level sentiment analysis aims to determine the sentiment polarity corresponding to the specific aspects of the target in the comment text.
[0003] In recent years, with the rise of deep learning technology, this technology has also been widely used in aspect-level sentiment analysis tasks. The most commonly used neural networks are convolutional neural networks (CNNs) and recurrent neural networks (RNNs). Since CNNs perform well in capturing semantic information from text, some researchers apply them to ABSA. However, the network cannot fully utilize the contextual information in the sentence, which is crucial for modeling the semantic relationship between an aspect and its context. Therefore, the performance of CNN-based neural network models is limited in aspect-level sentiment analysis tasks. To address this problem, many researchers have adopted RNNs, especially long short-term memory (LSTM) and gated recurrent units (GRU), to extract aspect-specific sentiment features for sentiment classification. Unlike CNN, RNN treats a sentence as a sequence of words, takes each word in chronological order, uses the output of the hidden layer as the input of the next hidden layer, and continuously learns contextual information in the sequence data. Tang et al. proposed using two LSTMs to model the left and right contexts of aspect terms, respectively, and generate comment text representation vectors for prediction. The RNN-based neural network model is significantly better than the CNN-based neural network model in ABSA.
[0004] The researchers pointed out that the sentiment polarity of a given aspect is determined by a few keywords rather than all the words in the context. RNN cannot accurately estimate the contribution of different context words to the aspect-level representation of sentiment classification. In contrast, the attention mechanism can capture the importance of each context word by calculating the attention weight of each context word on a given aspect and using this attention weight to calculate the aspect-level representation of sentiment classification.
[0005] However, these neural network models all ignore the syntactic dependency between a given aspect and its context words, which represents the dependency between words in a review sentence and is particularly important for correctly judging the sentiment polarity of an aspect. Recently, some scholars have used graph neural networks (GNNs) and their variants to consider syntactic information when learning aspect-level representations for sentiment classification. Zhang et al. combined a graph convolutional network (GCN) with an attention mechanism to capture the semantic relevance between context words and a given aspect. Zhang et al. proposed a graph convolutional structure model that combines a global vocabulary graph and a syntactic dependency graph, using the co-occurrence information of words at the corpus level as the edge relationship of the nodes, and finally making full use of the two graph structures through a two-layer interactive graph convolutional network to obtain a more accurate feature representation of the review text. Existing GNN-based models do not use an attention mechanism or simply use a traditional attention mechanism, and do not make full use of the edge relationship of the syntactic dependency tree, so it is difficult to accurately capture the importance of context words relative to a given aspect.
[0006] The current dataset of aspect-level sentiment analysis tasks has a small amount of data, resulting in poor model performance. At the same time, if there is a lack of corresponding knowledge, the semantic relationship between aspects and sentiment terms may not be obtained. Therefore, many researchers apply knowledge graphs to aspect-level sentiment analysis tasks as a supplement to the external knowledge of the model to improve model performance. Yang et al. proposed a hierarchical anthropomorphic strategy for aspect-level sentiment classification, which uses emotional language knowledge as prior knowledge to learn sentiment-aware document representation. Zhou et al. used externally constructed knowledge graph embedding and syntactic dependencies, and used two different structures of GCN to obtain the semantic relationship between context word nodes and given aspects. However, the existing knowledge graph-based models simply incorporate external knowledge into the comment sentence representation, without fully utilizing the graph structure of the knowledge graph, which leads to the loss of a lot of external knowledge information, or the combination of a lot of unnecessary knowledge generates noise for the model, so that the model performance improvement is not obvious. Summary of the invention
[0007] The purpose of the present invention is to provide a comment sentiment analysis method and system based on knowledge graph and interactive graph convolution, which is conducive to improving the accuracy of sentiment classification.
[0008] To achieve the above purpose, the technical solution adopted by the present invention is: a comment sentiment analysis method based on knowledge graph and interactive graph convolution, comprising the following steps:
[0009] Step A: Collect user comments, extract the aspect words of the product or service involved in the user comments, and mark the sentiment polarity of the user comments on the specific aspects of the product or service to construct the training set DS;
[0010] Step B: Using the training set DS, train a deep learning network model G based on the knowledge graph and the interactive graph convolutional network to analyze the sentiment polarity of user comments on specific aspects of products or services;
[0011] Step C: Input the user comments and the aspect words of the product or service involved in the user comments into the trained deep learning network model to obtain the sentiment polarity of the user comments for the specific aspects of the product or service.
[0012] Furthermore, the step B specifically includes the following steps:
[0013] Step B1: Encode each training sample in the training set DS to obtain the initial representation vector E of the user comment S , the initial characterization vector E A And the syntactic dependency adjacency matrix A S At the same time, according to the dependency tree KG subgraph generation strategy, the corresponding subgraph DKG of user comments is generated from the knowledge graph to obtain its adjacency matrix A DKG , and then encode its nodes to get the node representation H of the subgraph DKG DKG ;
[0014] Step B2: Enhance the representation of the specified aspect through the aspect enhancement strategy to obtain the aspect enhancement vector E AE , the initial characterization vector E obtained in step B1 S and aspect enhancement vector E AE Input them into two different bidirectional long short-term memory networks respectively to obtain the user comment sentence representation vector H S and aspect-enhanced representation vector H AE ;
[0015] Step B3: Obtain the edge vector E of the comment sentence through the aspect enhancement strategy E , for H S and E E In terms of using the relational attention mechanism, we obtain the relational attention sentence representation vector ERA ;
[0016] Step B4: H AE Perform average pooling to obtain aspect representation vector For H S Perform position weighting to obtain the position-enhanced comment sentence representation vector H PS , by connecting and H PS , get the representation vector G S,0 ;
[0017] Step B5: Represent the vector G S,0 and the subgraph node representation vector H DKG They are input into two different K-layer graph convolutional networks, denoted as comment sentence graph convolutional network SGCN and dependency tree knowledge graph convolutional network DKGGCN, respectively, to learn and extract syntactic dependencies and external knowledge. At the same time, each layer of the comment sentence graph convolutional network SGCN uses the dependency tree knowledge graph convolutional network DKGGCN to perform knowledge fusion through the knowledge interaction mechanism, and finally obtain the graph convolution representation vector G of user comments S,K ;
[0018] Step B6: Convolution the graph representation vector G S,K Perform mask operation to obtain the graph convolution mask representation vector G of user comments mask , and then the comment sentence representation vector H S By using the cross attention mechanism, the model feature extraction capability is further improved to obtain the representation vector E SD ;
[0019] Step B7: To address the noise caused by irregular sentences, use the multi-head attention mechanism to SD And the relational attention sentence representation vector E obtained in step B3 RA Fusion obtains sentence representation E that aggregates external knowledge and edge relationships MT , and then through a gated fusion mechanism, the final representation vector E is obtained FIN ;
[0020] Step B8: The final representation vector E FIN Input the final prediction layer, calculate the gradient of each parameter in the deep learning network model using the back propagation method according to the target loss function, and update each parameter using the stochastic gradient descent method;
[0021] Step B9: When the iterative change of the loss value generated by the deep learning network model is less than a given threshold or reaches the maximum number of iterations, the training process of the deep learning network model is terminated.
[0022] Furthermore, the step B1 specifically includes the following steps:
[0023] Step B11: traverse the training set DS, perform word segmentation on the user comments and aspects therein and remove stop words, and each training sample in DS is represented as ds = (s, a, p);
[0024] Where s is the user comment, a is the aspect word or phrase of the product or service involved in the user comment extracted from the user comment s, and p is the sentiment polarity of the comment on the aspect, including {positive, negative, neutral};
[0025] User comments s are represented as:
[0026]
[0027] in, is the i-th word in user comment s, i = 1, 2, ..., n, n is the number of words in user comment s;
[0028] Aspect a is represented by:
[0029]
[0030] in, is the i-th word in aspect a, i = 1, 2, …, m′, m′ is the number of words in aspect a;
[0031] Step B12: Get user comments on step B11 Encode and obtain the initial representation vector E of user comment s S ;
[0032] Among them, E S It is expressed as:
[0033]
[0034] in, For the i-th word The corresponding word vector is obtained by using the pre-trained word vector matrix where d represents the dimension of the word vector and |V| is the number of words in the dictionary V;
[0035] Step B13: Aspects obtained in step B11 Encode and obtain the initial representation vector E of aspect a A ;
[0036]
[0037] in, Represents the i-th word The corresponding word vector is obtained by using the pre-trained word vector matrix where d represents the dimension of the word vector and |V| is the number of words in the dictionary V;
[0038] Step B14: Perform syntactic dependency parsing on the user comment s to obtain a syntactic dependency tree DT;
[0039]
[0040] in, Representation word w i and word w j There are syntactic dependencies between them;
[0041] Step B15: Encode the parsed syntactic dependency tree DT into an n-order adjacency matrix A S , A S It is expressed as:
[0042]
[0043] Among them, A ij 1 represents word and words There is a syntactic dependency relationship between A and ij 0 represents the word and words There is no syntactic dependency between them;
[0044] Step B16: Encode the parsed syntactic dependency tree DT into an n-order edge relationship adjacency matrix B, where B is expressed as:
[0045]
[0046] Among them, B ij A non-zero real number representation word and words There is a syntactic dependency relationship between them. The same syntactic dependency relationship is represented by the same non-zero real number. ij 0 represents the word and words There is no syntactic dependency between them;
[0047] Step B17: Take each word node in the syntactic dependency tree DT as a seed node, take each seed node as a root node, expand the hop layer from the knowledge graph to generate child nodes, and select u nodes in each layer that have edge connections with the nodes in the previous layer in the knowledge graph as nodes of this layer, that is, each seed node has q = u hop+1 -1 expanded child node, and the total number of all nodes is z = n + n * q, and the dependency tree knowledge graph subgraph DKG is obtained;
[0048]
[0049] in, Representation word w i and word w j There is a syntactic dependency relationship between them. Expressive words Yes word The expansion node, Expressive words Yes word The extended child node of
[0050] Step B18: Encode the dependency tree knowledge graph subgraph DKG into a z-order adjacency matrix A DKG , A DKG It is expressed as:
[0051]
[0052] Among them, A ij A is 1, indicating that there is a connection between the two words. ij A value of 0 indicates that there is no connection between the two words;
[0053] Step B19: Encode the nodes of the dependency tree knowledge graph subgraph DKG through knowledge graph embedding, and obtain its node representation as To serve as the initial input of the dependency tree knowledge graph convolutional network DKGGCN in, For the i-th word The corresponding knowledge word vector is obtained by using the pre-trained knowledge word vector matrix It can be found in , where d represents the dimension of the knowledge word vector and |V| is the number of words in the knowledge word embedding V.
[0054] Furthermore, the step B2 specifically includes the following steps:
[0055] Step B21: Prune the syntactic dependency tree DT obtained in step B14 to perform aspect enhancement and obtain t context words connected to aspect a. Combining context cs with aspect a, we get aspect enhancement word ae, which is expressed as:
[0056]
[0057] in, is the i-th word among the remaining words after the aspect enhancement word ae is segmented and the stop words are removed, i=1,2,...,m, m is the number of words remaining after the aspect enhancement word ae is segmented and the stop words are removed;
[0058] Encode the aspect enhancement word ae to obtain the aspect enhancement vector EAE ;
[0059]
[0060] in, Indicates the i-th aspect enhancement word The corresponding word vector is obtained by using the pre-trained word vector matrix where d represents the dimension of the word vector and |V| is the number of words in the dictionary V;
[0061] Step B22: Initial representation vector E of user comment s S sequence Input the forward layer and reverse layer of the first bidirectional long short-term memory network in turn to obtain the state vector sequence of the forward hidden layer The state vector sequence of the reverse hidden layer in f is the activation function; concatenate to get the user comment representation vector ";" indicates a vector concatenation operation;
[0062] Step B23: Enhance the aspect vector Input the forward layer and reverse layer of the second bidirectional long short-term memory network in turn to obtain the forward hidden layer state vector sequence Reverse hidden state vector sequence in, f is the activation function; concatenate and transpose to get the aspect enhancement representation vector H AE , “;” indicates a vector concatenation operation.
[0063] Furthermore, the step B3 specifically includes the following steps:
[0064] Step B31: The edge relation syntactic dependency adjacency matrix B is pruned to retain only the context words directly connected to the given aspect words and their edge types; for aspects containing multiple words, the edge relation sequences of these k words directly connected are obtained respectively. The k-dimensional matrix is compressed into one dimension by adding rows, and the edge relationship sequence rs = {rs1, rs2, ..., rs n}; Initialize the edge type label sequence to obtain the edge vector E E ;
[0065]
[0066] in, Represents the edge vector corresponding to the i-th word;
[0067] Step B32: Opposite side vector E E And the user comment representation vector H obtained in step B22 S Use the relational attention mechanism to obtain the relational attention sentence representation vector The calculation process is as follows:
[0068]
[0069]
[0070]
[0071] in, represents the edge relationship vector between node i and aspect, Sentence representation vector representing relational attention, is a learnable weight matrix, is the bias vector.
[0072] Furthermore, the step B4 specifically includes the following steps:
[0073] Step B41: Enhance the aspect representation vector H AE Perform average pooling operation and get The calculation formula is as follows:
[0074]
[0075] in,
[0076] Step B42: Characterize the user comment vector H s Perform position weighting to obtain the position-enhanced representation vector H of the user comment PS , H PS It is expressed as:
[0077]
[0078] in, Strengthen the representation vector for the position corresponding to the i-th word in the user comment s. “·” represents the multiplication of the vector and the real number. is the i-th word in user comment s The corresponding position weight is calculated as follows:
[0079]
[0080] Where i=1,2,...,n represents the position of the current word in the sentence, τ represents the position of the first word of aspect a in user comment s, and τ+m-1 represents the position of the last word of aspect a in user comment s;
[0081] Step B43: The average pooled aspect enhancement representation vector obtained in step B41 is and H obtained in step B42 PS Connect and get the representation vector g 0 , It is expressed as:
[0082]
[0083] in, is the representation vector corresponding to the i-th word in the user comment s, input into the graph convolutional network, i = 1, 2, ..., n, It is expressed as:
[0084]
[0085] in, “;” indicates a vector concatenation operation.
[0086] Furthermore, the step B5 specifically includes the following steps:
[0087] Step B51: For the dependency tree graph convolutional network DKGGCN, the subgraph node representation vector G DKG,0 Input the first layer of graph convolutional network and use the adjacency matrix A DKG Update the vector representation of each subgraph node and output G DKG,1 , and used as the input of the next layer of graph convolutional network;
[0088] Among them, G DKG,1 It is expressed as:
[0089]
[0090] in, is the output of node i in the first layer of the graph convolutional network, The calculation formula is as follows:
[0091]
[0092]
[0093] in, is the weight matrix, is the bias term; W DKG , b DKG are all learnable parameters; relu is the activation function; node i in the graph convolutional network and the i-th word in the user comment Correspondingly, the edges between nodes in the graph convolutional network represent the knowledge connection relationship between words, d irepresents the degree of node i, choose d i +1 is used as the divisor to prevent the operation from going wrong when the degree of node i is 0. “;” indicates a vector connection operation.
[0094] Step B52: For the comment sentence graph convolution network SGCN, the comment sentence representation vector G S,0 Input the first layer of graph convolutional network and use the adjacency matrix A S Update the vector representation of each word and output G S,1 , through the knowledge interaction mechanism combined with the first layer output G of the dependency tree graph convolutional network DKGGCN DKG,1 And generate the input G of the next layer of graph convolutional network SD,1 ;
[0095] Among them, G S,1 , G SD,1 Respectively expressed as:
[0096]
[0097]
[0098] in, is the output of node i in the first layer of the graph convolutional network, The calculation formula is as follows:
[0099]
[0100]
[0101] in, is the weight matrix, is the bias term; W S , are all learnable parameters; relu is the activation function; node i in the graph convolutional network and the i-th word in the user comment Correspondingly, the edges between nodes in the graph convolutional network represent the syntactic dependencies between words in user comments, d i represents the degree of node i, choose d i +1 is used as the divisor to prevent the operation from going wrong when the degree of node i is 0. “;” indicates a vector connection operation.
[0102] For the knowledge interaction mechanism, we first output G of the first layer of DKGGCN DKG,1 Perform truncation to retain the words in the current user comment sentence and obtain the first layer of knowledge representation of the SGCN node Next, the interactive attention mechanism is used to combine it with the first layer output G of SGCN S,1 Combined with the knowledge, we can further obtain the user review sentence representation GSD,1 ;
[0103] Among them, G SD,1 It is expressed as:
[0104]
[0105] in, is the output of node i in the first layer of the SGCN graph convolutional network through the interaction mechanism, The calculation formula is as follows:
[0106]
[0107]
[0108]
[0109] in,(·) T represents the transpose operation, α i is the attention weight of the knowledge about the i-th word in the user comment s;
[0110] Step B53: G DKG,1 and G SD,1 Input to the next layer of graph convolutional network of DKGGCN and SGCN, and repeat steps B51 and B52;
[0111] For DKGGCN, the output of the k-th layer graph convolutional network is As the input of the k+1th layer of graph convolutional network, the graph convolution representation vector is obtained after the iteration For SGCN, the output of the k-th layer graph convolutional network is G S,k G is obtained by the same knowledge interaction mechanism as described in step B52. SD,k , as the input of the k+1th layer of graph convolutional network, after the iteration, the graph convolution representation vector is obtained K is the number of layers of the graph convolutional network, 1≤k≤K.
[0112] Furthermore, the step B6 specifically includes the following steps:
[0113] Step B61: G obtained in step B53 S,K Perform masking operation to shield the graph convolution output that does not belong to aspect words, and obtain the graph convolution mask representation vector G of user comments mask , the calculation process is as follows:
[0114] G mask ={0,...,g mask,τ ,...,g mask,τ+m-1 ,...,0}
[0115] Among them, 0 represents a zero vector with dimension 2d, τ represents the position of the first word of the aspect in the comment sentence, and g mask,τ The representation vector corresponding to the first word of the aspect, g mask,τ+m-1 The representation vector corresponding to the last word of the aspect;
[0116] Step B62: The user comment representation vector H obtained in step B24 is S And the graph convolution mask representation vector G of the user comment obtained in step B61 mask Input the attention network, select important word-level information through the attention network, and obtain the sentence-level representation vector E of the user comment SD , the calculation formula is as follows:
[0117]
[0118]
[0119]
[0120] in,(·) T represents the transpose operation, ε i is the attention weight of the i-th word in user review s.
[0121] Furthermore, the step B7 specifically includes the following steps:
[0122] Step B71: Select an integer N that can divide d, and write the sentence-level representation vector E of the user comment SD And the relational attention sentence representation vector E obtained in step B32 RA Divide it into N sub-vectors evenly on the last dimension to get a sub-vector sequence and in is the sentence-level representation vector E SD The h-th subvector of is the relational attention sentence representation vector E RA The h-th subvector of ;
[0123] Step B72: Transform the sentence-level representation vector E SD Each sub-vector of and the sentence-level representation vector e of the user comment w The corresponding subvectors in form a subvector pair, that is, The attention mechanism is used to calculate each sub-vector pair separately, and then concatenated and dimensionally reduced to obtain the sentence enhanced representation vector E of the user comment that integrates knowledge and edge relationships. MT , N is the number of heads of the multi-head attention mechanism. The calculation process of the multi-head attention mechanism is as follows:
[0124] l mt =2l / N
[0125]
[0126]
[0127] Among them, MHA represents the multi-head attention mechanism, Q, K, V represent the input vector of the multi-head attention mechanism, and Q represents the relational attention sentence representation vector E RA , K and V take the same value, both are the output E of the word-level attention mechanism SD ; is the output vector calculated using the attention mechanism for the i-th sub-vector pair of Q, K, and V, N is the number of sub-vector pairs, that is, the number of heads of the multi-head attention mechanism, is the training parameter of the multi-head attention mechanism, is the linear transformation matrix that transforms the input vectors Q, K, V into the i-th sub-vector pair, l mt Represents the dimension of the last dimension of the sub-vector;
[0128] Step B73: To address the noise brought by irregular sentences to the model, the sentence representation vector E of user comments that integrate knowledge and edge relationships is enhanced MT Input the gating function to filter irrelevant information and obtain the vector E SDA , and then input into the multi-layer perceptron MLP to get the final sentence representation vector E FIN ; The specific calculation process is as follows:
[0129]
[0130]
[0131] The present invention also provides a comment sentiment analysis system using the above method, comprising:
[0132] The data collection module is used to extract user comments, aspect words in comments, and the location information of aspect words, and to annotate the sentiment polarity of aspects to construct a training set;
[0133] The preprocessing module is used to preprocess the training samples in the training set, including word segmentation, stop word removal, syntactic dependency parsing, and dependency tree knowledge graph subgraph;
[0134] The encoding module is used to search the word vectors of the preprocessed user comments and the words in the aspect enhancement in the pre-trained word vector matrix to obtain the initial representation vectors of the user comments and the initial representation vectors of the aspect enhancement, and to search the word vectors of the nodes in the dependency tree knowledge graph subgraph in the pre-trained knowledge graph word vector matrix to obtain the initial representation vectors of the dependency tree knowledge graph subgraph related to the user comments;
[0135] A network training module, which is used to input the initial representation vector of the user comment, the initial representation vector of the aspect, and the initial representation vector of the dependency tree knowledge graph subgraph into the deep learning network, obtain the final representation vector of the user comment and use it to train the deep learning network, use the probability of the representation vector belonging to a certain category and the annotations in the training set as the loss, and train the entire deep learning network with the goal of minimizing the loss to obtain a deep learning network model based on the knowledge graph and the interactive graph convolutional network; and
[0136] The sentiment analysis module uses NLP tools to extract aspects from the input user comments, and then uses the trained deep learning network model based on knowledge graph and interactive graph convolutional network to analyze and process the input user comments and aspects, and outputs the sentiment evaluation polarity involving specific aspects in the user comments.
[0137] Compared with the prior art, the present invention has the following beneficial effects: the present invention first uses the knowledge graph and subgraph generation strategy to obtain the dependency tree knowledge subgraph of the corresponding comment sentence, then encodes the comment sentence and product aspect enhancement separately, and then uses the position information to weight the comment sentence representation, and at the same time learns the syntactic dependency and external knowledge in the comment sentence through two GCNs and a knowledge interaction mechanism, and finally uses a multi-granularity attention gating mechanism to fuse the edge relationship information and filter the sentence noise to enhance the representation of the comment sentence, which can improve the accuracy of the model's prediction of sentiment classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0138] Figure 1 is a flow chart of a method implementation of an embodiment of the present invention;
[0139] Figure 2 This is a model architecture diagram in an embodiment of the present invention;
[0140] Figure 3 Schematic diagram of the system structure of an embodiment of the present invention. DETAILED DESCRIPTION
[0141] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0142] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0143] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0144] like Figure 1 As shown, this embodiment provides a comment sentiment analysis method based on knowledge graph and interactive graph convolution, including the following steps:
[0145] Step A: Collect user comments, extract aspect words of the product or service involved in the user comments, and mark the sentiment polarity of the user comments on the specific aspects of the product or service to construct the training set DS.
[0146] Step B: Use the training set DS to train a deep learning network model G based on the knowledge graph and interactive graph convolutional network to analyze the sentiment polarity of user comments on specific aspects of products or services. The architecture of the deep learning network model G in this embodiment is as follows: Figure 2 shown.
[0147] Step C: Input the user comments and the aspect words of the product or service involved in the user comments into the trained deep learning network model to obtain the sentiment polarity of the user comments for the specific aspects of the product or service.
[0148] In this embodiment, step B specifically includes the following steps:
[0149] Step B1: Encode each training sample in the training set DS to obtain the initial representation vector E of the user comment S , the initial characterization vector E A And the syntactic dependency adjacency matrix A S At the same time, according to the dependency tree KG subgraph generation strategy, the corresponding subgraph DKG of user comments is generated from the knowledge graph to obtain its adjacency matrix A DKG , and then encode its nodes to get the node representation H of the subgraph DKG DKG The step B1 specifically comprises the following steps:
[0150] Step B11: traverse the training set DS, perform word segmentation on the user comments and aspects therein and remove stop words, and each training sample in DS is represented as ds = (s, a, p).
[0151] Where s is the user comment, a is the aspect word or phrase of the product or service involved in the user comment extracted from the user comment s, and p is the sentiment polarity of the comment on the aspect, which includes {positive, negative, neutral}.
[0152] User comments s are represented as:
[0153]
[0154] in, is the i-th word in user comment s, i = 1, 2, ..., n, and n is the number of words in user comment s.
[0155] Aspect a is represented by:
[0156]
[0157] in, is the i-th word in aspect a, i=1,2,…,m′, m′ is the number of words in aspect a.
[0158] Step B12: Get user comments on step B11 Encode and obtain the initial representation vector E of user comment s S .
[0159] Among them, E S It is expressed as:
[0160]
[0161] in, For the i-th word The corresponding word vector is obtained by using the pre-trained word vector matrix It can be found in , where d represents the dimension of the word vector and |V| is the number of words in the dictionary V.
[0162] Step B13: Aspects obtained in step B11 Encode and obtain the initial representation vector E of aspect a A ;
[0163]
[0164] in, Represents the i-th word The corresponding word vector is obtained by using the pre-trained word vector matrix It can be found in , where d represents the dimension of the word vector and |V| is the number of words in the dictionary V.
[0165] Step B14: Perform syntactic dependency parsing on the user comment s to obtain a syntactic dependency tree DT;
[0166]
[0167] in, Representation word w i and word w j There is a syntactic dependency relationship between them.
[0168] Step B15: Encode the parsed syntactic dependency tree DT into an n-order adjacency matrix A S , A S It is expressed as:
[0169]
[0170] Among them, A ij 1 represents word and words There is a syntactic dependency relationship between A and ij 0 represents the word and words There is no syntactic dependency between them.
[0171] Step B16: Encode the parsed syntactic dependency tree DT into an n-order edge relationship adjacency matrix B, where B is expressed as:
[0172]
[0173] Among them, B ij A non-zero real number representation word and words There is a syntactic dependency relationship between them. The same syntactic dependency relationship is represented by the same non-zero real number. ij 0 represents the word and words There is no syntactic dependency between them.
[0174] Step B17: Take each word node in the syntactic dependency tree DT as a seed node, take each seed node as a root node, expand the hop layer from the knowledge graph to generate child nodes, and select u nodes in each layer that have edge connections with the nodes in the previous layer in the knowledge graph as nodes of this layer, that is, each seed node has q = u hop+1 -1 expanded child node, and the total number of all nodes is z = n + n * q, and the dependency tree knowledge graph subgraph DKG is obtained;
[0175]
[0176] in, Representation word w i and word w j There is a syntactic dependency relationship between them. Expressive words Yes word The expansion node, Expressive words Yes word The extended child node.
[0177] Step B18: Encode the dependency tree knowledge graph subgraph DKG into a z-order adjacency matrix A DKG , A DKG It is expressed as:
[0178]
[0179] Among them, A ij A is 1, indicating that there is a connection between the two words. ij A value of 0 indicates that there is no connection between the two words.
[0180] Step B19: Encode the nodes of the dependency tree knowledge graph subgraph DKG through knowledge graph embedding, and obtain its node representation as To serve as the initial input of the dependency tree knowledge graph convolutional network DKGGCN in, For the i-th word The corresponding knowledge word vector is obtained by using the pre-trained knowledge word vector matrix It can be found in , where d represents the dimension of the knowledge word vector and |V| is the number of words in the knowledge word embedding V.
[0181] Step B2: Enhance the representation of the specified aspect through the aspect enhancement strategy to obtain the aspect enhancement vector E AE , the initial characterization vector E obtained in step B1 S and aspect enhancement vector E AE Input them into two different bidirectional long short-term memory networks respectively to obtain the user comment sentence representation vector H S and aspect-enhanced representation vector H AE .
[0182] The step B2 specifically comprises the following steps:
[0183] Step B21: Prune the syntactic dependency tree DT obtained in step B14 to perform aspect enhancement and obtain t context words connected to aspect a. Combining context cs with aspect a, we get aspect enhancement word ae, which is expressed as:
[0184]
[0185] in, is the ith word among the remaining words after the aspect enhancement word ae is segmented and the stop words are removed, i=1, 2, ..., m, and m is the number of words remaining after the aspect enhancement word ae is segmented and the stop words are removed.
[0186] Encode the aspect enhancement word ae to obtain the aspect enhancement vector E AE ;
[0187]
[0188] in, Indicates the i-th aspect enhancement word The corresponding word vector is obtained by using the pre-trained word vector matrix It can be found in , where d represents the dimension of the word vector and |V| is the number of words in the dictionary V.
[0189] Step B22: Initial representation vector E of user comment s S sequence Input the forward layer and reverse layer of the first bidirectional long short-term memory network in turn to obtain the state vector sequence of the forward hidden layer The state vector sequence of the reverse hidden layer in f is the activation function.
[0190] Concatenate to get the user comment representation vector “;” indicates a vector concatenation operation.
[0191] Step B23: Enhance the aspect vector Input the forward layer and reverse layer of the second bidirectional long short-term memory network in turn to obtain the forward hidden layer state vector sequence Reverse hidden state vector sequence in, f is the activation function. Concatenate and transpose to get the aspect enhancement representation vector H AE , “;” indicates a vector concatenation operation.
[0192] Step B3: Obtain the edge vector E of the comment sentence through the aspect enhancement strategy E , for H S and E E In terms of using the relational attention mechanism, we obtain the relational attention sentence representation vector E RA The step B3 specifically comprises the following steps:
[0193] Step B31: The edge relation syntactic dependency adjacency matrix B is pruned to retain only the context words directly connected to the given aspect words and their edge types. For aspects containing multiple words, the edge relation sequences of these k words directly connected are obtained respectively. The k-dimensional matrix is compressed into one dimension by adding rows, and the edge relationship sequence rs = {rs1, rs2, ..., rs n}. Initialize the edge type label sequence to obtain the edge vector E E ;
[0194]
[0195] in, Represents the edge vector corresponding to the i-th word.
[0196] Step B32: Opposite side vector E E And the user comment representation vector H obtained in step B22 S Use the relational attention mechanism to obtain the relational attention sentence representation vector The calculation process is as follows:
[0197]
[0198]
[0199]
[0200] in, represents the edge relationship vector between node i and aspect, Sentence representation vector representing relational attention, is a learnable weight matrix, is the bias vector.
[0201] Step B4: H AE Perform average pooling to obtain aspect representation vector For H S Perform position weighting to obtain the position-enhanced comment sentence representation vector H PS , by connecting and H PS , get the representation vector G S,0 The step B4 specifically comprises the following steps:
[0202] Step B41: Enhance the aspect representation vector H AE Perform average pooling operation and get The calculation formula is as follows:
[0203]
[0204] in,
[0205] Step B42: Characterize the user comment vector H s Perform position weighting to obtain the position-enhanced representation vector H of the user comment PS , H PS It is expressed as:
[0206]
[0207] in, Strengthen the representation vector for the position corresponding to the i-th word in the user comment s. “·” represents the multiplication of the vector and the real number. is the i-th word in user comment s The corresponding position weight is calculated as follows:
[0208]
[0209] Among them, i=1,2,...,n represents the position of the current word in the sentence, τ represents the position of the first word of aspect a in user comment s, and τ+m-1 represents the position of the last word of aspect a in user comment s.
[0210] Step B43: The average pooled aspect enhancement representation vector obtained in step B41 is and H obtained in step B42 PS Connect and get the representation vector g 0 , It is expressed as:
[0211]
[0212] in, is the representation vector corresponding to the i-th word in the user comment s, input into the graph convolutional network, i = 1, 2, ..., n, It is expressed as:
[0213]
[0214] in, “;” indicates a vector concatenation operation.
[0215] Step B5: Represent the vector G S,0 and the subgraph node representation vector H DKGThey are input into two different K-layer graph convolutional networks, denoted as comment sentence graph convolutional network SGCN and dependency tree knowledge graph convolutional network DKGGCN, respectively, to learn and extract syntactic dependencies and external knowledge. At the same time, each layer of the comment sentence graph convolutional network SGCN uses the dependency tree knowledge graph convolutional network DKGGCN to perform knowledge fusion through the knowledge interaction mechanism, and finally obtain the graph convolution representation vector G of user comments S,K The step B5 specifically comprises the following steps:
[0216] Step B51: For the dependency tree graph convolutional network DKGGCN, the subgraph node representation vector G DKG,0 Input the first layer of graph convolutional network and use the adjacency matrix A DKG Update the vector representation of each subgraph node and output G DKG,1 , and serves as the input of the next layer of graph convolutional network.
[0217] Among them, G DKG,1 It is expressed as:
[0218]
[0219] in, is the output of node i in the first layer of the graph convolutional network, The calculation formula is as follows:
[0220]
[0221]
[0222] in, is the weight matrix, is the bias term. DKG , b DKG are all learnable parameters. relu is the activation function. The node i in the graph convolutional network and the i-th word in the user comment Correspondingly, the edges between nodes in the graph convolutional network represent the knowledge connection relationship between words, d i represents the degree of node i, choose d i The +1 is used as a divisor to prevent the degree of node i from being 0, which would cause an operation error. The “;” indicates a vector connection operation.
[0223] Step B52: For the comment sentence graph convolution network SGCN, the comment sentence representation vector G S,0 Input the first layer of graph convolutional network and use the adjacency matrix A S Update the vector representation of each word and output G S,1 , through the knowledge interaction mechanism combined with the first layer output G of the dependency tree graph convolutional network DKGGCN DKG,1And generate the input G of the next layer of graph convolutional network SD,1 .
[0224] Among them, G S,1 , G SD,1 Respectively expressed as:
[0225]
[0226]
[0227] in, is the output of node i in the first layer of the graph convolutional network, The calculation formula is as follows:
[0228]
[0229]
[0230] in, is the weight matrix, is the bias term. S , are all learnable parameters. relu is the activation function. The node i in the graph convolutional network and the i-th word in the user comment Correspondingly, the edges between nodes in the graph convolutional network represent the syntactic dependencies between words in user comments, d i represents the degree of node i, choose d i The +1 is used as a divisor to prevent the degree of node i from being 0, which would cause an operation error. The “;” indicates a vector connection operation.
[0231] For the knowledge interaction mechanism, we first output G of the first layer of DKGGCN DKG,1 Perform truncation to retain the words in the current user comment sentence and obtain the first layer of knowledge representation of the SGCN node Next, the interactive attention mechanism is used to combine it with the first layer output G of SGCN S,1 Combined with the knowledge, we can further obtain the user review sentence representation G SD,1 .
[0232] Among them, G SD,1 It is expressed as:
[0233]
[0234] in, is the output of node i in the first layer of the SGCN graph convolutional network through the interaction mechanism, The calculation formula is as follows:
[0235]
[0236]
[0237]
[0238] in,(·) T represents the transpose operation, α i is the attention weight of the knowledge about the i-th word in the user review s.
[0239] Step B53: G DKG,1 and G SD,1 Input to the next layer of graph convolutional network of DKGGCN and SGCN, and repeat steps B51 and B52.
[0240] For DKGGCN, the output of the k-th layer graph convolutional network is As the input of the k+1th layer of graph convolutional network, the graph convolution representation vector is obtained after the iteration For SGCN, the output of the k-th layer graph convolutional network is G S,k G is obtained by the same knowledge interaction mechanism as described in step B52. SD,k , as the input of the k+1th layer of graph convolutional network, after the iteration, the graph convolution representation vector is obtained K is the number of layers of the graph convolutional network, 1≤k≤K.
[0241] Step B6: Convolution the graph representation vector G S,K Perform mask operation to obtain the graph convolution mask representation vector G of user comments mask , and then the comment sentence representation vector H S By using the cross attention mechanism, the model feature extraction capability is further improved to obtain the representation vector E SD The step B6 specifically comprises the following steps:
[0242] Step B61: G obtained in step B53 S,K Perform masking operation to shield the graph convolution output that does not belong to aspect words, and obtain the graph convolution mask representation vector G of user comments mask , the calculation process is as follows:
[0243] G mask ={0,...,g mask,τ ,...,g mask,τ+m-1 ,...,0}
[0244] Among them, 0 represents a zero vector with dimension 2d, τ represents the position of the first word of the aspect in the comment sentence, and g mask,τ The representation vector corresponding to the first word of the aspect, g mask,τ+m-1The representation vector corresponding to the last word of the aspect.
[0245] Step B62: The user comment representation vector H obtained in step B24 is S And the graph convolution mask representation vector G of the user comment obtained in step B61 mask Input the attention network, select important word-level information through the attention network, and obtain the sentence-level representation vector E of the user comment SD , the calculation formula is as follows:
[0246]
[0247]
[0248]
[0249] in,(·) T represents the transpose operation, ε i is the attention weight of the i-th word in user review s.
[0250] Step B7: To address the noise caused by irregular sentences, use the multi-head attention mechanism to SD And the relational attention sentence representation vector E obtained in step B3 RA Fusion obtains sentence representation E that aggregates external knowledge and edge relationships MT , and then through a gated fusion mechanism, the final representation vector E is obtained FIN The step B7 specifically comprises the following steps:
[0251] Step B71: Select an integer N that can divide d, and write the sentence-level representation vector E of the user comment SD And the relational attention sentence representation vector E obtained in step B32 RA Divide it into N sub-vectors evenly on the last dimension to get a sub-vector sequence and in is the sentence-level representation vector E SD The h-th subvector of is the relational attention sentence representation vector E RA The h-th subvector of .
[0252] Step B72: Transform the sentence-level representation vector E SD Each sub-vector of and the sentence-level representation vector e of the user comment w The corresponding subvectors in form a subvector pair, that is, The attention mechanism is used to calculate each sub-vector pair separately, and then concatenated and dimensionally reduced to obtain the sentence enhanced representation vector E of the user comment that integrates knowledge and edge relationships. MT, N is the number of heads of the multi-head attention mechanism. The calculation process of the multi-head attention mechanism is as follows:
[0253] l mt =2l / N
[0254]
[0255]
[0256] Among them, MHA represents the multi-head attention mechanism, Q, K, V represent the input vector of the multi-head attention mechanism, and Q represents the relational attention sentence representation vector E RA , K and V take the same value, both are the output E of the word-level attention mechanism SD . is the output vector calculated using the attention mechanism for the i-th sub-vector pair of Q, K, and V, N is the number of sub-vector pairs, that is, the number of heads of the multi-head attention mechanism, is the training parameter of the multi-head attention mechanism, is the linear transformation matrix that transforms the input vectors Q, K, V into the i-th sub-vector pair, l mt Represents the dimension of the last dimension of the subvector.
[0257] Step B73: To address the noise brought by irregular sentences to the model, the sentence representation vector E of user comments that integrate knowledge and edge relationships is enhanced MT Input the gating function to filter irrelevant information and obtain the vector E SDA , and then input into the multi-layer perceptron MLP to get the final sentence representation vector E FIN The specific calculation process is as follows:
[0258]
[0259]
[0260] Step B8: The final representation vector E FIN Input the final prediction layer, calculate the gradient of each parameter in the deep learning network model using the back propagation method according to the target loss function, and update each parameter using the stochastic gradient descent method.
[0261] Step B9: When the iterative change of the loss value generated by the deep learning network model is less than a given threshold or reaches the maximum number of iterations, the training process of the deep learning network model is terminated.
[0262] like Figure 3 As shown, this embodiment provides a comment sentiment analysis system for implementing the above method, including a data collection module, a preprocessing module, an encoding module, a network training module and a sentiment analysis module.
[0263] The data collection module is used to extract user comments, aspect words in the comments, and location information of aspect words, and to mark the sentiment polarity of the aspects to construct a training set.
[0264] The preprocessing module is used to preprocess the training samples in the training set, including word segmentation, removal of stop words, syntactic dependency parsing and dependency tree knowledge graph subgraph.
[0265] The encoding module is used to search for word vectors of words in preprocessed user comments and aspect enhancements in a pre-trained word vector matrix to obtain initial representation vectors of user comments and initial representation vectors of aspect enhancements, and to search for word vectors of nodes in a dependency tree knowledge graph subgraph in a pre-trained knowledge graph word vector matrix to obtain initial representation vectors of dependency tree knowledge graph subgraphs related to user comments.
[0266] The network training module is used to input the initial representation vectors of user comments, the initial representation vectors of aspects, and the initial representation vectors of dependency tree knowledge graph subgraphs into the deep learning network, obtain the final representation vectors of user comments and use them to train the deep learning network, use the probability that the representation vector belongs to a certain category and the annotations in the training set as the loss, and train the entire deep learning network with the goal of minimizing the loss, to obtain a deep learning network model based on the knowledge graph and interactive graph convolutional network.
[0267] The sentiment analysis module uses NLP tools to extract aspects from the input user comments, and then uses the trained deep learning network model based on the knowledge graph and interactive graph convolutional network to analyze and process the input user comments and aspects, and outputs the sentiment evaluation polarity involving specific aspects in the user comments.
[0268] The above is only a preferred embodiment of the present invention, and does not limit the present invention in other forms. Any technician familiar with the profession may use the above disclosed technical content to change or modify it into an equivalent embodiment with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the technical solution of the present invention still belongs to the protection scope of the technical solution of the present invention.
Claims
1. A comment sentiment analysis method based on knowledge graph and interactive graph convolution, characterized in that: The following steps are involved: Step A: Collect user comments, extract the aspect words of the product or service involved in the user comments, and mark the sentiment polarity of the user comments on the specific aspects of the product or service to construct the training set DS; Step B: Using the training set DS, train a deep learning network model G based on the knowledge graph and the interactive graph convolutional network to analyze the sentiment polarity of user comments on specific aspects of products or services; Step C: Input the user comments and the aspect words of the product or service involved in the user comments into the trained deep learning network model to obtain the sentiment polarity of the user comments for the specific aspects of the product or service; The step B specifically comprises the following steps: Step B1: Encode each training sample in the training set DS to obtain the initial representation vector E of the user comment S , the initial characterization vector E A And the syntactic dependency adjacency matrix A S At the same time, according to the dependency tree KG subgraph generation strategy, the corresponding subgraph DKG of user comments is generated from the knowledge graph to obtain its adjacency matrix A DKG , and then encode its nodes to get the node representation H of the subgraph DKG DKG ; Step B2: Enhance the representation of the specified aspect through the aspect enhancement strategy to obtain the aspect enhancement vector E AE , the initial characterization vector E obtained in step B1 S and aspect enhancement vector E AE Input them into two different bidirectional long short-term memory networks respectively to obtain the user comment sentence representation vector H S and aspect-enhanced representation vector H AE ; Step B3: Obtain the edge vector E of the comment sentence through the aspect enhancement strategy E , for H S and E E In terms of using the relational attention mechanism, we obtain the relational attention sentence representation vector E RA ; Step B4: H AE Perform average pooling to obtain aspect representation vector For H S Perform position weighting to obtain the position-enhanced comment sentence representation vector H PS , by connecting and H PS , get the representation vector G S,0 ; Step B5: Represent the vector G S,0 and the subgraph node representation vector H DKG The data are input into two different K-layer graph convolutional networks, denoted as comment sentence graph convolutional network SGCN and dependency tree knowledge graph convolutional network DKGGCN, respectively, to learn and extract syntactic dependencies and external knowledge. At the same time, each layer of the comment sentence graph convolutional network SGCN uses the dependency tree knowledge graph convolutional network DKGGCN to perform knowledge fusion through the knowledge interaction mechanism, and finally obtain the graph convolution representation vector G of user comments S,K ; Step B6: Convolution the graph representation vector G S,K Perform mask operation to obtain the graph convolution mask representation vector G of user comments mask , and then with the comment sentence representation vector H S Use the cross attention mechanism to further improve the model feature extraction capability and obtain the representation vector E SD ; Step B7: To address the noise caused by irregular sentences, use the multi-head attention mechanism to SD And the relational attention sentence representation vector E obtained in step B3 RA Fusion obtains sentence representation E that aggregates external knowledge and edge relationships MT , and then through a gated fusion mechanism, the final representation vector E is obtained FIN ; Step B8: The final representation vector E FIN Input the final prediction layer, calculate the gradient of each parameter in the deep learning network model using the back propagation method according to the target loss function, and update each parameter using the stochastic gradient descent method; Step B9: When the iterative change of the loss value generated by the deep learning network model is less than a given threshold or reaches the maximum number of iterations, the training process of the deep learning network model is terminated.
2. According to claim 1, the comment sentiment analysis method based on knowledge graph and interactive graph convolution is characterized in that: The step B1 specifically comprises the following steps: Step B11: traverse the training set DS, perform word segmentation on the user comments and aspects therein and remove stop words, and each training sample in DS is represented as ds = (s, a, p); Where s is the user comment, a is the aspect word or phrase of the product or service involved in the user comment extracted from the user comment s, and p is the sentiment polarity of the comment on the aspect, including {positive, negative, neutral}; User comments s are represented as: in, is the i-th word in the user comment s, i = 1, 2, ..., n, n is the number of words in the user comment s; Aspect a is represented by: in, is the i-th word in aspect a, i = 1, 2, ..., m′, m′ is the number of words in aspect a; Step B12: Get user comments on step B11 Encode and obtain the initial representation vector E of user comment s S ; Among them, E S It is expressed as: in, For the i-th word The corresponding word vector is obtained by using the pre-trained word vector matrix where d represents the dimension of the word vector and |V| is the number of words in the dictionary V; Step B13: Aspects obtained in step B11 Encode and obtain the initial representation vector E of aspect a A ; in, Represents the i-th word The corresponding word vector is obtained by using the pre-trained word vector matrix where d represents the dimension of the word vector and |V| is the number of words in the dictionary V; Step B14: Perform syntactic dependency parsing on the user comment s to obtain a syntactic dependency tree DT; in, Representation word w i and word w j There are syntactic dependencies between them; Step B15: Encode the parsed syntactic dependency tree DT into an n-order adjacency matrix A S , A S It is expressed as: Among them, A ij 1 represents word and words There is a syntactic dependency relationship between A and ij 0 represents the word and words There is no syntactic dependency between them; Step B16: Encode the parsed syntactic dependency tree DT into an n-order edge relationship adjacency matrix B, where B is expressed as: Among them, B ij A non-zero real number representation word and words There is a syntactic dependency relationship between them. The same syntactic dependency relationship is represented by the same non-zero real number. ij 0 represents the word and words There is no syntactic dependency between them; Step B17: Take each word node in the syntactic dependency tree DT as a seed node, take each seed node as a root node, expand the hop layer from the knowledge graph to generate child nodes, and select u nodes in each layer that have edge connections with the nodes in the previous layer in the knowledge graph as nodes of this layer, that is, each seed node has q = u hop+1 -1 expanded child node, and the total number of all nodes is z = n + n * q, and the dependency tree knowledge graph subgraph DKG is obtained; in, Representation word w i and word w j There is a syntactic dependency relationship between them. Expressive words Yes word The expansion node, Expressive words Yes word The extended child node of Step B18: Encode the dependency tree knowledge graph subgraph DKG into a z-order adjacency matrix A DKG , A DKG It is expressed as: Among them, A ij 1 represents word and words There is a syntactic dependency relationship between A and ij 0 represents the word and words There is no syntactic dependency between them; Step B19: Encode the nodes of the dependency tree knowledge graph subgraph DKG through knowledge graph embedding, and obtain its node representation as And used as the initial input of the dependency tree knowledge graph convolutional network DKGGCN in, For the i-th word The corresponding knowledge word vector is obtained by using the pre-trained knowledge word vector matrix It can be found in , where d represents the dimension of the knowledge word vector and |V| is the number of words in the knowledge word embedding V.
3. The comment sentiment analysis method based on knowledge graph and interactive graph convolution according to claim 2 is characterized in that: The step B2 specifically comprises the following steps: Step B21: Prune the syntactic dependency tree DT obtained in step B14 to perform aspect enhancement and obtain t context words connected to aspect a. Combining context cs with aspect a, we get aspect enhancement word ae, which is expressed as: in, is the i-th word among the remaining words after the aspect enhancement word ae is segmented and the stop words are removed, i=1,2,...,m, m is the number of words remaining after the aspect enhancement word ae is segmented and the stop words are removed; Encode the aspect enhancement word ae to obtain the aspect enhancement vector E AE ; in, Indicates the i-th aspect enhancement word The corresponding word vector is obtained by using the pre-trained word vector matrix where d represents the dimension of the word vector and |V| is the number of words in the dictionary V; Step B22: Initial representation vector E of user comment s S sequence Input the forward layer and reverse layer of the first bidirectional long short-term memory network in turn to obtain the state vector sequence of the forward hidden layer The state vector sequence of the reverse hidden layer in f is the activation function; concatenate to get the user comment representation vector ";" indicates a vector concatenation operation; Step B23: Enhance the aspect vector Input the forward layer and reverse layer of the second bidirectional long short-term memory network in turn to obtain the forward hidden layer state vector sequence Reverse hidden state vector sequence in, f is the activation function; concatenate and transpose to get the aspect enhancement representation vector H AE , ";" indicates a vector concatenation operation.
4. The comment sentiment analysis method based on knowledge graph and interactive graph convolution according to claim 3 is characterized in that: The step B3 specifically comprises the following steps: Step B31: The edge relation syntactic dependency adjacency matrix B is pruned to retain only the context words directly connected to the given aspect words and their edge types; for aspects containing multiple words, the edge relation sequences of these k words directly connected are obtained respectively. The k-dimensional matrix is compressed into one dimension by adding rows, and the edge relationship sequence rs = {rs1, rs2, ..., rs n }; Initialize the edge type label sequence to obtain the edge vector E E ; in, Represents the edge vector corresponding to the i-th word; Step B32: Opposite side vector E E and the user comment representation vector H obtained in step B22 S Use the relational attention mechanism to obtain the relational attention sentence representation vector The calculation process is as follows: in, represents the edge relationship vector between node i and aspect, Sentence representation vector representing relational attention, is a learnable weight matrix, is the bias vector.
5. The comment sentiment analysis method based on knowledge graph and interactive graph convolution according to claim 4 is characterized in that: The step B4 specifically comprises the following steps: Step B41: Enhance the aspect representation vector H AE Perform average pooling operation and get The calculation formula is as follows: in, Step B42: Characterize the user comment vector H s Perform position weighting to obtain the position-enhanced representation vector H of the user comment PS , H PS It is expressed as: in, Strengthen the representation vector for the position corresponding to the i-th word in the user comment s, is the i-th word in user comment s The corresponding position weight is calculated as follows: Where i=1,2,...,n represents the position of the current word in the sentence, τ represents the position of the first word of aspect a in user comment s, and τ+m-1 represents the position of the last word of aspect a in user comment s; Step B43: The average pooled aspect enhancement representation vector obtained in step B41 is and H obtained in step B42 PS Connect and get the representation vector g 0 , It is expressed as: in, is the representation vector corresponding to the i-th word in the user comment s, input into the graph convolutional network, i = 1, 2, ..., n, It is expressed as: in, ";" indicates a vector concatenation operation.
6. The comment sentiment analysis method based on knowledge graph and interactive graph convolution according to claim 5 is characterized in that: The step B5 specifically comprises the following steps: Step B51: For the dependency tree graph convolutional network DKGGCN, the subgraph node representation vector G DKG,0 Input the first layer of graph convolutional network and use the adjacency matrix A DKG Update the vector representation of each subgraph node and output G DKG,1 , and used as the input of the next layer of graph convolutional network; Among them, G DKG,1 It is expressed as: in, is the output of node i in the first layer of the graph convolutional network, The calculation formula is as follows: in, is the weight matrix, is the bias term; W DKG , b DKG are all learnable parameters; relu is the activation function; node i in the graph convolutional network and the i-th word in the user comment Correspondingly, the edges between nodes in the graph convolutional network represent the knowledge connection relationship between words, d i represents the degree of node i, choose d i +1 is used as the divisor to prevent the degree of node i from being 0, which may cause calculation errors; Step B52: For the comment sentence graph convolution network SGCN, the comment sentence representation vector G S,0 Input the first layer of graph convolutional network and use the adjacency matrix A S Update the vector representation of each word and output G S,1 , through the knowledge interaction mechanism combined with the first layer output G of the dependency tree graph convolutional network DKGGCN DKG,1 And generate the input G of the next layer of graph convolutional network SD,1 ; Among them, G S,1 , G SD,1 Respectively expressed as: in, is the output of node i in the first layer of the graph convolutional network, The calculation formula is as follows: in, is the weight matrix, is the bias term; W S , are all learnable parameters; relu is the activation function; node i in the graph convolutional network and the i-th word in the user comment Correspondingly, the edges between nodes in the graph convolutional network represent the syntactic dependencies between words in user comments, d i represents the degree of node i, choose d i +1 is used as a divisor to prevent the degree of node i from being 0, which may cause an operation error. ";" indicates a vector connection operation. For the knowledge interaction mechanism, we first output G of the first layer of DKGGCN DKG,1 Perform truncation to retain the words in the current user comment sentence and obtain the first layer of knowledge representation of the SGCN node Next, the interactive attention mechanism is used to combine it with the first layer output G of SGCN S,1 Combined with the knowledge, we can further obtain the user review sentence representation G SD,1 ; Among them, G SD,1 It is expressed as: in, is the output of node i in the first layer of the SGCN graph convolutional network through the interaction mechanism, The calculation formula is as follows: in,(·) T represents the transpose operation, α i is the attention weight of the knowledge about the i-th word in the user comment s; Step B53: G DKG,1 and G SD,1 Input to the next layer of graph convolutional network of DKGGCN and SGCN, and repeat steps B51 and B52; For DKGGCN, the output of the k-th layer graph convolutional network is As the input of the k+1th layer of graph convolutional network, the graph convolution representation vector is obtained after the iteration For SGCN, the output of the k-th layer graph convolutional network is G S,k G is obtained by the same knowledge interaction mechanism as described in step B52. SD,k , as the input of the k+1th layer of graph convolutional network, after the iteration, the graph convolution representation vector is obtained K is the number of layers of the graph convolutional network, 1≤k≤K.
7. The comment sentiment analysis method based on knowledge graph and interactive graph convolution according to claim 6 is characterized in that: The step B6 specifically comprises the following steps: Step B61: G obtained in step B53 S,K Perform masking operation to shield the graph convolution output that does not belong to aspect words, and obtain the graph convolution mask representation vector G of user comments mask , the calculation process is as follows: G mask ={0,...,g mask,τ ,...,g mask,τ+m-1 ,...,0} Among them, 0 represents a zero vector with dimension 2d, τ represents the position of the first word of the aspect in the comment sentence, and g mask,τ The representation vector corresponding to the first word of the aspect, g mask,τ+m-1 The representation vector corresponding to the last word of the aspect; Step B62: The user comment representation vector H obtained in step B24 is S And the graph convolution mask representation vector G of the user comment obtained in step B61 mask Input the attention network, select important word-level information through the attention network, and obtain the sentence-level representation vector E of the user comment SD , the calculation formula is as follows: in,(·) T represents the transpose operation, ε i is the attention weight of the i-th word in user review s.
8. The comment sentiment analysis method based on knowledge graph and interactive graph convolution according to claim 7 is characterized in that: The step B7 specifically includes the following steps: Step B71: Select an integer N that can divide d, and write the sentence-level representation vector E of the user comment SD And the relational attention sentence representation vector E obtained in step B32 RA Divide it into N sub-vectors evenly on the last dimension to get a sub-vector sequence and in is the sentence-level representation vector E SD The h-th subvector of is the relational attention sentence representation vector E RA The h-th subvector of ; Step B72: Transform the sentence-level representation vector E SD Each sub-vector of and the sentence-level representation vector e of the user comment w The corresponding subvectors in form a subvector pair, that is, The attention mechanism is used to calculate each sub-vector pair separately, and then concatenated and dimensionally reduced to obtain the sentence enhanced representation vector E of the user comment that integrates knowledge and edge relationships. MT , N is the number of heads of the multi-head attention mechanism. The calculation process of the multi-head attention mechanism is as follows: l mt =2l / N Among them, MHA represents the multi-head attention mechanism, Q, K, V represent the input vector of the multi-head attention mechanism, and Q represents the relational attention sentence representation vector E RA , K and V take the same value, both are the output E of the word-level attention mechanism SD ; is the output vector calculated using the attention mechanism for the i-th sub-vector pair of Q, K, and V, N is the number of sub-vector pairs, that is, the number of heads of the multi-head attention mechanism, is the training parameter of the multi-head attention mechanism, is the linear transformation matrix that transforms the input vectors Q, K, V into the i-th sub-vector pair, l mt Represents the dimension of the last dimension of the sub-vector; Step B73: To address the noise brought by irregular sentences to the model, the sentence representation vector E of user comments that integrate knowledge and edge relationships is enhanced MT Input the gating function to filter irrelevant information and obtain the vector E SDA , and then input into the multi-layer perceptron MLP to get the final sentence representation vector E FIN ; The specific calculation process is as follows:
9. A comment sentiment analysis system using the method according to any one of claims 1 to 8, characterized in that: include: The data collection module is used to extract user comments, aspect words in comments, and the location information of aspect words, and to annotate the sentiment polarity of aspects to construct a training set; The preprocessing module is used to preprocess the training samples in the training set, including word segmentation, stop word removal, syntactic dependency parsing, and dependency tree knowledge graph subgraph; The encoding module is used to search the word vectors of the preprocessed user comments and the words in the aspect enhancement in the pre-trained word vector matrix to obtain the initial representation vectors of the user comments and the initial representation vectors of the aspect enhancement, and to search the word vectors of the nodes in the dependency tree knowledge graph subgraph in the pre-trained knowledge graph word vector matrix to obtain the initial representation vectors of the dependency tree knowledge graph subgraph related to the user comments; The network training module is used to input the initial representation vector of the user comments, the initial representation vector of the aspects, and the initial representation vector of the dependency tree knowledge graph subgraph into the deep learning network to obtain the final representation vector of the user comments and use it to train the deep learning network. The probability that the representation vector belongs to a certain category and the annotations in the training set are used as the loss. The entire deep learning network is trained with the goal of minimizing the loss to obtain a deep learning network model based on the knowledge graph and the interactive graph convolutional network. as well as The sentiment analysis module uses NLP tools to extract aspects from the input user comments, and then uses the trained deep learning network model based on knowledge graph and interactive graph convolutional network to analyze and process the input user comments and aspects, and outputs the sentiment evaluation polarity involving specific aspects in the user comments.
Citation Information
Patent Citations
Aspect-level user product comment emotion analysis method and system
CN111274398A
Emotion classification system based on Chinese syntax and graph convolutional neural network
CN112001187A