An aspect-level sentiment binary tuple extraction method fusing syntactic dependency relationship

By using the SpaCy toolkit and graph convolutional networks, combined with syntactic dependency trees and pre-trained models, the problem of failing to effectively utilize syntactic dependency tree information in existing technologies is solved, achieving more accurate aspect-level sentiment tuple extraction and improving the effect of sentiment analysis.

CN117610542BActive Publication Date: 2026-11-27BEIJING INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311431792.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-31
Publication Date
2026-11-27
Estimated Expiration
2043-10-31

AI Technical Summary

Technical Problem

Existing methods fail to fully utilize syntactic dependency tree information in aspect-level sentiment binary extraction tasks, resulting in an inability to effectively capture words with significant influence on the sentiment polarity of aspect words, thus affecting extraction performance.

Method used

We use the SpaCy toolkit to obtain syntactic dependency trees, count the types of syntactic dependency relations, encode them into adjacency matrices, combine pre-trained vectors and graph convolutional networks, and perform sequence labeling through attention mechanisms and softmax layers to determine aspect words and sentiment polarity.

Benefits of technology

By incorporating syntactic dependency relations, the performance of aspect-level sentiment analysis is improved, enabling more accurate identification of aspect words and their sentiment polarity, thus enriching sentence representation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117610542B_ABST
    Figure CN117610542B_ABST
Patent Text Reader

Abstract

The application relates to a kind of fusion syntax dependency relationship aspect-level sentiment binary tuple extraction method, belong to natural language processing sentiment analysis technical field.This method first extracts the syntax dependency tree of sentence, then statistics syntax dependency relationship of training set.The syntax dependency tree of sentence is encoded, then the feature representation of word in sentence is obtained, then graph convolution network training is carried out, the sequence labeling of word in sentence is carried out, and finally aspect word and sentiment polarity are obtained.This method uses syntax dependency category information to expand the sentence information containing aspect word, enriches the semantic expression of sentence, can better model sentence representation, and improves the performance of aspect-level sentiment analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for extracting aspect-level sentiment binary tuples that incorporates syntactic dependency relations, belonging to the field of natural language processing sentiment analysis technology. Background Technology

[0002] With the development of the internet and social networks, text sentiment analysis has become a popular research area in natural language processing. Sentiment analysis allows for a precise understanding of the emotions expressed in text, providing insights into customer thoughts and preferences.

[0003] Sentiment analysis is an important subtask of natural language processing (NLP). It utilizes NLP technologies to analyze, process, and extract sentiment from texts carrying subjective emotional connotations. Sentiment analysis techniques can be categorized by granularity into document-level sentiment analysis, sentence-level sentiment analysis, and aspect-level sentiment analysis. Aspect-level sentiment binary extraction, as one research direction within aspect-level sentiment analysis, can simultaneously extract aspect words and their corresponding sentiment polarities from a sentence. Therefore, it is also known as end-to-end aspect-level sentiment analysis. It can intuitively reveal a specific aspect of the object being addressed by the person making the opinion and determine the sentiment polarity of multiple words in the text.

[0004] Currently, some research has been conducted on aspect-level tuple extraction tasks, attempting to incorporate word-to-word dependency information into the model, allowing it to learn syntactic features. Existing methods often use syntactic dependency trees and convert the trees into adjacency matrices to provide the model with more comprehensive syntactic information. Such methods do indeed encode word-related relationships better.

[0005] However, these methods do not consider the types of syntactic dependency relations during the conversion to adjacency matrices. In syntactic dependency relations, aspect words may be related to multiple words. If the model does not analyze the importance of dependency relations and does not treat the relationships between words equally, it will fail to capture words that have a significant impact on the sentiment polarity of aspect words, negatively affecting the aspect-level bigram extraction task. Summary of the Invention

[0006] The purpose of this invention is to address the technical shortcomings of existing technologies, such as the failure to fully utilize syntactic dependency tree information in aspect-level sentiment binary extraction tasks. To solve the technical problem of effectively capturing the types of syntactic dependency relations between words in sentences, this invention creatively proposes an aspect-level sentiment binary extraction method that integrates syntactic dependency relations.

[0007] First, the relevant content and concepts involved in this invention will be explained.

[0008] The text sequence X. The expression is: {X=w1,w2,...,w n} represents a sentence that requires aspect-level sentiment tuple extraction, containing n words w1, w2, ..., w n The index n represents the length of the sentence word sequence, and w i Let X be the i-th word in the text sequence X.

[0009] Aspect-level sentiment binary (a, s): This is a binary tuple consisting of aspect word a and sentiment polarity s. For aspect word a, its expression is {a = w}. a1 ,w a2 ,...,w am} represents the main aspect involved in the sentence, and this word consists of n words w a1 ,w a2 ,...,w am Composition, where the subscript m represents the length of the aspect word sequence, w i Let X be the i-th word in the text sequence X.

[0010] Emotional polarity s: indicates the polarity of the emotion expressed by aspect word a in the sentence. In this task, it takes one of three values: positive (POS), neutral (NEU), or negative (NEG).

[0011] Syntactic dependency relations express the dependence relationships between words. A syntactic dependency relation connects two words, one is the core word and the other is the modifier. By establishing unidirectional connections between lexical units according to syntactic dependency relations, from the core word to the modifier, the resulting tree structure is called a syntactic dependency tree.

[0012] Word feature vectors of the input text sequence: These refer to the pre-trained vectors used to vectorize the input text sequence, including semantic vectors; where the semantic vector h... i Refers to the word w i semantic feature information, w i Let X be the i-th word in the text sequence X.

[0013] Attention refers to the phenomenon where humans focus their attention on specific parts of external information during the acquisition of information. For example, when listening to others speak, the listener will pay more attention to certain words. Specifically, if the word "w" appears in a sentence... i With another word w in the sentence j If a syntactic dependency exists, then the word w in the sentence... i The representation of h i When integrating syntactic dependency information, assign word w j The representation of h j Higher weight.

[0014] The present invention is achieved using the following technical solution.

[0015] An aspect-level sentiment binary extraction method incorporating syntactic dependency relations includes the following steps:

[0016] Step 1: You can use tools such as SpaCy to obtain the syntactic dependency tree of the text sequence X.

[0017] SpaCy is an open-source Python library for solving NLP tasks. It can be used to process text sequences X to obtain syntactic dependency trees.

[0018] Step 2: For the trained dataset, count all types of syntactic dependency relations that have appeared.

[0019] Specifically, before the statistics are compiled, cases where there is no syntactic dependency relationship between the core word and the modifier are encoded as 0, and cases where the core word and the modifier are the same word are encoded as 1. Syntactic dependency relationships pointing to the root node of the syntactic dependency tree are also considered as syntactic dependency types. After the statistics are compiled, the statistical results of syntactic dependency relationship types are added and encoded one by one to ensure that different syntactic dependency relationships have different codes, ultimately resulting in a coding table D.

[0020] Step 3: Encode the syntactic dependency tree of the text sequence X according to the encoding table D to obtain an n*n weighted adjacency matrix R with dependency relation information.

[0021] The R expression is:

[0022]

[0023] Wherein, the element r in matrix R ij The value of includes two cases: if there is no direct syntactic dependency relationship between word i and word j, the value is 0; if there is a direct syntactic dependency relationship, the corresponding value in the encoding table D obtained in step 2 is taken according to the type of syntactic dependency relationship between word i and word j.

[0024] Step 4: For the input sentence that requires aspect-level sentiment bigram extraction, i.e., the text sequence, pre-trained word feature vectors are used to represent the vectorized representation of each word in the text sequence.

[0025] The corresponding text sequence {X=w1,w2,...,w n Step 3 yields its vectorized representation. Representative word w i The representation vectors of the pre-trained model were passed.

[0026] Step 5: Combine the weighted adjacency matrix R obtained in Step 2 with the vectorized representation h obtained in Step 3. (0) The input consists of a network built from L graph convolutional layers.

[0027] Specifically, the l-th graph convolutional network layer in the network uses a weighted adjacency matrix R and a vector h. (l-1) For input.

[0028] First, an attention mechanism is used to calculate the information in the sentence. right Attention score

[0029]

[0030] Where, r ij represents an element in matrix R.

[0031] Subsequently, the graph convolutional layer calculates the words according to Equation 3. Output

[0032]

[0033] Where δ() is the activation function for deep learning, and W (l) These are the training parameters for the l-th layer of the graph convolutional network. The output vector of the l-th layer of the graph convolutional network is:

[0034] After passing through the network layer, we obtain the vectorized representation h of each word that incorporates syntactic dependency information. (L) .

[0035] Step 6: Pass the vectorized representation of each word obtained in Step 5 through a Softmax layer to calculate the corresponding probability vector, and perform sequence labeling on each word.

[0036] Each element of the probability vector represents the probability of the corresponding word in the sequence label, as shown in Equation 4:

[0037]

[0038]

[0039] Among them, y i The word w iThe labels are defined with values ​​ranging from {'O', 'B-POS', 'B-NEU', 'B-NEG', 'I'}, where 'O' indicates the word is not an aspect term, 'B' indicates the first word of an aspect term, 'POS' indicates a positive sentiment polarity, 'NEU' indicates a neutral sentiment polarity, 'NEG' indicates a negative sentiment polarity, and 'I' indicates the word is not the first word of an aspect term; W represents the weight matrix; O i This represents the probability distribution vector of the word's corresponding label, obtained by aligning the vectorized representation with the label space. K represents the dimension of the probability distribution vector. Representing vector O i The k-th dimension.

[0040] The final label sequence Y is:

[0041] Y = {y1, y2, y3, ..., y} n} (6)

[0042] Step 7: Based on the sequence labeling results in Step 6, obtain the sequence length, starting position, and sentiment polarity corresponding to the aspect words in the sentence.

[0043] Among them, the starting position B of all aspect terms a The definition is as follows:

[0044] B a ={i|y i =′B-POS′}∪{i|y i =′B-NEU′}∪{i|y i =′B-NEG′}∪{n} (7)

[0045] In this context, 'B' also indicates the first word of an aspect term.

[0046] Then, B a The elements in the middle are arranged in ascending order to obtain sequence B′. a B′ a The i-th element in the sentence, which is the aspect word 'a'. i starting position Its sequence length for:

[0047]

[0048] aspect word a i The corresponding emotional polarity sen i Its values ​​are as follows:

[0049]

[0050] Among them, POS represents positive, NEU represents neutral, and NEG represents negative.

[0051] After the above steps, we obtain the aspect word 'a' in the sentence. i Corresponding sequence length Starting position With emotional polarity i .

[0052] After obtaining the sequence length, starting position, and sentiment polarity of the terms in the sentence, cross-entropy is used as the loss function, and gradient descent is used to update the parameters to minimize the model's prediction error.

[0053] Thus far, from step 1 to step 7, all aspect-level sentiment pairs for the given sentence have been obtained, completing the aspect-level sentiment pair extraction that incorporates syntactic dependency relations.

[0054] Beneficial effects

[0055] The method of the present invention has the following advantages compared with the prior art:

[0056] This method takes into account that the syntactic dependency type information of other words in the sentence can help determine the sentiment polarity of the aspect words. It uses the syntactic dependency type information to expand the information of sentences containing aspect words, enriching the semantic expression of the sentences, which can better model sentence representation and improve the performance of aspect-level sentiment analysis. Attached Figure Description

[0057] Figure 1 This is a flowchart of the method of the present invention.

[0058] Figure 2 This is a schematic diagram of the visualization results of the syntactic dependency tree.

[0059] Figure 3 This is a schematic diagram of the adjacency matrix for encoding the syntactic dependency tree in a sentence. Detailed Implementation

[0060] The method of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.

[0061] like Figure 1 As shown, the present invention includes the following steps:

[0062] Step 1: Extract the syntactic dependency tree of the sentence;

[0063] Step 2: Analyze the syntactic dependency relations of the training set;

[0064] Step 3: Encode the syntactic dependency tree of the sentence;

[0065] In this embodiment, the syntactic dependency tree in the sentence is encoded as an n×n adjacency matrix, where n is the same as the length of the words in the sentence;

[0066] Step 4: Obtain the feature representations of words in the sentence;

[0067] Specifically, in this embodiment, the sentence is input into the BERT model (a pre-trained model that can obtain feature representations of words containing contextual information) to obtain feature representations of each word in the sentence.

[0068] Step 5: Training the graph convolutional network:

[0069] Step 6: Perform sequence tagging on the words in the sentence;

[0070] Step 7: Obtain aspect terms and sentiment polarity.

[0071] Example

[0072] Taking the sentiment sentence "Complimentary chips and salsa to start" containing aspect words as an example, this embodiment will provide a detailed explanation of the specific operation steps of the aspect-level sentiment bigram extraction method that integrates syntactic dependency relations as described in this invention.

[0073] A method for extracting aspect-level sentiment binary tuples that incorporates syntactic dependency relations, such as Figure 1 As shown, it includes the following steps:

[0074] Step 1: Extract the syntactic dependency tree of the sentence;

[0075] Specifically, in this embodiment, "Complimentary chips and salsa to start," the syntactic dependencies are obtained through SpaCy, and a syntactic dependency tree is formed. The visualization result of the syntactic dependency tree is as follows: Figure 2 As shown, the root node of this syntactic dependency tree is 'chips'. Figure 2 The letters on each side represent syntactic dependency relations;

[0076] Step 2: Analyze the syntactic dependency relations of the training set;

[0077] Specifically, in this embodiment, using this sentence as the training set, there are 5 different syntactic dependency relations. By encoding them starting from 0 in the manner of step 2, an encoding table can be obtained.

[0078] Step 3: Encode the syntactic dependency tree of the sentence;

[0079] Specifically, in this embodiment, the syntactic dependency tree in the sentence is encoded as a 6×6 adjacency matrix, ultimately resulting in the following: Figure 3The matrix shown has the following meanings as described in step 2: 2 represents that the word is the root node, and the remaining values ​​represent 5 different syntactic dependency relations.

[0080] Step 4: Obtain the feature representations of words in the sentence;

[0081] Inputting the sentence "Complimentary chips and salsa to start" into the BERT model yields the word vector representation of the sentence;

[0082] Step 5: Training the graph convolutional network:

[0083] Specifically, in this embodiment, the weighted adjacency matrix R obtained in step 2 and the vectorized representation h obtained in step 3 are compared. (0) The input consists of a network built from L graph convolutional layers.

[0084] Step 6: Perform sequence tagging on the words in the sentence;

[0085] Specifically, in this embodiment, the vectorized representation of each word obtained in step 5 is passed through the Softmax layer to calculate the corresponding probability vector, and sequence labeling is performed on each word. The result is {'Complimentary':'O','chips':'B-POS','and':'O','salsa':'B-POS','to':'O','start':'O'};

[0086] Step 7: Obtain aspect terms and sentiment polarity;

[0087] Specifically, in this embodiment, based on the sequence labeling results in step 6, the sequence length, starting position, and sentiment polarity corresponding to aspect words in the sentence are obtained. Therefore, the result obtained from the above example is {[1,1,'POS'],[3,1,'POS']}. The meaning of the result is that if the number of the first word in the sentence is set to 0, then the word 'chips' with number 1 and the word 'salsa' with number 3 are both aspect words, and their sentiment polarity is positive (POS).

Claims

1. A method for extracting aspect-level sentiment binary tuples that integrates syntactic dependency relations, characterized in that, Includes the following steps: Step 1: Extract sentences, that is, the syntactic dependency tree of text sequence X; Step 2: For the trained dataset, count all the types of syntactic dependency relations that have appeared, and obtain an encoding table D; Step 3: Encode the syntactic dependency tree of the sentence; The syntactic dependency tree of the text sequence X is encoded according to the encoding table D to obtain an n*n weighted adjacency matrix R with dependency relation information; The R expression is: Wherein, the element r in matrix R ij The value of includes two cases: if there is no direct syntactic dependency relationship between word i and word j, the value is 0; if there is a direct syntactic dependency relationship, the corresponding value in the encoding table D obtained in step 2 is taken according to the type of syntactic dependency relationship between word i and word j. Step 4: Obtain the feature representations of words in the sentence; For the input sentence that requires aspect-level sentiment bigram extraction, i.e., the text sequence, pre-trained word feature vectors are used to represent the vectorized representation of each word in the text sequence. The corresponding text sequence {X = w1, w2, ..., w n Step 3 yields its vectorized representation. ={ , , ,… }, Representative word w i The representation vectors of the pre-trained model were passed; The l-th layer of the graph convolutional network in the network uses a weighted adjacency matrix R and a vector For input; First, an attention mechanism is used to calculate the information in the sentence. right Attention score : in, These are the elements in matrix R; Subsequently, the graph convolutional layer calculates the word according to the following formula. Output : in, For deep learning activation functions, These are the training parameters for the l-th graph convolutional network layer; the output vector of the l-th graph convolutional layer is: ; After passing through the network layer, we obtain a vectorized representation of each word that incorporates syntactic dependency information. ; Step 5: Training the graph convolutional network; The weighted adjacency matrix R and its vectorized representation The input consists of a network built from L graph convolutional layers. Each element of the probability vector represents the probability of the corresponding word in the sequence label, as shown in the following formula: in, The word w i The tag, the tag value range is , The first word indicating aspect, This indicates that the word has a positive emotional polarity. This indicates that the emotional polarity of the word is neutral. This indicates that the emotional polarity of the word is negative. This indicates that the word is not the first word; Represents the weight matrix; This represents the probability distribution vector of the word's corresponding label, obtained by aligning the vectorized representation with the label space. K represents the dimension of the probability distribution vector. Representative vector The k-th dimension; The final label sequence Y is: Y = { }; Step 6: Perform sequence tagging on the words in the sentence; The vectorized representation of each word obtained in step 5 is passed through a Softmax layer to calculate the corresponding probability vector, and sequence labeling is performed on each word; Step 7: Obtain aspect terms and sentiment polarity; Based on the sequence labeling results in step 6, we obtain the sequence length, starting position, and sentiment polarity corresponding to the aspect words in the sentence; Then, cross-entropy is used as the loss function, and gradient descent is used to update the parameters to minimize the model's prediction error. Among them, the starting position of all aspect terms The definition is as follows: in, The first word indicating aspect; Then, The elements in the middle are arranged in ascending order to obtain the sequence. The i-th element in the sentence, which is the aspect word. starting position Its sequence length for: +1 aspect words Corresponding emotional polarity Its values ​​are as follows: Among them, POS represents positive, NEU represents neutral, and NEG represents negative; After the above steps, we obtain the aspect words in the sentence. Corresponding sequence length Starting position With emotional polarity .

2. The method for extracting aspect-level sentiment binary tuples by incorporating syntactic dependency relations as described in claim 1, characterized in that, In step 2, before the statistics are performed, the case where there is no syntactic dependency relationship between the core word and the modifier is encoded as 0, and the case where the core word and the modifier are the same word is encoded as 1. At the same time, the syntactic dependency relationship pointing to the root node of the syntactic dependency tree is also regarded as a type of syntactic dependency. After the statistics are compiled, the statistical results of the types of syntactic dependency relations are added and coded one by one to ensure that different syntactic dependency relations have different codes, and finally a coding table is obtained.