Aspect-level sentiment analysis method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202310897393.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-20
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2043-07-20
AI Technical Summary
然而现有的深度学习方案在提取情感信息的过程中仍有许多不合理的地方,在面临结构复杂的语句时,无法充分利用结构信息,忽略了句子中方面词与上下文之间存在的位置信息,进而模型无法获得更加丰富的情感信息,从而导致最终的情感分析结果的准确性低
[0010]Compared to existing technologies, the aspect-level sentiment analysis method of this invention fully utilizes the positional information between aspect words and their context by combining local and global contextual features related to aspect words. This results in richer sentiment information in the sentiment features used for sentiment classification and prediction. Furthermore, by extracting features from local contextual features through a graph attention network, it can accurately capture syntactic information and long-distance words, solving the problem of long-distance multi-word dependencies. This allows for the acquisition of deeper syntactic information in the sentence and effectively eliminates the influence of irrelevant words on the sentiment polarity judgment of aspect words, achieving a more reasonable allocation of attention weights and thus improving the accuracy of sentiment analysis results.
Smart Images

Figure CN117076669B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of aspect-level sentiment analysis technology, and in particular to an aspect-level sentiment analysis method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] Aspect-Based Sentiment Analysis (ABSA) is a fine-grained sentiment analysis task at the entity level, aiming to determine the sentiment polarity (positive, negative, or neutral) of a given aspect in a sentence. ABSA places extremely high demands on semantic understanding within a sentence; therefore, obtaining deeper and more accurate sentiment information is crucial for the final sentiment polarity determination. In recent years, ABSA using deep learning has primarily introduced attention mechanisms into traditional neural networks to model the sentiment information of aspect words and their context. However, existing deep learning solutions still have many shortcomings in extracting sentiment information. When faced with structurally complex sentences, they fail to fully utilize structural information and ignore the positional information between aspect words and their context, thus preventing the model from obtaining richer sentiment information and resulting in low accuracy of the final sentiment analysis results. Summary of the Invention
[0003] The purpose of this invention is to overcome the shortcomings and deficiencies of the prior art and provide an aspect-level sentiment analysis method that can obtain richer aspect word sentiment features in sentence structure, thereby improving the accuracy of sentiment analysis results.
[0004] This invention is achieved through the following technical solution: an aspect-level sentiment analysis method, comprising the following steps:
[0005] Obtain the text to be analyzed, and perform word embedding processing on several words adjacent to the words to be analyzed in the text to obtain local context features;
[0006] The text to be analyzed is subjected to word embedding processing to obtain global context features;
[0007] The local context features are subjected to graph attention-based feature extraction to obtain local graph attention features;
[0008] The local graph attention features are fused with the global context features to obtain the sentiment features;
[0009] Based on the emotional features, classification and prediction are performed to obtain the emotional polarity of the terms to be analyzed.
[0010] Compared to existing technologies, the aspect-level sentiment analysis method of this invention fully utilizes the positional information between aspect words and their context by combining local and global contextual features related to aspect words. This results in richer sentiment information in the sentiment features used for sentiment classification and prediction. Furthermore, by extracting features from local contextual features through a graph attention network, it can accurately capture syntactic information and long-distance words, solving the problem of long-distance multi-word dependencies. This allows for the acquisition of deeper syntactic information in the sentence and effectively eliminates the influence of irrelevant words on the sentiment polarity judgment of aspect words, achieving a more reasonable allocation of attention weights and thus improving the accuracy of sentiment analysis results.
[0011] Furthermore, graph attention-based feature extraction is performed on the local context features using a graph attention network;
[0012] The graph attention network includes an adjacency layer, an attention layer, and a weighted summation layer. The adjacency layer includes X consecutive adjacency update modules. The adjacency update modules are used to perform convolution processing on the local upper and lower features based on the adjacency matrix of the aspect words to be analyzed, so as to obtain updated local context features.
[0013] The attention layer includes L sub-attention layers, and each sub-attention layer includes K attention heads. The attention heads are used to calculate the attention coefficient between every two word vectors in the updated local context features based on the attention head parameters. The local context features are then convolved based on the attention coefficients to obtain the updated local context features.
[0014] The weighted summation layer is used to perform convolutional summation on the local context features output by the attention layer to obtain local graph attention features.
[0015] Furthermore, after performing word embedding processing on several words adjacent to the word to be analyzed in the text to obtain local context features, the method further includes the following steps:
[0016] Calculate the semantic relevance distance between each word vector in the local context features and the word to be analyzed;
[0017] The local context features are weighted based on the semantic relevance distance to obtain enhanced local context features.
[0018] Furthermore, the expression for the semantic relevance distance is:
[0019]
[0020] Where, d iLet represent the semantic relevance distance between the i-th word vector in the local context features and the aspect word to be analyzed, where i is the position of the i-th word vector in the local context features, p is the center position of the aspect word to be analyzed, and n is the position of the i-th word vector in the local context features. a The length of the terms to be analyzed.
[0021] Furthermore, the weight vector V of the i-th word vector in the local context features i The expression is:
[0022]
[0023] Where α is the relevance threshold, E is the unit vector, and n is the number of word vectors in the local context features.
[0024] Further, the local graph attention features are fused with the global context features, including the following steps:
[0025] Gated convolution is performed on the local graph attention features and the global context features to obtain fused convolution features;
[0026] The local graph attention features are subjected to gated convolution to obtain local convolution features;
[0027] The fused convolutional features and the local convolutional features are processed by dot product to obtain the sentiment features.
[0028] Further, classification and prediction based on the emotional features includes the following steps:
[0029] After concatenating the emotion features with the global context features, multi-head attention feature extraction is performed to obtain the attention feature matrix;
[0030] A linear transformation and activation are performed on the first vector of the attention feature matrix to obtain the target prediction vector;
[0031] Based on the target prediction vector, classification prediction is performed to obtain the sentiment polarity of the words to be analyzed.
[0032] Based on the same inventive concept, the present invention also provides an aspect-level sentiment analysis device, comprising:
[0033] The local word embedding submodule is used to obtain the text to be analyzed, and to perform word embedding processing on several words adjacent to the words to be analyzed in the text to obtain local context features;
[0034] The global word embedding submodule is used to perform word embedding processing on the text to be analyzed to obtain global context features;
[0035] The graph attention module is used to perform graph attention-based feature extraction on the local context features to obtain local graph attention features;
[0036] The feature fusion module is used to fuse the local graph attention features with the global context features to obtain sentiment features;
[0037] The classification prediction module is used to perform classification prediction based on the sentiment features to obtain the sentiment polarity of the aspect words to be analyzed.
[0038] Based on the same inventive concept, the present invention also provides an electronic device, characterized in that it comprises:
[0039] processor;
[0040] Memory for storing computer programs executed by the processor;
[0041] The steps of the above method are implemented when the processor executes the computer program.
[0042] Based on the same inventive concept, the present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that, when the computer program is executed, it implements the steps of the above-described method.
[0043] To better understand and implement this invention, the following detailed description is provided in conjunction with the accompanying drawings. Attached Figure Description
[0044] Figure 1 This is a flowchart illustrating the aspect-level sentiment analysis method in the embodiments.
[0045] Figure 2 For execution Figure 1 A schematic diagram of the aspect-level sentiment analysis device for the method shown;
[0046] Figure 3 for Figure 1 A flowchart illustrating step S2 of the method shown;
[0047] Figure 4 This is a schematic diagram of the network structure of the graph attention network in the embodiment.
[0048] Figure 5 for Figure 1 The flowchart of step S4 of the method shown is as follows;
[0049] Figure 6 for Figure 1 The flowchart of step S5 of the method shown is illustrated. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0051] Please also refer to Figure 1 and Figure 2 ,in Figure 1 This is a flowchart illustrating the aspect-level sentiment analysis method in this embodiment. Figure 2 For execution Figure 1 The diagram illustrates the structure of an aspect-level sentiment analysis device. This device includes a word embedding module 10, a feature enhancement module 20, a graph attention module 30, a feature fusion module 40, and a classification prediction module 50.
[0052] The word embedding module 10 includes a local word embedding submodule 11 and a global word embedding submodule 12. The local word embedding submodule 11 is used to perform step S11: perform word embedding processing on several words adjacent to the aspect word to be analyzed in the text to be analyzed, and obtain local context features.
[0053] The text to be analyzed includes both sentiment terms and opinion terms, such as "The weather is not so good today, but the scenery here is beautiful," where "weather" and "scenery" are sentiment terms, and "not so good" and "beautiful" are opinion terms corresponding to those sentiment terms. The sentiment terms to be analyzed are those in the text for which sentiment analysis is currently required. The words adjacent to the sentiment terms to be analyzed are those words in the text that are positionally adjacent to the sentiment terms to be analyzed, forming a local context sequence. For example, if the sentiment term to be analyzed is "weather," then the local context sequence includes "The weather is not so good." The number of words extracted can be set according to the actual implementation.
[0054] Word embedding processing involves embedding text into a low-dimensional vector representation. In practice, this can be performed using the BERT model. During processing, the local context sequence is input into the BERT model in the format "[CLS]+text+[SEP]", where "[CLS]" and "[SEP]" are the start and end identifiers, respectively. For a local context sequence containing n words, the resulting local context feature representation after word embedding is c. L ={c L1 ,c L2 ,...,c Ln}
[0055] The global word embedding submodule 12 is used to perform step S12: perform word embedding processing on the text to be analyzed to obtain global context features.
[0056] In the word embedding process, the text to be analyzed is input into the BERT model in the format "[CLS]+text+[SEP]+aspect+[SEP]". For a local context sequence containing m words, the global context feature representation after word embedding is c. G ={c G1 ,c G2 ,...,c Gm}
[0057] The feature enhancement module 20 is used to perform step S2: feature enhancement processing on local context features.
[0058] To further capture relevant information from aspects and local contexts, and to preserve aspect information and the overall semantics of the sentence, feature enhancement processing is applied to local context features. Please refer to [link to details]. Figure 3 This is a flowchart illustrating step S2 performed by the feature enhancement module 20. The feature enhancement module 20 includes a distance calculation submodule 21 and a weighted processing submodule 22. The distance calculation submodule 21 is used to perform step S21: calculating the semantic relevance distance between each word vector in the local context features and the word to be analyzed.
[0059] Here, semantic relevance distance is the positional distance between two words in the text. It measures the relevance between each word vector in the local context features and the word to be analyzed. The semantic relevance distance d between the i-th word vector in the local context features and the word to be analyzed is... i The expression is:
[0060]
[0061] Where i is the position of the i-th word vector in the local context features, p is the center position of the word to be analyzed, and n a The length of the terms to be analyzed.
[0062] The weighted processing submodule 22 is used to perform step S22: weighting the local context features according to the semantic relevance distance to obtain enhanced local context features.
[0063] Among them, word vectors with a semantic relevance distance less than the set relevance threshold are highly relevant to the words in the aspect to be analyzed, and their features are preserved; word vectors with a semantic relevance distance greater than the set relevance threshold are less relevant to the words in the aspect to be analyzed, and their features are weighted and attenuated. Specifically, the weight vector V of the i-th word vector in the local context features...i The expression is:
[0064]
[0065] Where α is the correlation threshold and E is the unit vector.
[0066] By weighting the word vectors in the local context features using weight vectors, we obtain enhanced local context features.
[0067] The graph attention module 30 is used to perform step S3: extract local context features based on graph attention to obtain local graph attention features.
[0068] Specifically, a graph attention network is used to extract local contextual features based on graph attention. Please refer to [link to relevant documentation]. Figure 4 This is a schematic diagram of the graph attention network structure in this embodiment. The graph attention network includes an adjacency layer 31, an attention layer 32, and a weighted summation layer 33. The adjacency layer 31 includes X consecutive adjacency update modules (A1, A2, ..., AX). Each adjacency update module performs convolution processing on the local context features based on the adjacency matrix of the aspect word to be analyzed, obtaining updated local context features. The adjacency matrix includes elements corresponding to the local context feature word vectors, with values of 0 or 1, indicating whether the corresponding word vector is adjacent to the aspect word to be analyzed. If adjacent, the element value is 1; otherwise, it is 0. The updated local context features obtained by the x-th adjacency update module include the i-th word vector. The expression is:
[0069]
[0070] Where σ() is the activation function, A ij Let W be the adjacency matrix. x Let x be the weight of the x-th adjacency update module. Let b be the word vector of the j-th word in the updated local context features obtained by the (x-1)-th adjacency update module. x This is the bias of the x-th adjacency update module.
[0071] The number of adjacency update modules can be set according to the specific implementation. In one specific implementation, the number of adjacency update modules is set to 2.
[0072] Attention layer 32 includes L sub-attention layers, and each sub-attention layer includes K attention heads (a 11 ,...,a lk ,...,a LKThe first sub-attention layer processes the local context features output by the adjacent layer 31, and the second to Lth sub-attention layers process the local context features output by the sub-attention layer above them. Each attention head is used to calculate the attention coefficient between every two word vectors in the local context features based on the attention head parameters. The local context features are then convolved based on the attention coefficients to obtain the updated local context features.
[0073] Among them, the attention coefficient between the k-th attention head of the l-th sub-attention layer and the i-th and j-th word vectors in the local context features. The expression is:
[0074]
[0075] Where ReLU() is the activation function. W represents the attention head parameters of the k-th attention head in the l-th sub-attention layer. lk Let be the weight of the k-th attention head in the l-th sub-attention layer. The input is the i-th word vector from the local context features of the l-th sub-attention layer. Given the j-th word vector from the local context features of the l-th sub-attention layer, The input is the word vector that is closest to the word to be analyzed in the local context features of the l-th sub-attention layer.
[0076] The k-th attention head of the l-th sub-attention layer is based on the attention coefficient. The local context features are convolved, and the output is the updated word vector in the local context features. The expression is:
[0077]
[0078] Where σ() is the sigmoid activation function.
[0079] The number of sub-attention layers and the number of attention heads in each layer can be set according to the specific implementation. In one specific implementation, the number of sub-attention layers is set to 2, and the number of attention heads in each sub-attention layer is set to 32.
[0080] The weighted summation layer 33 is used to perform convolutional summation on the K local context features output by the attention layer 32 to obtain the local graph attention features.
[0081] Wherein, the i-th word vector h of the local graph attention feature i ′ The expression is:
[0082]
[0083] Where, α ij W is the weighting coefficient. α As weight, Let be the i-th word vector of the k-th local context feature.
[0084] The feature fusion module 40 is used to perform step S4: fusing local graph attention features with global context features to obtain sentiment features.
[0085] Specifically, the local graph attention features are fused with the global context features into a single feature vector, which yields the sentiment feature. For further details, please refer to [link to relevant documentation]. Figure 5 This is a flowchart of step S4 executed by the feature fusion module 40. The feature fusion module 40 includes a fusion convolution submodule 41, a local convolution submodule 42, and a weighted processing submodule 43. The fusion convolution submodule 41 is used to execute step S41: perform gated convolution processing on the local graph attention features and the global context features to obtain fusion convolution features.
[0086] The expression for the fused convolutional feature 'a' is:
[0087] a = f relu (h i ′ · a + G · a + a )
[0088] Among them, f relu W is the ReLU activation function. a and V a Let b be the weight matrix. a For bias.
[0089] The local convolution submodule 42 is used to perform step S42: gating convolution processing on the local graph attention features to obtain local convolution features.
[0090] The expression for the local convolutional feature s is:
[0091] s = f relu (h i ′ · s + s )
[0092] Among them, f relu W is the ReLU activation function. s Let b be the weight matrix. s For bias.
[0093] The weighted processing submodule 43 is used to perform step S43: perform dot product processing on the fused convolutional features and local convolutional features to obtain sentiment features.
[0094] Among them, emotional feature C GAT The expression is:
[0095] C GAT =·a
[0096] The classification prediction module 50 is used to perform step S5: perform classification prediction based on sentiment features to obtain the sentiment polarity of the words to be analyzed.
[0097] Specifically, by using a classifier to classify and predict based on sentiment features, the sentiment polarity of the words to be analyzed can be obtained. Further details can be found in the following section. Figure 6 This is a flowchart illustrating step S5 performed by the classification prediction module 50. The classification prediction module 50 includes a multi-head attention submodule 51, a linear transformation submodule 52, and a classification prediction submodule 53. The multi-head attention submodule 51 is used to perform step S51: after concatenating the sentiment features and global context features, multi-head attention feature extraction is performed to obtain the attention feature matrix.
[0098] Specifically, the concatenated feature O is obtained by concatenating the sentiment feature and the global context feature and performing a linear transformation. con Its expression is:
[0099] O con =[C GAT ; G ]×W o
[0100] Among them, W o This is the weight matrix.
[0101] Based on splicing characteristics O con Scaled dot product attention is calculated using multiple attention heads, where the attention representation H output by the i-th attention head is... i The expression is:
[0102]
[0103] Q i =O con ·W i q
[0104] K i =O con ·W i k
[0105] V i =O con ·Wi v
[0106] Among them, W i q W i k and W i v For parameter Q i ,K i V i The weight matrix, d h denoted as the dimension of the hidden layer, and h as the number of attention heads.
[0107] The attention representation H obtained through calculation i splicing feature O con After weighting, the attention feature matrix O is obtained. MHSA Its expression is:
[0108] O MHSA =f tanh ({H1,H2,...,H h}·W MHSA )O con
[0109] Among them, W MHSA Let f be the weight matrix. tanh () is the Tanh activation function.
[0110] The linear transformation submodule 52 is used to perform step S52: perform a linear transformation on the first vector of the attention feature matrix and activate it to obtain the target prediction vector.
[0111] Wherein, the target prediction vector x pool The expression is:
[0112] x pool =f tanh (O MHSA [:,0]·W d×d )
[0113] Among them, O MHSA [:,0] represents the first vector of the attention feature matrix, W d×d Let be a weight matrix of dimension d×d, where d is the dimension of the hidden layer.
[0114] The classification prediction submodule 53 is used to perform step S53: perform classification prediction based on the target prediction vector to obtain the sentiment polarity of the words to be analyzed.
[0115] The sentiment polarity y of the words to be analyzed is obtained by classifying and predicting based on the target prediction vector using the softmax function. Its expression is as follows:
[0116]
[0117] Where C represents the number of categories. In this embodiment, the categories corresponding to the emotional polarity of the aspect words are positive, neutral, and negative, and the number of categories C is 3.
[0118] Compared to existing technologies, the aspect-level sentiment analysis method of this invention fully utilizes the positional information between aspect words and their context by combining local and global contextual features related to aspect words. This results in richer sentiment information in the sentiment features used for sentiment classification and prediction. Furthermore, by extracting features from local contextual features through a graph attention network, it can accurately capture syntactic information and long-distance words, solving the problem of long-distance multi-word dependencies. This allows for the acquisition of deeper syntactic information in the sentence and effectively eliminates the influence of irrelevant words on the sentiment polarity judgment of aspect words, achieving a more reasonable allocation of attention weights and thus improving the accuracy of sentiment analysis results.
[0119] Furthermore, by dynamically weighting local contextual features through semantic relevance distance, extracting contextual features of different granularities through gated convolution, and capturing semantic associations within sentences through multi-head attention mechanisms to focus on important parts of sentences, we can further capture syntactic information related to aspect semantics, thereby enriching the sentiment features.
[0120] Based on the same inventive concept, this application also provides an electronic device, which can be a server, desktop computing device, or mobile computing device (e.g., laptop computing device, handheld computing device, tablet computer, netbook, etc.). The device includes one or more processors and a memory, wherein the processor is used to execute an aspect-level sentiment analysis method implementing a method embodiment; the memory is used to store a computer program executable by the processor.
[0121] Based on the same inventive concept, this application also provides a computer-readable storage medium corresponding to the aforementioned embodiments of the aspect-level sentiment analysis method. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the aspect-level sentiment analysis method described in any of the above embodiments.
[0122] This application may take the form of a computer program product implemented on one or more storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing program code. Computer storage media include permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information may be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to: phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.
[0123] The embodiments described above are merely examples of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and the present invention also intends to include these modifications and variations.
Claims
1. An aspect-level sentiment analysis method, characterized in that, Including the following steps: Obtain the text to be analyzed, and perform word embedding processing on several words adjacent to the words to be analyzed in the text to obtain local context features; The text to be analyzed is subjected to word embedding processing to obtain global context features; The local context features are extracted using a graph attention network to obtain local graph attention features. The local graph attention features are fused with the global context features to obtain the sentiment features; Based on the emotional features, classification and prediction are performed to obtain the emotional polarity of the words to be analyzed. The graph attention network includes an adjacency layer, an attention layer, and a weighted summation layer. The adjacency layer includes X consecutive adjacency update modules. The adjacency update modules are used to perform convolution processing on the local upper and lower features according to the adjacency matrix of the aspect word to be analyzed, so as to obtain updated local context features. The adjacency matrix includes elements corresponding to the local upper and lower feature word vectors. The element value is 0 or 1, which is used to indicate whether the corresponding word vector is adjacent to the aspect word to be analyzed. If they are adjacent, the element value is 1; if they are not adjacent, the element value is 0. The attention layer includes L sub-attention layers, and each sub-attention layer includes K attention heads. The attention heads are used to calculate the attention coefficient between every two word vectors in the updated local context features based on the attention head parameters. The local context features are then convolved based on the attention coefficients to obtain the updated local context features. The weighted summation layer is used to perform convolutional summation on the local context features output by the attention layer to obtain local graph attention features; The process of fusing the local graph attention features with the global context features includes the following steps: Gated convolution is performed on the local graph attention features and the global context features to obtain fused convolution features; The local graph attention features are subjected to gated convolution to obtain local convolution features; The fused convolutional features and the local convolutional features are processed by dot product to obtain the sentiment features.
2. The method according to claim 1, characterized in that, After performing word embedding processing on several words adjacent to the word to be analyzed in the text to be analyzed to obtain local context features, the method further includes the following steps: Calculate the semantic relevance distance between each word vector in the local context features and the word to be analyzed; The local context features are weighted based on the semantic relevance distance to obtain enhanced local context features.
3. The method according to claim 2, characterized in that, The expression for the semantic relevance distance is: in, This represents the semantic relevance distance between the i-th word vector in the local context features and the word to be analyzed. This represents the position of the i-th word vector in the local context features. The central position of the terms to be analyzed. The length of the terms to be analyzed.
4. The method according to claim 2 or 3, characterized in that, The weight vector of the i-th word vector in the local context features The expression is: in, For the relevant threshold, Let n be a unit vector, and n be the number of word vectors in the local context features. This represents the semantic relevance distance between the i-th word vector in the local context features and the word to be analyzed. This represents the position of the i-th word vector in the local context features.
5. The method according to claim 1, characterized in that, The classification and prediction based on the emotional features includes the following steps: After concatenating the emotion features with the global context features, multi-head attention feature extraction is performed to obtain the attention feature matrix; A linear transformation and activation are performed on the first vector of the attention feature matrix to obtain the target prediction vector; Based on the target prediction vector, classification prediction is performed to obtain the sentiment polarity of the words to be analyzed.
6. An aspect-level sentiment analysis device, characterized in that, include: The local word embedding submodule is used to obtain the text to be analyzed, and to perform word embedding processing on several words adjacent to the words to be analyzed in the text to obtain local context features; The global word embedding submodule is used to perform word embedding processing on the text to be analyzed to obtain global context features; The graph attention module is used to extract local context features based on graph attention through a graph attention network to obtain local graph attention features. The graph attention network includes an adjacency layer, an attention layer, and a weighted summation layer. The adjacency layer includes X consecutive adjacency update modules. Each adjacency update module performs convolution processing on the local upper and lower features based on the adjacency matrix of the aspect word to be analyzed, obtaining updated local context features. The adjacency matrix includes elements corresponding to the word vectors of the local upper and lower features, with element values of 0 or 1, indicating whether the corresponding word vector is adjacent to the aspect word to be analyzed; if adjacent, the element value is 1, and if not adjacent, the element value is 0. The attention layer includes L sub-attention layers, and each sub-attention layer includes K attention heads. The attention heads are used to calculate the attention coefficient between every two word vectors in the updated local context features based on the attention head parameters. The local context features are then convolved based on the attention coefficients to obtain the updated local context features. The weighted summation layer is used to perform convolutional summation on the local context features output by the attention layer to obtain local graph attention features; A feature fusion module is used to fuse the local graph attention features with the global context features to obtain sentiment features. The feature fusion module includes a fusion convolution submodule, a local convolution submodule, and a weighted processing submodule. The fusion convolution submodule performs gated convolution on the local graph attention features and the global context features to obtain fused convolutional features. The local convolution submodule performs gated convolution on the local graph attention features to obtain local convolutional features. The weighted processing submodule performs dot product processing on the fused convolutional features and the local convolutional features to obtain sentiment features. The classification prediction module is used to perform classification prediction based on the sentiment features to obtain the sentiment polarity of the aspect words to be analyzed.
7. An electronic device, characterized in that, include: processor; Memory for storing computer programs executed by the processor; Wherein, when the processor executes the computer program, it implements the steps of the method according to any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed, it performs the steps of the method according to any one of claims 1-5.
Citation Information
Patent Citations
Text aspect level emotion recognition method based on bidirectional LSTM (Long Short Term Memory) and multi-head attention mechanism
CN114648031A