Aspect-level sentiment analysis method based on structured tree and aspect word relation
By constructing an aspect-level sentiment analysis network based on structured trees and aspect word relationships, the problem of lack of interaction between semantic representation and syntactic constraints is solved, improving the accuracy of sentiment analysis and the robustness of the network, especially its ability to analyze in multi-aspect co-occurrence contexts.
Patent Information
- Application Number
- CN202511098555.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-06
- Publication Date
- 2025-11-21
AI Technical Summary
Existing methods have failed to effectively construct an interaction mechanism between semantic representation and syntactic constraints in sentiment analysis, resulting in the fusion of semantic representation and syntactic structure remaining at a superficial level. Furthermore, in situations where multiple aspects co-occur, they neglect the emotional consistency or contrast between different aspects, hindering the effective mining and utilization of cross-faceted emotional cues by the network.
An aspect-level sentiment analysis method based on structured trees and aspect word relationships is adopted. By constructing a sentiment analysis network, optimizing the global aspect word feature network and sentiment classification network, and combining semantically enhanced graph neural network and syntactically enhanced graph neural network, semantic and syntactic features are fused. Furthermore, a multi-head attention network is used to capture the interaction relationships between aspect words and dynamically correct aspect word features.
It improves the accuracy of sentiment analysis and the robustness of the network, especially its ability to analyze in complex contexts, and achieves high-accuracy aspect-level sentiment classification.
Smart Images

Figure CN120996029A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of natural language processing and deep learning, and particularly relates to a sentiment analysis method and a full-supervised learning method. BACKGROUND
[0002] With the rapid development of social networks, the Internet is flooded with massive user-generated texts, which contain users' attitudes. However, the complexity and timeliness of massive data make it difficult to quickly and accurately capture and analyze the sentiment tendency and intensity in the text, resulting in ambiguous sentiment direction and missing key information when analyzing public opinion events involving multiple entities and multiple viewpoints, which seriously restricts the accuracy and timeliness of public opinion insight.
[0003] On the technical level, the existing method has two significant shortcomings: first, it fails to build an effective interaction mechanism between semantic representation and syntactic constraints, resulting in a shallow fusion of semantic representation and syntactic structure, which makes it difficult to fully explore the deep emotional logic of the text; second, in the context of multiple co-occurrences, existing researches mostly use independent aspect modeling methods, ignoring the potential emotional consistency or contrast relationship between different aspects, which hinders the effective mining and utilization of cross-aspect emotional clues. In order to solve the above problems, an aspect-level sentiment analysis method based on structured tree and aspect-word relationship is developed.
[0004] In the field of aspect-level sentiment analysis, one of the technical problems that needs to be urgently solved is to provide an analysis method with high classification accuracy for complex texts and strong network robustness. SUMMARY
[0005] The technical problem to be solved by the application is to overcome the shortcomings of the prior art and provide an aspect-level sentiment analysis method based on structured tree and aspect-word relationship with high classification accuracy for different aspects and strong network robustness.
[0006] The technical solution adopted to solve the above technical problems is as follows:
[0007] (1) Obtain a data set
[0008] Download the SemEval-2014 Task 4 data set from the official website https: / / alt.qcri.org / semeval2014 / task4 / , including the Restaurant data set and the Laptop data set. Both data sets contain more than 3K English sentences, each containing single or at least two aspects of sentiment classification words, which are labeled using XML tags. 2579 data are selected from the Restaurant data set, containing 4727 aspect words, and 1863 data are selected from the Laptop data set, containing 2875 aspect words.
[0009] The MAMS dataset is downloaded from the official website https: / / github.com / siat-nlp / MAMS-for-ABSA, which contains 8879 English sentences, each containing at least two aspect sentiment classification words, and 5297 data are selected, containing 13854 aspect words.
[0010] (2) Divide the dataset
[0011] The Restaurant dataset is divided into training set and test set, the training set contains 1980 data, and the test set contains 599 data; the Laptop dataset is divided into training set and test set, the training set contains 1454 data, and the test set contains 409 data; the MAMS dataset is divided into training set, validation set and test set, the training set contains 4297 data, the validation set contains 500 data, and the test set contains 500 data.
[0012] (3) Extract text features
[0013] Input text sequence seq and aspect word As set:
[0014] seq=(w1,w2,…,w n )
[0015] As={a1,a2,…,a t}
[0016] Where w n represents a word in the word sequence, n is the length of the text, n∈[1,100], a t represents the target aspect word, and t represents the number of aspect words.
[0017] Use the start symbol [CLS] and the interval symbol [SEP] to construct the input sequence ([CLS], seq, [SEP], a t , [SEP]), and use the pre-trained BERT model to extract features from the input sequence.
[0018] (4) Construct sentiment analysis network
[0019] The sentiment analysis network is composed of a global aspect word feature optimization network and a sentiment classification network in series.
[0020] The global aspect word feature optimization network is composed of a single aspect word feature optimization network and a global aspect word relationship extraction network in parallel, and a multi-head attention network in series.
[0021] (5) Train the sentiment analysis network
[0022] 1) Construct the loss function
[0023] The loss Loss is constructed as follows:
[0024]
[0025] where s represents the sentence number, S represents the number of sentences, m represents the aspect word number, t represents the number of aspect words in a sentence, y sm represents the sentiment label of the aspect word in the training set, y sm ∈{0,1,2}, represents the sentiment prediction of the aspect word in the training set, 0 represents positive, 1 represents neutral, and 2 represents negative.
[0026] 2) Training the sentiment analysis network
[0027] The training set is input into the sentiment analysis network for training, and the training parameters are as follows: the training batch size is 32, the number of iterations is 20, the server is GTX 3090, the optimizer is Adam optimizer, the learning rate is 3×10 -5 , the regularization rate is 4×10 -4 , and the training is performed until the loss function Loss converges.
[0028] (6) Testing the sentiment analysis network
[0029] The test set is input into the trained sentiment analysis network for testing, and the sentiment probability of the user aspect word is output.
[0030] (7) Identifying the sentiment polarity of aspect words
[0031] The extracted text features are input into the trained sentiment analysis network, and a full connection layer and a Softmax layer are used for regression to obtain the probability values of different sentiment categories: the positive probability p pos , p pos ∈[0,1], the neutral probability p neu , p neu ∈[0,1], the negative probability p neg , p neg ∈[0,1], and p pos +p neu +p neg =1.
[0032] The aspect sentiment category is predicted as follows:
[0033]
[0034] p t =(p pos ,p neu ,p neg )
[0035] where, argmax(·) represents selecting the element corresponding to the maximum value in the probability distribution as the result.
[0036] In step (4) of constructing the sentiment analysis network of the present application, the one-sided word feature optimization network is connected to the output of the semantic enhancement graph neural network and the syntactic enhancement graph neural network and the semantic-syntactic fusion layer.
[0037] The semantic enhancement graph neural network of the present application is connected to the output of the semantic enhancement network and the graph relationship network and the graph attention network 1 network.
[0038] The semantic enhancement network of the present application is connected in series to the sentiment dictionary feature extraction layer and the context feature fusion layer.
[0039] The graph relationship network of the present application is connected in series to the syntactic feature extraction layer 2 and the structured layer.
[0040] In step (4) of constructing the sentiment analysis network of the present application, the construction method of the one-sided word feature optimization network is as follows:
[0041] 1) Construction method of the semantic enhancement network
[0042] The sentiment dictionary features E' are obtained according to formula (1):
[0043] E' = E x W e +b e (1)
[0044]
[0045] wherein E represents the initial feature matrix of the sentiment dictionary, the dimension of E is n x 3, that is, each word in the text corresponds to three scores: sc pos,n represents the positive score, sc pos,n ∈ [0, 1], sc obj,n represents the objective score, sc obj,n ∈ [0, 1], sc neg,n represents the negative score, sc neg,n ∈ [0, 1], and sc pos,n + sc obj,n + sc neg,n = 1, n represents the length of the sentence, n ∈ [1, 100], the dimension of E' is n x D1, D1 represents the dimension of the hidden layer, W e is a weight matrix of 3 x D1, b e represents a parameter, and is a bias term of D1 dimension.
[0046] The text features are enhanced according to the following formula:
[0047] H' = G E' + (1 - G) O H
[0048] G = σ(concat(H, E') x W g + b g )
[0049] where G represents the gating value of the text feature and the sentiment feature, G e [0, 1], H represents the text feature output by the BERT model, the dimension of H is n x D1, O represents element-wise multiplication, σ(·) represents the sigmoid function, concat(·) represents the concatenation operation, W g is a 2D1x D1dimensional weight matrix, and b g is a 2D1dimensional bias term.
[0050] 2) Construction method of graph relationship network
[0051] Download the toolkit as a constituent phrase parser from https: / / github.com / yzhangcs / crfpar, and obtain the constituent structure tree parsing result Y according to the following formula:
[0052] Y = (V ori ,E ori )
[0053] V ori = {v1, v2, …, v ζ}
[0054] E ori = {e1, e2, …, e ξ}
[0055] where V ori represents the node set contained in the constituent structure tree, v ζ represents the node in the constituent structure tree, E ori represents the edge set contained in the constituent structure tree, and e ξ represents the edge in the constituent structure tree.
[0056] Generate the tertiary structure tree node set V Υ according to formula (2):
[0057] V Υ = C Υ P Υ ∪ W Υ (2)
[0058] C Υ = {c1, c2, …, c α}
[0059] P Υ = {p1, p2, …, pβ}
[0060] W Υ ={w1,w2,…,w n}
[0061] wherein C Υ represents a set of clause nodes in the constituent structure tree, c α represents a clause node in the constituent structure tree, c α ∈V ori , α represents a number of clause nodes, α ∈ [1, 10], P Υ represents a set of phrase nodes in the constituent structure tree, p β represents a phrase node in the constituent structure tree, p β ∈V ori , β represents a number of phrase nodes, β ∈ [1, 100], W Υ represents a set of word nodes in the constituent structure tree, w n represents a word node.
[0062] The set of edges E Υ of the three-level structure tree is generated according to the following formula:
[0063]
[0064]
[0065] wherein, represents an edge with a source node being a clause node c1 and a target node being a phrase node p θ , represents an edge with a source node being a clause node c2 and a target node being a phrase node , represents an edge with a source node being a clause node c α and a target node being a phrase node p β , represents an edge with a source node being a phrase node p1 and a target node being a word node w φ , represents an edge with a source node being a phrase node p2 and a target node being a word node w ω , represents an edge with a source node being a phrase node p β and a target node being a word node w n .
[0066] The graph relation network GR is generated according to the following formula:
[0067] GR = (V Υ , E Υ ) 3) Construction method of graph attention network 1
[0068] The outputs of the semantic enhancement network and the graph relation network are input into the graph attention network 1:
[0069] GR′=(H (0) E Υ )
[0070]
[0071] Among them, H (0) H represents the initial input feature matrix of Graph Attention Network 1. (0) The dimension is (α+β+n)×D1. Indicates the clause node c α The feature vectors are initialized using random sampling from a standard normal distribution. Represents phrase node p β The feature vectors are initialized using random sampling from a standard normal distribution. Represents word node w n eigenvectors, and
[0072] Phrase-level feature aggregation is performed according to formula (3):
[0073]
[0074] in, It is a phrase node p β The attention weight of the u-th attention head. It is a phrase node p β The weight matrix corresponding to the u-th attention head Let τ represent the eigenvector of the i-th element, and let τ represent the eigenvector of E. Υ With phrase node p β Let τ be the number of source nodes and target nodes, where τ is a finite positive integer, and LeakyReLU(·) represents the activation function. Let represent the transpose of the attention vector, ||| denotes vector concatenation, and U is the number of attention heads. H represents (0) Middle phrase node p β eigenvectors.
[0075] The clause-level aggregation method is the same as the phrase-level aggregation method. The obtained clause-level aggregation features are assigned to the corresponding aspect words to obtain the aspect word semantic features.
[0076] 4) Construction method of semantic-syntactic fusion layer
[0077] The constituent structure tree and syntactic dependency tree are obtained using a syntactic parsing toolkit, and the constituent adjacency matrix A is obtained as follows: con With the dependency adjacency matrix Adep :
[0078]
[0079] Input the two adjacency matrices into the syntax fusion layer and fuse them using the following formula to obtain the fused adjacency matrix:
[0080] A′=A con +(A con ⊙A dep )
[0081] By fusing the adjacency matrix into the graph attention network 2, aspect-word syntax features are obtained.
[0082] The semantic features of the output aspect words of the semantically enhanced graph neural network and the syntactic features of the output aspect words of the syntactically enhanced graph neural network are fused together according to the following formula to obtain the aspect word fusion features.
[0083]
[0084] in, a (aspect) t semantic features, a (aspect) t Syntactic features.
[0085] In equation (3) of the method for constructing the graph attention network 1 in step 3) of the present invention, τ represents E Υ With phrase node p β τ represents the number of target nodes of the source node, τ∈[1,100]; U represents the number of attention heads, U takes values from 1 to 4.
[0086] The multi-head attention network construction method of the present invention is as follows:
[0087] The generated component structure tree and the target aspect word set As are input to the aspect word relation extraction layer. Aspect word pair relations are extracted using the following formula to obtain the segmented words of the aspect pairs:
[0088]
[0089] Where LCA(·) represents the Lowest Common Ancestor algorithm, which searches for a in the component structure tree. i ,a j The common parent node between them, a i and a j These are words that indicate two different aspects.
[0090] By concatenating the aspect word features with the segmentation word features using the following formula, a heterogeneous node sequence X is obtained:
[0091]
[0092] wherein, represents the aspect word a t the aspect word fusion feature of the aspect word a l represents the BERT model output feature of the segmentation word tex l ∈H.
[0093] The heterogeneous node sequence X is input into a multi-head attention network, and the query parameter matrix W Q , the key parameter matrix W K , the value parameter matrix W V is projected into a query matrix Q, a key matrix K, and a value matrix V:
[0094] Q=X×W Q
[0095] K=X×W K
[0096] V=X×W V
[0097] wherein, X represents the heterogeneous node sequence, the dimension of Q is D2×d k , the dimension of K is D2×d k , the dimension of V is D2×d v , D2 represents the length of the heterogeneous node sequence, d k represents the dimension of the query vector, d v represents the dimension of the value vector, W Q represents a weight matrix with the dimension of D1×d k , W K represents a weight matrix with the dimension of D1×d k , W V represents a weight matrix with the dimension of D1×d v .
[0098] The single-head attention weight is calculated according to formula (4):
[0099]
[0100] The outputs of the U attention heads are spliced to obtain the final global interaction enhancement:
[0101]
[0102] wherein, u represents the u-th attention head, U represents the total number of attention heads, a residual connection and layer normalization are performed by using a feedforward neural network FNN to obtain the final feature.
[0103] The application constructs a neural network comprising global aspect word feature optimization and sentiment classification, which is used to realize the polarity classification of aspect word sentiment. In the neural network training process, the aspect word semantic features are constructed by a semantic enhanced graph neural network, and the aspect word syntax features are constructed by a syntax enhanced graph neural network, which solves the problem of lack of effective interaction between semantic representation and syntax constraint, and improves the analysis accuracy of the network in complex context; the syntax information coding layer and the multi-head attention network are used to capture the interaction relationship between aspect words, and the aspect word features are dynamically corrected, which solves the analysis bottleneck in the context of sentiment turning or multi-aspect word interaction, and improves the accuracy of the network in this kind of scene. The application method is compared with the existing aspect-level sentiment analysis method, and the experimental results show that the application method has the advantages of accurate analysis, high classification accuracy and strong network robustness, and can be applied to sentiment analysis in complex context. BRIEF DESCRIPTION OF DRAWINGS
[0104] Figure 1 is a flowchart of embodiment 1 of the application.
[0105] Figure 2 is a structural schematic diagram of a sentiment analysis network.
[0106] Figure 3 is Figure 2 a structural schematic diagram of a global aspect word feature optimization network in the application.
[0107] Figure 4 is Figure 3 a structural schematic diagram of a single aspect word feature optimization network in the application
[0108] Figure 5 is Figure 2 a structural schematic diagram of a sentiment classification network in the application. DETAILED DESCRIPTION
[0109] The application will be further described in detail below in combination with the drawings and embodiments, but the application is not limited to these embodiments.
[0110] Embodiment 1
[0111] As Figure 1 shown, the aspect-level sentiment analysis method based on the structured tree and aspect word relationship in the embodiment comprises the following steps:
[0112] (1) Obtain data set
[0113] Download the SemEval-2014 Task 4 dataset, including the Restaurant dataset and the Laptop dataset, from the official website https: / / alt.qcri.org / semeval2014 / task4 / , both of which contain more than 3K English sentences, each containing single or at least two aspect words for sentiment classification, labeled using XML tags. From the Restaurant dataset, 2579 data are selected, containing 4727 aspect words, and from the Laptop dataset, 1863 data are selected, containing 2875 aspect words.
[0114] Download the MAMS dataset from the official website https: / / github.com / siat-nlp / MAMS-for-ABSA, which contains 8879 English sentences, each containing at least two aspect words for sentiment classification, and select 5297 data, containing 13854 aspect words.
[0115] (2) Divide the dataset
[0116] Divide the Restaurant dataset into training set and test set, the training set contains 1980 data, the test set contains 599 data; divide the Laptop dataset into training set and test set, the training set contains 1454 data, the test set contains 409 data; divide the MAMS dataset into training set, validation set and test set, the training set contains 4297 data, the validation set contains 500 data, and the test set contains 500 data.
[0117] (3) Extract text features
[0118] Input text sequence seq and aspect word set As:
[0119] seq=(w1,w2,…,w n )
[0120] As={a1,a2,…,a t}
[0121] Where w n represents a word in the word sequence, n is the length of the text, n∈[1,100], a t represents the target aspect word, and t represents the number of aspect words.
[0122] Use the start symbol [CLS] and the separator [SEP] to construct the input sequence ([CLS], seq, [SEP], a t , [SEP]), and use the pre-trained BERT model to extract features from the input sequence.
[0123] (4) Construct sentiment analysis network
[0124] Figure 2 The structural schematic diagram of the sentiment analysis network of the embodiment is given. In Figure 2 the embodiment, the sentiment analysis network is composed of a global aspect word feature optimization network and a sentiment classification network in series.
[0125] Figure 3 The structural schematic diagram of the global aspect word feature optimization network of the embodiment is given. In Figure 3 the embodiment, the global aspect word feature optimization network is composed of a single aspect word feature optimization network and the output end of a global aspect word relationship extraction network connected with a multi-head attention network.
[0126] Figure 4 The structural schematic diagram of the single aspect word feature optimization network of the embodiment is given. In Figure 4 the embodiment, the single aspect word feature optimization network is composed of the output end of a semantic enhancement graph neural network and a syntactic enhancement graph neural network connected with a semantic syntactic fusion layer.
[0127] The construction method of the single aspect word feature optimization network of the embodiment is as follows:
[0128] 1) Construction method of the semantic enhancement network
[0129] The sentiment dictionary feature E' is obtained according to formula (1):
[0130] E' = E x W + b e (1) e
[0131]
[0132] Wherein, E represents the initial feature matrix of the sentiment dictionary, the dimension of E is n x 3, that is, each word in the text corresponds to three scores: sc pos,n represents the positive score, sc pos,n ∈ [0, 1], sc obj,n represents the objective score, sc obj,n ∈ [0, 1], sc neg,n represents the negative score, sc neg,n ∈ [0, 1], and sc pos,n + sc obj,n + sc neg,n = 1, the value of sc pos,n in the embodiment is 0.3, the value of sc obj,n is 0.3, and the value of sc neg,n is 0.4, n represents the length of the sentence, n ∈ [1, 100], the value of n in the embodiment is 50, the dimension of E' is n x D1, D1 represents the dimension of the hidden layer, W e is a 3×D1 weight matrix, b e is a D1-dimensional bias term.
[0133] The text features are enhanced according to the following formula:
[0134] H′=G⊙E′+(1-G)⊙H
[0135] G=σ(concat(H,E′)×W g +b g )
[0136] wherein G represents the gating value of the text features and the sentiment features, G∈[0,1], H represents the text features output by the BERT model, the dimension of H is n×D1, ⊙ represents element-wise multiplication, σ(·) represents the sigmoid function, concat(·) represents the concatenation operation, W g is a 2D1×D1 weight matrix, b g is a 2D1 bias term.
[0137] 2) Construction method of graph relationship network
[0138] Download the toolkit as a constituent syntax parser from https: / / github.com / yzhangcs / crfpar, and obtain the constituent structure tree parsing result Y according to the following formula:
[0139] Y=(V ori ,E ori )
[0140] V ori ={v1,v2,…,v ζ}
[0141] E ori ={e1,e2,…,e ξ}
[0142] wherein V ori represents the node set contained in the constituent structure tree, v ζ represents the node in the constituent structure tree, E ori represents the edge set contained in the constituent structure tree, and e ξ represents the edge in the constituent structure tree.
[0143] The third-level structure tree node set V Υ is generated according to formula (2):
[0144] V Υ =C Υ P Υ ∪W Υ (2)
[0145] CΥ ={c1,c2,…,c α}
[0146] P Υ ={p1,p2,…,p β}
[0147] W Υ ={w1,w2,…,w n}
[0148] wherein C Υ represents a collection of clause nodes in the constituent structure tree, c α represents a clause node in the constituent structure tree, c α ∈V ori , and a represents the number of clause nodes, a ∈ [1, 10], the value of a in this embodiment is 5, P Υ represents a collection of phrase nodes in the constituent structure tree, p β represents a phrase node in the constituent structure tree, p β ∈V ori , and β represents the number of phrase nodes, β ∈ [1, 100], the value of β in this embodiment is 50, and W Υ represents a collection of word nodes in the constituent structure tree, w n represents a word node.
[0149] The third-level structure tree edge set E Υ is generated according to the following formula:
[0150]
[0151]
[0152] wherein E represents an edge with the source node being the clause node c1 and the target node being the phrase node p θ , represents an edge with the source node being the clause node c2 and the target node being the phrase node p , represents an edge with the source node being the clause node c α and the target node being the phrase node p β , represents an edge with the source node being the phrase node p1 and the target node being the word node w φ , represents an edge with the source node being the phrase node p2 and the target node being the word node w ω , represents an edge with the source node being the phrase node p β and the target node being the word node w n .
[0153] Generate a graph relation network GR using the following formula:
[0154] GR=(V Υ E Υ 3) Construction method of graph attention network 1
[0155] The outputs of the semantic enhancement network and the graph relation network are input into the graph attention network 1:
[0156] GR′=(H (0) E Υ )
[0157]
[0158] Among them, H (0) H represents the initial input feature matrix of Graph Attention Network 1. (0) The dimension is (α+β+n)×D1. Indicates the clause node c α The feature vectors are initialized using random sampling from a standard normal distribution. Represents phrase node p β The feature vectors are initialized using random sampling from a standard normal distribution. Represents word node w n eigenvectors, and
[0159] Phrase-level feature aggregation is performed according to equation (3):
[0160]
[0161] in, It is a phrase node p β The attention weight of the u-th attention head, This embodiment The value is 0.5. It is a phrase node p β The weight matrix corresponding to the u-th attention head Let τ represent the eigenvector of the i-th element, and let τ represent the eigenvector of E. Υ With phrase node p β Let τ be the number of target nodes from the source nodes, τ∈[1,100]. In this embodiment, τ is 50. LeakyReLU(·) represents the activation function. represents the transpose of the attention vector, ||| represents vector concatenation, and U represents the number of attention heads, with a value of 1 to 4. In this embodiment, U is 3. H represents (0) Middle phrase node p β eigenvectors.
[0162] The clause-level aggregation method of the embodiment is the same as the phrase-level aggregation method, and the obtained clause-level aggregation features are assigned to the corresponding aspect words to obtain aspect word semantic features.
[0163] 4) Construction method of semantic syntax fusion layer
[0164] The constituent structure tree and the syntax dependency tree are obtained through the syntax analysis toolkit, and the constituent adjacency matrix A is obtained according to the following formula con and the dependency adjacency matrix A dep :
[0165]
[0166] The two adjacency matrices are input into the syntax fusion layer, and the fusion adjacency matrix is obtained by fusion according to the following formula.
[0167] A′=A con +(A con ⊙A dep )
[0168] The fusion adjacency matrix is input into the graph attention network 2 to obtain the aspect word syntax features.
[0169] The output aspect word semantic features of the semantic enhanced graph neural network and the output aspect word syntax features of the syntax enhanced graph neural network are fused according to the following formula to obtain the aspect word fusion features:
[0170]
[0171] Wherein, h t sem represents the semantic features of the aspect word a t , represents the syntax features of the aspect word a t .
[0172] The construction method of the multi-head attention network of the embodiment is as follows:
[0173] The generated constituent structure tree and the target aspect word set As are input into the aspect word relationship extraction layer, and the aspect word pair relationship is extracted according to the following formula to obtain the segmentation words of the aspect pair:
[0174]
[0175] Wherein, LCA(·) represents the least common ancestor algorithm, that is, finding the common parent node between a i ,a j in the constituent structure tree, a i and a j represent two different aspect words.
[0176] The aspect word features and the segmented word features are spliced according to the following formula to obtain a heterogeneous node sequence X:
[0177]
[0178] wherein, represents the aspect word fusion feature of the aspect word a t , h l represents the BERT model output feature of the segmented word tex, h l ∈H.
[0179] The heterogeneous node sequence X is input into a multi-head attention network, and is projected into a query matrix Q, a key matrix K and a value matrix V through a query parameter matrix W Q , a key parameter matrix W K and a value parameter matrix W V .
[0180] Q=X×W Q
[0181] K=X×W K
[0182] V=X×W V
[0183] wherein, X represents the heterogeneous node sequence, the dimension of Q is D2×d k , the dimension of K is D2×d k , the dimension of V is D2×d v , D2 represents the length of the heterogeneous node sequence, d k represents the dimension of the query vector, d v represents the dimension of the value vector, W Q represents a weight matrix with the dimension of D1×d k , W K represents a weight matrix with the dimension of D1×d k , and W V represents a weight matrix with the dimension of D1×d v .
[0184] The single-head attention weight is calculated according to formula (4):
[0185]
[0186] The outputs of the U attention heads are spliced to obtain the final global interaction enhancement:
[0187]
[0188] wherein, u represents the u-th attention head, U represents the total number of attention heads, and U has the same value as U in formula (3); the residual connection and layer normalization are performed by using a feedforward neural network FNN to obtain the final feature.
[0189] The semantic enhancement graph neural network of the embodiment is connected to the output end of the semantic enhancement network and the graph relation network and the graph attention network 1.
[0190] The semantic enhancement network of the embodiment is connected in series by a sentiment dictionary feature extraction layer and a context feature fusion layer.
[0191] The graph relation network of the embodiment is connected in series by a syntax feature extraction layer 2 and a structured layer.
[0192] Figure 5 The structure diagram of the sentiment classification network of the embodiment is given. In Figure 5 the sentiment classification network of the embodiment is connected in series by a full connection layer and a softmax layer.
[0193] (5) Training the sentiment analysis network
[0194] 1) Constructing a loss function
[0195] The loss Loss is constructed according to the following formula:
[0196]
[0197] wherein s represents the sentence number, S represents the number of sentences, m represents the aspect word number, t represents the number of aspect words in a sentence, y sm represents the sentiment label of the aspect word in the training set, y sm ∈{0,1,2}, represents the sentiment prediction of the aspect word in the training set, 0 represents positive, 1 represents neutral, and 2 represents negative.
[0198] 2) Training the sentiment analysis network
[0199] The training set is input into the sentiment analysis network for training, and the training parameters are as follows: the training batch size is 32, the iteration number is 20, the server is GTX 3090, the optimizer is an Adam optimizer, the learning rate is 3x10 -5 , the regular rate is 4x10 -4 , and the training is performed until the loss function Loss converges.
[0200] (6) Testing the sentiment analysis network
[0201] The test set is input into the trained sentiment analysis network for testing, and the sentiment probability of the user aspect word is output.
[0202] (7) Identifying the sentiment polarity of the aspect word
[0203] The extracted text features are input into the trained sentiment analysis network, and a full connection layer and a Softmax layer are used for regression to obtain probability values of different sentiment categories: positive probability p pos , p pos ∈ [0, 1], neutral probability p neu , p neu ∈ [0, 1], and negative probability p neg , p neg ∈ [0, 1], and p pos + p neu + p neg = 1, p pos of the embodiment takes a value of 0.3, p neu takes a value of 0.3, and p neg takes a value of 0.4.
[0204] The aspect sentiment category is predicted according to the following formula:
[0205]
[0206] p t = (p pos , p neu , p neg )
[0207] wherein, argmax(·) represents selecting the sentiment polarity corresponding to the element with the maximum value in the probability distribution as the result.
[0208] The aspect-level sentiment analysis method based on the structured tree and aspect word relationship is completed.
[0209] Embodiment 2
[0210] The aspect-level sentiment analysis method based on the structured tree and aspect word relationship of the embodiment consists of the following steps:
[0211] (1) Obtain a data set
[0212] This step is the same as that in Embodiment 1.
[0213] (2) Divide the data set
[0214] This step is the same as that in Embodiment 1.
[0215] (3) Extract text features
[0216] This step is the same as that in Embodiment 1.
[0217] (4) Construct a sentiment analysis network
[0218] The structure of the sentiment analysis network is the same as that in Embodiment 1.
[0219] The construction method of the one-sided word feature optimization network of the embodiment is as follows:
[0220] 1) Construction method of semantic enhancement network
[0221] The sentiment dictionary feature E' is obtained according to formula (1):
[0222] The expression of formula (1) is the same as that of embodiment 1.
[0223] In formula (1), E represents the initial feature matrix of the sentiment dictionary, and the dimension of E is n x 3, that is, each word in the text corresponds to three scores respectively:
[0224] sc pos,n represents a positive score, sc pos,n ∈ [0, 1], sc obj,n represents an objective score, sc obj,n ∈ [0, 1], sc neg,n represents a negative score, sc neg,n ∈ [0, 1], and sc pos,n + sc obj,n + sc neg,n = 1, sc pos,n of the embodiment takes a value of 0, sc obj,n takes a value of 0, sc neg,n takes a value of 0, and sc neg,n takes a value of 1, n represents the length of the sentence, n ∈ [1, 100], and n of the embodiment takes a value of 1. The meanings and value ranges of other parameters and variables are the same as those of embodiment 1.
[0225] The other steps in this step are the same as those of embodiment 1.
[0226] 2) Construction method of graph relationship network
[0227] The third-level structure tree node set V is generated according to formula (2): Υ
[0228] The expression of formula (2) is the same as that of embodiment 1.
[0229] In formula (2), a represents the number of sentence nodes, a ∈ [1, 10], a of the embodiment takes a value of 1, p β represents a phrase node in the constituent structure tree, p β ∈ V ori , β represents the number of phrase nodes, β ∈ [1, 100], and β of the embodiment takes a value of 1. The meanings and value ranges of other parameters and variables are the same as those of embodiment 1.
[0230] The other steps in this step are the same as those of embodiment 1.
[0231] 3) Construction method of graph attention network 1
[0232] Phrase-level feature aggregation is performed according to formula (3):
[0233] The expression of formula (3) is the same as that of embodiment 1.
[0234] In formula (3), is the phrase node p β The attention weight of the u-th attention head, The is 0, and τ represents the number of E Υ The number of target nodes taking the phrase node p β as the source node, τ ∈ [1, 100], τ of the present embodiment takes the value of 1, U represents the number of attention heads, U takes the value of 1-4, and U of the present embodiment takes the value of 1. The meanings and value ranges of other parameters and variables are the same as those of embodiment 1.
[0235] The other steps in this step are the same as those of embodiment 1.
[0236] 4) Construction method of semantic syntax fusion layer
[0237] This step is the same as that of embodiment 1.
[0238] The multi-head attention network construction method of the present embodiment is as follows:
[0239] The multi-head attention network construction method of the present embodiment is the same as that of embodiment 1.
[0240] (5) Training of sentiment analysis network
[0241] This step is the same as that of embodiment 1.
[0242] (6) Testing of sentiment analysis network
[0243] This step is the same as that of embodiment 1.
[0244] (7) Identifying aspect word sentiment polarity
[0245] The extracted text features are input into the trained sentiment analysis network, and a full connection layer and a Softmax layer are used for regression to obtain probability values of different sentiment categories: positive probability p pos , p pos ∈ [0, 1], neutral probability p neu , p neu ∈ [0, 1], negative probability p neg , p neg ∈ [0, 1], and p pos + p neu + p neg = 1, and ppos = 0, p neu = 0, p neg = 1.
[0246] The other steps of this step are the same as those of Example 1.
[0247] The aspect-level sentiment analysis method based on the structured tree and aspect word relationship is completed.
[0248] Example 3
[0249] The aspect-level sentiment analysis method based on the structured tree and aspect word relationship of this embodiment comprises the following steps:
[0250] (1) Obtain a data set
[0251] This step is the same as that of Example 1.
[0252] (2) Divide the data set
[0253] This step is the same as that of Example 1.
[0254] (3) Extract text features
[0255] This step is the same as that of Example 1.
[0256] (4) Construct a sentiment analysis network
[0257] The structure of the sentiment analysis network is the same as that of Example 1.
[0258] The construction method of the single aspect word feature optimization network of this embodiment is as follows:
[0259] 1) Construction method of semantic enhancement network
[0260] The sentiment dictionary feature E' is obtained according to formula (1):
[0261] The expression of formula (1) is the same as that of Example 1.
[0262] In formula (1), E represents the initial feature matrix of the sentiment dictionary, and the dimension of E is n x 3, that is, each word in the text corresponds to three scores respectively:
[0263] sc pos,n represents a positive score, sc pos,n ∈ [0, 1], sc obj,n represents an objective score, sc obj,n ∈ [0, 1], sc neg,n represents a negative score, sc neg,n ∈ [0, 1], and sc pos,n + sc obj,n + sc neg,n = 1, scpos,n sc takes the value 1 obj,n sc takes the value 0 neg,n n represents the sentence length, n ∈ [1, 100], and n takes the value 100 in this embodiment. The meanings and value ranges of other parameters and variables are the same as in Embodiment 1.
[0264] The other steps in this step are the same as in Embodiment 1.
[0265] 2) Construction method of graph relationship network
[0266] The tertiary structure tree node set V is generated according to formula (2) Υ :
[0267] The expression of formula (2) is the same as in Embodiment 1.
[0268] In formula (2), a represents the number of sentence nodes, a ∈ [1, 10], and a takes the value 10 in this embodiment, p β represents a phrase node in the constituent structure tree, p β ∈ V ori , and β represents the number of phrase nodes, β ∈ [1, 100], and β takes the value 100 in this embodiment. The meanings and value ranges of other parameters and variables are the same as in Embodiment 1.
[0269] The other steps in this step are the same as in Embodiment 1.
[0270] 3) Construction method of graph attention network 1
[0271] Phrase-level feature aggregation is performed according to formula (3):
[0272] The expression of formula (3) is the same as in Embodiment 1.
[0273] In formula (3), is a phrase node p β is the attention weight of the u-th attention head, in this embodiment takes the value 1, and τ represents the number of target nodes in E Υ with the phrase node p β as the source node, τ ∈ [1, 100], and τ takes the value 100 in this embodiment, and U represents the number of attention heads, U takes the value 1-4, and U takes the value 4 in this embodiment. The meanings and value ranges of other parameters and variables are the same as in Embodiment 1.
[0274] The other steps in this step are the same as in Embodiment 1.
[0275] 4) Construction method of semantic syntax fusion layer
[0276] This step is the same as that in Embodiment 1.
[0277] The multi-head attention network construction method of this embodiment is as follows:
[0278] The multi-head attention network construction method of this embodiment is the same as that in Embodiment 1.
[0279] (5) Training the sentiment analysis network
[0280] This step is the same as that in Embodiment 1.
[0281] (6) Testing the sentiment analysis network
[0282] This step is the same as that in Embodiment 1.
[0283] (7) Identifying aspect word sentiment polarity
[0284] The extracted text features are input into the trained sentiment analysis network, and a full connection layer and a Softmax layer are used for regression to obtain probability values of different sentiment categories: positive probability p pos , p pos ∈ [0, 1], neutral probability p neu , p neu ∈ [0, 1], negative probability p neg , p neg ∈ [0, 1], and p pos + p neu + p neg = 1, p pos of this embodiment takes a value of 1, p neu takes a value of 0, and p neg takes a value of 0.
[0285] The other steps of this step are the same as those in Embodiment 1.
[0286] The aspect-level sentiment analysis method based on the structured tree and aspect word relationship is completed.
[0287] The other steps are the same as those in Embodiment 1.
[0288] The aspect-level sentiment analysis method based on the structured tree and aspect word relationship is completed.
[0289] Embodiment 4
[0290] In the above Embodiments 1-3, the aspect-level sentiment analysis method based on the structured tree and aspect word relationship of this embodiment is composed of the following steps:
[0291] (1) Obtaining a data set
[0292] This step is the same as that in Embodiment 1.
[0293] (2) Dividing the data set
[0294] This step is the same as that in Example 1.
[0295] (3) Extracting text features
[0296] This step is the same as that in Example 1.
[0297] (4) Constructing a sentiment analysis network
[0298] The structure of the sentiment analysis network is the same as that in Example 1.
[0299] The construction method of the one-sided word feature optimization network of this embodiment is as follows:
[0300] 1) Construction method of semantic enhancement network
[0301] The sentiment dictionary feature E' is obtained according to formula (1):
[0302] The expression of formula (1) is the same as that in Example 1.
[0303] In formula (1), E represents the initial feature matrix of the sentiment dictionary, and the dimension of E is n x 3, that is, each word in the text corresponds to three scores respectively:
[0304] sc pos,n represents a positive score, sc pos,n ∈ [0, 1], sc obj,n represents an objective score, sc obj,n ∈ [0, 1], sc neg,n represents a negative score, sc neg,n ∈ [0, 1], and sc pos,n + sc obj,n + sc neg,n = 1, sc pos,n of this embodiment takes the value of 0, sc obj,n takes the value of 1, sc neg,n takes the value of 0, n represents the length of the sentence, n ∈ [1, 100], and n of this embodiment takes the value of 100. The meanings and value ranges of other parameters and variables are the same as those in Example 1.
[0305] The other steps in this step are the same as those in Example 1.
[0306] (5) Training the sentiment analysis network
[0307] This step is the same as that in Example 1.
[0308] (6) Testing the sentiment analysis network
[0309] This step is the same as that in Example 1.
[0310] (7) Identifying aspect word sentiment polarity
[0311] The extracted text features are input into the trained sentiment analysis network, and the probabilities of different sentiment categories are obtained by regression with a full connection layer and a Softmax layer: positive probability p pos , p pos ∈ [0, 1], neutral probability p neu , p neu ∈ [0, 1], and negative probability p neg , p neg ∈ [0, 1], and p pos + p neu + p neg = 1, p pos of the embodiment takes a value of 0, p neu takes a value of 1, and p neg takes a value of 0.
[0312] The other steps of this step are the same as those of Embodiment 1.
[0313] The aspect-level sentiment analysis method based on the structured tree and aspect word relationship is completed.
[0314] In order to verify the beneficial effects of the present application, the aspect-level sentiment analysis method based on the structured tree and aspect word relationship of the embodiment 1 of the present application (hereinafter referred to as the method of the present application) and the Attentional encoder network for targeted sentiment classification (hereinafter referred to as comparative experiment 1), Modeling sentiment dependencies with graph convolutional networks for aspect-level sentiment classification (hereinafter referred to as comparative experiment 2), Relational graph attention network for aspect-based sentiment analysis (hereinafter referred to as comparative experiment 3), Dual graph convolutional networks for aspect-based sentiment analysis (hereinafter referred to as comparative experiment 4), Bi-syntax aware graph attention network for aspect-based sentiment analysis (hereinafter referred to as comparative experiment 5), Aspect-pair supervised contrastive learning for aspect-based sentiment analysis (hereinafter referred to as comparative experiment 6), Incorporating syntax and semantics with dual graph neural networks for aspect-level sentiment analysis (hereinafter referred to as comparative experiment 7) were used to carry out computer comparison simulation experiments. The accuracy and F1 scores were calculated and tested on the Laptop dataset, MAMS dataset and MAMS dataset. The experimental results are shown in Table 1.
[0315] Table 1 Experimental results of the present application and comparative experiments
[0316]
[0317]
[0318] As shown in Table 1, compared with the comparative experiment 1, the accuracy on the Laptop dataset is increased by 2.81%, and the F1 score is increased by 3.95%; compared with the comparative experiment 2, the accuracy on the Restaurant dataset is increased by 4.01%, and the F1 score is increased by 5.17%; compared with the comparative experiment 3, the accuracy on the Restaurant dataset is increased by 0.9%, and the F1 score is increased by 0.72%; compared with the comparative experiment 4, the accuracy on the Laptop dataset is increased by 2.05%, and the F1 score is increased by 2.99%; compared with the comparative experiment 5, the accuracy on the Laptop dataset is increased by 0.95%, and the F1 score is increased by 1.07%; compared with the comparative experiment 6, the accuracy on the MAMS dataset is increased by 1.19%, and the F1 score is increased by 1.22%; compared with the comparative experiment 7, the accuracy on the MAMS dataset is increased by 0.68%, and the F1 score is increased by 1.3%; the method has the advantages of accurate analysis, high sentiment classification accuracy and the like, and can be used for sentiment analysis.
Claims
1. An aspect-level sentiment analysis method based on structured trees and aspect word relationships, characterized in that... It consists of the following steps: (1) Obtaining the dataset Download the SemEval-2014 Task 4 dataset from the official website https: / / alt.qcri.org / semeval2014 / task4 / . It includes the Restaurant dataset and the Laptop dataset. Both datasets contain more than 3,000 English sentences, each containing one or more sentiment classification words. The sentences are annotated with XML tags. 2,579 data points containing 4,727 sentiment words were selected from the Restaurant dataset, and 1,863 data points containing 2,875 sentiment words were selected from the Laptop dataset. Download the MAMS dataset from the official website https: / / github.com / siat-nlp / MAMS-for-ABSA. There are 8879 English sentences in total. Each English sentence contains at least two sentiment classification words. 5297 data points were selected, containing 13854 sentiment words. (2) Split the dataset The Restaurant dataset was divided into training and test sets, with 1980 data points in the training set and 599 data points in the test set; the Laptop dataset was divided into training and test sets, with 1454 data points in the training set and 409 data points in the test set; and the MAMS dataset was divided into training, validation, and test sets, with 4297 data points in the training set, 500 data points in the validation set, and 500 data points in the test set. (3) Extracting text features Input text sequence seq and aspect term set As: seq=(w1,w2,…,w n ) As={a1,a2,…,a t } Among them, w n Let a represent the words in the word sequence, n be the text length, n∈[1, 100], and a t The term "t" represents the target aspect, and "t" represents the number of aspect terms. Construct the input sequence ([CLS], seq, [SEP], a) using the start term [CLS] and the separator [SEP]. t [SEP]) uses a pre-trained BERT model to extract features from the input sequence; (4) Constructing a sentiment analysis network The sentiment analysis network consists of a global aspect word feature optimization network and a sentiment classification network connected together; The global aspect word feature optimization network is composed of a single aspect word feature optimization network and a global aspect word relation extraction network connected in parallel and then connected in series with a multi-head attention network; (5) Training the sentiment analysis network 1) Constructing the loss function Loss is calculated as follows: Where s represents the sentence number, S represents the number of sentences, m represents the aspect term number, t represents the number of aspect terms in a sentence, and y represents the number of aspect terms in a sentence. sm The sentiment annotation of words in the training set, y sm ∈{0,1,2}, This represents the sentiment prediction of words in the training set. 0 represents positive, 1 represents neutral, and 2 represents negative; 2) Training the sentiment analysis network The training set was fed into the sentiment analysis network for training. The training parameters were: batch size of 32, number of iterations of 20, server of GTX 3090, Adam optimizer used, and learning rate of 3×10⁻⁶. -5 The regularization rate is 4×10 -4 Train until the loss function converges; (6) Testing the sentiment analysis network The test set is input into the trained sentiment analysis network for testing, and the sentiment probability of user-related words is output. (7) Identifying the emotional polarity of words The extracted text features are input into the trained sentiment analysis network, and regression is performed using fully connected layers and softmax layers to obtain the probability values of different sentiment categories: positive probability p. pos p pos ∈[0,1], neutral probability p neu p neu ∈[0,1], negative probability p neg p neg ∈[0,1], and p pos +p neu +p neg =1; Predict the sentiment category of each aspect using the following formula: p t =(p pos ,p neu ,p neg ) in, argmax(·) means selecting the sentiment polarity corresponding to the element with the largest value in the probability distribution as the result.
2. The aspect-level sentiment analysis method based on structured tree and aspect word relationships according to claim 1, characterized in that: In step (4), the sentiment analysis network is constructed by connecting the outputs of the semantic enhancement graph neural network and the syntactic enhancement graph neural network to the semantic-syntactic fusion layer.
3. The aspect-level sentiment analysis method based on structured tree and aspect word relationships according to claim 2, characterized in that: The semantic enhancement graph neural network consists of the outputs of the semantic enhancement network and the graph relation network connected to the graph attention network 1.
4. The aspect-level sentiment analysis method based on structured tree and aspect word relationships according to claim 3, characterized in that: The semantic enhancement network consists of a sentiment dictionary feature extraction layer and a context feature fusion layer connected in series.
5. The aspect-level sentiment analysis method based on structured tree and aspect word relationships according to claim 3, characterized in that: The graph relation network is composed of a syntactic feature extraction layer 2 and a structuring layer connected in series.
6. The aspect-level sentiment analysis method based on structured tree and aspect word relationships according to claim 1 or 2, characterized in that... In step (4), the construction method of the one-sided word feature optimization network in the construction of the sentiment analysis network is as follows: 1) Methods for constructing semantic augmentation networks Obtain the sentiment dictionary features E′ according to formula (1): E′=E×W e +b e (1) Where E represents the initial feature matrix of the sentiment lexicon, and E has a dimension of n×3, meaning that each word in the text corresponds to three scores: sc pos,n sc represents positive scores. pos,n ∈[0,1],sc obj,n sc represents objective scores obj,n ∈[0,1],sc neg,n Indicates a negative score, sc neg,n ∈[0,1], and sc pos,n +sc obj,n +sc neg,n =1, n represents the sentence length, n∈[1,100], the dimension of E′ is n×D1, D1 represents the hidden layer dimension, W e Let b be a 3×D1 dimensional weight matrix. e The parameter is a D1-dimensional bias term; Enhance text features using the following formula: H′=G⊙E′+(1-G)⊙H G=σ(concat(H,E′)×W g +b g ) Where G represents the gating value between text features and sentiment features, G∈[0,1], H represents the text features output by the BERT model, H has a dimension of n×D1, ⊙ represents element-wise multiplication, σ(·) represents the sigmoid function, concat(·) represents the concatenation operation, and W g Let b be a 2D1×D1 dimensional weight matrix. g For a 2D 1-dimensional bias term; 2) Methods for constructing graph relationship networks Download the toolkit from https: / / github.com / yzhangcs / crfpar as a constituent syntax parser, and obtain the constituent structure tree parsing result Υ using the following formula: Υ=(V ori ,E ori ) V ori ={v1,v2,…,v ζ } THE ori }{e1,e2,…,e ξ } Among them, V ori v represents the set of nodes contained in the component structure tree. ζ E represents a node in the component structure tree. ori e represents the set of edges contained in the component structure tree. ξ Represents the edges in the component structure tree; Generate the set of nodes V of the three-level structure tree according to formula (2). Υ : In Υ =C Υ ∪P Υ ∪W Υ (2) C Υ ={c1,c2,…,c α } P Υ ={p1,p2,…,p β } IN Υ ={w1,w2,…,w n } Among them, C Υ c represents the set of clause nodes in the component structure tree. α c represents the clause node in the component structure tree. α ∈V ori α represents the number of clause nodes, α∈[1,10], P Υ p represents the set of phrase nodes in the constituent structure tree. β p represents a phrase node in the constituent structure tree. β ∈V ori β represents the number of phrase nodes, β∈[1,100], W Υ w represents the set of word nodes in the constituent structure tree. n Represents word nodes; Generate the edge set E of the three-level structure tree using the following formula. Υ : in, This indicates that the source node is a clause node c1 and the target node is a phrase node p. θ The edge, This indicates that the source node is a clause node c2 and the target node is a phrase node. The edge, This indicates that the source node is the clause node c. α And the target node is a phrase node p β The edge, This indicates that the source node is a phrase node p1 and the target node is a word node w. φ The edge, This indicates that the source node is a phrase node p2 and the target node is a word node w. ω The edge, This indicates that the source node is a phrase node p. β And the target node is the word node w n The edge; Generate a graph relation network GR using the following formula: GR=(V Υ ,E Υ ) 3) Construction method of graph attention network 1 The outputs of the semantic enhancement network and the graph relation network are input into the graph attention network 1: GR′=(H (0) ,BY Υ ) Among them, H (0) H represents the initial input feature matrix of Graph Attention Network 1. (0) The dimension is (α+β+n)×D1. Indicates the clause node c α The feature vectors are initialized using random sampling from a standard normal distribution. Represents phrase node p β The feature vectors are initialized using random sampling from a standard normal distribution. Represents word node w n eigenvectors, and Phrase-level feature aggregation is performed according to equation (3): in, It is a phrase node p β The attention weight of the u-th attention head, It is a phrase node p β The weight matrix corresponding to the u-th attention head Let τ represent the eigenvector of the i-th element, and let τ represent the eigenvector of E. Υ With phrase node p β Let τ be the number of source nodes and target nodes, where τ is a finite positive integer, and LeakyReLU(·) represents the activation function. Let || denote the transpose of the attention vector, || denotes vector concatenation, and U is the number of attention heads. H represents (0) Middle phrase node p β eigenvectors; The clause-level aggregation method is the same as the phrase-level aggregation method, in which the obtained clause-level aggregation features are assigned to the corresponding aspect words to obtain aspect word semantic features; 4) Construction method of semantic-syntactic fusion layer The constituent structure tree and syntactic dependency tree are obtained using a syntactic parsing toolkit, and the constituent adjacency matrix A is obtained as follows: con With the dependent adjacency matrix A dep : Input the two adjacency matrices into the syntax fusion layer and fuse them using the following formula to obtain the fused adjacency matrix: A′=A con +(A con ⊙A dep ) The adjacency matrix is fused into the graph attention network 2 to obtain aspect word syntax features; The semantic features of aspect words output by the semantically augmented graph neural network and the syntactic features of aspect words output by the syntactically augmented graph neural network are fused together using the following formula to obtain the aspect word fusion features: in, a (aspect) t semantic features a (aspect) t Syntactic features.
7. The aspect-level sentiment analysis method based on structured tree and aspect word relationships according to claim 6, characterized in that... In equation (3) of the method for constructing graph attention network 1 in step 3), τ represents the value of E. Υ With phrase node p β τ represents the number of target nodes of the source node, τ∈[1,100]; U represents the number of attention heads, U takes values from 1 to 4.
8. The aspect-level sentiment analysis method based on structured tree and aspect word relationships according to claim 1, characterized in that... The method for constructing a multi-head attention network is as follows: The generated component structure tree and the target aspect word set As are input to the aspect word relation extraction layer. Aspect word pair relations are extracted using the following formula to obtain the segmented words of the aspect pairs: Where LCA(·) represents the Lowest Common Ancestor algorithm, which searches for a in the component structure tree. i ,a j The common parent node between them, a i and a j Indicates two different aspects; By concatenating the aspect word features with the segmentation word features using the following formula, a heterogeneous node sequence X is obtained: in, a (aspect) t The aspect of word fusion features, h l h represents the BERT model output features for segmenting words tex. l ∈H; Input the heterogeneous node sequence X into the multi-head attention network and query the parameter matrix W. Q Key parameter matrix W K Value parameter matrix W V The projection is the query matrix Q, the key matrix K, and the value matrix V: Q=X×W Q K=X×W K H=X×W V Where X represents a heterogeneous node sequence, and Q has a dimension of D2×d. k The dimension of K is D2×d k The dimension of V is D2×d v D2 represents the length of the heterogeneous node sequence, d k d represents the query vector dimension. v W represents the dimension of the value vector. Q The dimension is represented as D1×d k The weight matrix, W K The dimension is represented as D1×d k The weight matrix, W V The dimension is represented as D1×d v The weight matrix; Calculate the single-head attention weights according to formula (4): The outputs of the U attention heads are concatenated to enhance the final global interaction: Where u represents the u-th attention head, and U represents the total number of attention heads, the final features are obtained by performing residual connections and layer normalization using a feedforward neural network (FNN).