Aspect-level sentiment analysis method based on semantic and syntactic relation graph convolution
By combining the self-attention mechanism and the aspect distance attention mechanism, we construct an aspect distance matrix, and design a multi-level syntactic relationship matrix. Combined with the graph neural convolution network, we solve the problem of difficulty in capturing long-distance dependencies and grammatical information in the existing technology. , improves the accuracy of aspect-level sentiment analysis.
Patent Information
- Application Number
- CN202410790743.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-06-18
AI Technical Summary
The existing technology is difficult to effectively capture long-range dependencies and grammatical information in aspect-level sentiment analysis, making it difficult to correctly capture related emotional words when emotional items are separated from emotional polarity, and syntactic structure information is ignored.
Using a method based on semantic and syntactic relationship graph convolution, the aspect distance matrix is constructed through the self-attention mechanism and the aspect distance attention mechanism, a new dependency tree is designed and a multi-order syntactic relationship matrix is constructed, and the graph neural convolution network is combined to integrate features. This enriches the expressive capabilities of the sentiment analysis model.
It provides more effective semantic and syntactic information, improves the accuracy of aspect-level sentiment analysis, and can better utilize syntactic structure and semantic information to classify the sentiment polarity of aspect items.
Smart Images

Figure CN118643154A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of sentiment analysis, and in particular to an aspect-level sentiment analysis method based on semantic and syntactic relationship graph convolution. Background Art
[0002] Sentiment analysis (SA) is a very popular topic in natural language processing (NLP) and is used to predict the sentiment polarity of a sentence. However, in real-world scenarios, a sentence may have multiple aspect items, which is difficult to handle with traditional sentence-level sentiment analysis. Therefore, the aspect-level sentiment analysis task is proposed. Aspect-based sentiment analysis (ABSA, also known as aspect-level sentiment analysis) aims to determine the sentiment polarity of a given aspect item in a sentence.
[0003] Aspect-level sentiment analysis is to determine the different sentiment polarities corresponding to different aspect items in a sentence. For the ABSA task, current research uses recurrent neural networks (RNNs) to model aspect words in sentences and their corresponding sentiment polarities. However, due to the limitations of RNNs, it is impossible to capture long-distance dependencies and grammatical information may be lost.
[0004] Recent studies have found that attention-based neural networks can effectively solve the problem of semantic relevance between aspect terms and context in aspect-level sentiment analysis. For example, Wang et al. used attention-based LSTM to extract semantic information related to aspect terms and judge sentiment polarity. Ma et al. used an interactive attention mechanism to represent aspect words and context words. In addition, grammatical knowledge can also be used to improve ABSA tasks. Dong et al. proposed an adaptive recursive neural network that relies on dependency trees to propagate sentiment. He et al. combined dependency trees with attention mechanisms to calculate the weight information of context words. Zhang and Sun et al. used graph convolutional networks (GCNs) to extract rich node information on dependency trees for sentiment classification. In response to the shortcomings of RNNs, attention mechanisms and gating mechanisms have been proposed to alleviate long-distance dependencies. However, the above methods still lack effective use of syntactic information. When sentiment terms are separated from sentiment polarity, it is difficult to correctly capture related sentiment words. There is still a lack of use of syntactic structure information. Most of them only consider the relevant node information near the current node, ignoring the semantic information and syntactic structure information related to aspect terms of other nodes. Moreover, in a sentence, some sentences vaguely express the sentiment of the aspect words without direct syntactic relationship. Therefore, considering only the semantic information and syntactic structure of the dependency tree is still insufficient. Summary of the invention
[0005] In order to expand the syntactic structure information and integrate the semantic information, the present invention provides an aspect-level sentiment analysis method based on semantic and syntactic relationship graph convolution, which fully considers the semantic information and syntactic structure information related to different aspect terms, thereby being able to better utilize the syntactic structure and semantic information to classify the sentiment polarity of aspect items.
[0006] The aspect-level sentiment analysis method based on semantic and syntactic relationship graph convolution provided by the present invention includes:
[0007] Step 1: Input the dataset to be analyzed into the encoding layer to obtain the sentence embedding and corresponding aspect item embedding of each sentence;
[0008] Step 2: Input the sentence embedding and the aspect item embedding into the semantic information layer to obtain the overall semantic information; wherein the semantic information layer includes a self-attention mechanism module and an aspect distance attention mechanism module;
[0009] Step 3: Input the data set to be analyzed into the multi-order syntactic relationship layer to obtain a multi-order syntactic relationship matrix; wherein the multi-order syntactic relationship layer includes a dependency parser;
[0010] Step 4: The overall semantic information and multi-order syntactic relationship matrix are fused and input into the graph convolutional neural network to extract the feature vectors of sentences and aspect items;
[0011] Step 5: The feature vectors of sentences and aspect items are sequentially passed through the average pooling layer and the softmax activation function to obtain the sentiment polarity of each aspect item.
[0012] Furthermore, step 1 specifically includes:
[0013] Step 1.1: For any sentence s in the dataset to be analyzed, n}, extract the aspect item a in the sentence = {a1, a2, ..., a m}, and save the sentiment word position corresponding to the aspect item; where n represents the number of words in the sentence, and m represents the number of aspect words in n words;
[0014] Step 1.2: Use CoreNLP dependency parser to extract the dependencies between words in the sentence;
[0015] Step 1.3: Construct sentence-aspect pairs according to dependencies as the input sequence of the encoding layer to obtain sentence embeddings and aspect term embeddings.
[0016] Furthermore, step 2 specifically includes:
[0017] Step 2.1: Feed the sentence embedding into the self-attention module to obtain the attention score Then the global semantic information of the sentence is obtained; where j represents the jth sentence in the data set to be analyzed;
[0018]
[0019] Where Q and K represent any two word embeddings in the sentence embedding; W represents the learnable weight, and d represents the feature dimension of the word embedding;
[0020] Step 2.2: Input sentence embedding and aspect item embedding into the aspect distance attention mechanism module to obtain global semantic information related to the aspect and local semantic information related to aspects Then we get the aspect distance matrix
[0021]
[0022] Among them, tanh and softmax are both activation functions, H a The hidden state vector representing the aspect item, W a represents the learnable weight, P represents the hidden state vector of the sentence, b represents the bias term, T represents the transposition, S j represents the shortest distance between context words and aspect words, and R represents the distance threshold between context words and aspect words;
[0023] Step 2.3: Combine the global semantic information of the sentence with the aspect distance matrix to obtain the overall semantic information D j ;
[0024] Furthermore, step 3 specifically includes:
[0025] Step 3.1: For any sentence in the dataset to be analyzed, use the CoreNLP dependency parser to get the original dependency tree of the sentence;
[0026] Step 3.2: Take the aspect word as the root node, and take the word nodes in the original dependency tree that have a direct relationship with the aspect word as the first level of the new dependency tree; establish a new connection between the word nodes in the original dependency tree that have no direct relationship with the aspect word but have a direct relationship with the word nodes in the first level and the aspect word, and take the new connection as the second level of the new dependency tree, and so on to obtain a new dependency tree containing n levels; n is an integer not less than 3;
[0027] Step 3.3: Convert the new dependency tree into an n-order syntactic relation matrix.
[0028] Beneficial effects of the present invention:
[0029] (1) The self-attention mechanism and the aspect distance attention mechanism are combined to construct the aspect distance matrix to integrate the semantic information of the sentence, thereby providing more effective semantic information for aspect-level sentiment analysis.
[0030] (2) A new dependency tree is designed, in which the direct dependency relationships between aspect words and context words at different levels are added, and a multi-order syntactic relationship matrix is constructed based on the new dependency tree, thereby providing more effective syntactic information for aspect-level sentiment analysis.
[0031] (3) A graph neural convolutional network is used to integrate the features extracted from the aspect distance matrix and the multi-order syntactic relationship matrix, thereby enriching the expressive power of the entire aspect-level sentiment analysis model. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 The overall architecture diagram of the aspect-level sentiment analysis method based on semantic and syntactic relationship graph convolution provided by the embodiment of the present invention;
[0033] Figure 2 A flowchart of an aspect-level sentiment analysis method based on semantic and syntactic relationship graph convolution provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] Combination Figure 1 and Figure 2 As shown, an embodiment of the present invention provides an aspect-level sentiment analysis method based on semantic and syntactic relationship graph convolution, comprising the following steps:
[0036] S101: preprocessing the data set to be analyzed, and inputting the preprocessed data set into the encoding layer to obtain the sentence embedding of each sentence and the corresponding aspect item embedding;
[0037] Specifically, taking any sentence s in the data set to be analyzed as an example, this step specifically includes the following sub-steps:
[0038] S1011: Assume that sentence s = {s1, s2, ..., s n}, extract the aspect item a in the sentence = {a1, a2, ..., a m}, and save the sentiment word position corresponding to the aspect item; where n represents the number of words in the sentence, and m represents the number of aspect words in n words;
[0039] S1012: Use CoreNLP dependency parser to extract dependencies between words in a sentence;
[0040] S1013: Construct sentence aspect pairs (such as [CLS]+s+[SEP]+a+[SEP]) according to the dependency relationship as the input sequence of the encoding layer to obtain sentence embedding and aspect item embedding.
[0041] S102: Inputting sentence embedding and aspect item embedding into a semantic information layer to obtain overall semantic information; wherein the semantic information layer includes a self-attention mechanism module and an aspect distance attention mechanism module;
[0042] Specifically, this step includes the following sub-steps:
[0043] S1021: Input the sentence embedding into the self-attention mechanism module to obtain the attention score Then the global semantic information of the sentence is obtained; where j represents the jth sentence in the data set to be analyzed;
[0044]
[0045] Where Q and K represent any two word embeddings in the sentence embedding; W represents the learnable weight, and d represents the feature dimension of the word embedding;
[0046] S1022: Input the sentence embedding and aspect item embedding into the aspect distance attention mechanism module to obtain global semantic information related to the aspect and local semantic information related to aspects Then we get the aspect distance matrix
[0047]
[0048] Among them, tanh and softmax are both activation functions, H a The hidden state vector representing the aspect item, W a represents the learnable weight, P represents the hidden state vector of the sentence, b represents the bias term, T represents the transposition, S j represents the shortest distance between context words and aspect words, and R represents the distance threshold between context words and aspect words;
[0049] S1023: Combine the global semantic information of the sentence and the aspect distance matrix to obtain the overall semantic information D j ;
[0050] S103: Inputting the preprocessed data set to be analyzed into a multi-order syntactic relationship layer to obtain a multi-order syntactic relationship matrix; wherein the multi-order syntactic relationship layer includes a dependency parser;
[0051] Specifically, this step includes the following sub-steps:
[0052] S1031: For any sentence in the data set to be analyzed, use the CoreNLP dependency parser to obtain the original dependency tree of the sentence;
[0053] S1032: taking the aspect word as the root node, taking the word nodes in the original dependency tree that are directly related to the aspect word as the first level of the new dependency tree; establishing new connections between the word nodes in the original dependency tree that are not directly related to the aspect word but are directly related to the word nodes in the first level and the aspect word, and taking the new connections as the second level of the new dependency tree, and so on to obtain a new dependency tree containing n levels; n is an integer not less than 3;
[0054] Specifically, the connection between the word nodes of the first level and the aspect words is uniformly recorded as a first-order relationship, the connection between the word nodes of the second level and the aspect words is uniformly recorded as a second-order relationship, and so on, the connection between the word nodes of the nth level and the aspect words is uniformly recorded as an n-order relationship. In this embodiment, n=3, that is, the context words with a connection with the aspect words exceeding the third order in the original dependency tree are considered to have no relationship with the aspect words and are discarded, thereby achieving the purpose of simplifying the dependency tree and removing interference.
[0055] S1033: Use a dependency parsing tool (such as Stanford Parser) to convert the new dependency tree into an n-order syntactic relationship matrix, where n=3.
[0056] S104: The overall semantic information and the multi-order syntactic relationship matrix are fused and input into the graph convolutional neural network GCN to extract the feature vectors of sentences and aspect items;
[0057] S105: The feature vectors of the sentences and aspect items are sequentially passed through an average pooling layer and a softmax activation function to obtain the sentiment polarity of each aspect item.
[0058] Specifically, the feature vector output by the graph convolutional neural network is and The data is input into the pooling layer for average pooling operation, and then the output after the average pooling operation is input into the activation function softmax to obtain the relevant emotional polarity.
[0059] It can be understood that the aspect-level sentiment analysis model proposed in the present invention mainly includes an encoding layer, a semantic information layer, a multi-order syntactic relationship layer, a GCN, an average pooling layer and a softmax layer. The model needs to be trained with training data before it has corresponding functions.
[0060] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. Aspect-level sentiment analysis method based on semantic and syntactic relationship graph convolution, characterized by: include: Step 1: Input the dataset to be analyzed into the encoding layer to obtain the sentence embedding and corresponding aspect item embedding of each sentence; Step 2: Input the sentence embedding and the aspect item embedding into the semantic information layer to obtain the overall semantic information; wherein the semantic information layer includes a self-attention mechanism module and an aspect distance attention mechanism module; Step 3: Input the data set to be analyzed into the multi-order syntactic relationship layer to obtain a multi-order syntactic relationship matrix; wherein the multi-order syntactic relationship layer includes a dependency parser; Step 4: The overall semantic information and multi-order syntactic relationship matrix are fused and input into the graph convolutional neural network to extract the feature vectors of sentences and aspect items; Step 5: The feature vectors of sentences and aspect items are sequentially passed through the average pooling layer and the softmax activation function to obtain the sentiment polarity of each aspect item.
2. The aspect-level sentiment analysis method based on semantic and syntactic relationship graph convolution according to claim 1 is characterized in that: Step 1 specifically includes: Step 1.1: For any sentence s={s1,s2,...,s n }, extract the aspect item a in the sentence = {a1, a2, ..., a m }, and save the sentiment word position corresponding to the aspect item; where n represents the number of words in the sentence, and m represents the number of aspect words in n words; Step 1.2: Use CoreNLP dependency parser to extract the dependencies between words in the sentence; Step 1.3: Construct sentence-aspect pairs according to dependencies as the input sequence of the encoding layer to obtain sentence embeddings and aspect term embeddings.
3. The aspect-level sentiment analysis method based on semantic and syntactic relationship graph convolution according to claim 1 is characterized in that: Step 2 specifically includes: Step 2.1: Feed the sentence embedding into the self-attention module to obtain the attention score Then the global semantic information of the sentence is obtained; where j represents the jth sentence in the data set to be analyzed; Where Q and K represent any two word embeddings in the sentence embedding; W represents the learnable weight, and d represents the feature dimension of the word embedding; Step 2.2: Input sentence embedding and aspect item embedding into the aspect distance attention mechanism module to obtain global semantic information related to the aspect and local semantic information related to aspects Then we get the aspect distance matrix Among them, tanh and softmax are both activation functions, H a The hidden state vector representing the aspect item, W a represents the learnable weight, P represents the hidden state vector of the sentence, b represents the bias term, T represents the transposition, S j represents the shortest distance between context words and aspect words, and R represents the distance threshold between context words and aspect words; Step 2.3: Combine the global semantic information of the sentence with the aspect distance matrix to obtain the overall semantic information D j ; 4. The aspect-level sentiment analysis method based on semantic and syntactic relationship graph convolution according to claim 1 is characterized in that: Step 3 specifically includes: Step 3.1: For any sentence in the dataset to be analyzed, use the CoreNLP dependency parser to get the original dependency tree of the sentence; Step 3.2: Take the aspect word as the root node, and take the word nodes in the original dependency tree that have a direct relationship with the aspect word as the first level of the new dependency tree; establish a new connection between the word nodes in the original dependency tree that have no direct relationship with the aspect word but have a direct relationship with the word nodes in the first level and the aspect word, and take the new connection as the second level of the new dependency tree, and so on to obtain a new dependency tree containing n levels; n is an integer not less than 3; Step 3.3: Convert the new dependency tree into an n-order syntactic relation matrix.
Citation Information
Patent Citations
Aspect-level sentiment analysis method and device based on syntax and graph convolutional network
CN114417823A
Information classification extraction method, apparatus, computer device and storage medium
WO2021042503A1
Cited By
Aspect-level sentiment analysis method based on double-branch graph structure
CN122713256A
