Aspect-level sentiment analysis method, device, electronic device and storage medium

By constructing an influence matrix to generate dependency trees and dynamic local features in aspect-level sentiment analysis, and combining global word embedding vectors for feature fusion, the problem of insufficient accuracy of dependency trees in the existing technology is solved, and the accuracy and prediction of sentiment analysis are improved. result.

CN115017916BActive Publication Date: 2024-09-27QIZHITU TECHNOLOGY (GUANGZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210742644.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-28
Publication Date
2024-09-27
Estimated Expiration
2042-06-28

AI Technical Summary

Technical Problem

The accuracy of the dependency tree generated by existing aspect-level sentiment analysis methods is not high, leading to error propagation and affecting the accuracy of the final prediction results.

Method used

By constructing an influence matrix in the target text to generate a dependency tree, the relationship between words is obtained, the dynamic threshold determines the local context features, and the global word embedding vector is combined for feature fusion to predict the emotional polarity of aspect words.

Benefits of technology

It improves the accuracy of inter-word relationships, reduces error propagation, improves the accuracy of aspect-level sentiment analysis and predicts the polarity of target aspect words.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115017916B
    Figure CN115017916B
Patent Text Reader

Abstract

The present invention relates to an aspect-level sentiment analysis method: obtaining a target text to be analyzed and a target aspect word; after masking and marking the i-th word in the target text, inputting the pre-trained language model to obtain a first vector representation; after masking and marking the i-th word and the j-th word in the target text together, inputting the pre-trained language model to obtain a second vector representation; calculating the influence value between the i-th word and the j-th word according to the first vector representation and the second vector representation, and constructing an influence matrix according to the influence value between every two words; extracting a dependency tree from the influence matrix; obtaining local context features according to the dependency tree and the target aspect word; inputting the target text and the target aspect word into a word embedding model to obtain a global word embedding vector; fusing the global word embedding vector and the local context feature to obtain a fused feature; predicting according to the fused feature to obtain the polarity of the target aspect word in the target text. The accuracy of polarity prediction of the target aspect word is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of aspect-level sentiment analysis, and in particular to an aspect-level sentiment analysis method, device, electronic device and storage medium. Background Art

[0002] With the rapid development of information technology and the Internet, Internet users have changed from passive receivers of information to active providers, and a large amount of valuable commentary information about events, goods, services, etc. has been generated online, expressing the emotional tendencies and opinions of Internet users. The rapid expansion of network information has put forward higher requirements for the collection, processing and analysis of information, and has also promoted the development of sentiment analysis as a research direction.

[0003] Among them, aspect-based sentiment analysis (ABSA) is a fine-grained sentiment analysis task that aims to mine the sentiment polarity of specified aspect words from text. For example, in the user comments of a certain life APP, for a sentence (such as: today's movie is very good) and a specified aspect word (such as: movie), the sentiment polarity of the aspect word is positive through aspect-based sentiment analysis. Compared with paragraph or sentence-level sentiment classification, aspect-based sentiment analysis can provide more comprehensive and in-depth analysis.

[0004] The existing aspect-level sentiment analysis method includes the following steps: obtaining a target text to be analyzed and aspect words in the target text; generating a dependency tree based on the target text through traditional open source tools; extracting the path length from the aspect word to the word having a dependency relationship with the aspect word from the dependency tree, and determining the local context scope and dependency cluster according to the path length; performing attention calculation on the dependency cluster to determine the semantic information within the local context scope; and performing prediction based on the semantic information within the local context scope and the global context information to determine the sentiment polarity of the aspect word in the target text.

[0005] However, the dependency tree generated by this aspect-level sentiment analysis method is not very accurate, which leads to the problem of error propagation in subsequent steps and affects the accuracy of the final prediction results. Summary of the invention

[0006] The purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and to provide an aspect-level sentiment analysis method that can improve the accuracy of the influence relationship between words and reduce error propagation, thereby improving the accuracy of aspect-level sentiment analysis.

[0007] The present invention is implemented by the following technical scheme: an aspect-level sentiment analysis method, comprising the steps of:

[0008] Obtain the target text and target aspect words to be analyzed;

[0009] After masking the i-th word in the target text, the target text is input into a pre-trained language model to obtain a first vector representation of the i-th word; after masking the i-th word and the j-th word in the target text together, the target text is input into a pre-trained language model to obtain a second vector representation of the i-th word; the influence value between the i-th word and the j-th word is calculated according to the first vector representation and the second vector representation, and an influence matrix is ​​constructed according to the influence value between every two words in the target text; a dependency tree is extracted from the influence matrix; and local context features of the target text are obtained according to the dependency tree and the target aspect word;

[0010] Input the target text and the target aspect word into a word embedding model to obtain a global word embedding vector;

[0011] Performing feature fusion on the global word embedding vector and the local context feature to obtain a fused feature;

[0012] Prediction is performed based on the fused features to obtain the polarity of the target aspect word in the target text.

[0013] Compared with the prior art, the present invention provides an aspect-level sentiment analysis method that generates a dependency tree through an influence matrix composed of inter-word distances in a target text, and can obtain accurate inter-word relationships. The dynamic threshold obtained through this dependency tree is used to determine the local range of local context features, and more effective local semantic information can be obtained, thereby improving the accuracy of polarity prediction for target aspect words.

[0014] Further, obtaining the local context features of the target text according to the dependency tree and the target aspect words comprises the steps of:

[0015] According to the dependency tree, the proximity value between each word in the target text and the target aspect word is obtained, and the maximum proximity value is determined as a dynamic threshold. According to the dynamic threshold, a dynamic local feature is determined through a context dynamic mask or a context dynamic weighting, and the dynamic local feature is determined as a local context feature.

[0016] Further, obtaining the local context features of the target text according to the dependency tree and the target aspect words comprises the steps of:

[0017] Obtaining the proximity value between each word in the target text and the target aspect word according to the dependency tree, determining the maximum proximity value as a dynamic threshold, and determining a dynamic local feature according to the dynamic threshold through a context dynamic mask or a context dynamic weighting;

[0018] Extracting a dependent cluster and a dependent cluster of the target aspect word in the target text according to the dependency tree, wherein the dependent cluster is a collection of dependent words of the target aspect word, and the dependent cluster is an aggregation of dependent words of the target aspect word;

[0019] The dynamic local feature is respectively fused with the dependent cluster and the dependent cluster to obtain a local dependent feature and a local dependent feature;

[0020] A local context feature is obtained according to the local dependent feature and the local dependent feature.

[0021] Furthermore, obtaining the local context feature of the target text according to the dependency tree and the target aspect word also includes the steps of: extracting the part-of-speech feature of each word in the target text, and fusing the part-of-speech feature with the dynamic local feature to obtain a local part-of-speech feature;

[0022] After the dynamic local feature is fused with the dependent cluster and the dependent cluster respectively to obtain the local dependent feature and the local dependent feature, the method further includes the steps of: adding local part-of-speech features to the local dependent feature and the local dependent feature respectively.

[0023] Further, obtaining a local context feature according to the local dependency feature and the local dependent feature comprises the steps of:

[0024] After performing multi-head attention calculation on the local dependent features and the local dependent features, pooling is performed to obtain dependent clustering features and dependent clustering features;

[0025] The dependent clustering features and the dependent clustering features are respectively mapped to a high-dimensional space through a linear function to obtain a high-dimensional vector, and then the high-dimensional vector is calculated through a linear function to obtain a local dependent semantic value and a local dependent semantic value;

[0026] A local context feature is obtained through a gating mechanism according to the local dependency semantic value and the local dependent semantic value. The expression of the local context feature is:

[0027]

[0028] in, is the local context feature; V CDM / CDM W is the dynamic local feature determined by context dynamic mask or context dynamic weighting; j sub =W sub *R j , W j gov =Wgov *(1-R j ), W sub is the dependency cluster, W gov is the dependent cluster, R j is the reset function, reset function R j The expression is:

[0029] R j =sigmoid(W r1 ·GS j +W r2 ·SS j +b r )

[0030] Among them, W r1 and W r2 is a trainable parameter; b r is the bias term; GS j is the local dependent semantic value; SS j The local dependent semantic value.

[0031] Further, the global word embedding vector and the local context feature are subjected to feature fusion to obtain a fused feature, comprising the steps of:

[0032] After the global word embedding vector and the local context feature are concatenated, they are fused through the PCT model and encoded through multi-head attention to obtain the fused feature.

[0033] Based on the same inventive concept, the present invention also provides an aspect-level sentiment analysis device, comprising:

[0034] An acquisition module is used to acquire the target text and target aspect words to be analyzed;

[0035] A local context feature acquisition module is used to perform mask marking on the i-th word in the target text, input the target text into a pre-trained language model to obtain a first vector representation of the i-th word; perform mask marking on the i-th word and the j-th word in the target text together, input the target text into a pre-trained language model to obtain a second vector representation of the i-th word; calculate the influence value between the i-th word and the j-th word according to the first vector representation and the second vector representation, and construct an influence matrix according to the influence value between every two words in the target text; extract a dependency tree from the influence matrix; and obtain the local context feature of the target text according to the dependency tree and the target aspect word;

[0036] A global word embedding vector acquisition module is used to input the target text and the target aspect word into a word embedding model to obtain a global word embedding vector;

[0037] A feature fusion module, used for fusing the global word embedding vector and the local context feature to obtain a fused feature;

[0038] The prediction module is used to make predictions based on the fusion features to obtain the polarity of the target aspect word in the target text.

[0039] Furthermore, the local context feature acquisition module includes:

[0040] The dynamic local feature acquisition submodule is used to obtain the proximity value between each word in the target text and the target aspect word according to the dependency tree, determine the maximum proximity value as a dynamic threshold, determine the dynamic local feature according to the dynamic threshold through context dynamic masking or context dynamic weighting, and determine the dynamic local feature as a local context feature.

[0041] Based on the same inventive concept, the present invention also provides an electronic device, including:

[0042] processor;

[0043] a memory for storing a computer program executed by the processor;

[0044] Wherein, the processor implements the steps of the above method when executing the computer program.

[0045] Based on the same inventive concept, the present invention also provides a computer-readable storage medium on which a computer program is stored, and the steps of the above method are implemented when the computer program is executed.

[0046] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 Schematic diagram of the process of aspect-level sentiment analysis method of an embodiment;

[0048] Figure 2 A schematic diagram of a process of generating a dependency tree according to a target text in an embodiment;

[0049] Figure 3 A schematic diagram of a process of obtaining local context features of a target text according to a dependency tree in an embodiment;

[0050] Figure 4 A schematic diagram of a process of obtaining a local context feature according to a local dependent feature and a local dependent feature in an embodiment;

[0051] Figure 5 It is a structural schematic diagram of the aspect-level sentiment analysis device of an embodiment. DETAILED DESCRIPTION

[0052] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

[0053] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0054] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0055] In the description of the present application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0056] See also Figure 1 , which is a flow chart of the aspect-level sentiment analysis method of this embodiment. The method comprises the steps of:

[0057] S1: Obtain the target text and target aspect words to be analyzed.

[0058] S2: Generate a dependency tree based on the target text, and obtain the local context features of the target text based on the dependency tree and the target aspect words.

[0059] S3: Input the target text and target aspect words into the word embedding model to obtain the global word embedding vector.

[0060] S4: Fuse the global word embedding vector and local context features to obtain fused features.

[0061] S5: Predict based on the fused features to obtain the polarity of the target aspect word in the target text.

[0062] In step S1, the target text to be analyzed may be one or more sentences, and the target aspect word is an aspect word in the target text.

[0063] In step S2, a dependency tree (DT) is generated for each word in the target text. For example, if an adjective modifies a noun, then the noun depends on the adjective. The dependency tree can be used to explore the modification relationship between words in the target text. Figure 2 , which is a flow chart of generating a dependency tree according to a target text in this embodiment, including the steps of:

[0064] S211: After masking and marking the i-th word in the target text, the target text is input into the pre-trained language model to obtain the first vector representation of the i-th word.

[0065] S212: After masking and marking the i-th word and the j-th word in the target text, the target text is input into the pre-trained language model to obtain a second vector representation of the i-th word.

[0066] In a specific implementation, the pre-trained language model in steps S211 and S212 can be selected as RoBERTa.

[0067] S213: Calculate the influence value between the i-th word and the j-th word according to the first vector representation and the second vector representation, and construct an influence matrix according to the influence value between every two words in the target text.

[0068] For a target text containing n words The i-th word and the jth word The impact value between It can be expressed by Euclidean distance. The expression is:

[0069]

[0070] in, is the i-th word in the target text The first vector representation of ; is the i-th word in the target text The second vector representation of .

[0071] By calculating the influence value between each two words Construct influence matrix M∈R T×T , affecting the element in row i and column j of the matrix

[0072] S214: Extract a dependency tree from the impact matrix.

[0073] In a specific implementation, a tree decoding algorithm, such as the Eisner, Chu-Liu / Edmonds algorithm, may be used to extract a dependency tree from the influence matrix.

[0074] See also Figure 3 , which is a flow chart of obtaining local context features of a target text according to a dependency tree in this embodiment, specifically comprising the steps of:

[0075] S221: Obtain a dynamic local feature of the target text according to the dependency tree, and determine that the dynamic local feature is a local context feature.

[0076] Specifically, the proximity value between each word in the target text and the target aspect word is obtained according to the dependency tree. The proximity value is the root of the shortest path SRD from the word in the target text to the target aspect word in the dependency tree; or, when the aspect is composed of multiple aspect words, the proximity value is the root of the average distance of each aspect word in the words in the target text. The acquisition of the proximity value can be achieved through the proximity weighted convolutional network (PWCN) model. The expression of the proximity value between the i-th word and the target aspect word is

[0077]

[0078] The maximum proximity value in the target text is determined as the dynamic threshold, that is, the local feature range, and the dynamic local features are determined according to the dynamic threshold through context dynamic mask (CDM) or context dynamic weighted (CDW). Among them, the words with proximity values ​​greater than the dynamic threshold are regarded as non-local context words. The context dynamic mask masks the features of non-local context words by setting them to zero vectors. Then the mask vector of the i-th word in the target text is The expression is:

[0079]

[0080] Among them, SRD i is the proximity value corresponding to the i-th word in the target text, α is the dynamic threshold, α=Dynamic_threshold(SRD max ), I is a vector of 1s, and O is a vector of 0s.

[0081] Dynamic local features V obtained by contextual dynamic mask CDM The expression is:

[0082]

[0083] in, is the local word embedding vector of the target text. Each word can be mapped to the embedding vector through the pre-trained language model Bert where d h is the hidden layer dimension. Before the target text is input into Bert, each word of the target text is first converted into a word index through Bert's index vocabulary, and auxiliary information such as segment embedding and position embedding are constructed; then the word index, segment embedding and position embedding are input into the Bert encoder to obtain the Bert local context embedding In the specific implementation, BERT-Base is used as input, namely "[CLS]" + sequence + "[SEP]".

[0084] M is the mask matrix,

[0085] Context dynamic weighting weakens the features of non-local context words by weakening their weights. Then the weight vector of the i-th word in the target text is The expression is:

[0086]

[0087] Dynamic local features V obtained by dynamic context weighting CDM The expression is:

[0088]

[0089] Where W is the weight matrix,

[0090] In a preferred embodiment, obtaining the local context features of the target text according to the dependency tree specifically includes the following steps:

[0091] S221: Obtain the dynamic local feature of the target text according to the dependency tree, and determine that the dynamic local feature is a local context feature. The specific details are the same as step S221 in the above embodiment, and will not be repeated here.

[0092] S222: Extracting the dependency cluster and the dependent cluster of the target aspect word in the target text according to the dependency tree.

[0093] Among them, the dependency cluster is a collection of dependent words. The dependent words are the words pointed to by the target aspect words in the dependency tree, usually adjectives or sentiment words used to modify aspect words. The dependency cluster is expressed as

[0094] The dependent cluster is a collection of dependent words. A dependent word is a word that points to the target aspect word in the dependency tree. The dependent cluster is represented as

[0095] The extraction process also includes disconnected clusters, which are sets of words that have no connection with the target aspect words. Disconnected clusters are represented as

[0096] S224: Fusing the dynamic local features with the dependent cluster and the dependent cluster respectively to obtain local dependent features and local dependent features.

[0097] Specifically, the Mask(x1,x2) function can be used to perform matrix multiplication on the dependent cluster and the dependent cluster with the dynamic local features to obtain the local dependent features. The expression is:

[0098]

[0099] Locally dependent features The expression is:

[0100]

[0101] S225: Obtain local context features according to the local dependency features and the local dependent features.

[0102] Specifically, see Figure 4 , which is a flow chart of obtaining local context features according to local dependent features and local dependent features in this embodiment, including the steps of:

[0103] S2251: After multi-head attention (MHSA) calculation is performed on the local dependent features and the local dependent features, they are pooled to obtain dependent clustering features and dependent clustering features.

[0104] Among them, the attention H of h attention heads can be calculated by scaling the dot product attention mechanism, the attention H of h attention heads are spliced ​​through the hidden layer, and Tanh is applied as the activation function. The expression of multi-head attention calculation is:

[0105] MHSA(X D )=Tanh({H1;H2;...;H h}·W h +b h )

[0106] Among them, X D is the input word vector, i.e., the local dependency feature or locally dependent features W h is the trainable weight; b h is the bias vector; the attention H of the i-th attention head i The expression is:

[0107]

[0108] in, are the trainable weights of Q, K, and V respectively, are the bias vectors of Q, K, and V respectively; is the dimension of the hidden layer of the input word vector.

[0109] The local dependency features and local dependent features calculated by the head attention are pooled to further extract semantic information. During pooling, the first vector in the local dependency features and local dependent features is used as the aggregated semantic information. The expression of the pooling process is:

[0110] POOL(x1,x2,...,x n )=Tanh(x1·W p +b p )

[0111] Among them, (x1,x2,...,x n ) is the vector of the local dependent feature or local dependent feature of the input pool; W p is the trainable weight; b p For bias.

[0112] S2252: Calculate the local dependency semantic value and the local dependent semantic value according to the dependency clustering feature and the dependent clustering feature.

[0113] Specifically, the dependent clustering features and the dependent clustering features are mapped to the high-dimensional space through the linear function Linear to obtain a high-dimensional vector, and then the high-dimensional vector is calculated through the linear function Linear to obtain the local dependency semantic value SS with deeper semantic information j and the local dependent semantic value GS j When the linear function is used to map to a high-dimensional space, the activation function used is GELU. When the linear function is used to calculate a high-dimensional vector, the activation function used is Sigmoid.

[0114] S2253: Obtain local context features through a gating mechanism (GM) based on the local dependency semantic value and the local dependent semantic value. The expression is:

[0115]

[0116]

[0117] Among them, R jis a reset function for local dependency semantic value SS j and the local dependent semantic value GS j The weight value is evaluated and expressed as:

[0118] R j =sigmoid(W r1 ·GS j +W r2 ·SS j +b r )

[0119] Among them, W r1 and W r2 is a trainable parameter, b r is the bias term.

[0120] Therefore, by resetting the function R j After allocating attention to the dependent cluster and the dependent cluster, they are multiplied with the dynamic local features and then added together to obtain the final local context features.

[0121] In a preferred embodiment, the local context features of the target text are obtained according to the dependency tree, and step S223 is also included: extracting the part-of-speech features of each word in the target text, and fusing the part-of-speech features with the dynamic local features to obtain local part-of-speech features.

[0122] Among them, the part-of-speech feature is expressed as:

[0123] The expression of local part-of-speech feature is:

[0124]

[0125] In step S224, after the dynamic local features are fused with the dependent cluster and the dependent cluster to obtain the local dependent features and the local dependent features, the step of adding the local part-of-speech features to the local dependent features and the local dependent features is further included. Then, the local dependent features The expression is:

[0126]

[0127] Locally dependent features The expression is:

[0128]

[0129] In step S3, each word of the target text can be mapped to an embedding vector using the pre-trained language model Bert where d his the hidden layer dimension. Before the target text is input into Bert, each word of the target text is first converted into a word index through Bert's index vocabulary, and auxiliary information such as segment embedding and position embedding is constructed; then the word index, segment embedding and position embedding are input into the Bert encoder to obtain the global word embedding vector represented as In the specific implementation, BERT-SPC is used as input, namely “[CLS]”+sequence+“[SEP]”+aspect+“[SEP]”.

[0130] In step S4, the global word embedding vector and local context features After splicing, the PCT (Position-Wise Convolution Transformation) model is used for fusion, and the multi-head attention MHSA is used for encoding to obtain the fusion feature. The expression is:

[0131]

[0132] in, Characteristic of PCT fusion, W1 and W2 are trainable parameters, b1 and b2 are bias terms, W lg is the global word embedding vector and local context features splicing.

[0133] In step S5, after merging the fused features with the hidden state of the target text through pooling, the polarity of the target aspect word in the target text is predicted through the argmax layer. The expression of the predicted value of the polarity, Sentiment_Polarity, is:

[0134] Sentiment_Polarity=argmax(O pool *W o +b o )

[0135] in, It is the merging of the fusion features and the hidden state of the target text.

[0136] The hidden state of the target text is the semantic representation of the target text, usually a vector of multiple dimensions, which can be called from BERT.

[0137] Compared with the prior art, the present invention generates a dependency tree through an influence matrix formed by the distance between words in the target text, which can obtain accurate inter-word relationships. The local scope of the local context feature is determined by the dynamic threshold obtained through this dependency tree, which can obtain more effective local semantic information, thereby improving the accuracy of the polarity prediction of the target aspect word. Furthermore, the present invention integrates the dependency relationship between the target aspect word and the remaining words in the local context feature, and analyzes the contribution of the dependent cluster and the dependent cluster to the semantics through attention and weighted calculation, so as to locate the words with a higher degree of influence on the sentiment polarity prediction in the local scope, which can further improve the accuracy of the polarity prediction of the target aspect word. In addition, the present invention also integrates the part-of-speech features of the target text in the local context feature. The part-of-speech features can further enrich the semantic information of the local context feature and help predict the polarity of the target aspect word.

[0138] Based on the same inventive concept, the present invention also provides an aspect-level sentiment analysis device. Figure 5 , which is a structural diagram of the aspect-level sentiment analysis device of this embodiment, the device includes an acquisition module 10, a local context feature acquisition module 20, a global word embedding vector acquisition module 30, a feature fusion module 40 and a prediction module 50, wherein the acquisition module 10 is used to acquire the target text and target aspect words to be analyzed; the local context feature acquisition module 20 is used to generate a dependency tree according to the target text, and obtain the local context features of the target text according to the dependency tree and the target aspect words; the global word embedding vector acquisition module 30 is used to input the target text and the target aspect words into the word embedding model together to obtain the global word embedding vector; the feature fusion module 40 is used to fuse the global word embedding vector and the local context feature to obtain the fused feature; the prediction module 50 is used to predict according to the fused feature to obtain the polarity of the target aspect word in the target text.

[0139] More specifically, the local context feature acquisition module 20 includes a dependency tree generation submodule 21 and a dynamic local feature acquisition submodule 22 .

[0140] The dependency tree generation submodule 21 is used to mask and mark the i-th word in the target text, and then input the target text into the pre-trained language model to obtain the first vector representation of the i-th word; mask and mark the i-th word and the j-th word in the target text together, and then input the target text into the pre-trained language model to obtain the second vector representation of the i-th word; calculate the influence value between the i-th word and the j-th word according to the first vector representation and the second vector representation, and construct an influence matrix according to the influence value between every two words in the target text; and extract the dependency tree from the influence matrix.

[0141] The dynamic local feature acquisition submodule 22 is used to obtain the dynamic local features of the target text according to the dependency tree, and determine that the dynamic local features are local context features. Specifically, the proximity value between each word in the target text and the target aspect word is obtained according to the dependency tree; the maximum proximity value in the target text is determined as the dynamic threshold, that is, the local feature range, and the dynamic local features are determined according to the dynamic threshold through context dynamic masking or context dynamic weighting.

[0142] In a preferred embodiment, the local context feature acquisition module 20 also includes a cluster extraction submodule 23, a first fusion submodule 24 and a second fusion submodule 25, wherein the cluster extraction submodule 23 is used to extract the dependency cluster and the dependent cluster of the target aspect word in the target text according to the dependency tree; the first fusion submodule 24 is used to fuse the dynamic local features with the dependency cluster and the dependent cluster respectively to obtain local dependency features and local dependent features; the second fusion submodule 25 is used to obtain local context features based on the local dependency features and the local dependent features.

[0143] More specifically, the final fusion submodule 25 is used to perform multi-head attention (MHSA) calculation on the local dependency features and the local dependent features, and then perform pooling to obtain dependency clustering features and dependent clustering features; calculate the local dependency semantic value and the local dependent semantic value based on the dependency clustering features and the dependent clustering features; and obtain the local context features through a gating mechanism (GM) based on the local dependency semantic value and the local dependent semantic value.

[0144] In a preferred embodiment, the local context feature acquisition module 20 further includes a local part-of-speech feature acquisition submodule 26, which is used to extract the part-of-speech feature of each word in the target text, and fuse the part-of-speech feature with the dynamic local feature to obtain the local part-of-speech feature. The first fusion submodule 24 fuses the dynamic local feature with the dependent cluster and the dependent cluster to obtain the local dependent feature and the local dependent feature, and then adds the local part-of-speech feature to the local dependent feature and the local dependent feature.

[0145] As for the device embodiment, since it basically corresponds to the method embodiment, please refer to the description of the method embodiment for relevant details.

[0146] Based on the same inventive concept, the present invention also provides an electronic device, which may be a terminal device such as a server, a desktop computing device or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). The electronic device includes one or more processors and a memory, wherein the processor is used to execute the aspect-level sentiment analysis method of the program implementation method embodiment; and the memory is used to store a computer program executable by the processor.

[0147] Based on the same inventive concept, the present invention also provides a computer-readable storage medium, corresponding to the embodiment of the aforementioned aspect-level sentiment analysis method, wherein the computer-readable storage medium stores a computer program thereon, and when the program is executed by a processor, the steps of the aspect-level sentiment analysis method recorded in any of the above-mentioned embodiments are implemented.

[0148] The present 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-usable storage media include permanent and non-permanent, removable and non-removable media, and information storage can be achieved by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.

[0149] The above-mentioned embodiments only express several implementation methods of the present invention, and the description is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, and the present invention is also intended to include these modifications and modifications.

Claims

1. A method for aspect-level sentiment analysis, characterized in that: Includes steps: Obtain the target text and target aspect words to be analyzed; After masking the i-th word in the target text, the target text is input into a pre-trained language model to obtain a first vector representation of the i-th word; After masking the i-th word and the j-th word in the target text, the target text is input into a pre-trained language model to obtain a second vector representation of the i-th word; the influence value between the i-th word and the j-th word is calculated according to the first vector representation and the second vector representation, and an influence matrix is ​​constructed according to the influence value between every two words in the target text; a dependency tree is extracted from the influence matrix; and local context features of the target text are obtained according to the dependency tree and the target aspect word; Input the target text and the target aspect word into a word embedding model to obtain a global word embedding vector; Performing feature fusion on the global word embedding vector and the local context feature to obtain a fused feature; Predicting based on the fusion features to obtain the polarity of the target aspect word in the target text; Wherein, obtaining the local context features of the target text according to the dependency tree and the target aspect words specifically includes the steps of: Obtaining the proximity value between each word in the target text and the target aspect word according to the dependency tree, determining the maximum proximity value as a dynamic threshold, and determining a dynamic local feature according to the dynamic threshold through a context dynamic mask or a context dynamic weighting; Extracting a dependent cluster and a dependent cluster of the target aspect word in the target text according to the dependency tree, wherein the dependent cluster is a collection of dependent words of the target aspect word, and the dependent cluster is an aggregation of dependent words of the target aspect word; The dynamic local feature is respectively fused with the dependent cluster and the dependent cluster to obtain a local dependent feature and a local dependent feature; Obtaining a local context feature according to the local dependent feature and the local dependent feature; The step of obtaining the local context feature according to the local dependency feature and the local dependent feature specifically includes the following steps: After performing multi-head attention calculation on the local dependent features and the local dependent features, pooling is performed to obtain dependent clustering features and dependent clustering features; The dependent clustering features and the dependent clustering features are respectively mapped to a high-dimensional space through a linear function to obtain a high-dimensional vector, and then the high-dimensional vector is calculated through a linear function to obtain a local dependent semantic value and a local dependent semantic value; A local context feature is obtained through a gating mechanism according to the local dependency semantic value and the local dependent semantic value. The expression of the local context feature is: in, is the local context feature; V CDM / CDW The dynamic local feature is determined by context dynamic mask or context dynamic weighting; W sub is the dependency cluster, W gov For the dependent cluster, R j is the reset function, reset function R j The expression is: R j =sigmoid(W r1 ·GS j +W r2 ·SS j +b r ) Among them, W r1 and W r2 is a trainable parameter; b r is the bias term; GS j is the local dependent semantic value; SS j is the locally dependent semantic value.

2. The method according to claim 1, characterized in that Obtaining the local context features of the target text according to the dependency tree and the target aspect words comprises the steps of: According to the dependency tree, the proximity value between each word in the target text and the target aspect word is obtained, and the maximum proximity value is determined as a dynamic threshold. According to the dynamic threshold, a dynamic local feature is determined through a context dynamic mask or a context dynamic weighting, and the dynamic local feature is determined as a local context feature.

3. The method according to claim 1, characterized in that Obtaining the local context features of the target text according to the dependency tree and the target aspect words, further comprising the steps of: extracting the part-of-speech features of each word in the target text, and fusing the part-of-speech features with the dynamic local features to obtain local part-of-speech features; After the dynamic local feature is fused with the dependent cluster and the dependent cluster respectively to obtain the local dependent feature and the local dependent feature, the method further includes the steps of: adding local part-of-speech features to the local dependent feature and the local dependent feature respectively.

4. The method according to claim 1, characterized in that: The global word embedding vector and the local context feature are subjected to feature fusion to obtain a fusion feature, including the steps of: After the global word embedding vector and the local context feature are concatenated, they are fused through the PCT model and encoded through multi-head attention to obtain the fused feature.

5. An aspect-level sentiment analysis device, characterized in that: include: An acquisition module is used to acquire the target text and target aspect words to be analyzed; A local context feature acquisition module, used for performing mask marking on the i-th word in the target text, and then inputting the target text into a pre-trained language model to obtain a first vector representation of the i-th word; After masking the i-th word and the j-th word in the target text, the target text is input into a pre-trained language model to obtain a second vector representation of the i-th word; the influence value between the i-th word and the j-th word is calculated according to the first vector representation and the second vector representation, and an influence matrix is ​​constructed according to the influence value between every two words in the target text; a dependency tree is extracted from the influence matrix; and local context features of the target text are obtained according to the dependency tree and the target aspect word; A global word embedding vector acquisition module is used to input the target text and the target aspect word into a word embedding model to obtain a global word embedding vector; A feature fusion module, used for fusing the global word embedding vector and the local context feature to obtain a fused feature; A prediction module, used for making predictions based on the fusion features to obtain the polarity of the target aspect word in the target text; Wherein, obtaining the local context features of the target text according to the dependency tree and the target aspect words specifically includes the steps of: Obtaining the proximity value between each word in the target text and the target aspect word according to the dependency tree, determining the maximum proximity value as a dynamic threshold, and determining a dynamic local feature according to the dynamic threshold through a context dynamic mask or a context dynamic weighting; Extracting a dependent cluster and a dependent cluster of the target aspect word in the target text according to the dependency tree, wherein the dependent cluster is a collection of dependent words of the target aspect word, and the dependent cluster is an aggregation of dependent words of the target aspect word; The dynamic local feature is respectively fused with the dependent cluster and the dependent cluster to obtain a local dependent feature and a local dependent feature; Obtaining a local context feature according to the local dependent feature and the local dependent feature; The step of obtaining the local context feature according to the local dependency feature and the local dependent feature specifically includes the following steps: After performing multi-head attention calculation on the local dependent features and the local dependent features, pooling is performed to obtain dependent clustering features and dependent clustering features; The dependent clustering features and the dependent clustering features are respectively mapped to a high-dimensional space through a linear function to obtain a high-dimensional vector, and then the high-dimensional vector is calculated through a linear function to obtain a local dependent semantic value and a local dependent semantic value; A local context feature is obtained through a gating mechanism according to the local dependency semantic value and the local dependent semantic value. The expression of the local context feature is: in, is the local context feature; V CDM / CDW The dynamic local feature is determined by context dynamic mask or context dynamic weighting; W sub is the dependency cluster, W gov is the dependent cluster, R j is the reset function, reset function R j The expression is: R j =sigmoid(W r1 ·GS j +W r2 ·SS j +b r ) Among them, W r1 and W r2 is a trainable parameter; b r is the bias term; GS j is the local dependent semantic value; SS j The local dependent semantic value.

6. The device according to claim 5, characterized in that The local context feature acquisition module includes: The dynamic local feature acquisition submodule is used to obtain the proximity value between each word in the target text and the target aspect word according to the dependency tree, determine the maximum proximity value as a dynamic threshold, determine the dynamic local feature according to the dynamic threshold through context dynamic masking or context dynamic weighting, and determine the dynamic local feature as a local context feature.

7. An electronic device, characterized in that: include: processor; a memory for storing a computer program executed by the processor; Wherein, when the processor executes the computer program, the steps of the method described in any one of claims 1 to 4 are implemented.

8. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed, the steps of the method according to any one of claims 1 to 4 are implemented.