Emotion type prediction method and device, storage medium and program product
By introducing the grammatical and long-range semantic features of target attribute words in parallel extracting the grammatical and long-range semantic features of target attribute words in the model, the problem that the deep learning model is difficult to capture long-distance word association features in emotional prediction is solved, and the accuracy and interpretability of emotion type prediction are improved.
Patent Information
- Application Number
- CN202510992926.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-18
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2045-07-18
AI Technical Summary
When performing aspect-level sentiment analysis, it is difficult to capture the emotional feature dependence between attribute words and long-distance word elements in the text, resulting in low emotional prediction accuracy.
The grammatical semantic dual-path dependency module is introduced into the model, and the syntactic structure capture unit and semantic dependency modeling unit are used to extract the grammatical correlation features of target attribute words and adjacent word elements and the long-range semantic features of long-distance word elements through syntactic structure capture unit and semantic dependency modeling unit in parallel, and integrate it through the gated fusion module, and finally use the emotion classifier for prediction.
It improves the accuracy of emotion type prediction, solves the problem that attention mechanism is difficult to capture long-distance word element association characteristics, and improves the accuracy and interpretability of emotion type prediction.
Smart Images

Figure CN120508658A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an emotion type prediction method, device, storage medium, and program product. Background Art
[0002] Aspect-level sentiment analysis is a fine-grained sentiment analysis task that focuses on identifying the emotional tendency towards specific attributes in text. It has important significance and broad development potential in natural language processing.
[0003] Related technologies typically use deep learning models that incorporate an attention mechanism to predict the sentiment of attribute words in text. However, these models, through the attention mechanism, can only capture the sentiment characteristics of nearby word units, making it difficult to capture the dependency between attribute words and sentiment characteristics of distant word units in the text. This, in turn, affects the accuracy of sentiment prediction for attribute words in text. Summary of the Invention
[0004] The present application provides an emotion type prediction method, device, storage medium and program product to at least solve the problem of low accuracy of emotion prediction in related technologies.
[0005] The present application provides a sentiment type prediction method, including: obtaining a text to be analyzed, and obtaining a target attribute word from the text to be analyzed. According to the text to be analyzed, extract the basic semantic features corresponding to the target attribute word. Input the basic semantic features and the text to be analyzed into a grammatical semantic two-way dependency module to extract the grammatical association features and long-range semantic features corresponding to the target attribute word, wherein the grammatical association features represent the association features between the target attribute word and adjacent word elements in the text to be analyzed, and the long-range semantic features represent the association features between the target attribute word and distant word elements in the text to be analyzed. Input the grammatical association features and the long-range semantic features into a gated fusion module to output the sentiment association features. Input the sentiment association features into a pre-trained sentiment classifier to output the sentiment type prediction result of the target attribute word in the text to be analyzed.
[0006] This application also provides an emotion type prediction device, comprising:
[0007] The text acquisition module is used to acquire the text to be analyzed and obtain the target attribute words from the text to be analyzed.
[0008] The basic semantic feature extraction module is used to extract the basic semantic features corresponding to the target attribute words based on the text to be analyzed.
[0009] The association feature extraction module is used to input the basic semantic features and the text to be analyzed into the grammatical semantic two-way dependency module to extract the grammatical association features and long-range semantic features corresponding to the target attribute words, where the grammatical association features represent the association features between the target attribute words and the adjacent words in the text to be analyzed, and the long-range semantic features represent the association features between the target attribute words and the distant words in the text to be analyzed.
[0010] The gated fusion module is used to input grammatical association features and long-range semantic features into the gated fusion module and output sentiment association features.
[0011] The sentiment classification module is used to input sentiment-related features into the pre-trained sentiment classifier and output the sentiment type prediction results of the target attribute word in the text to be analyzed.
[0012] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned emotion type prediction methods when executing the computer program.
[0013] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned emotion type prediction methods are implemented.
[0014] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned emotion type prediction methods when executed by a processor.
[0015] The emotion type prediction method, device, storage medium and program product of the present application, by introducing a grammatical semantic dual-path dependency module into the model, extracts the association features of the target attribute word with adjacent word elements and the association features of the target attribute word with distant word elements in the text to be analyzed in parallel, and integrates the association features with adjacent word elements and the association features with distant word elements in the gated fusion module to obtain the emotion association features of the target attribute word that fuses the adjacent grammatical association features and the distant long-range semantic features, and finally uses the emotion classifier to predict the emotion type of the emotion association features. This method can solve the problem that the attention mechanism is difficult to capture the association features of the target attribute word and the distant word elements in the text to be analyzed, thereby improving the accuracy of emotion type prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0017] Figure 1 This is a diagram of the overall architecture of the model for implementing the emotion type prediction method provided in the embodiment of the present application;
[0018] Figure 2 A flowchart of the emotion type prediction method provided in an embodiment of the present application;
[0019] Figure 3 A schematic diagram of the structure of the emotion type prediction device provided in an embodiment of the present application;
[0020] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0022] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0023] In order to clearly understand the technical solution of this application, the solution of the prior art is first introduced in detail. Aspect-level sentiment analysis extracts sentiment orientation by parsing a large number of user comments. Related technologies introduce an attention mechanism into a deep learning model and use a deep learning model to predict the sentiment type of attribute words in a text. However, the attention mechanism can only capture the sentiment features of adjacent word elements in the text, and it is difficult to capture the dependency relationship between the sentiment features of attribute words and distant word elements in the text, resulting in low accuracy of the deep learning model in predicting the sentiment of attribute words in the text.
[0024] In order to solve the above technical problems, the inventors came up with the idea of introducing a grammatical and semantic dual-path dependency module into the model, extracting in parallel the association features between the target attribute word and adjacent word elements and the association features between the target attribute word and distant word elements in the text to be analyzed, and integrating the association features with adjacent word elements and the association features with distant word elements through a gated fusion module, thereby obtaining the sentiment association features of the target attribute word that fuses the adjacent grammatical association features and the distant long-range semantic features, and predicting the sentiment type of the sentiment association features through a sentiment classifier. The above method can solve the problem that the attention mechanism is difficult to capture the association features between the target attribute word and distant word elements in the text to be analyzed, thereby improving the accuracy of sentiment type prediction.
[0025] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0026] In conjunction with the specific application environment architecture or specific hardware architecture on which the execution of the emotion type prediction method depends, the specific application environment architecture or specific hardware architecture is described here. Figure 1 , Figure 1 This is a diagram of the overall architecture of the model for implementing the emotion type prediction method provided in the embodiment of this application. Figure 1 As shown in the figure, the text to be analyzed is first converted into a structured feature matrix that can be processed by the syntactic structure capture unit and the semantic dependency modeling unit. At the same time, the target attribute word is located in the text to be analyzed, and then the basic semantic features corresponding to the target attribute word are extracted through the pre-trained language model. On this basis, the syntactic structure capture unit is used to mine the grammatical association features between the target attribute word and nearby words in the text to be analyzed. On the other hand, the semantic dependency modeling unit is used to mine the long-range semantic features between the target attribute word and distant words in the text to be analyzed. The grammatical association features and long-range semantic features are dynamically weighted through the fusion mechanism of the gated fusion module to generate sentiment association features that integrate grammatical and semantic information. The sentiment association features are input into the sentiment classifier to output the sentiment type prediction result of the target attribute word in the text to be analyzed.
[0027] Figure 2 A flow chart of the emotion type prediction method provided in the embodiment of the present application is shown as follows: Figure 2 As shown, the embodiment of the present application provides a method for predicting emotion types, and the method is described in detail, including the following steps S201 to S205:
[0028] S201: Obtain a text to be analyzed, and obtain a target attribute word from the text to be analyzed.
[0029] Specifically, after obtaining the text to be analyzed, it is necessary to perform preprocessing operations on the text to be analyzed, wherein the preprocessing operations include Sa1 to Sa4:
[0030] Sa1: Remove redundant symbols, duplicate content, and stop words from the text to be analyzed, and obtain the cleaned text.
[0031] Among them, redundant symbols include meaningless punctuation marks and special characters; duplicate content includes continuously repeated words or sentence fragments; stop words include "de", "le", etc.
[0032] Sa2: Segment the cleaned text into independent words, and perform case unification operations on the independent words to obtain the standardized text.
[0033] Specifically, if the independent words in the cleaned text include words, then unify the case of each word.
[0034] Sa3: Determine whether there are synonyms of the target attribute word in the standardized text.
[0035] Exemplarily, if the target attribute word is "screen", the synonyms may include "display screen", "荧幕", etc.
[0036] Sa4: If there are synonyms of the target attribute word, convert the synonyms to the target attribute word.
[0037] Specifically, if there are synonyms of the target attribute word, unify and convert each synonym to the target attribute word.
[0038] S202: Extract the basic semantic features corresponding to the target attribute word according to the text to be analyzed.
[0039] Specifically, the steps of extracting the basic semantic features corresponding to the target attribute word from the text to be analyzed include Sb1 to Sb5:
[0040] Sb1: Perform word segmentation on the text to be analyzed to generate a sequence of word tokens.
[0041] Specifically, first perform word segmentation on the text to be analyzed, split the continuous text characters into an independent sequence of word tokens. For English text, after splitting by spaces, abbreviations need to be processed. For Chinese text, a word segmentation tool based on a dictionary or machine learning is used.
[0042] Sb2: Perform feature processing on the sequence of word tokens to generate an input feature vector.
[0043] Specifically, the process of feature processing includes: encoding each word token in the sequence of word tokens to obtain the word vector corresponding to each word token; encoding the position of each word token in the text to be analyzed to obtain the position encoding vector corresponding to each word token; marking a special type encoding vector for the target attribute word; generating an input feature vector according to the word vector, position encoding vector, and special type encoding vector corresponding to each word token.
[0044] Specifically, using a pre-trained vocabulary such as Word2Vec or BERT, each word is mapped into a fixed-dimensional word vector, such as 768, to capture the word's semantic information. A position vector is generated for each word, identifying its positional order in the original text. A unique type encoding vector is added to the target attribute word to distinguish it from other words, with the type encoding serving as an additional feature. Finally, the word vector, position vector, and type vector of each word are concatenated according to their dimensions to generate the complete input feature vector.
[0045] Sb3: Input the input feature vector into the pre-trained language model and output the state feature vector of each word in the text to be analyzed.
[0046] The language model used is the BERT (Bidirectional Encoder Representations from Transformers) model.
[0047] Specifically, the pre-trained language model uses a multi-layer Transformer architecture to perform deep semantic modeling on the text being processed. After each word undergoes multiple layers of nonlinear transformations, it outputs a corresponding state feature vector. These state feature vectors not only contain the word's own semantics but also incorporate contextual information.
[0048] Sb4: Based on the position information of the target attribute word in the text to be analyzed, the state feature vector corresponding to the target attribute word is extracted from the state feature vectors of each word unit.
[0049] Specifically, according to the position index of the target attribute word in the original text, the vector of the corresponding position is extracted from the state feature vectors of all word units. This vector is the representation of the target attribute word in the deep semantic space of the model and contains the associated information of the global context of the text.
[0050] Sb5: Aggregate the state feature vectors corresponding to the target attribute words to generate the basic semantic features corresponding to the target attribute words.
[0051] Among them, commonly used aggregation methods include mean pooling, which averages multiple vectors; maximum pooling, which takes the maximum value of each dimension or attention-weighted aggregation, which assigns weights according to importance.
[0052] Specifically, since the target attribute word may be composed of multiple word units, it is necessary to aggregate the state feature vectors of all word units contained in the target attribute word, and define the aggregated vector as the basic semantic feature corresponding to the target attribute word.
[0053] S203: Input the basic semantic features and the text to be analyzed into the grammatical semantic two-way dependency module to extract the grammatical association features and long-range semantic features corresponding to the target attribute word, where the grammatical association features represent the association features between the target attribute word and the adjacent word elements in the text to be analyzed, and the long-range semantic features represent the association features between the target attribute word and the distant word elements in the text to be analyzed.
[0054] Among them, the grammatical and semantic two-way dependency module includes: a syntactic structure capture unit and a semantic dependency modeling unit.
[0055] Specifically, the basic semantic features and the text to be analyzed are input into the syntactic structure capture unit, which outputs the grammatical association features corresponding to the target attribute word. The basic semantic features and the text to be analyzed are input into the semantic dependency modeling unit, which outputs the long-range semantic features corresponding to the target attribute word.
[0056] The syntactic structure capture unit includes a pre-trained multi-layer attention aggregation model. Accordingly, the basic semantic features and the text to be analyzed are input into the syntactic structure capture unit, and the specific process of outputting the grammatical association features corresponding to the target attribute word includes Sc1 to Sc3:
[0057] Sc1: Generate a grammatical structure tree of the text to be analyzed based on the syntactic dependencies of the text to be analyzed. The nodes of the grammatical structure tree represent the tokens in the text to be analyzed, and the edges of the grammatical structure tree represent the syntactic relationships between the tokens.
[0058] Specifically, a syntactic analyzer, such as a dependency parser based on a graph convolutional network, parses the syntactic structure of the text to be analyzed, constructing a grammatical structure tree with tokens as nodes and syntactic relations as edges. Each level of the phrase structure tree consists of several tokens, each of which contains independent semantic blocks. Based on each level of tokens, a related graph is constructed, taking each sentence as a unit.
[0059] Sc2: Bind the feature vectors corresponding to each word in the basic semantic features to each node of the grammatical structure tree to obtain a structure tree model containing the basic semantic features.
[0060] Specifically, the basic semantic features output by the pre-trained language model are mapped to the corresponding nodes of the grammatical structure tree. For example, if the basic semantic vector corresponding to "price" is [v1, v2, ..., v n ], then this vector is assigned to the "price" node in the grammatical structure tree. Through binding, the original independent word element vector is integrated into the syntactic structure framework, forming a hybrid representation that combines semantic information and syntactic structure.
[0061] Sc3: Input the structure tree model containing basic semantic features into the pre-trained multi-layer attention aggregation model to output the grammatical association features corresponding to the target attribute word.
[0062] The multi-layer attention aggregation model is an HGAT block composed of multiple layers of GAT (Graph Attention Network). These GAT layers aggregate information from neighbors using a masked self-attention mechanism and map the representations to the same semantic space through a fully connected feedforward network.
[0063] The semantic dependency modeling unit includes a pre-trained masked multi-head attention model and a temporal dependency modeling sub-unit. Accordingly, the basic semantic features and the text to be analyzed are input into the semantic dependency modeling unit, and the process of outputting the long-range semantic features corresponding to the target attribute word includes Sd1 to Sd4:
[0064] Sd1: Generate a mask matrix based on the position of the target attribute word in the text to be analyzed.
[0065] Specifically, a mask matrix is generated based on the position of the target attribute word, guiding the subsequent attention mechanism to focus on the context related to the target attribute word. For example, for the attribute word "price" at the i-th position in the text to be analyzed, the mask matrix will set the corresponding element in the i-th row to 1, and all other irrelevant positions to 0.
[0066] Sd2: Input the basic semantic features and mask matrix into the pre-trained masked multi-head attention model to output the context-enhanced features of the target attribute words.
[0067] Among them, the masked multi-head attention model adopts the MHA (Multi-Head Attention) mechanism.
[0068] Specifically, the pre-trained masked multi-head attention model receives the basic semantic features and the mask matrix, and uses the multi-head attention mechanism to capture the semantic associations of different subspaces in parallel. The mask matrix limits the scope of attention calculation, so that the model only focuses on the context related to the target attribute word.
[0069] Specifically, MHA follows the standard six layers of the Transformer architecture, calculates attention weights, and extracts key semantics through the interaction of "query Q, key K, and value V".
[0070] 1) Generate Q, K, V matrices:
[0071]
[0072] Where, represents the input feature of the j-th word in the l-1 layer, 、 、 It is a learnable weight matrix used to linearly transform the input features into three matrices: key K, query Q, and value V.
[0073] 2) Calculate attention weight:
[0074]
[0075] Where, Indicates the correlation score between words, and Mask is used to limit the scope of attention. is the dimension of each word unit vector, which is used to scale the association scores between words to avoid the value being too large after the dot product. Softmax is the activation function used to normalize the scaled association scores. Score is the final attention weight matrix.
[0076] 3) Weighted summation generates attention output:
[0077]
[0078] Where, It represents the final output of attention feature representation after calculation by the multi-head attention mechanism, score represents the obtained attention weight matrix, and V represents the value matrix obtained by linear transformation of the input word feature.
[0079] 4) Residual connection and layer normalization:
[0080]
[0081] Where, represents the context-enhanced features obtained after weighted summation to generate attention output, Represents the output attention feature representation, h represents the original input feature, that is, the input feature of the layer before entering the masked multi-head attention model, LayerNorm represents the layer normalization operation, + represents the residual connection, and the preliminary attention feature and the original input feature of the layer are added element by element.
[0082] Sd3: Input the context-enhanced features into the temporal dependency modeling subunit and output a state feature vector containing long-range temporal dependencies.
[0083] The temporal dependency modeling subunit includes: a pre-trained structured state space model. Accordingly, the processing of the temporal dependency modeling subunit includes Se1 to Se3:
[0084] Se1: Perform dimension mapping on the context-enhanced features to generate the initial feature vector that adapts the structured state space model.
[0085] Specifically, through linear transformation, convolution, and activation, the context-enhanced features are converted into a format that can be processed by structured state space sequence models (SSMs). The specific process is as follows: first, the input context-enhanced features are linearly projected, the feature dimension is adjusted, 1D convolution is used to extract local word-unit associations, and nonlinearity is introduced through SiLU activation to finally output the initial feature vector.
[0086] Se2: Input the initial feature vector into the pre-trained structured state space model and output a state feature vector sequence containing long-range temporal dependencies.
[0087] Specifically, a structured state space model is used to mine the semantic dependencies of long-distance word units, generating a sequence of state feature vectors containing global associations. The specific process is as follows: the obtained initial feature vector is input into a pre-trained SSM. Based on the state space evolution mechanism, the semantics of historical word units are encoded into continuous states, which are then passed to subsequent word units to efficiently capture long-range dependencies. At the same time, another branch linearly transforms the context-enhanced feature units and activates them with SiLU to obtain residual supplements. The SSM output is fused with the residual supplements element by element, and then linearly transformed to obtain a sequence of state feature vectors. Each position feature in this state feature vector sequence incorporates the semantic associations of long-distance word units in the text.
[0088] Se3: Extract the state feature vector of the target attribute word at the corresponding position in the text to be analyzed from the state feature vector sequence.
[0089] Specifically, the feature vector corresponding to the target attribute word is extracted from the state feature vector sequence containing long-range temporal dependencies. The specific process is: based on the position of the target attribute word in the text to be analyzed, the feature vector corresponding to the position is directly extracted from the state feature vector sequence containing long-range temporal dependencies. This vector incorporates the long-range semantic dependencies of the entire text to be analyzed.
[0090] Sd4: Concatenate the state feature vector with the context-enhanced feature to generate the long-range semantic features of the target attribute word.
[0091] Specifically, the state feature vector output by the temporal dependency modeling subunit is concatenated with the context-enhanced features output by the masked multi-head attention. The concatenation operation integrates the complementary information of the two features: the context-enhanced features retain the local association between the attribute words and the specific context, while the state feature vector encodes the long-range temporal dependency.
[0092] S204: Input the grammatical association features and the long-range semantic features into the gated fusion module, and output the sentiment association features.
[0093] The gated fusion module includes a pre-trained dual-branch gated network model. Correspondingly, the emotion-related feature extraction methods include Sf1 to Sf3:
[0094] Sf1: Map grammatical association features and long-range semantic features to the feature space of the same dimension to generate aligned grammatical association features and aligned long-range semantic features.
[0095] Specifically, since grammatical association features and long-range semantic features come from different units, the dimensions and feature spaces may be incompatible, so the grammatical association features and long-range semantic features are mapped to the feature space of the same dimension through linear transformation.
[0096] Sf2: Input the aligned grammatical association features and the aligned long-range semantic features into the pre-trained two-branch gating network model to generate grammatical gating weights and semantic gating weights.
[0097] The two-branch gated network model is a Kolmogorov-Arnold Network (KAN), which features a unique architecture that differs from traditional multi-layer perceptrons. KAN uses learnable activation functions at network edges, rather than fixed activation functions at nodes. This involves replacing traditional linear weight matrices with adaptive spline functions. These spline functions are parameterized and optimized during training, resulting in a more flexible and responsive model architecture that can dynamically adapt to complex data patterns.
[0098] Specifically, the input grammatical association features are processed by KAN and activated by Sigmoid to obtain grammatical gating weights, and the long-range semantic features are processed to obtain semantic gating weights.
[0099] Sf3: Based on the grammatical gating weight and semantic gating weight, the aligned grammatical association features and the aligned long-range semantic features are weightedly fused to generate sentiment association features.
[0100] Specifically, the aligned grammatical association features and the aligned long-range semantic features are weightedly fused according to the formula, and their contributions are dynamically weighed according to the text characteristics. For example, if grammatical association is more critical to sentiment judgment in short texts, the grammatical gating weight will dominate the fusion. If long-range semantics have a greater impact in long texts with transitions, the semantic gating weight will play a major role, and finally generate sentiment association features that integrate grammatical and semantic information. The above formula is:
[0101]
[0102] Where, Indicates emotional association features; represents the grammatical gating weight; represents the semantic gating weight; Represents the aligned grammatical association features; Represents the aligned long-range semantic features.
[0103] S205: Input the sentiment-related features into a pre-trained sentiment classifier, and output a prediction result of the sentiment type of the target attribute word in the text to be analyzed.
[0104] The sentiment classifier is a pre-trained linear classification network model. Accordingly, the process of using the linear classification network model to analyze sentiment-related features to obtain the sentiment type prediction result of the target attribute word in the text to be analyzed includes Sg1 to Sg4:
[0105] Sg1: Input the sentiment-related features into the projection layer of the pre-trained linear classification network model to generate an intermediate feature vector.
[0106] Specifically, the sentiment-related features are first averaged: the features of the sequence dimension are compressed to retain the global semantics, and then the feature dimension is adjusted through the projection layer of the linear classifier to generate an intermediate feature vector.
[0107] Sg2: Perform nonlinear activation operations on the intermediate feature vectors to generate activated feature vectors.
[0108] Specifically, nonlinear activation functions such as ReLU and SiLU are used to inject nonlinearity into the intermediate feature vector to generate an activated feature vector.
[0109] Sg3: Input the activated feature vector into the classification layer of the pre-trained linear classification network model to generate the probability distribution of sentiment types.
[0110] Specifically, a linear classification layer is used to calculate the unnormalized sentiment score, and the sentiment score is converted into a probability distribution of sentiment types through softmax normalization.
[0111] Sg4: Determine the category with the highest probability from the sentiment type probability distribution as the sentiment type prediction result of the target attribute word in the text to be analyzed.
[0112] Specifically, the obtained emotion type probability distribution covers the possibility that the target attribute word belongs to various emotion types. By comparing the probability bands corresponding to different emotion types in the probability distribution, the emotion type with the highest probability value is screened out and determined as the emotion type prediction result of the target attribute word in the text to be analyzed.
[0113] For example, if the probability distribution is "positive: 0.7, negative: 0.2, neutral: 0.1", since the probability 0.7 corresponding to "positive" is the highest among the three, the sentiment type of the target attribute word is determined to be positive.
[0114] In summary, by introducing a grammatical and semantic dual-path dependency module into the model, the association features between the target attribute word and nearby words and the association features between the target attribute word and distant words in the text to be analyzed are extracted in parallel. The association features with nearby words and distant words are integrated in the gated fusion module to obtain the sentiment association features of the target attribute word that fuse the nearby grammatical association features and the distant long-range semantic features. Finally, a sentiment classifier is used to predict the sentiment type of the sentiment association features. This method can solve the problem that the attention mechanism has difficulty capturing the association features between the target attribute word and distant words in the text to be analyzed, thereby improving the accuracy of sentiment type prediction.
[0115] In another embodiment provided in the present application, explainability support is provided for the sentiment type prediction results. By tracing the influence of feature dimensions and text words on the prediction results, keywords are screened and a report is generated to help clarify the causes of the sentiment prediction results of the target attribute words. The method includes:
[0116] S301: Calculate the explanatory feature weight of each dimension in the emotion-related feature to the emotion type prediction result, and generate an explanatory feature weight matrix, wherein the explanatory feature weight represents the contribution of each dimension to the emotion type prediction result.
[0117] Specifically, after obtaining sentiment-related features, explanatory feature weights must be calculated to clarify the contribution of each feature dimension to sentiment type prediction. Sentiment-related features are composed of multiple dimensions, each of which contains various semantic information related to the target attribute word in the analyzed text. Using attribution methods such as gradient attribution, SHAP (SHapley Additive exPlanations), or LIME (Local Interpretable Model-agnostic Explanations), the degree of correlation between each feature dimension and the final sentiment type prediction is measured. The resulting value represents the contribution of that dimension to the sentiment type prediction result. The contributions of all dimensions are combined to generate an explanatory feature weight matrix.
[0118] S302: Based on the explanatory feature weight matrix, the influence score of each word in the text to be analyzed on the sentiment type prediction result of the target attribute word is calculated.
[0119] Specifically, each dimension of the sentiment-related feature is generated by encoding and other operations in the text to be analyzed, resulting in a "feature-to-token" mapping relationship. Using the attention weights in the attention mechanism, or the reverse association established through feature attribution, the contribution of each dimension in the resulting explanatory feature weight matrix is transferred back to the corresponding text token, calculating the impact score of each token on the predicted sentiment type of the target attribute word.
[0120] S303: Extracting word units with influence scores higher than a preset threshold as sentiment contribution words.
[0121] Specifically, the obtained influence scores of each word are compared with the preset threshold, and the words with influence scores higher than the preset threshold are selected. These words play a key role in the sentiment type prediction results of the target attribute word, so they are regarded as sentiment contribution words.
[0122] S304: Generate an explanatory report of the target attribute word for the prediction result of the emotion type according to the emotion contribution words and the corresponding influence scores.
[0123] Specifically, after determining the sentiment contribution words and their influence scores, an explanatory report is generated to make the basis for the sentiment type prediction more intuitive and understandable. This report integrates the sentiment contribution words, their corresponding influence scores, and the final sentiment type prediction results in a clear and understandable format. For example, it explains the sentiment prediction category of the target attribute word, lists the main influencing sentiment contribution words, and the degree to which each word contributes to the sentiment judgment.
[0124] In summary, by generating an explainability report through feature attribution and word-unit influence mapping, model judgments are converted into intuitive sentiment contribution words and influence weights. This not only meets the accuracy requirements of sentiment analysis, but also solves the problem of explainability of model decisions, effectively enhancing the credibility and transparency of the model.
[0125] The emotion type prediction method provided in the embodiment of the present application is illustrated with a specific example. Using Pycharm as the development platform, experiments were conducted on the Laptop, Restaurant, Twitter, and MAMS datasets. The statistical data of the datasets are shown in Table 1.
[0126] Table 1: Dataset statistics
[0127]
[0128] The accuracy (ACC) and F1 score are selected to evaluate the model of the sentiment type prediction method provided in the embodiment of this application. Accuracy (ACC) is the simplest and most intuitive evaluation indicator in sentiment classification problems. It represents the percentage of correctly classified samples to the total number of samples. The calculation formula is as follows:
[0129]
[0130] Precision is also called detection probability, which refers to the percentage of samples that are actually positive and accurately predicted among the samples predicted by the model to be positive. The calculation formula is as follows:
[0131]
[0132] The recall rate, also known as the recall rate, indicates the percentage of samples that are actually positive and accurately predicted among all positive emotion samples. The calculation formula is as follows:
[0133]
[0134] The F1 score is the harmonic mean of precision and recall, and is calculated as follows:
[0135]
[0136] Where, T p The number of samples that are actually positive and predicted by the model as positive; T n F represents the number of samples that are actually negative and are also predicted by the model to be negative; p Indicates the number of samples that are actually negative emotions but are misjudged as positive emotions by the model; F n Indicates the number of samples that are actually positive emotions but are misclassified as negative emotions by the model.
[0137] The text is subjected to ablation experiments on the dataset to examine the impact of various components on the performance of the model for implementing the sentiment type prediction method provided by the embodiment of the present application. As shown in Table 2, w / o MHA means removing the masked multi-head attention model from the model. The results show that on the Restaurant, Laptop, and Twitter datasets, the model performance drops by 1.89%, 2.01%, and 2.2%, respectively. w / o Mamba means removing the temporal dependency modeling subunit from the model. The results show that on the Restaurant, Laptop, and Twitter datasets, the performance drops by 3.59%, 2.84%, and 3.74%, respectively. w / o KAN means removing the gated fusion module from the model. The results show that on the Restaurant, Laptop, and Twitter datasets, the model performance drops by 1.84%, 1.12%, and 2.52%, respectively.
[0138] Table 2: Ablation experiment results
[0139]
[0140] Based on the above steps, the present embodiment conducted a comparative experiment to evaluate the effectiveness of the model implementing the emotion type prediction method, comparing the model implementing the emotion type prediction method provided by the present embodiment with the polar line model. The baseline models used included an attention-based model, a grammar-based model, and a pre-trained model.
[0141] Attention-based models include:
[0142] IAN: The model interactively calculates the attention weights of context words and aspect words to obtain richer contextual features.
[0143] RAM: Using multi-layer memory networks with attention mechanism to obtain contextual features.
[0144] MGAN: Obtaining interactive features of context words and aspect words through multi-granularity attention mechanism.
[0145] GCNet: Incorporates global semantic features into the sequence modeling process, enabling it to consider the overall sentiment tendency of the sentence.
[0146] Grammar-based models include:
[0147] ASGCN: proposed to use GCN to learn aspect-specific representations for aspect-oriented sentiment classification.
[0148] CDT: Construct a GCN model through a syntactic dependency tree to extract the grammatical relationship between context words and aspect words.
[0149] BiGCN: Fusion of word co-occurrence information and contextual dependency information using a hierarchical graph structure.
[0150] R-GAT: constructs aspect-specific dependency trees through reconstruction and pruning, and uses a new GAT model to encode dependency relations.
[0151] DGEDT: A dependency graph-enhanced dual transformer network is proposed by jointly considering planar representation and graph-based representation via a mutual biaffine module.
[0152] DualGCN: This model constructs both syntactic and semantic graphs, and uses a dual affine mechanism to complete the information exchange between syntax and semantics, and finally integrates all information for classification.
[0153] SSEGCN: Combines the attention matrix constructed by the attention mechanism with the syntactic mask matrix to achieve the interaction between syntactic structure and semantic information.
[0154] IDGNN: A dual-graph neural network that integrates syntax and semantics is proposed. It uses a relational graph attention network to encode syntactic dependency trees and obtain syntactic information, while combining dependency labels to enhance aspect representation.
[0155] DAGCN: We propose a distance-based aspect-oriented graph convolutional network (DAGCN) that focuses on the local scope of aspects in the pruned dependency tree, thereby reducing the candidate opinion word pool.
[0156] LD2G: Propose a learnable dependency-based two-layer graph (LD2G) model for aspect-based sentiment classification.
[0157] Pre-trained models include:
[0158] BERT-SPC: proposes an attention encoder network that avoids recurrence and uses an attention-based encoder to model the relationship between context and target. Pre-trained BERT is applied to this task.
[0159] IPOS-BERT: Proposes a PLM-based language enhancement framework to perform aspect-based sentiment analysis by combining part-whole relation-speech (POS).
[0160] ACLT: This model extracts features based on BERT and shortens the distance between aspects and corresponding opinion words by learning an aspect-centered tree structure.
[0161] Using accuracy and macro-average F1 as evaluation criteria, the results of experiments with various models on four public datasets are shown in Table 3. Acc represents accuracy, and F1 represents Macro-F1 score.
[0162] Table 3: Experimental results of different models on four datasets
[0163]
[0164] In summary, the model implementing the sentiment type prediction method provided by the embodiment of this application achieved accuracies of 86.68%, 81.80%, 77.67%, and 84.58% on the Restaurant, Laptop, Twitter, and MAMS datasets, respectively, and Macro-F1 achieved results of 80.86%, 78.59%, 76.88%, and 84.39%, respectively. Compared with attention-based models such as IAN, RAM, MGAN, and GCNet, the accuracy indicators on the four datasets differed by 3.11%-8.08%, 3.71%-9.75%, 1.33%-8.31%, and 7.98%, respectively. Compared with grammar-based models such as ASGCN, CDT, BiGCN, R-GAT, IDGNN, DGEDT, DualGCN, SSEGCN, DAGCN and LD2G, the accuracy indicators on the four datasets of Restaurant, Laptop, Twitter, and MAMS differ by 0.7%-5.91%, 1.24%-6.25%, 0.57%-5.52%, and 1.01% respectively. Compared with pre-trained models such as BERT-SPC, IPOS-BERT, and ACLT, the accuracy indicators on the four datasets of Restaurant, Laptop, Twitter, and MAMS differ by 0.97%-2.22%, 1.24%-2.81%, 1.56%-4.12%, and 2.49% respectively. Therefore, the model for implementing the emotion type prediction method provided in the embodiment of the present application combines the powerful representation learning ability and rich hierarchical structure of the pre-trained model, further improving the performance of the model.
[0165] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0166] Figure 3 This is a schematic diagram of the structure of the emotion type prediction device provided in the embodiment of the present application. Figure 3 As shown, an embodiment of the present application further provides an emotion type prediction device, including: a text acquisition module 301, a basic semantic feature extraction module 302, an associated feature extraction module 303, a gated fusion module 304 and an emotion classification module 305.
[0167] The text acquisition module 301 is used to acquire the text to be analyzed and obtain target attribute words from the text to be analyzed.
[0168] The basic semantic feature extraction module 302 is used to extract the basic semantic features corresponding to the target attribute words based on the text to be analyzed.
[0169] The association feature extraction module 303 is used to input the basic semantic features and the text to be analyzed into the grammatical semantic two-way dependency module to extract the grammatical association features and long-range semantic features corresponding to the target attribute word, wherein the grammatical association features represent the association features between the target attribute word and the adjacent word elements in the text to be analyzed, and the long-range semantic features represent the association features between the target attribute word and the distant word elements in the text to be analyzed.
[0170] The gated fusion module 304 is used to input the grammatical association features and the long-range semantic features into the gated fusion module and output the sentiment association features.
[0171] The sentiment classification module 305 is used to input the sentiment-related features into a pre-trained sentiment classifier and output a prediction result of the sentiment type of the target attribute word in the text to be analyzed.
[0172] In one possible implementation, the association feature extraction module 303 is specifically used to input the basic semantic features and the text to be analyzed into a syntactic structure capture unit, and output the grammatical association features corresponding to the target attribute words; input the basic semantic features and the text to be analyzed into a semantic dependency modeling unit, and output the long-range semantic features corresponding to the target attribute words.
[0173] In one possible implementation, the association feature extraction module 303 is specifically used to generate a grammatical structure tree of the text to be analyzed based on the syntactic dependency of the text to be analyzed, where the nodes of the grammatical structure tree represent the words in the text to be analyzed, and the edges of the grammatical structure tree represent the syntactic relationship of the words; the feature vectors corresponding to the words in the basic semantic features are bound to the nodes of the grammatical structure tree to obtain a structure tree model containing the basic semantic features; the structure tree model containing the basic semantic features is input into a pre-trained multi-layer attention aggregation model to output the grammatical association features corresponding to the target attribute words.
[0174] In a possible implementation, the associated feature extraction module 303 is specifically configured to generate a mask matrix according to the position of the target attribute word in the text to be analyzed;
[0175] The basic semantic features and mask matrix are input into the pre-trained masked multi-head attention model to output the context-enhanced features of the target attribute word; the context-enhanced features are input into the temporal dependency modeling subunit to output a state feature vector containing long-range temporal dependencies; the state feature vector is concatenated with the context-enhanced features to generate the long-range semantic features of the target attribute word.
[0176] In one possible implementation, the associated feature extraction module 303 is specifically used to perform dimensional mapping on the context-enhanced features to generate an initial feature vector adapted to the structured state space model; input the initial feature vector into the pre-trained structured state space model, and output a state feature vector sequence containing long-range temporal dependencies; and extract the state feature vector of the target attribute word at the corresponding position in the text to be analyzed from the state feature vector sequence.
[0177] In one possible implementation, the gated fusion module 304 is specifically used to map grammatical association features and long-range semantic features to a feature space of the same dimension to generate aligned grammatical association features and aligned long-range semantic features; input the aligned grammatical association features and aligned long-range semantic features into a pre-trained two-branch gated network model to generate grammatical gating weights and semantic gating weights; and perform weighted fusion of the aligned grammatical association features and aligned long-range semantic features according to the grammatical gating weights and semantic gating weights to generate sentiment association features.
[0178] In a possible implementation, the gated fusion module 304 generates the emotion-related features using the formula:
[0179]
[0180] Where, Indicates emotional association features; represents the grammatical gating weight; represents the semantic gating weight; Represents the aligned grammatical association features; Represents the aligned long-range semantic features.
[0181] In one possible implementation, the sentiment classification module 305 is specifically used to input sentiment-related features into the projection layer of a pre-trained linear classification network model to generate an intermediate feature vector; perform a nonlinear activation operation on the intermediate feature vector to generate an activated feature vector; input the activated feature vector into the classification layer of a pre-trained linear classification network model to generate a sentiment type probability distribution; and determine the category with the highest probability from the sentiment type probability distribution as the sentiment type prediction result of the target attribute word in the text to be analyzed.
[0182] In one possible implementation, the basic semantic feature extraction module 302 is specifically used to perform word segmentation processing on the text to be analyzed to generate a word-unit sequence; perform feature processing on the word-unit sequence to generate an input feature vector; input the input feature vector into a pre-trained language model to output a state feature vector of each word-unit in the text to be analyzed; based on the position information of the target attribute word in the text to be analyzed, extract the state feature vector corresponding to the target attribute word from the state feature vector of each word-unit; aggregate the state feature vector corresponding to the target attribute word to generate a basic semantic feature corresponding to the target attribute word.
[0183] In one possible implementation, the basic semantic feature extraction module 302 is specifically used to encode each word in a word sequence to obtain a word vector corresponding to each word; encode the position of each word in the text to be analyzed to obtain a position encoding vector corresponding to each word; mark a special type encoding vector for the target attribute word; and generate an input feature vector based on the word vector, position encoding vector and special type encoding vector corresponding to each word.
[0184] In a possible embodiment, the device also includes: an explanatory feature output module, which is used to calculate the explanatory feature weights of each dimension in the emotion-related features to the emotion type prediction results, and generate an explanatory feature weight matrix, wherein the explanatory feature weights represent the contribution of each dimension to the emotion type prediction results; based on the explanatory feature weight matrix, calculate the influence score of each word in the text to be analyzed on the emotion type prediction results of the target attribute word; extract word elements with influence scores higher than a preset threshold as emotion contribution words; and generate an explanatory report of the target attribute word for the emotion type prediction results based on the emotion contribution words and the corresponding influence scores.
[0185] In a possible embodiment, the device also includes: a preprocessing module, which is used to remove redundant symbols, repeated content and stop words in the text to be analyzed to obtain a cleaned text; dividing the cleaned text into independent words, and performing a case unification operation on the independent words to obtain a standardized text; judging whether there are synonyms of the target attribute word in the standardized text; if there are synonyms of the target attribute word, converting the synonyms into the target attribute word.
[0186] For the description of the features in the embodiment corresponding to the emotion type prediction device, please refer to the relevant description of the embodiment corresponding to the emotion type prediction method, and no further details will be given here.
[0187] Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiment of the present application. Figure 4As shown, the electronic device provided by this embodiment includes: at least one processor 401 and a memory 402. Optionally, the electronic device further includes a communication component 403. The processor 401, the memory 402 and the communication component 403 are connected via a bus.
[0188] In a specific implementation process, at least one processor 401 executes the computer-executable instructions stored in the memory 402 , so that at least one processor 401 executes the above-mentioned emotion type prediction method embodiment.
[0189] The specific implementation process of the processor 401 can be found in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here in this embodiment.
[0190] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the application may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.
[0191] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage.
[0192] A bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, the buses in the drawings of this application are not limited to just one bus or just one type of bus.
[0193] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned emotion type prediction method embodiments when running.
[0194] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0195] An embodiment of the present application further provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned emotion type prediction method embodiments when executed by a processor.
[0196] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, implementing the steps of any of the above-mentioned emotion type prediction method embodiments.
[0197] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0198] The above is a detailed introduction to the emotion type prediction method, device, storage medium and program product provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A method for predicting emotional types, characterized in that: include: Obtaining a text to be analyzed, and obtaining a target attribute word from the text to be analyzed; Extracting basic semantic features corresponding to the target attribute words according to the text to be analyzed; Input the basic semantic features and the text to be analyzed into a grammatical semantic two-way dependency module, extracting grammatical association features and long-range semantic features corresponding to the target attribute word, wherein the grammatical association features represent association features between the target attribute word and adjacent words in the text to be analyzed, and the long-range semantic features represent association features between the target attribute word and distant words in the text to be analyzed; Inputting the grammatical association features and the long-range semantic features into a gated fusion module, and outputting the sentiment association features; The emotion-related features are input into a pre-trained emotion classifier, and the emotion type prediction result of the target attribute word in the text to be analyzed is output.
2. The emotion type prediction method according to claim 1, characterized in that: The grammatical and semantic two-way dependency module includes: a syntactic structure capture unit and a semantic dependency modeling unit; Accordingly, the step of inputting the basic semantic features and the text to be analyzed into a grammatical semantic two-way dependency module to extract the grammatical association features and long-range semantic features corresponding to the target attribute word includes: Inputting the basic semantic features and the text to be analyzed into the syntactic structure capture unit, and outputting the grammatical association features corresponding to the target attribute word; The basic semantic features and the text to be analyzed are input into the semantic dependency modeling unit, and the long-range semantic features corresponding to the target attribute word are output.
3. The emotion type prediction method according to claim 2, characterized in that: The syntactic structure capture unit includes: a pre-trained multi-layer attention aggregation model; Accordingly, the step of inputting the basic semantic features and the text to be analyzed into the syntactic structure capture unit and outputting the grammatical association features corresponding to the target attribute word includes: Generating a grammatical structure tree of the text to be analyzed according to the syntactic dependency of the text to be analyzed, wherein the nodes of the grammatical structure tree represent the tokens in the text to be analyzed, and the edges of the grammatical structure tree represent the syntactic relationships between the tokens; Binding the feature vectors corresponding to the respective word units in the basic semantic features to the respective nodes of the grammatical structure tree to obtain a structure tree model including the basic semantic features; The structure tree model containing basic semantic features is input into the pre-trained multi-layer attention aggregation model, and the grammatical association features corresponding to the target attribute word are output.
4. The emotion type prediction method according to claim 2, characterized in that: The semantic dependency modeling unit includes: a pre-trained masked multi-head attention model and a temporal dependency modeling sub-unit; Accordingly, the step of inputting the basic semantic features and the text to be analyzed into the semantic dependency modeling unit and outputting the long-range semantic features corresponding to the target attribute word includes: Generate a mask matrix according to the position of the target attribute word in the text to be analyzed; Inputting the basic semantic features and the mask matrix into the pre-trained masked multi-head attention model, and outputting the context-enhanced features of the target attribute word; Inputting the context enhancement feature into the temporal dependency modeling subunit, and outputting a state feature vector containing long-range temporal dependency; The state feature vector is concatenated with the context enhancement feature to generate a long-range semantic feature of the target attribute word.
5. The emotion type prediction method according to claim 4, characterized in that: The temporal dependency modeling subunit includes: a pre-trained structured state space model; Accordingly, the step of inputting the context-enhanced features into the temporal dependency modeling subunit and outputting a state feature vector containing long-range temporal dependency includes: Performing dimension mapping on the context-enhanced features to generate an initial feature vector adapted to the structured state space model; Inputting the initial feature vector into the pre-trained structured state space model, and outputting a state feature vector sequence containing long-range temporal dependencies; The state feature vector of the target attribute word at the corresponding position in the text to be analyzed is extracted from the state feature vector sequence.
6. The emotion type prediction method according to claim 1, characterized in that: The gated fusion module includes: a pre-trained two-branch gated network model; Accordingly, the step of inputting the grammatical association features and the long-range semantic features into a gated fusion module and outputting the sentiment association features includes: Mapping the grammatical association features and the long-range semantic features to a feature space of the same dimension to generate aligned grammatical association features and aligned long-range semantic features; Inputting the aligned grammatical association features and the aligned long-range semantic features into the pre-trained two-branch gating network model to generate grammatical gating weights and semantic gating weights; The aligned grammatical association features and the aligned long-range semantic features are weightedly fused according to the grammatical gating weight and the semantic gating weight to generate the emotion association features.
7. The emotion type prediction method according to claim 6, characterized in that: The formula for generating the emotion-related feature is: Where, representing the emotion-related features; represents the grammar gating weight; represents the semantic gating weight; Representing the aligned grammatical association features; Represents the aligned long-range semantic features.
8. The emotion type prediction method according to claim 1, characterized in that: The sentiment classifier is: a pre-trained linear classification network model; Accordingly, the step of inputting the emotion-related features into a pre-trained emotion classifier and outputting the emotion type prediction result of the target attribute word in the text to be analyzed includes: Inputting the emotion-related features into the projection layer of the pre-trained linear classification network model to generate an intermediate feature vector; Performing a nonlinear activation operation on the intermediate feature vector to generate an activated feature vector; Inputting the activated feature vector into the classification layer of the pre-trained linear classification network model to generate a probability distribution of emotion types; The category with the highest probability is determined from the emotion type probability distribution as the emotion type prediction result of the target attribute word in the text to be analyzed.
9. The emotion type prediction method according to claim 1, characterized in that: The step of extracting basic semantic features corresponding to the target attribute words based on the text to be analyzed includes: Performing word segmentation processing on the text to be analyzed to generate a word unit sequence; Performing feature processing on the word-unit sequence to generate an input feature vector; Inputting the input feature vector into the pre-trained language model, and outputting the state feature vector of each word in the text to be analyzed; Extracting a state feature vector corresponding to the target attribute word from the state feature vectors of each word unit based on the position information of the target attribute word in the text to be analyzed; Aggregate the state feature vectors corresponding to the target attribute words to generate basic semantic features corresponding to the target attribute words.
10. The emotion type prediction method according to claim 9, characterized in that: The performing feature processing on the word sequence to generate an input feature vector includes: Encode each word in the word-unit sequence to obtain a word vector corresponding to each word; Encoding the position of each word in the text to be analyzed to obtain a position encoding vector corresponding to each word; Marking a special type encoding vector for the target attribute word; The input feature vector is generated according to the word vector corresponding to each word unit, the position encoding vector and the special type encoding vector.
11. The emotion type prediction method according to claim 1, characterized in that: After outputting the target attribute word in the sentiment type prediction result of the text to be analyzed, the method further includes: Calculating the explanatory feature weight of each dimension in the emotion-related feature to the emotion type prediction result to generate an explanatory feature weight matrix, wherein the explanatory feature weight represents the contribution of each dimension to the emotion type prediction result; Calculating, based on the explanatory feature weight matrix, an influence score of each word in the text to be analyzed on the sentiment type prediction result of the target attribute word; Extracting word units with an influence score higher than a preset threshold as sentiment contribution words; An explanatory report of the target attribute word with respect to the prediction result of the emotion type is generated according to the emotion contribution words and the corresponding influence scores.
12. The emotion type prediction method according to claim 1, characterized in that: Before extracting the basic semantic features corresponding to the target attribute words according to the text to be analyzed, the method further includes: Removing redundant symbols, repeated content, and stop words from the text to be analyzed to obtain a cleaned text; Segmenting the cleaned text into independent words and performing a case-unification operation on the independent words to obtain a standardized text; Determining whether there are synonyms of the target attribute word in the standardized text; If there is a synonym of the target attribute word, the synonym is converted into the target attribute word.
13. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the emotion type prediction method according to any one of claims 1 to 12 when executing the computer program.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the emotion type prediction method according to any one of claims 1 to 12 are implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the emotion type prediction method according to any one of claims 1 to 12 are implemented.
Citation Information
Patent Citations
Emotion classification method and system, storage medium and equipment
CN110826336A
Semantic sentiment analysis method fusing depth features and time sequence model
CN112560503A
Aspect sentiment analysis method based on two-channel graph convolutional network
CN114218922A
Public opinion text sentiment analysis method based on semantic dependency relationship fusion features
CN115098634A
Aspect-level emotion prediction method and device based on semantic syntax
CN115860006A