Aspect-level sentiment analysis system based on multi-type knowledge fusion
Patent Information
- Application Number
- CN202410214375.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-27
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2044-02-27
AI Technical Summary
此外,本发明还解决了句法知识中存在的噪声问题,提出了一种基于特殊依赖类型切分的算法来重塑句法依赖树,以更精确地编码句法信息
[0079](1)本发明在处理ABSA任务时融合了四种类型的知识信息,包括句法、情感、概念知识以及上下文信息。相比以往方法,这一综合考虑各种知识的方法在实验中取得了更好的性能,充分挖掘了多重知识信息对该任务的贡献。
Smart Images

Figure CN118069845B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of text sentiment analysis and relates to an aspect-level sentiment analysis system based on the fusion of multiple types of knowledge. Background Technology
[0002] Sentiment analysis is a crucial task in the field of natural language processing. Depending on the granularity, sentiment analysis can be divided into coarse-grained and fine-grained levels. From a coarse-grained perspective, sentiment analysis encompasses document-level and sentence-level analysis; while fine-grained sentiment analysis focuses on aspect-based sentiment analysis (ABSA). Past sentiment analysis tasks primarily concentrated on coarse-grained sentiment analysis, typically analyzing people's attitudes towards individual entities in sentences or documents, such as product objects, public opinion events, etc. However, simply identifying a single sentiment is insufficient to resolve the polarity ambiguity of an entity due to multiple aspects (attributes). For example, in the sentence "The food was delicious in this restaurant but the service here are terrible," it is difficult to determine the overall polarity of the entity "restaurant" because the two aspects "food" and "service" are described as "delicious" and "terrible" respectively, exhibiting different polarities, which hinders the sentiment judgment of the entity "restaurant." In response to this situation, many studies have begun to focus on aspect-level sentiment analysis (ABSA) tasks, the main goal of which is to identify the sentiment tendency of a sentence toward a given aspect.
[0003] The ABSA task can be divided into two methods: traditional machine learning methods and deep learning methods. Deep learning methods, with their advantage of automatically extracting features, are significantly superior to traditional methods and have become dominant. In this task, deep learning methods are mainly divided into three categories: (1) Context-based models: These models mainly use convolutional neural networks (CNN), recurrent neural networks (RNN, LSTM, etc.) and joint attention mechanisms to model the relationship between aspects and context, thereby extracting contextual information of specific aspects for classification. However, these models only identify the sentiment of aspects from single contextual knowledge and do not consider additional information. (2) Graph-based models: These models extract relevant syntactic features by introducing prior knowledge such as syntactic structure into graph neural networks (GNN). These features are usually used in combination with contextual information to obtain better performance. It has been proven that syntactic knowledge is indispensable in improving the performance of this task. (3) Knowledge-based models: In addition to syntactic knowledge, these models also consider external knowledge such as linguistics and common sense, and have made successful progress. Currently, most methods combine syntactic knowledge, contextual information, and other external knowledge (sentiment dictionaries, common sense graphs, etc.) to improve the model's utilization of information. Compared to models that use only single or dual knowledge (syntactic and contextual information), this integrated knowledge model achieves a significant improvement in classification performance.
[0004] Although knowledge-based models have improved compared to the past, some problems still exist: (1) Insufficient utilization of knowledge information: Current methods can only consider a maximum of three types of knowledge (syntactic, common sense, and contextual information), and few models can analyze more than three types of knowledge at the same time, which may limit the expressive power of the model. Therefore, the current work to be considered is to design a model that can integrate more than three types of knowledge and effectively utilize this knowledge. (2) Noise in the original syntactic structure: Current models that utilize syntactic knowledge have not solved or effectively processed the noise of the association between aspects and context in the syntactic structure, which may lead to the inability to correctly encode syntactic information. (3) Inaccurate extraction of contextual information: Attention mechanisms have global modeling capabilities, enabling them to capture long-distance dependencies between aspects and context. Accordingly, context-based models have made progress in modeling the semantic relationship between aspect-opinion words using attention mechanisms. However, when modeling this relationship in multi-aspect sentences, weight mismatch may occur, that is, aspect words and their corresponding opinion words cannot be fully aligned, resulting in inaccurate extraction of contextual information. Summary of the Invention
[0005] Therefore, this invention aims to provide an aspect-level sentiment analysis system based on the fusion of multiple types of knowledge. Unlike previous works, this invention proposes a model capable of simultaneously analyzing three or more types of knowledge, syntactically, emotionally, conceptually, and contextually, to obtain more accurate classification results. Furthermore, this invention addresses the noise problem in syntactic knowledge by proposing an algorithm based on specific dependency type segmentation to reshape the syntactic dependency tree for more accurate encoding of syntactic information. Finally, this invention mitigates the attention weight mismatch phenomenon during context information extraction by introducing a dynamic context weighting mechanism. Specifically, by pre-assigning attenuation weights to non-local contexts, the impact on aspects during attention score calculation is reduced, thereby ensuring accurate alignment between aspects and local opinion words.
[0006] To achieve the above objectives, the present invention provides the following technical solution:
[0007] An aspect-level sentiment analysis system based on multi-type knowledge fusion includes:
[0008] Text embedding encoding layer: For the input sentence, it is first mapped to a sentence vector using a pre-trained GloVe embedding matrix. Then, a bidirectional long short-term memory network (BiLSTM) is used to encode the sentence vector to obtain preliminary contextual features;
[0009] The sentiment enhancement module incorporates syntactic and sentiment knowledge. First, the Spacy tool is used to parse the sentence's syntactic dependency tree. Then, the dependency tree is reshaped according to the specific dependency type "conj," retaining only the dependency of the clause containing the aspect and removing the rest to reduce redundant noise. Simultaneously, a sentiment knowledge base (such as SenticNet) is used to enhance the syntactic dependencies, representing the dependency degree through the sum of sentiment scores, and an adjacency matrix is constructed. Next, the enhanced adjacency matrix and contextual features are fed into a graph convolutional network to extract syntactic features. Finally, an attention mechanism is used to obtain a contextual representation of the specific aspect based on the enhanced syntax.
[0010] Conceptual Knowledge Embedding Module: This module incorporates conceptual knowledge. Knowledge representation learning is performed on the Conceptual Knowledge Graph (WordNet) using the OpenKE toolkit, learning global knowledge representations of words from simple to abstract concepts at the semantic understanding level. Then, the mapping from the input sentence to the global knowledge representation (knowledge embedding) is concatenated into the contextual features. Finally, an attention mechanism is used to obtain aspect-specific contextual representations based on conceptual knowledge.
[0011] Context Information Extraction Module: To address the misalignment between aspect and viewpoint words that arises after introducing the attention mechanism (if aspect words and irrelevant viewpoint words co-occur frequently, they may generate more weights during attention calculation), this invention introduces a Context Dynamic Weighting (CDW) mechanism. This mechanism is based on the idea of "prior weighting," influencing the downstream structure modeling process by pre-assigning weights to context features. Specifically, according to linguistic rules—the sentiment of aspect words is often determined by their local context—the CDW mechanism, centered on the aspect word, pre-assigns attenuation weights to its non-local context according to the "nearer is larger, farther is smaller" strategy based on semantic relative distance. Finally, the weighted context features are sequentially fed into the self-attention layer and the attention layer to obtain contextual information for specific aspects.
[0012] Output layer: First, the three representations—specific aspect-based contextual representation, conceptual knowledge-based contextual representation, and contextual information—are concatenated row-wise into a vector. Next, this vector is fed into a multilayer perceptron (MLP) for feature extraction and nonlinear transformation. Finally, a softmax classifier is used to classify the processed vector, outputting the classification result.
[0013] Furthermore, in the text embedding encoding layer, for the input sentence This includes a sequence of aspect words of length m. here, It represents the i-th word in the context. The i-th word in the sequence of terms representing aspects;
[0014] First, using pre-trained GloVe embedding matrices The words in the input sentence S are embedded into vectors of a specified dimension to obtain the sentence embedding representation. in Here, |V| represents the size of the vocabulary, d e Indicates the embedding dimension;
[0015] Next, the sentence embedding representation X is fed into a BiLSTM for encoding to obtain preliminary contextual features. in Here, h i d represents the hidden state vector of the i-th word in the BiLSTM at the t-th time step. h This represents the encoding dimension. The encoding process is represented by the following formula:
[0016]
[0017]
[0018] Furthermore, the processing steps of the emotion knowledge enhancement module are as follows:
[0019] Step 1: Use the Spacy natural language parsing tool to obtain the syntactic dependency tree T of the sentence, and construct the adjacency matrix M based on it, where
[0020]
[0021] Among them, s i Let represent the i-th word in sentence S. In the adjacency matrix M, if s i and s j If there is a correlation, then the corresponding element M ij It is 1 if it is not 1, otherwise it is 0.
[0022] Step 2: To address the indirect dependency noise present in different clauses within the dependency tree structure of a complex sentence, an algorithm for reshaping the dependency tree is proposed. Specifically, based on the special dependency type "conj" in the dependency tree T, the complex sentence is logically divided into multiple clauses using this type. Then, only the dependencies in the clause containing the given aspect are retained, while all dependencies in the remaining clauses are removed to reduce redundant noise. Finally, the reshaped dependency tree T' is obtained, and the adjacency matrix is updated to M' accordingly.
[0023] Step 3: To highlight the importance of words with strong emotions in syntactic features, we leverage emotional knowledge to enhance the dependency on syntactic knowledge. First, we use the SenticNet parsing tool to obtain the i-th word s in the sentence. i The emotional intensity score is denoted as SenticNet(s) i )∈[-1,1]. Where, SenticNet(s i ) = 0 indicates word s i Is it neutral or lacking in emotional intensity? Then, construct the emotional enhancement matrix S according to the following strategy. ij :
[0024]
[0025] Among them, s i Let the i-th word in sentence S represent the sentiment enhancement matrix S. ij In the middle, if s i and s j Related use This indicates the degree of dependency. Here, |SenticNet(s) i )|+|SenticNet(s j The sum of the sentiment scores of two words is represented by 1. Self-associations are represented by 0.
[0026] However, in analyzing the parsing results of the Rest15 dataset, 2251 words lacking sentiment intensity were found, accounting for approximately 62% of the total vocabulary. Similar findings were observed in other datasets. Clearly, this includes words carrying significant sentiment information, such as adverbs, verbs, and adjectives, whose information was not effectively utilized. To compensate for the loss of sentiment information due to the limitations of the SenticeNet knowledge base's parsing capabilities, an exponential function exp is used to further enhance sentiment dependence. Simultaneously, an incremental matrix T is defined. ij To highlight the degree of dependence between the aspect word and other words:
[0027]
[0028] Among them, s i This represents the i-th word in sentence S, in the increment matrix T. ij In the middle, if s i and s j If one of the terms is an aspect term, use 1 to represent it; otherwise, use 0.
[0029] Then, the adjacency matrix A after sentiment enhancement is obtained using the following formula. ij :
[0030] A ij =M ij ×(S ij +T ij (6)
[0031] Among them, M ij It is the reshaped adjacency matrix, S ij It is the emotion enhancement matrix, T ij It is an increment matrix.
[0032] Finally, the adjacency matrix A after emotion enhancement ij The context features H are input into a graph convolutional network (GCN) to extract syntactic features. The i-th node of the l-th GCN layer represents... Hidden representation through its neighborhood renew:
[0033]
[0034] in, W represents the number of edges associated with the i-th node. l b is the trainable matrix of the l-th layer. l It is a bias unit, and σ(·) is the ReLU activation function. The syntactic features finally obtained after L layers of GCN are: in Then, for H LThe hidden state of the subscript i of the term "China-Africa aspect" Perform a masking operation to obtain aspect syntactic features. in
[0035] Step 4: Incorporate aspect syntactic features The context features H are fed into an attention mechanism to obtain a context representation R based on specific aspects and enhanced syntax. s :
[0036]
[0037]
[0038]
[0039]
[0040] Where, β i It is the attention weight matrix for the i-th word, α i It is the normalized weight matrix, R s It is a context representation based on enhanced syntax after weighted summation.
[0041] Furthermore, the conceptual knowledge embedding module processes the following steps:
[0042] Step 1: To enrich sentence semantic features and understand rare words from the perspective of common words, thereby reducing sentence semantic complexity, a WordNet concept knowledge graph is introduced to learn the concepts between aspect words and context, from simple to abstract. Simultaneously, the knowledge graph is trained using the OpenKE open-source toolkit to obtain a global knowledge representation of the words.
[0043] Step 2: First, map the input sentence in the global knowledge representation to obtain the knowledge embedding. in Then, embed the knowledge into H k Concatenating the context feature H with the context feature yields a context feature carrying global knowledge. in
[0044] Step 3: Then, capture specific aspect-based contextual representations of R based on conceptual knowledge through an attention mechanism. k This process can be represented by the following formula:
[0045] H d =[H k ;H] (12)
[0046]
[0047]
[0048]
[0049]
[0050] In this context, ";" indicates a concatenation operation. It is an aspect feature that carries global knowledge, R k It is a contextual representation based on conceptual knowledge.
[0051] Furthermore, the processing steps of the context information extraction module are as follows:
[0052] Step 1: To address potential weight mismatches when modeling aspect-opinion semantic relationships based on attention mechanisms, a context-based dynamic weighting (CDW) mechanism is introduced. This mechanism pre-assigns decay weights to non-local contexts to mitigate weight matching biases that may arise from attention mechanisms.
[0053] First, the concept of semantic relative distance (SRD) is defined, as follows:
[0054]
[0055] Where i represents the position of the word, P a The SRD is the center position of the word sequence A, where m is the length of the sequence. i The distance from the word at position i to both ends of the aspect word sequence A;
[0056] Then, based on the relationship between the specified threshold α and the semantic relative distance (SRD), the context is divided into local and non-local parts (SRD greater than α is non-local, and vice versa). Then, according to the "nearer-larger, farther-smaller" strategy, attenuation weights are assigned to the non-local context, as shown in the following formula:
[0057]
[0058]
[0059] H w =H·W (20)
[0060] in, Let I represent the weight of the i-th word, W be the identity matrix, and H be the weight matrix. w It is a weighted context feature;
[0061] Step 2: Utilize two attention mechanisms to capture specific aspects of contextual information (R) c:
[0062] First, a self-attention mechanism is used to indirectly correct weight allocation errors and learn deep semantic features. in Then, an attention mechanism is used to weight the context features H. ws Weights are assigned to the aspect word sequence A. Finally, the context features H are... ws Perform a weighted summation to obtain contextual information R for a specific aspect. c The process is as follows:
[0063] H ws =SelfAttention(H w ) (twenty one)
[0064]
[0065]
[0066]
[0067] in, It is the j-th hidden state vector of the aspect word sequence A, β t It is the attention weight matrix for the t-th word, α t It is the normalized weight matrix, R c It is contextual information about a specific aspect after weighted summation.
[0068] Furthermore, the output layer processing steps are as follows:
[0069] Step 1: Convert the different representations R from the three modules c R s and R k The final representation [R] is obtained by fusion. c ;R s ;R k The semicolon (;) here indicates a concatenation operation, and the merge is represented as r;
[0070] r = concat(R) c ,R s ,R k (25)
[0071] Here, concat(·) represents the concatenation operation.
[0072] Step 2: Feed the fused representation r into a multilayer perceptron (MLP) and obtain the classification probability p through a softmax classifier:
[0073] p = softmax(MLP(r)) (26)
[0074] Here, softmax is the activation function used to learn emotion classification;
[0075] Step 3: Finally, use the cross-entropy loss function to guide the optimization and training process:
[0076]
[0077] Where i represents the index of the dataset sample, j represents the index of the emotion classification category, Θ represents all trainable parameters, and λ is the L2 regularization coefficient.
[0078] The beneficial effects of this invention are as follows:
[0079] (1) This invention integrates four types of knowledge information when processing the ABSA task, including syntactic, sentiment, conceptual knowledge, and contextual information. Compared with previous methods, this method, which comprehensively considers various types of knowledge, achieved better performance in experiments and fully explored the contribution of multiple knowledge information to the task.
[0080] (2) In view of the dependency noise problem existing in the current syntactic knowledge, this invention proposes an effective dependency tree reshaping algorithm to solve the problem.
[0081] (3) In view of the problem of lost emotional information caused by the parsing function defects of the SenticNet emotional knowledge base, this invention proposes an emotional compensation and enhancement strategy to solve the problem. This strategy aims to compensate for the lost emotional information and enhance syntactic dependencies to highlight the role of contexts with strong emotions in syntactic features.
[0082] (4) This invention introduces a context dynamic weighting mechanism (CDW) to alleviate the misalignment of aspect-opinion word weights caused by the use of attention mechanisms in the process of extracting contextual information. This mechanism aims to distinguish between local and non-local contexts and pre-assign decay weights to non-local contexts according to the "nearer is larger, farther is smaller" strategy of semantic relative distance (SRD) to reduce their influence on aspects in the attention mechanism.
[0083] Other advantages, objectives, and features of the invention will be set forth in part in the description which follows, and in part will be apparent to those skilled in the art from the following examination, or may be learned from practice of the invention. The objectives and other advantages of the invention can be realized and obtained through the following description. Attached Figure Description
[0084] To make the objectives, technical solutions, and advantages of the present invention clearer, the preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings, wherein:
[0085] Figure 1 This is an overall flowchart of the aspect-level sentiment analysis system based on multi-type knowledge fusion as described in this invention;
[0086] Figure 2 This is a model framework diagram of the aspect-level sentiment analysis system based on multi-type knowledge fusion as described in this invention;
[0087] Figure 3 The syntactic dependency graph and the reshaped dependency graph of the example sentence in this invention;
[0088] Figure 4 The diagram shows the effect of threshold α on accuracy Acc in the context dynamic weighting (CDW) mechanism of this invention, where (a) is the Lap14 dataset and (b) is the Rest14 dataset. Detailed Implementation
[0089] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0090] The accompanying drawings are for illustrative purposes only and are schematic diagrams, not actual pictures. They should not be construed as limiting the invention. To better illustrate the embodiments of the invention, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions. It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0091] In the accompanying drawings of the embodiments of the present invention, the same or similar reference numerals correspond to the same or similar components. In the description of the present invention, it should be understood that if terms such as "upper," "lower," "left," "right," "front," and "rear" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, they are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, the terms used to describe positional relationships in the drawings are only for illustrative purposes and should not be construed as limiting the present invention. For those skilled in the art, the specific meaning of the above terms can be understood according to the specific circumstances.
[0092] like Figure 1 and Figure 2As shown, the aspect-level sentiment analysis system based on multi-type knowledge fusion includes:
[0093] Text Embedding and Encoding Layer: This layer aims to embed and encode the input sentence to obtain preliminary contextual features. First, the input sentence is embedded using a pre-trained GloVe embedding matrix. Then, a Bidirectional Long Short-Term Memory (BiLSTM) network is used to encode the embedded sentence vector to initially obtain the sequence's contextual features. Specifically, for a given sentence... S consists of a sequence of aspect words of length m. in It represents the i-th word in the context. The i-th word representing the aspect. First, a pre-trained GloVe embedding matrix is used. The words in sentence S are embedded into vectors of a specified dimension to obtain the sentence embedding representation. Where |V| represents the size of the vocabulary, d e This represents the embedding dimension. Next, the sentence embedding representation X is fed into the BiLSTM encoder to obtain the hidden state vector. Among them, h i d represents the hidden state vector of the i-th word in the BiLSTM at the t-th time step. h This represents the encoding dimension. The encoding process can be represented by the following formula:
[0094]
[0095]
[0096] The Affective Knowledge Enhancement Module aims to enhance syntactic dependencies using affective knowledge and obtain aspect-specific contextual representations based on enhanced syntax. First, the module uses the Spacy tool to parse the syntactic dependency tree T of the input sentence. Then, based on the special dependency type "conj", T is logically segmented to obtain a reshaped dependency tree T', which is pruned around a given aspect to reduce structurally irrelevant dependencies. Simultaneously, to highlight contextual information with strong emotional content, an affective enhancement strategy is proposed, which strengthens syntactic features by enhancing syntactic dependencies and constructing an adjacency matrix. Finally, the enhanced adjacency matrix and contextual features are fed into a graph convolutional network and an attention mechanism to obtain aspect-specific contextual representations based on enhanced syntax. Specifically, first, the Spacy natural language parsing tool is used to obtain the syntactic dependency tree T of the sentence, and an adjacency matrix M is constructed based on the dependency tree.
[0097]
[0098] Among them, s i Let represent the i-th word in sentence S. In the adjacency matrix M, if s i and s j If there is a correlation, then the corresponding M ij The element is 1 if it is 1, otherwise it is 0.
[0099] To address the noise problem in dependency trees under complex sentence structures, an algorithm for reshaping the dependency tree is proposed, such as... Figure 3 As shown. The specific steps are as follows: First, based on the special dependency type "conj" in the dependency tree T, the complex sentence is split into multiple clauses. Then, the dependency relationship is retained in the clause containing the given aspect, while all dependencies in other clauses are removed to reduce redundant noise. Finally, the reshaped dependency tree T' is obtained, and the adjacency matrix is updated to M' accordingly.
[0100] To highlight the importance of words with strong sentiment in syntactic features, we leverage sentiment knowledge to enhance the dependency on syntactic knowledge. First, we use the SenticNet sentiment knowledge base to obtain the i-th word s in sentence S. i The emotional intensity score is represented as SenticNet(s) i )∈[-1,1]. Where, SenticNet(s i ) = 0 indicates word s i Is it neutral or lacking in emotional intensity? Then, construct the emotional enhancement matrix S according to the following strategy. ij :
[0101]
[0102] Among them, s i Let the i-th word in sentence S represent the sentiment enhancement matrix S. ij In the middle, if s i and s j If they are related, then use This indicates that |SenticNet(s) i )|+|SenticNet(s j The )| indicates the degree of dependence between two words, represented by the sum of their sentiment intensity scores. Self-associations are represented by 1, and all others by 0.
[0103] Surprisingly, due to parsing limitations of SenticNet, statistical analysis of the Rest15 dataset revealed 2251 words lacking sentiment intensity, accounting for approximately 62% of the total vocabulary, as shown in Table 1. Clearly, this includes words carrying significant sentiment information (such as adverbs, verbs, and adjectives), whose sentiment information cannot be effectively utilized.
[0104] Table 1
[0105]
[0106] To compensate for this missing emotional information, an exponential function exp is used to further enhance the emotional dependence. Furthermore, to highlight the dependence between aspect words and other words, an increment matrix T is defined. ij :
[0107]
[0108] Among them, s i This represents the i-th word in sentence S, in the increment matrix T. ij In the middle, if s i and s j If one side is an aspect term, then set the corresponding element to 1; otherwise, set it to 0.
[0109] Then, the adjacency matrix A after sentiment enhancement is calculated using the following formula. ij :
[0110] A ii =M ij ×(S ij +T ij (6)
[0111] Among them, M ij It is the reshaped adjacency matrix, S ij It is the emotion enhancement matrix, T ij It is an increment matrix.
[0112] Finally, the adjacency matrix A after emotion enhancement ij The context features H are input into a graph convolutional network (GCN) to extract syntactic features. The hidden representation of the i-th node in the l-th GCN layer... Hidden representation through its neighborhood Update, specifically:
[0113]
[0114] in, W represents the number of edges associated with the i-th node. l b is the trainable matrix of the l-th layer. l Here, σ is a bias unit, and σ(·) is the ReLU activation function. The syntactic features finally obtained by the L-layer GCN are: in Then for H L The hidden state of the subscript i of the term "China-Africa aspect" Perform a masking operation to obtain aspect syntactic features. in
[0115] Next, we will discuss aspect syntax features. The context features H are fed into an attention mechanism to obtain a context representation R based on specific aspects and enhanced syntax. s :
[0116]
[0117]
[0118]
[0119]
[0120] Where, β i It is the attention weight matrix for the i-th word, α i It is the normalized weight matrix, R s It is a context representation based on enhanced syntax after weighted summation.
[0121] The Conceptual Knowledge Embedding Module aims to generate aspect-specific contextual representations based on conceptual knowledge. First, knowledge representation learning is performed on the WordNet conceptual knowledge graph to obtain a global knowledge representation. Next, the mapping from the input sentence to the global knowledge representation (knowledge embedding) is concatenated into the contextual features. Finally, an attention mechanism is used to obtain aspect-specific contextual representations based on conceptual knowledge. Specifically, to enrich the semantic features of sentences and understand rare words from the perspective of common words, thereby reducing the semantic complexity of sentences, the WordNet conceptual knowledge graph is introduced. This knowledge graph helps aspect words and context learn semantic concepts from simple to abstract neighboring words. Then, the knowledge graph is trained using the OpenKE open-source toolkit to obtain a global knowledge representation. Finally, the mapping generated from the input sentence in the knowledge representation, i.e., the knowledge embedding, is... Concatenating it with the context feature H yields the context feature carrying global knowledge. Finally, attention mechanisms are used to capture aspect-specific and conceptually knowledge-based contextual representations of R. k The above process can be represented by the following formula:
[0122] H d =[H k ;H] (12)
[0123]
[0124]
[0125]
[0126]
[0127] In this context, ";" indicates a concatenation operation. It is an aspect feature that carries global knowledge, R k It is a contextual representation based on conceptual knowledge.
[0128] Context Information Extraction Module: This module aims to extract specific aspect-related contextual information from the context. To address the aspect-opinion word misalignment problem that may occur when the attention mechanism assigns weights, this module introduces a context-based dynamic weighting (CDW) mechanism, which pre-assigns decay weights to non-local contexts. Then, the weighted contextual features are fed into the self-attention layer and the attention layer to obtain specific aspect-related contextual information. Specifically, based on the weight mismatch phenomenon caused by the attention mechanism when modeling aspect-opinion word semantic relationships, the context-based dynamic weighting (CDW) mechanism is introduced to pre-assign decay weights to non-local contexts.
[0129] First, we define the concept of semantic relative distance (SRD) as follows:
[0130]
[0131] Where i represents the position of the word, P a The SRD is the center position of the word sequence A, where m is the length of the sequence. i This represents the distance from the word at index i to both ends of the aspect word sequence A;
[0132] Next, based on the relationship between the specified threshold α and the semantic relative distance (SRD), the context is divided into local and non-local parts (SRD greater than α is non-local, and vice versa). Then, according to the "nearer is larger, farther is smaller" strategy, a decay weight is assigned to the non-local context, as shown in the following formula:
[0133]
[0134]
[0135] H w =H·W (20)
[0136] in, Let I represent the weight of the i-th word, W be the identity matrix, and H be the weight matrix. w It is a weighted context feature.
[0137] Finally, two attention mechanisms are used to capture specific aspects of contextual information R. cFirst, a self-attention mechanism is used to indirectly correct weight allocation errors, and deep semantic features are learned. Then, an attention mechanism is used to weight the context features H. ws Weights are assigned to the aspect word sequence A. Finally, the context features H are... ws Weighted summation to obtain contextual information for a specific aspect of R c The process is as follows:
[0138] H ws =SelfAttention(H w ) (twenty one)
[0139]
[0140]
[0141]
[0142] in, It is the j-th hidden state vector of the aspect word sequence A, β t It is the attention weight matrix for the t-th word, α t It is the normalized weight matrix, R c It is contextual information about a specific aspect after weighted summation.
[0143] Output Layer: This layer is responsible for fusing three different representations and feeding them into a classifier to obtain the classification result. First, the context representation based on enhanced syntax and conceptual knowledge, along with the context information, are concatenated row-wise into a vector. Then, this vector is fed into a multilayer perceptron (MLP), and a softmax classifier is used to output the sentiment classification result. Specifically, the different representations R from the three modules are fused. c R s and R k The final representation is formed by connecting the elements into [R]. c ;R s ;R k The semicolon ";" here indicates a concatenation operation, and the merged result is represented as r:
[0144] r = concat(R) c ,R s ,R k (25)
[0145] Here, concat(·) represents the concatenation operation.
[0146] Then, the fused representation r is fed into a multilayer perceptron (MLP), and the classification probability p is obtained through a softmax classifier:
[0147] p = softmax(MLP(r)) (26)
[0148] Here, softmax is the activation function used to learn emotion classification;
[0149] Finally, the cross-entropy loss function is used to guide the optimization and training process:
[0150]
[0151] Where i represents the index of the dataset sample, j represents the index of the emotion classification category, Θ represents all trainable parameters, and λ is the L2 regularization coefficient.
[0152] This invention utilizes the most widely used datasets in the ABSA domain, including SemEval 2014 Task 4, SemEval 2016 Task 5, and the Twitter dataset. SemEval 2014 Task 4 covers the restaurant and laptop domains, including review data related to the topics of restaurants and laptops. SemEval 2016 Task 5 also focuses on the restaurant domain.
[0153] Table 2
[0154] Twitter - Training Set 1561 3127 1560 Twitter - Test Set 173 346 173 Lap14-Training Set 994 464 870 Lap14 - Test Set 341 169 128 Rest14 Training Set 2164 637 807 Rest14 Test Set 728 196 196 Rest15 Training Set 912 36 256 Rest15 - Test Set 326 34 182 Rest16 Training Set 1240 69 439 Rest16 - Test Set 469 30 117
[0155] The experiments in this invention employed a 300-dimensional GloVe word embedding matrix, with the hidden state vector in the BiLSTM encoder having a dimension of 300. The learning rate was 0.001, the L2 regularization coefficient was 10^-5, and the batch size was 32. During training, the Adam optimizer was used to update the parameters. The experimental environment was a PyCharm platform running Windows 10. The CUDA version was 11.3, the Python version was 3.8, and the GPU used for acceleration was a GeForce GTX 3060.
[0156] The evaluation metrics of this invention include accuracy (Accc) and F1 score.
[0157]
[0158]
[0159]
[0160]
[0161] Here, TP represents the number of true positives, TN represents the number of true negatives, FP represents the number of positive pluses, and FN represents the number of false negatives. Precision (Acc) is defined as the number of true positives divided by the sum of true and false positives. The F1 score is the weighted average of precision (p) and recall (r).
[0162] Table 3 shows a comparison of the experimental results using GloVe word embeddings on five datasets with previous work. These results are primarily derived from data in their respective papers. Best results are indicated in bold, and second-best results are indicated by underline.
[0163] Table 3
[0164]
[0165] Compared to models that only consider three types of knowledge (such as KGAN, SenticGCN, SK-GCN, and EKGCN), this invention demonstrates superior performance, further proving the advantages of integrating four types of knowledge. Taking the Lap14 dataset as an example, compared to the second-best model KGAN (Acc: 78.91%, F1: 75.21%), the accuracy (Acc) and F1 score of this invention are improved by 0.93% and 0.31%, respectively (Acc: 79.84%, F1: 75.52%). On the Rest15 and Rest16 datasets, the performance of this invention is superior to the KGAN baseline by more than 0.50%. Although the F1 score on the Rest14 dataset is not ideal, the accuracy (Acc) is improved by 0.78%. Additionally, the results of this invention are relatively poor on the Twitter dataset, which may be due to the informal comments in this dataset limiting the effectiveness of the improvements.
[0166] Table 4
[0167]
[0168] To further demonstrate the effectiveness of the improvement, this invention conducted extensive ablation studies to investigate the effects of integrating multiple types of knowledge, reshaping the dependency tree, and the CDW (Context Dynamic Weighting) mechanism. C represents the CDW mechanism, S represents the Sentiment Knowledge Base SenticNet, and R (Reshape) represents the dependency tree using the reshaped structure. According to the results in Table 4, it can be observed that removing the CDW mechanism, SenticNet, or not using R all lead to performance degradation. In particular, the performance is consistently poor when both SenticNet and R are removed simultaneously. In contrast, the performance is slightly improved when both CDW and R are removed simultaneously. This indicates that considering only conceptual knowledge and ignoring noise in the syntactic structure suppresses classification performance. Specifically, compared to the Sentiment GCN model, which only considers sentiment knowledge, the present invention outperforms it because it addresses the problem of Sentiment information being ignored due to SentimentNet's inability to fully parse all words. This invention supplements this information by utilizing the exponential function exp to further enhance the dependencies between context and aspects. On the other hand, removing the CDW mechanism slightly reduced performance, indicating that pre-assigning weights to the context can prompt aspects to focus on local contexts and reduce sensitivity to non-local contexts, thus reducing weight mismatches during attention score calculation. Furthermore, this invention compares experimental results on the Lap14 and Rest14 datasets at different thresholds α, such as... Figure 4 As shown in the figure, the classification accuracy (Acc) of the Lap14 and Rest14 datasets is significantly affected by the threshold. Specifically, optimal performance is achieved when the threshold α is equal to 3 and 4, respectively. Furthermore, the choice of threshold α has a greater impact on the performance of the Lap14 dataset. Compared to the Rest14 dataset, the performance of the Lap14 dataset fluctuates more, possibly due to its smaller sample size and imbalanced class distribution. Increasing the amount of data can alleviate this phenomenon to some extent.
[0169] Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium. When the program is executed, it can implement the steps of the method. The storage medium may be, for example, ROM / RAM, magnetic disk, optical disk, etc.
[0170] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. An aspect-level sentiment analysis system based on multi-type knowledge fusion, characterized in that: include: Text embedding encoding layer: For the input sentence, it is mapped to a sentence vector through a pre-trained GloVe embedding matrix; The sentence vector is encoded using a bidirectional long short-term memory network (BiLSTM) to obtain preliminary contextual features; The affective knowledge enhancement module uses the Spacy tool to parse the syntactic dependency tree of a sentence; Reshape the dependency tree based on the special dependency type "conj", retaining only the dependency relationships of the clauses containing aspect terms; Syntactic dependencies are enhanced using the Sentiment Knowledge Base SenticNet, with the sum of sentiment scores representing the degree of dependency, and an adjacency matrix is constructed. The enhanced adjacency matrix and contextual features are then fed into a graph convolutional network to extract syntactic features. Obtain specific aspects of contextual representations based on enhanced syntax through attention mechanisms; Conceptual knowledge embedding module: Uses the OpenKE toolkit to learn knowledge representation on the concept knowledge graph WordNet, learns global knowledge representation of words from simple to abstract concepts at the semantic understanding level; and concatenates the mapping from the input sentence to the global knowledge representation into the context features; Obtain contextual representations of specific aspects based on conceptual knowledge through attention mechanisms; Context information extraction module: Based on the attention mechanism, the module models the weight mismatch phenomenon caused by multi-faceted sentences and introduces a dynamic context weighting mechanism; taking aspect words as the center, it pre-assigns decay weights to their non-local contexts according to the "nearer is larger, farther is smaller" strategy of semantic relative distance; the weighted context features are sent to the self-attention layer to indirectly correct the weight allocation error; and the attention mechanism is used to obtain context information of specific aspects. Output layer: Concatenates the context representation and context information based on specific aspects and enhanced syntax and conceptual knowledge into a vector line by line; feeds the vector into a multilayer perceptron (MLP) for feature extraction and nonlinear transformation; uses a softmax classifier to classify the processed vector and outputs the final classification result; The conceptual knowledge embedding module processes the following steps: Step 1: Introduce the WordNet concept knowledge graph to learn the concepts from simple to abstract between aspect words and context; use the OpenKE open-source toolkit to train the knowledge graph, thereby obtaining a global knowledge representation of words; Step 2: First, map the input sentence in the global knowledge representation to obtain the knowledge embedding. ,in Then, embed the knowledge. With context features By concatenating the features, we obtain contextual features that carry global knowledge. ,in , Indicates the encoding dimension; Step 3: Capture specific aspect-based contextual representations of concepts through attention mechanisms. , represented as: In this context, ";" indicates a concatenation operation. It is a characteristic that carries global knowledge. It is the first Word attention weight matrix, It is the normalized weight matrix. It is a contextual representation based on conceptual knowledge; The processing steps of the context information extraction module are as follows: Step 1: Introduce a context-weighted dynamic CDW mechanism to pre-allocate decay weights to non-local contexts; First, the concept of semantic relative distance (SRD) is defined, and the process is as follows: in, Indicates the position of a word. It is a sequence of terms The central location, It is the length of the sequence. Indicates position Word to aspect word sequence The distance between the two ends; Then, based on the specified threshold The relationship between the relative semantic distance (SRD) and the context is used to divide the context into local and non-local parts. The SRD is greater than [a certain value]. The context is considered nonlocal if it is larger than the context, and local if it is smaller than the context. Then, according to the "nearer larger, farther smaller" strategy, a decay weight is assigned to the nonlocal context, as shown in the following formula: in, Indicates the first The weight of each word It is the identity matrix. It is a weight matrix. It is a weighted context feature; Step 2: Utilize two attention mechanisms to capture specific contextual information. : First, a self-attention mechanism is used to indirectly correct weight allocation errors, and then deep semantic features are learned. ,in Then, an attention mechanism is used to assign weighted contextual features. Assigned to aspect word sequence Weights; finally, context features. Perform a weighted summation to obtain contextual information for a specific aspect. The process is as follows: in, It is a sequence of terms The There are hidden state vectors. It is the first Word attention weight matrix, It is the normalized weight matrix. It is contextual information about a specific aspect after weighted summation.
2. The aspect-level sentiment analysis system based on multi-type knowledge fusion according to claim 1, characterized in that: In the text embedding encoding layer, for the input sentence This includes lengths of Aspect word sequence ;in Indicates the first in the context One word, The first in the sequence of aspect words One word; Using pre-trained GloVe embedding matrices , will input sentence The words in the sentence are embedded into vectors of a specified dimension to obtain sentence embedding representations. ,in , Indicates the size of the vocabulary. Indicates the embedding dimension; Embedding sentences The data is fed into a BiLSTM for encoding to obtain preliminary contextual features. ,in , This indicates that BiLSTM is in the first... The first time step The hidden state vectors of n words; the encoding process is represented by the following formula: 。 3. The aspect-level sentiment analysis system based on multi-type knowledge fusion according to claim 2, characterized in that: The processing steps of the emotion knowledge enhancement module are as follows: Step 1: Use the Spacy natural language parsing tool to obtain the syntactic dependency tree of the sentence. And construct an adjacency matrix based on this. ,in in, Sentence The Middle Each word in the adjacency matrix In the middle, if and If there is a relationship, then the corresponding elements =1, otherwise =0; Step 2: Based on the dependency tree Special dependency types conj This type of algorithm splits a complex sentence into multiple clauses, retaining only the dependencies in the clause containing a given aspect while removing all dependencies from the remaining clauses, ultimately resulting in a reshaped dependency tree. And update the adjacency matrix accordingly. ; Step 3: Enhance syntactic knowledge with affective knowledge: First, use SenticNet parsing tools to obtain the first... Word The emotional intensity score is denoted as ;in, Indicator Is it neutral or lacking in emotional intensity? Then, construct an emotion enhancement matrix based on the following strategies. : in, Sentence The Middle Each word in the sentiment enhancement matrix In the middle, if and Related use Indicates the degree of dependence; This represents the sum of the sentiment scores of two words; self-associations are represented by 1, and other cases by 0. The exponential function exp is used to further enhance emotional dependence, and an incremental matrix is defined. To highlight the degree of dependence between the aspect word and other words: in, Sentence The Middle Each word in the increment matrix In the middle, if and If one of the terms is an aspect term, use 1 to represent it; otherwise, use 0. Then, the adjacency matrix after sentiment enhancement is obtained using the following formula. : in, It is a reshaped adjacency matrix. It is an emotion enhancement matrix. It is an increment matrix; Finally, the adjacency matrix with enhanced emotion and context features The input is fed into a graph convolutional network (GCN) to extract syntactic features; The first GCN layer Each node represents Through the hidden representation of its neighborhood renew: in, Indicates the relationship with the first The number of edges associated with each node. It is the first The trainable matrix of the layer, It is a bias unit. ( ) is the ReLU activation function; after The syntactic features ultimately obtained by the layer GCN are ,in Then, for The subscript of the term "China-Africa aspect" Hidden state Perform masking operations To obtain the syntactic features of the aspect ,in ; Step 4: Incorporate aspect syntactic features and context features Feeding into an attention mechanism to obtain contextual representations based on specific aspects and enhanced syntax. : in, It is a context representation based on enhanced syntax after weighted summation.
4. The aspect-level sentiment analysis system based on multi-type knowledge fusion according to claim 3, characterized in that: The output layer processing steps are as follows: Step 1: Represent the different elements from the three modules , and The final representation is obtained by fusion. The semicolon ";" indicates a concatenation operation, and merging is represented as... ; in, Indicates a splicing operation; Step 2: Merge representation The data is fed into a multilayer perceptron (MLP) and the classification probability is obtained through a softmax classifier. : Here, softmax is the activation function used to learn emotion classification; Step 3: Finally, use the cross-entropy loss function to guide the optimization and training process: in, Indicates the index of a sample in the dataset. An index representing the emotion category. This represents all trainable parameters; yes The regularization coefficient.
Citation Information
Patent Citations
Aspect-level sentiment analysis method, system and device for enhancing sentiment knowledge and medium
CN116383377A
Aspect-level sentiment analysis method based on multi-level knowledge enhancement
CN117033635A