An Intensity-Aware Emotion Classification Method Based on Hierarchical Knowledge-Enhanced Graph Neural Networks

By explicitly modeling sentiment intensity information using hierarchical knowledge-enhanced graph neural networks, this approach addresses the insufficient modeling of the combination of degree words and sentiment words in Chinese sentiment analysis. It improves the accuracy of sentiment classification and the robustness of the model, making it suitable for public opinion monitoring, product review analysis, and mental health assessment.

CN122309737APending Publication Date: 2026-06-30XIAN UNIV OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XIAN UNIV OF TECH
Filing Date
2026-03-18
Publication Date
2026-06-30

Smart Images

  • Figure CN122309737A_ABST
    Figure CN122309737A_ABST
Patent Text Reader

Abstract

This invention discloses an intensity-aware emotion classification method based on a hierarchical knowledge-enhanced graph neural network. Its key features include: preprocessing the Chinese text to be classified by word segmentation, syntactic parsing, and dependency tree construction; extracting word-level contextual semantic vectors and global sentence representations using a pre-trained language model; identifying sentiment words and degree words in the text, calculating the dynamic sentiment intensity of lemmas, and adaptively expanding the sentiment lexicon; extracting a sentiment knowledge subgraph and aggregating knowledge embeddings, followed by seed-driven pruning to obtain a sparse dependency subgraph; fusing semantic and knowledge features to generate initial node representations, and learning these representations using a hierarchical intensity-aware graph neural network; finally, generating graph-level features through dual-path pooling, fusing global semantics, and outputting the emotion classification result through a multi-task framework. This invention solves the problem of ambiguous emotion classification caused by insufficient modeling of the combined intensity of "degree words + sentiment words" in existing technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of natural language processing technology, specifically relating to an intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks. Background Technology

[0002] Currently, social media, product reviews, online consultations, and other scenarios are continuously generating massive amounts of subjective text. Compared to merely distinguishing sentiment polarity (positive / negative / neutral), accurately identifying sentiment intensity (such as the difference between "somewhat happy" and "very happy") has significant practical value for downstream tasks such as public opinion early warning, user satisfaction assessment, and mental health monitoring. The combination pattern of "degree words + sentiment words" is widespread in Chinese text. The decomposability and modification effect of this pattern require sentiment analysis methods to not only determine sentiment polarity but also to perform refined modeling of sentiment intensity, thereby providing support for more accurate downstream decision-making and intervention.

[0003] Currently, Chinese sentiment analysis methods are mainly divided into three categories: dictionary-based rule-based methods, traditional machine learning methods, and deep learning-based end-to-end methods. Dictionary-based methods (relying on sentiment dictionaries and degree vocabularies) possess strong interpretability but suffer from limited text coverage. Pre-trained language models, represented by the BERT family, excel in semantic modeling and have been widely applied to sentiment polarity classification tasks. Meanwhile, graph neural networks are used to incorporate syntactic structures or knowledge graphs into semantic representation learning, and knowledge augmentation methods (such as using HowNet, Emotion Knowledge Graph, or Entity Embedding) are used to supplement semantic information and common sense knowledge. While these studies have made significant progress in sentiment polarity classification and semantic understanding, most works treat sentiment intensity processing as a secondary task, achieving it only through simple feature appending, failing to fully explore the core information of sentiment intensity.

[0004] Specifically, existing technologies suffer from the following three core problems: First, most deep learning models treat degree words and sentiment words as ordinary tokens, failing to explicitly model the multiplicative modification relationship of "degree word × sentiment word," which weakens the sentiment intensity information and makes it difficult for the model to effectively represent the intensity differences between different emotions, thereby affecting the ability to distinguish emotion categories and reducing the accuracy of emotion classification results. Second, manually constructed dictionaries suffer from insufficient coverage and have difficulty handling out-of-vocabulary (OOV) words and new domain words, while existing dictionary expansion or knowledge graph injection methods are significantly insufficient in maintaining semantic consistency and sentiment polarity consistency. Third, directly using the complete dependency tree as input to a GNN easily introduces irrelevant noise, and prematurely fusing unreliable sentiment intensity information during GNN modeling will further amplify the error propagation effect. Summary of the Invention

[0005] The purpose of this invention is to provide an intensity-aware emotion classification method based on hierarchical knowledge-enhanced graph neural networks, which solves the problem of ambiguous emotion classification caused by insufficient modeling of the combined intensity of "degree words + sentiment words" in existing technologies.

[0006] The technical solution adopted in this invention is an intensity-aware emotion classification method based on a hierarchical knowledge-enhanced graph neural network. This method includes preprocessing the Chinese text to be classified, performing word segmentation, syntactic parsing, and constructing a dependency tree; extracting word-level contextual semantic vectors and global sentence representations through a pre-trained language model; identifying sentiment words and degree words in the text, calculating the dynamic sentiment intensity of lemmas, and adaptively expanding the sentiment lexicon; subsequently extracting a sentiment knowledge subgraph and aggregating knowledge embeddings, and obtaining a sparse dependency subgraph through seed-driven pruning; then fusing semantic and knowledge features to generate initial node representations, and completing node representation learning through a hierarchical intensity-aware graph neural network; finally, generating graph-level features through dual-path pooling, fusing global semantics, and outputting the emotion classification result through a multi-task framework.

[0007] The invention is further characterized in that, Includes the following steps: S1. Obtain the Chinese text data to be classified, preprocess the text, complete word segmentation, part-of-speech tagging and dependency parsing, and construct the dependency tree structure of the sentence; at the same time, input the word sequence after word segmentation into the Chinese pre-trained language model to obtain the context semantic vector corresponding to each word, as well as the global sentence representation vector representing the semantics of the whole sentence; S2. Based on the preset degree dictionary and sentiment dictionary, match the word segments after word segmentation, identify sentiment words and degree words in the text, calculate the dynamic sentiment intensity value of each sentiment word, and complete the sentiment intensity modeling at the word level. S3. For the out-of-vocabulary words not covered by the sentiment dictionary in step S2, perform a two-layer verification of word-level semantic similarity retrieval and sentence-level contextual consistency, filter out candidate sentiment words and complete sentiment attribute mapping, and realize the adaptive expansion of the sentiment dictionary. S4. Using sentiment words and candidate sentiment words as query keys, extract the corresponding local knowledge subgraphs from the pre-built sentiment knowledge graph and aggregate them to obtain the knowledge graph embedding vector corresponding to each word element. S5. Using sentiment words as seed nodes, perform seed-driven subgraph pruning on the constructed dependency tree structure, filter and retain nodes and dependency relationships related to sentiment expression, and generate sparse dependency subgraphs as the input structure of the graph neural network. S6. For each node in the obtained dependency subgraph, the word context semantic vector and the knowledge graph embedding vector are fused through a learnable gating mechanism to generate the initial node representation of the graph neural network. S7. Input the dependency subgraph, initial node representation, and word sentiment intensity value into the hierarchical intensity-aware graph neural network, complete message passing and node representation update in a hierarchical and progressive manner, and output a node-level representation that integrates syntactic structure, semantic features and sentiment intensity information. S8. Based on the node-level representation of the output, extract the statistical features of the sentiment intensity distribution within the graph. At the same time, adopt a dual-path pooling method of semantic structure pooling and intensity-guided pooling to aggregate the global semantic structure representation and intensity-aware graph representation respectively. After fusion, generate the final graph-level feature representation. S9. The obtained graph-level feature representation is gated and fused with the sentence global representation vector from step S1. Based on the fused comprehensive features, the sentiment classification result of the text and the sentence-level sentiment intensity prediction value are output simultaneously through a multi-task learning framework.

[0008] Step S2 is as follows: S21. Match the segmented words with the sentiment dictionary. Mark the successfully matched words as sentiment words and read their corresponding basic sentiment intensity values. Set the sentiment intensity values ​​of unmatched words to 0. S22. For the identified sentiment words, search for degree words in the matching degree dictionary within the preset forward search window. If a corresponding degree word is found, read its modification coefficient and multiply it by the basic sentiment intensity value of the sentiment word to obtain the dynamic sentiment intensity value of the word element. If no degree word is found, directly use the basic sentiment intensity value as the dynamic sentiment intensity value of the word element. S23. Perform min-max normalization on the dynamic sentiment intensity values ​​of all word elements to uniformly map the values ​​to the [0,1] interval; at the same time, calculate the preliminary sentiment intensity representation of the sentence based on the average intensity of all sentiment words in the sentence and the sentiment density factor, which serves as a weak supervision signal for model training.

[0009] Step S3 includes: S31. For out-of-vocabulary words, within a word set with the same sentiment polarity, retrieve the sentiment word with the highest semantic similarity to the target word based on the semantic database as a candidate, and sort them by similarity to obtain a candidate word set; S32. Replace the out-of-vocabulary words in the original sentence with candidate words to generate a replacement sentence. Semantically encode the original sentence and the replacement sentence using a pre-trained language model, and calculate the word-level semantic similarity and sentence-level contextual similarity between the original sentence and the replacement sentence. S33. Set a dual verification threshold. Only when both the word-level semantic similarity and the sentence-level contextual similarity exceed the corresponding threshold will the candidate word be marked as a valid candidate word, and a sentiment attribute mapping relationship between the out-of-vocabulary word and the candidate sentiment word will be established.

[0010] In step S4, the extraction of the local knowledge subgraph takes the target sentiment word as the central node, prioritizes the expansion of one-hop neighbor nodes, and expands to two-hop neighbor nodes as needed; for multiple entity nodes mapped to the same word element, the entity embedding vector is aggregated by averaging or weighted averaging to obtain the knowledge graph embedding vector corresponding to the word element.

[0011] Step S5 is as follows: S51. Using sentiment words as seed nodes, a multi-source breadth-first search strategy is adopted to expand and retain nodes within a preset number of hops in the dependency tree. S52. Set a dependency whitelist and retain all nodes and connections corresponding to subject relations, object relations, adjective modification relations and adverb modification relations in the whitelist, regardless of the number of hops. S53. When the number of nodes after filtering is lower than the preset minimum threshold, nodes are added according to the connectivity of the nodes in the dependency tree to ensure the minimum connectivity of the subgraph and finally generate a sparse dependency subgraph.

[0012] The expression for fusion via a learnable gating mechanism in step S6 is shown below: ; ; In the formula, For learnable gated vectors; For activation functions; Let i be the context semantic vector of node i; Embed the knowledge graph vector for node i; For element-wise multiplication; The weight matrix is ​​a learnable weight matrix; This is the initial node generated.

[0013] The hierarchical representation learning process of the hierarchical intensity-aware graph neural network in step S7 specifically includes: S71. The first layer is a pure structure learning layer. Node updates and message passing rely only on the topological structure of the dependency subgraph and do not introduce sentiment intensity information. The syntactic skeleton of the sentence is learned through graph attention convolution, and the node representation of the first layer is output. S72. The intermediate layer is an intensity multiplicative modulation layer. First, the sentiment intensity value of the word is nonlinearly transformed through a multilayer perceptron to obtain an enhanced intensity vector. Then, the enhanced intensity vector is used as a modulation factor for the attention weights by a multiplicative mechanism to participate in the message passing of the graph attention convolution, so that the high-intensity sentiment word nodes can obtain higher weights in the message passing and output the intermediate layer node representation. S73. The last layer is the intensity-gated fusion layer, which adaptively adjusts the contribution of sentiment intensity information to attention weights through learnable gating weight vectors, completes the final node representation update, and outputs a node-level representation that integrates syntactic structure, semantic features and sentiment intensity information.

[0014] In step S8, the statistical features of intensity distribution include the average value of sentiment intensity, dispersion, sentiment word coverage, distribution skewness, distribution entropy, and peak value. In the dual-path pooling, one path uses standard graph pooling to obtain the global semantic structure representation, and the other path is intensity-guided pooling, which weights and aggregates node representations based on the semantic importance and intensity importance of nodes to obtain the intensity-aware graph representation.

[0015] In step S9, the multi-task learning framework simultaneously performs an emotion polarity multi-classification task and a sentence-level emotion intensity regression task. The output of the emotion polarity multi-classification task is the classification results of six categories: happiness, sadness, fear, anger, surprise, and disgust. The output of the emotion intensity regression task is a continuous intensity value normalized to the [0,1] interval.

[0016] The beneficial effects of this invention are: This invention explicitly models emotional intensity information at three levels: lexical layer, node layer, and layer layer. This enables the model to characterize the differences in emotional intensity at different levels, thereby improving the ability to distinguish different emotional categories and increasing the accuracy of emotional classification results. Furthermore, it employs a two-layer validation emotional dictionary expansion method, combined with knowledge injection from an emotional knowledge graph. Through semantic relation validation and graph structure information constraints, it improves the accuracy and coverage of emotional word recognition, thereby enhancing the model's ability to recognize out-of-vocabulary words and emerging emotional expressions.

[0017] Furthermore, this invention designs a graph structure pruning strategy driven by seed words and a graph neural network model based on hierarchical intensity fusion. By screening key nodes and relationships related to emotion and performing hierarchical information fusion, the effectiveness of graph structure information is improved, thereby enhancing the model's robustness to graph noise and improving the performance of joint prediction of emotion polarity and emotion intensity in Chinese text. This enables it to be better applied to scenarios such as public opinion monitoring, product review analysis, and mental health assessment. Attached Figure Description

[0018] Figure 1 This is a flowchart illustrating the intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks of this invention. Detailed Implementation The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0019] Example 1 This invention presents an intensity-aware emotion classification method based on a hierarchical knowledge-enhanced graph neural network. The method includes preprocessing the Chinese text to be classified, performing word segmentation, syntactic parsing, and constructing a dependency tree; extracting word-level contextual semantic vectors and global sentence representations using a pre-trained language model; identifying sentiment words and degree words in the text, calculating the dynamic sentiment intensity of lemmas, and adaptively expanding the sentiment lexicon; subsequently extracting a sentiment knowledge subgraph and aggregating knowledge embeddings, followed by seed-driven pruning to obtain a sparse dependency subgraph; fusing semantic and knowledge features to generate initial node representations, and learning these representations using a hierarchical intensity-aware graph neural network; finally, generating graph-level features through dual-path pooling, fusing global semantics, and outputting the emotion classification result through a multi-task framework.

[0020] like Figure 1 As shown, the specific steps include: S1. Obtain the Chinese text data to be classified, and preprocess the text. Preprocessing includes denoising and standardizing the text. The core is to clean and unify the format of the original input text, eliminate text noise, and provide standardized and effective text input for subsequent steps such as word segmentation and semantic encoding.

[0021] After preprocessing, the sentence is segmented into words using existing Chinese word segmentation methods, dividing a continuous sequence of Chinese characters into semantically complete word units. After word segmentation, the words in the sentence are tagged with parts of speech. Part-of-speech tagging is used to identify the grammatical category of words in the sentence, including basic parts of speech such as nouns, verbs, adjectives, and adverbs. Next, dependency parsing is performed on the sentence. Dependency parsing is an existing technology in the field of natural language processing. It analyzes the syntactic dependency relationships between words in the sentence, constructs a dependency tree structure with words as nodes and dependency relationships as edges, and generates corresponding dependency relationship labels to describe the grammatical relationships between words. Simultaneously, the segmented word sequence is input into a pre-trained Chinese language model for semantic representation learning. Specifically, the segmented word sequence is input into the pre-trained Chinese language model, and the sentence is semantically encoded through its multi-layer transformer encoding structure to obtain the context semantic vector representation of each word, as well as the global representation vector (such as the vector representation corresponding to the sentence beginning tag) used to represent the semantic information of the entire sentence. The word vector representation and the global semantic representation of the sentence will serve as the basic input for subsequent node representation construction and semantic similarity calculation.

[0022] S2. A degree dictionary and a sentiment dictionary are prepared. The degree dictionary records common degree adverbs and their corresponding modification coefficients or weights, while the sentiment dictionary records sentiment words and their basic sentiment intensity values. Based on the pre-set degree and sentiment dictionaries, the segmented lexical units are matched to identify sentiment words and degree words in the text, and the dynamic sentiment intensity value of each sentiment lexical unit is calculated, completing the lexical-level sentiment intensity modeling. S3. For the out-of-vocabulary words not covered by the sentiment dictionary in step S2, perform a two-layer verification of word-level semantic similarity retrieval and sentence-level contextual consistency, filter out candidate sentiment words and complete sentiment attribute mapping, and realize the adaptive expansion of the sentiment dictionary. S4. Using the sentiment words and candidate sentiment words as query keys, extract the corresponding local knowledge subgraphs from the pre-built sentiment knowledge graph and aggregate them to obtain the knowledge graph embedding vector corresponding to each word element. S5. Using sentiment words as seed nodes, perform seed-driven subgraph pruning on the constructed dependency tree structure, filter and retain nodes and dependency relationships related to sentiment expression, and generate sparse dependency subgraphs as the input structure of the graph neural network. S6. For each node in the obtained dependency subgraph, the word context semantic vector and the knowledge graph embedding vector are fused through a learnable gating mechanism to generate the initial node representation of the graph neural network. S7. Input the dependency subgraph, initial node representation, and word sentiment intensity value into the hierarchical intensity-aware graph neural network, complete message passing and node representation update in a hierarchical and progressive manner, and output a node-level representation that integrates syntactic structure, semantic features and sentiment intensity information. S8. Based on the node-level representation of the output, extract the statistical features of the sentiment intensity distribution within the graph. At the same time, adopt a dual-path pooling method of semantic structure pooling and intensity-guided pooling to aggregate the global semantic structure representation and intensity-aware graph representation respectively. After fusion, generate the final graph-level feature representation. S9. The obtained graph-level feature representation is gated and fused with the sentence global representation vector from step S1. Based on the fused comprehensive features, the sentiment classification result of the text and the sentence-level sentiment intensity prediction value are output simultaneously through a multi-task learning framework.

[0023] Example 2 Based on Embodiment 1 above, step S2 of this invention specifically includes: S21. Match the segmented words with the sentiment dictionary. When a word matches a word in the sentiment dictionary, mark the word as a sentiment word and read its corresponding basic sentiment intensity value. Set the sentiment intensity value of words that do not match to 0. S22. For a lexical unit identified as a sentiment word, search forward in the sentence for the nearest degree word and check if there is a word in the degree dictionary within a preset forward window range (e.g., a range of 3 lexical units). If a degree word is found, read the modification coefficient corresponding to the degree word and modify the basic intensity of the sentiment word to obtain the dynamic sentiment intensity value of the lexical unit. If no degree word is found, directly use the basic sentiment intensity value as the dynamic sentiment intensity value of the lexical unit. S23. After obtaining the sentiment intensity of all word elements, perform unified normalization on the intensity values ​​involved in the dataset to ensure that the intensity values ​​from different sources or of different types are within a unified numerical range; specifically, perform minimum-maximum normalization on the dynamic sentiment intensity values ​​of all word elements, and map the degree word weight, the basic intensity of sentiment words, and the dynamic sentiment intensity of word elements to the [0,1] interval. Furthermore, after calculating the sentiment intensity at the word level, the set of sentiment words in the sentence is aggregated to obtain a preliminary sentiment intensity representation of the sentence. First, the average intensity of all sentiment words in the sentence is calculated as the average intensity. Then, the sentiment density factor is calculated based on the proportion of sentiment words in the total number of words in the sentence to reflect the impact of the density of sentiment expression on the overall sentiment intensity. Finally, the preliminary sentiment intensity representation of the sentence is obtained by multiplying the average intensity by the density factor. This sentence-level intensity can be used as a weak supervision signal or auxiliary feature input in subsequent model training.

[0024] Example 3 Based on Embodiment 2 above, step S3 of this invention includes: S31. For out-of-vocabulary words, within a word set with the same sentiment polarity, retrieve the sentiment word with the highest semantic similarity to the target word based on the semantic database as a candidate, and sort them by similarity to obtain a candidate word set; S32. For the candidate word set obtained from word-level retrieval, the candidate words are used to replace the target words in the original sentence in turn to construct the corresponding replacement sentences. Then, a pre-trained Chinese language model is used to semantically encode the original and replacement sentences. The pre-trained language model is a bidirectional encoder-transformer model (BERT), whose input is the word sequence after word segmentation, and a sentence-beginning marker is added to the beginning of the sentence to represent the overall semantic information of the sentence. The model performs context modeling on the input sequence through a multi-layer transformer encoding structure, thereby obtaining the context semantic vector representation corresponding to each word and the overall semantic representation vector of the sentence. During the encoding process, the position of the target word in the sentence is marked, and the context vector representation of the corresponding word in the original and replacement sentences is extracted as the word-level semantic representation. At the same time, the vector corresponding to the sentence-beginning marker is extracted as the sentence-level semantic representation.

[0025] Subsequently, the semantic similarity between the original sentence and the replacement sentence at the word level and the sentence level is calculated respectively. The word level similarity is used to measure the semantic closeness between the candidate word and the target word, and the sentence level context similarity is used to measure the impact of the replacement operation on the overall semantics of the sentence. The sentence level context similarity can be calculated by cosine similarity, and its calculation formula is shown in the following formula (1): (1); in, This represents the semantic vector corresponding to the initial marker of the original sentence. This represents the semantic vector corresponding to the initial marker of the replaced sentence.

[0026] S33. In order to ensure the semantic rationality of candidate words, a dual verification mechanism is adopted to screen candidate words. Only words that pass both word-level semantic similarity verification and sentence-level contextual consistency verification are marked as candidate words. The judgment rule is as follows (2): (2); in, Candidate words, Original emotional words, This represents the word-level similarity calculated based on the semantic relationships in the sentiment dictionary. and A preset threshold is used. For words that simultaneously meet both of the above conditions, they are marked as valid candidate sentiment words, and a sentiment attribute mapping relationship is established between out-of-vocabulary words and these candidate sentiment words. .

[0027] In the subsequent sentiment knowledge graph injection stage, the similar sentiment word is used as the query key to extract the corresponding knowledge subgraph from the sentiment knowledge graph and assign it to the target word. This achieves a combination of sentiment dictionary expansion and knowledge enhancement, introducing structural information from the knowledge graph while ensuring semantic accuracy, so as to improve the model's ability to identify out-of-vocabulary words or semantic variants.

[0028] Furthermore, the query key in step S4 is the sentiment word mapping key obtained through word-level and sentence-level dual verification in the previous step, so only one subgraph extraction process is performed. The sentiment knowledge graph is further organized from the aforementioned degree dictionary and sentiment dictionary, where sentiment words serve as entity nodes, and the modification relationships between degree words and sentiment words, as well as the semantic association relationships between sentiment words, constitute the edges in the graph, thus forming a sentiment knowledge graph structure containing sentiment word entities and their semantic relationships.

[0029] Furthermore, the extraction of local knowledge subgraphs takes the target sentiment word as the central node, prioritizes expanding one-hop neighbor nodes to obtain directly related sentiment semantic information, and expands to two-hop neighbors when necessary to obtain richer composite sentiment relationship information, thereby constructing a local sentiment knowledge subgraph. For multiple entity nodes mapped to the same word element, their corresponding entity embedding vectors are aggregated, for example, by using an average or weighted average method to calculate a unified knowledge representation vector, thereby forming the knowledge graph representation corresponding to the word element. If a word element fails to match a corresponding entity in the sentiment knowledge graph, its knowledge representation is set to an empty vector for unified processing in subsequent model processing.

[0030] Example 4 Based on Embodiment 3 above, step S5 of this invention specifically includes: S51. Using sentiment words as seed nodes, a multi-source breadth-first search strategy is adopted. Starting from multiple sentiment seed nodes, the dependency tree is expanded, and related nodes within a preset number of hops are retained. S52. At the same time, in order to ensure that key semantic relationships are not accidentally deleted, a dependency relationship whitelist is set up. For the subject relationship, object relationship, adjective modification relationship, and adverb modification relationship in the whitelist, the nodes and connections corresponding to such dependency relationships are retained even if the node connections of such dependency relationships exceed the preset number of hops. S53. When the number of nodes after filtering is lower than the preset minimum threshold, nodes are added according to the connectivity of the nodes in the dependency tree to ensure the minimum connectivity of the subgraph.

[0031] Through the above processing, a sparse dependency subgraph is constructed on the basis of the original dependency tree. This subgraph effectively reduces syntactic nodes and connections that are not related to emotion while retaining key structural information related to emotion expression, thereby reducing structural noise and providing more effective graph structure input for the representation learning of subsequent graph neural network models.

[0032] Further, step S6 specifically involves mapping the semantic vector representation generated by the pre-trained language model and the corresponding knowledge graph embedding to the same dimension for each node in the pruned dependency subgraph, and then fusing them using a learnable gating mechanism. The gating fusion mechanism is designed to avoid the problem of high-dimensional semantic features masking knowledge features when directly splicing knowledge graph features with semantic features, thereby achieving adaptive information integration. The expressions for fusion through the learnable gating mechanism are shown in equations (3) and (4) below: (3); (4); In the formula, The learnable gated vector is obtained by performing a nonlinear transformation on the combination of node semantic features and knowledge features, and then applying the Sigmoid activation function. For activation functions; Let i be the context semantic vector of node i; Embed the knowledge graph vector for node i; For element-wise multiplication; The weight matrix is ​​a learnable weight matrix; This is the initial node generated.

[0033] Example 5 Based on Embodiment 4 above, step S7 of this invention aims to input the initial node representation obtained through gating fusion and the pruned dependency subgraph obtained in the aforementioned steps into the hierarchical graph neural network, and gradually introduce the intensity information of emotion words in a hierarchical manner. Specifically, the hierarchical representation learning process of the hierarchical intensity-aware graph neural network includes the following steps: S71. The first layer is a pure structure learning layer. Node updates and message passing rely solely on the topological structure of the dependency subgraph and do not introduce sentiment intensity information. The syntactic skeleton of the sentence is learned through graph attention convolution, and the node representation of the first layer is output. The learning process can be represented by the following formula (5): (5); Among the nodes The representation of Updates are performed using graph attention convolution (GATConv). Specifically, nodes... initial vector (Obtained by gating fusion of BERT semantic representation and knowledge graph embedding) as input, along with its set of neighboring nodes. They participated in the calculation together, among which Indicates neighboring nodes, Indicates the type of dependency relationship between nodes.

[0034] S72. The intermediate layer is the intensity multiplicative modulation layer, which introduces emotional intensity information to enhance the sensitivity of the graph neural network to emotional features. First, the emotional intensity values ​​of the word units are nonlinearly transformed through a multilayer perceptron to obtain the enhanced intensity vector, as shown in the following equation (6): (6); in, This represents the enhanced emotion intensity vector. It is a learnable nonlinear mapping function.

[0035] Subsequently, in the Graph Attention Network (GAT), the enhancement intensity vector is used as the modulation factor of the attention weights through a multiplicative mechanism, as shown in Equation (7): (7); in, For the first Layer nodes The representation vector, This is the set of edges in the graph, containing information about the dependencies between nodes. This indicates the use of a multiplicative modulation mechanism, which directly applies intensity information to attention weights.

[0036] The specific calculation method for attention weights is as follows (8): (8); in, Represents a node For neighboring nodes Attention weights For learnable attention vectors, This represents the concatenation of node features. For neighboring nodes It enhances emotional intensity and is used to modulate attention weights.

[0037] This mechanism ensures message passing in the graph attention convolution, giving high-intensity sentiment word nodes higher weight in message passing and outputting intermediate layer node representations. The multiplicative mechanism is simple and effective, with moderate influence, and is suitable for introduction into the intermediate layer to balance the transmission of structural information and emotional intensity information.

[0038] S73. After the model has gone through multiple layers of message passing and intermediate layer intensity modulation, the nodes have fully learned the structural information of the sentence. In order to enable the model to adaptively determine the contribution of sentiment intensity information, the last layer is an intensity-gated fusion layer. Through a learnable gating weight vector, it adaptively adjusts the contribution of sentiment intensity information to attention weights, completes the final node representation update, and outputs a node-level representation that integrates syntactic structure, semantic features and sentiment intensity information.

[0039] Specifically, the enhanced emotional intensity As a modulotable factor added to the attention calculation, the node representation update formula is Equation (9): (9); in, This represents the node at the next higher level. Let the graph be a set of edges containing dependency relationship information. This is the enhanced node sentiment intensity vector. This indicates the adoption of a learnable gating mechanism, which introduces strength information into node updates in an adaptive manner.

[0040] The gating attention weights are calculated as follows (10): (10); in, Represents a node For neighboring nodes Attention weights For learnable attention vectors, This represents the concatenation of node features. The model uses learnable gating weight vectors to... Learn how to use node strength information.

[0041] This mechanism allows the model to adaptively adjust the intensity contribution for different nodes or sentences: for nodes where intensity information is important, A larger value gives it greater weight in message passing; for nodes where intensity information is not important, the model can reduce their influence, thus balancing structural and emotional intensity information. Ultimately, the gating mechanism ensures that the last layer of node representations simultaneously considers both structural and intensity information, enhancing the model's expressive power and flexibility.

[0042] After the graph neural network propagates, the scalar emotion intensity is encoded into a vector and then fused with the graph neural network output through another gating step. This avoids noise amplification caused by the introduction of intensity information in the early stages of propagation, thereby ensuring that the final node representation effectively integrates syntactic structure, semantic features, and emotion intensity information.

[0043] Example 6 Based on Embodiment 5 above, in step S8 of this invention, the statistical features of intensity distribution include the average sentiment intensity, dispersion, sentiment word coverage, distribution skewness, distribution entropy, and peak value. In the dual-path pooling, one path uses standard graph pooling to obtain the global semantic structure representation, and the other path uses intensity-guided pooling to weight and converge node representations based on the semantic importance and intensity importance of nodes, resulting in an intensity-aware graph representation. The representations of the two paths are fused with the statistical features to form the final graph-level feature representation.

[0044] Furthermore, in step S9, the multi-task learning framework simultaneously performs an emotion polarity multi-classification task and a sentence-level emotion intensity regression task. The output of the emotion polarity multi-classification task is the classification results of six categories: happiness, sadness, fear, anger, surprise, and disgust. The output of the emotion intensity regression task is a continuous intensity value normalized to the [0,1] interval.

[0045] This invention employs a weighted joint loss function for end-to-end training, enabling classification tasks to benefit from fine-grained supervision of intensity information, while emotion intensity regression benefits from complementary representations of graph structure and global semantic information, thereby achieving synergistic optimization and mutual enhancement of the two tasks.

[0046] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0047] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. An intensity-aware emotion classification method based on hierarchical knowledge-enhanced graph neural networks, characterized in that, The process includes preprocessing the Chinese text to be classified, performing word segmentation, syntactic parsing and constructing dependency trees, extracting word-level contextual semantic vectors and global sentence representations through a pre-trained language model; then identifying sentiment words and degree words in the text, calculating the dynamic sentiment intensity of word units, and adaptively expanding the sentiment dictionary; subsequently extracting the sentiment knowledge subgraph and aggregating knowledge embeddings, and obtaining a sparse dependency subgraph through seed-driven pruning. The initial node representation is generated by fusing semantic and knowledge features, and node representation learning is completed through a hierarchical intensity-aware graph neural network. Finally, graph-level features are generated through dual-path pooling, and the emotion classification result is output through a multi-task framework after fusing global semantics.

2. The intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks according to claim 1, characterized in that, Includes the following steps: S1. Obtain the Chinese text data to be classified, preprocess the text, complete word segmentation, part-of-speech tagging and dependency parsing, and construct the dependency tree structure of the sentence; at the same time, input the word sequence after word segmentation into the Chinese pre-trained language model to obtain the context semantic vector corresponding to each word, as well as the global sentence representation vector representing the semantics of the whole sentence; S2. Based on the preset degree dictionary and sentiment dictionary, match the word segments after word segmentation, identify sentiment words and degree words in the text, calculate the dynamic sentiment intensity value of each sentiment word, and complete the sentiment intensity modeling at the word level. S3. For the out-of-vocabulary words not covered by the sentiment dictionary in step S2, perform a two-layer verification of word-level semantic similarity retrieval and sentence-level contextual consistency, filter out candidate sentiment words and complete sentiment attribute mapping, and realize the adaptive expansion of the sentiment dictionary. S4. Using sentiment words and candidate sentiment words as query keys, extract the corresponding local knowledge subgraphs from the pre-built sentiment knowledge graph and aggregate them to obtain the knowledge graph embedding vector corresponding to each word element. S5. Using sentiment words as seed nodes, perform seed-driven subgraph pruning on the constructed dependency tree structure, filter and retain nodes and dependency relationships related to sentiment expression, and generate sparse dependency subgraphs as the input structure of the graph neural network. S6. For each node in the obtained dependency subgraph, the word context semantic vector and the knowledge graph embedding vector are fused through a learnable gating mechanism to generate the initial node representation of the graph neural network. S7. Input the dependency subgraph, initial node representation, and word sentiment intensity value into the hierarchical intensity-aware graph neural network, complete message passing and node representation update in a hierarchical and progressive manner, and output a node-level representation that integrates syntactic structure, semantic features and sentiment intensity information. S8. Based on the node-level representation of the output, extract the statistical features of the sentiment intensity distribution within the graph. At the same time, adopt a dual-path pooling method of semantic structure pooling and intensity-guided pooling to aggregate the global semantic structure representation and intensity-aware graph representation respectively. After fusion, generate the final graph-level feature representation. S9. The obtained graph-level feature representation is gated and fused with the sentence global representation vector from step S1. Based on the fused comprehensive features, the sentiment classification result of the text and the sentence-level sentiment intensity prediction value are output simultaneously through a multi-task learning framework.

3. The intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks according to claim 2, characterized in that, Step S2 specifically involves: S21. Match the segmented words with the sentiment dictionary. Mark the successfully matched words as sentiment words and read their corresponding basic sentiment intensity values. Set the sentiment intensity values ​​of unmatched words to 0. S22. For the identified sentiment words, search for degree words in the matching degree dictionary within the preset forward search window. If a corresponding degree word is found, read its modification coefficient and multiply it by the basic sentiment intensity value of the sentiment word to obtain the dynamic sentiment intensity value of the word element. If no degree word is found, directly use the basic sentiment intensity value as the dynamic sentiment intensity value of the word element. S23. Perform min-max normalization on the dynamic sentiment intensity values ​​of all word elements to uniformly map the values ​​to the [0,1] interval; at the same time, calculate the preliminary sentiment intensity representation of the sentence based on the average intensity of all sentiment words in the sentence and the sentiment density factor, which serves as a weak supervision signal for model training.

4. The intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks according to claim 2, characterized in that, Step S3 includes: S31. For out-of-vocabulary words, within a word set with the same sentiment polarity, retrieve the sentiment word with the highest semantic similarity to the target word based on the semantic database as a candidate, and sort them by similarity to obtain a candidate word set; S32. Replace the out-of-vocabulary words in the original sentence with candidate words to generate a replacement sentence. Semantically encode the original sentence and the replacement sentence using a pre-trained language model, and calculate the word-level semantic similarity and sentence-level contextual similarity between the original sentence and the replacement sentence. S33. Set a dual verification threshold. Only when both the word-level semantic similarity and the sentence-level contextual similarity exceed the corresponding threshold will the candidate word be marked as a valid candidate word, and a sentiment attribute mapping relationship between the out-of-vocabulary word and the candidate sentiment word will be established.

5. The intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks according to claim 2, characterized in that, In step S4, the extraction of the local knowledge subgraph takes the target sentiment word as the central node, prioritizes the expansion of one-hop neighbor nodes, and expands to two-hop neighbor nodes as needed; for multiple entity nodes mapped to the same word element, the entity embedding vector is aggregated by averaging or weighted averaging to obtain the knowledge graph embedding vector corresponding to the word element.

6. The intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks according to claim 2, characterized in that, Step S5 specifically involves: S51. Using sentiment words as seed nodes, a multi-source breadth-first search strategy is adopted to expand and retain nodes within a preset number of hops in the dependency tree. S52. Set a dependency whitelist and retain all nodes and connections corresponding to subject relations, object relations, adjective modification relations and adverb modification relations in the whitelist, regardless of the number of hops. S53. When the number of nodes after filtering is lower than the preset minimum threshold, nodes are added according to the connectivity of the nodes in the dependency tree to ensure the minimum connectivity of the subgraph and finally generate a sparse dependency subgraph.

7. The intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks according to claim 2, characterized in that, The expression for fusion via a learnable gating mechanism in step S6 is shown below: ; ; In the formula, For learnable gated vectors; For activation functions; Let i be the context semantic vector of node i; Embed the knowledge graph vector for node i; For element-wise multiplication; The weight matrix is ​​a learnable weight matrix; This is the initial node generated.

8. The intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks according to claim 2, characterized in that, The hierarchical representation learning process of the hierarchical intensity-aware graph neural network in step S7 specifically includes: S71. The first layer is a pure structure learning layer. Node updates and message passing rely only on the topological structure of the dependency subgraph and do not introduce sentiment intensity information. The syntactic skeleton of the sentence is learned through graph attention convolution, and the node representation of the first layer is output. S72. The intermediate layer is an intensity multiplicative modulation layer. First, the sentiment intensity value of the word is nonlinearly transformed through a multilayer perceptron to obtain an enhanced intensity vector. Then, the enhanced intensity vector is used as a modulation factor for the attention weights by a multiplicative mechanism to participate in the message passing of the graph attention convolution, so that the high-intensity sentiment word nodes can obtain higher weights in the message passing and output the intermediate layer node representation. S73. The last layer is the intensity-gated fusion layer, which adaptively adjusts the contribution of sentiment intensity information to attention weights through learnable gating weight vectors, completes the final node representation update, and outputs a node-level representation that integrates syntactic structure, semantic features and sentiment intensity information.

9. The intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks according to claim 2, characterized in that, In step S8, the statistical features of intensity distribution include the average value of emotional intensity, dispersion, coverage of emotional words, distribution skewness, distribution entropy and peak value; in the dual-path pooling, one path uses standard graph pooling to obtain the global semantic structure representation, and the other path is intensity-guided pooling to aggregate node representations based on the semantic importance and intensity importance of nodes, thus obtaining the intensity-aware graph representation.

10. The intensity-perceived emotion classification method based on hierarchical knowledge-enhanced graph neural networks according to claim 2, characterized in that, In step S9, the multi-task learning framework simultaneously performs an emotion polarity multi-classification task and a sentence-level emotion intensity regression task. The output of the emotion polarity multi-classification task is the classification results of six categories: happiness, sadness, fear, anger, surprise, and disgust. The output of the emotion intensity regression task is a continuous intensity value normalized to the [0,1] interval.