Emotion analysis method and system based on natural language processing
By introducing sentiment word weight adjustment, interaction terms, and a gradual change mechanism, the loss function is optimized, which solves the problems of fragmented contextual information and rigid sentiment classification in existing sentiment analysis, and improves the reliability and effectiveness of sentiment analysis.
Patent Information
- Application Number
- CN202511690013.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-02-24
AI Technical Summary
Existing sentiment analysis methods suffer from fragmented contextual information, insufficient expression of sentiment semantics, neglect of sentiment interaction effects, and poor synergy between sentiment goals and tendency predictions, resulting in low reliability of sentiment analysis. Furthermore, rigid sentiment classification ignores the non-discrete nature of sentiment, has a weak correlation between sentiment goals and tendencies, and is prone to logical contradictions, leading to poor sentiment analysis results.
We introduce sentiment word weight adjustment for text contextualization, introduce interaction terms to capture the sentiment reversal effect of negative words, and use dual-branch shared features to process sentiment target extraction and tendency prediction in parallel. We combine sentiment gradient mechanism and target-polarity co-occurrence penalty term to optimize loss function and adopt staged dynamic perturbation parameter adjustment.
It improves the reliability and effectiveness of sentiment analysis, enhances the accuracy of sentiment target boundary and type identification, strengthens the logical consistency between sentiment target and tendency, and solves the problems of fragmented contextual information and rigid sentiment classification.
Smart Images

Figure CN121561103A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, specifically to a sentiment analysis method and system based on natural language processing. Background Technology
[0002] Sentiment analysis is a technique that processes subjective information in data such as text and speech to identify emotional targets and determine their sentiment tendencies. However, general sentiment analysis methods suffer from problems such as fragmented contextual information, insufficient expression of emotional semantics, neglect of emotional interaction effects, and poor synergy between emotional targets and sentiment predictions, leading to low reliability of sentiment analysis. Furthermore, general sentiment analysis methods suffer from rigid sentiment classification, neglect of the non-discrete nature of sentiment, weak correlation between emotional targets and tendencies, and susceptibility to logical contradictions, resulting in poor sentiment analysis performance. Summary of the Invention
[0003] To address the aforementioned issues and overcome the shortcomings of existing technologies, this invention provides a sentiment analysis method and system based on natural language processing. Addressing the problems of fragmented contextual information, insufficient semantic expression of sentiment, neglect of sentiment interaction effects, and poor synergy between sentiment target and tendency prediction in general sentiment analysis methods, leading to low reliability, this solution introduces sentiment word weight adjustment and contextualized text processing to make the contextualized results more focused on sentiment expression. It also introduces an interaction term to capture the effect of negation words reversing sentiment, and through dual-branch shared features and joint optimization, it processes sentiment target extraction and sentiment tendency prediction in parallel, improving the accuracy of sentiment target boundary and sentiment type recognition, thereby enhancing the reliability of sentiment analysis. Furthermore, addressing the problems of rigid sentiment classification, neglect of the non-discrete nature of sentiment, weak correlation between sentiment target and tendency, and easy logical contradictions in general sentiment analysis methods, leading to poor sentiment analysis results, this solution introduces a sentiment gradation mechanism to solve the adaptation problem of discrete classification to non-discrete sentiment. It introduces a target-polarity co-occurrence penalty term into the loss function to strengthen the logical consistency between sentiment target and tendency; and combines staged dynamic perturbation parameter optimization to improve efficiency, thereby improving the sentiment analysis effect.
[0004] The technical solution adopted by this invention is as follows: The sentiment analysis method based on natural language processing provided by this invention includes the following steps:
[0005] Step S1: Data Acquisition;
[0006] Step S2: Contextualizing the text;
[0007] Step S3: Sentiment feature extraction;
[0008] Step S4: Establish a sentiment analysis model;
[0009] Step S5: Sentiment Analysis.
[0010] Furthermore, in step S1, the data acquisition involves obtaining text data and performing text preprocessing, including text cleaning and contextual word segmentation; and adding standardized tags and performing sentiment tag annotation, including sentiment tendency tags and sentiment target tags.
[0011] Further, in step S2, the text contextualization is to assume the text is... Generate a fusion vector for each word and introduce sentiment word weights; obtain a sequence of contextualized units.
[0012] Furthermore, in step S3, the emotion feature extraction involves extracting nine types of features from the preprocessed text and the contextualized unit sequence, integrating them into a feature vector, including the number of emojis. Number of exclamation marks and question marks Number of words in all capital letters Number of negative words TF-IDF value , Polarity score of sentiment words Word2Vec word vectors Co-occurrence distance between emotional target and emotional words Introducing feature interaction terms , to obtain the feature vector .
[0013] Furthermore, in step S4, establishing the sentiment analysis model specifically includes the following steps:
[0014] Step S41: Model architecture design; Based on feature vectors, construct a deep neural network architecture with single input, dual branches, and joint output; The architecture is divided into 5 layers, including an input layer, a feature mapping layer, a dual-branch parallel layer, a loss fusion layer, and an output layer;
[0015] Step S42: Design of the sentiment target prediction branch; adopt a bidirectional LSTM+CRF architecture to transform sentiment target extraction into a sequence labeling task, capture contextual dependencies through bidirectional LSTM; concatenate to obtain word-level features; map the word-level features to the state scores of each label corresponding to each word through a fully connected layer, and output the sentiment target extraction label;
[0016] Step S43: Sentiment Tendency Prediction Branch Design; For each sentiment objective, output a probabilistic sentiment tendency; Specifically including:
[0017] Step S431: Gradual subset partitioning of emotion; the emotion feature space is divided into 3 gradual subsets;
[0018] Step S432: Calculate the fit function; quantify the degree to which the feature vector belongs to the gradient subset;
[0019] Step S433: Gradual rule generation; generate rules based on training data and calculate rule reliability;
[0020] Step S434: Sample classification; Based on the gradual rules in the feature matching rule set of the input sample, and combined with the rule reliability, calculate the comprehensive fit of the sample to each sentiment category, and finally output the optimal category;
[0021] Step S44: Loss function design; simultaneous optimization of the two branches; construction of the total loss function, and introduction of a target-polarity co-occurrence penalty term;
[0022] Step S45: Model evaluation; evaluate the model. If it meets the criteria, the sentiment analysis model is established; otherwise, optimize the parameters.
[0023] Step S46: Parameter optimization; Initialize the search space based on model parameters; Initialize proxy positions; Each proxy position represents a set of model parameter settings; For the weight vector of each proxy, calculate the corresponding sentiment classification error as the fitness value; Update the proxy positions in stages, when... , It is the distance between the current agent position and the optimal agent position; the step size is adjusted using dynamic perturbation values; when Move closer to the optimal weight while fine-tuning with dynamic perturbation values; when the maximum number of iterations is reached or the iteration converges, output the optimal dynamic perturbation weight vector; and proceed to step S45.
[0024] Furthermore, in step S5, the sentiment analysis involves acquiring text data in real time, preprocessing the text, contextualizing the text, and extracting sentiment features, and then inputting it into the sentiment analysis model to obtain sentiment tendency and sentiment target as the sentiment analysis result.
[0025] The sentiment analysis system based on natural language processing provided by this invention includes a data acquisition module, a text contextualization module, a sentiment feature extraction module, a sentiment analysis model building module, and a sentiment analysis module;
[0026] The data acquisition module acquires text data and performs text preprocessing and sentiment tagging.
[0027] The text contextualization module sets the text as a sequence of words, generates a fusion vector for each word, introduces sentiment word weight adjustment, and obtains a sequence of contextualized units.
[0028] The emotion feature extraction module extracts features from preprocessed text and contextualized unit sequences, and introduces feature interaction terms;
[0029] The sentiment analysis model building module constructs a deep neural network architecture with a single input, two branches, and joint output, and designs a total loss function with a co-occurrence penalty term;
[0030] The sentiment analysis module performs sentiment analysis on the real-time acquired text data based on a sentiment analysis model.
[0031] The beneficial effects achieved by the present invention using the above solution are as follows:
[0032] (1) To address the problems of fragmented contextual information, insufficient expression of emotional semantics, neglect of emotional interaction effects, poor synergy between emotional target and tendency prediction in general sentiment analysis methods, which leads to low reliability of sentiment analysis, this scheme introduces emotional word weight adjustment and text contextualization processing to make the contextualized results more focused on emotional expression; it introduces interaction terms to capture the effect of negative words reversing sentiment, and through dual-branch shared features and joint optimization, it processes emotional target extraction and emotional tendency prediction in parallel to improve the recognition accuracy of emotional target boundary and emotional type, thereby improving the reliability of sentiment analysis.
[0033] (2) To address the problems of rigid sentiment classification, neglect of the non-discrete nature of sentiment, weak correlation between sentiment goals and tendencies, and easy logical contradictions in general sentiment analysis methods, which lead to poor sentiment analysis results, this scheme introduces a sentiment gradient mechanism to solve the problem of adapting discrete classification to non-discrete sentiment; introduces a target-polarity co-occurrence penalty term in the loss function to strengthen the logical consistency between sentiment goals and tendencies; and combines phased dynamic perturbation parameter optimization to improve efficiency; thereby improving the sentiment analysis effect. Attached Figure Description
[0034] Figure 1 A flowchart illustrating the sentiment analysis method based on natural language processing provided by this invention;
[0035] Figure 2 This is a schematic diagram of the sentiment analysis system based on natural language processing provided by the present invention.
[0036] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof. Detailed Implementation
[0037] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0038] In the description of this invention, it should be understood that the terms "upper", "lower", "front", "rear", "left", "right", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the system or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0039] Example 1, see Figure 1 The present invention provides a sentiment analysis method based on natural language processing, which includes the following steps:
[0040] Step S1: Data Acquisition; Obtain text data and perform text preprocessing and sentiment tagging;
[0041] Step S2: Text contextualization; Assuming the text is a sequence of words, generate a fusion vector for each word, introduce sentiment word weight adjustment, and obtain a contextualized unit sequence;
[0042] Step S3: Sentiment feature extraction; extract features from the preprocessed text and contextualized unit sequence, and introduce feature interaction terms;
[0043] Step S4: Establish a sentiment analysis model; construct a deep neural network architecture with single input, dual branches, and joint output, and design a total loss function with a co-occurrence penalty term;
[0044] Step S5: Sentiment Analysis; Based on the sentiment analysis model, perform sentiment analysis on the real-time acquired text data.
[0045] Example 2, see Figure 1 This embodiment is based on the above embodiment. In step S1, data acquisition involves obtaining text data, including e-commerce reviews, social media, movie reviews, and customer service conversations; and performing text preprocessing, including text cleaning and contextual word segmentation; the text cleaning involves removing HTML tags, special symbols, and repeated characters, unifying capitalization, and correcting typos based on dictionary mapping; the contextual word segmentation uses BERT's bidirectional Transformer architecture to split the text into contextualized units, avoiding ambiguity of polysemous words in different emotional scenarios; and adding standardized tags for emotional labeling, including sentiment tendency tags and sentiment target tags; sentiment tendency tags include positive emotion, negative emotion, and neutral emotion; the sentiment target tag is the specific object being evaluated in the text.
[0046] Example 3, see Figure 1 This embodiment is based on the above embodiment. In step S2, text contextualization is to set the text as... ; and It is a word, and L is the length; for each word Generate a fused vector of word embeddings, positional identifier vectors, and sentence boundary vectors. By introducing sentiment word weights and dynamically adjusting the embedding vectors, the contextualized expression of sentiment-related semantics is enhanced, as shown below: ; Where WEb(·) is the word embedding, a Word2Vec pre-trained word vector; PEb(·) is the position embedding, marking the word position; and SEb(·) is the sentence boundary vector, distinguishing sentence boundaries. It is the weight of sentiment words. yes The sentiment intensity score is output through the BERT sentiment classification layer; thus, a contextualized unit sequence is obtained. ; and It is a contextualized unit; it preserves the semantic meaning of the context.
[0047] Example 4, see Figure 1 This embodiment is based on the above embodiment. In step S3, the emotion feature extraction extracts nine types of features from the preprocessed text and the contextualized unit sequence, and integrates them into a feature vector F, including the number of emojis. Number of exclamation marks and question marks Number of words in all capital letters Number of negative words TF-IDF value , Polarity score of sentiment words Word2Vec word vectors Co-occurrence distance between emotional target and emotional words The sentiment word polarity scores are obtained based on the SentiWordNet sentiment dictionary, and the Word2Vec word vectors are pre-trained on the sentiment corpus. To capture the sentiment interactions between features, a feature interaction term is introduced. Capture the emotional superposition effect of non-independent features; obtain feature vectors. .
[0048] Example 5, see Figure 1This embodiment is based on the above embodiment. In step S4, establishing the sentiment analysis model specifically includes step S41: model architecture design; based on feature vectors, a deep neural network architecture with single input, dual branches, and joint output is constructed to achieve parallel processing and collaborative optimization of sentiment target extraction and sentiment tendency prediction; the architecture is divided into 5 layers, including an input layer that receives preprocessed feature vectors; a feature mapping layer that performs dimensionality transformation and semantic enhancement on the feature vectors; a dual-branch parallel layer where branch 1 performs sentiment target extraction and branch 2 performs sentiment tendency prediction; a loss fusion layer that calculates the dual-branch loss and co-occurrence penalty term to generate the total loss; and an output layer that integrates the dual-branch results and outputs the final analysis conclusion.
[0049] By performing the above operations, this scheme addresses the problems of fragmented contextual information, insufficient semantic expression of sentiment, neglect of sentiment interaction effects, and poor synergy between sentiment target and tendency prediction, which lead to low reliability of sentiment analysis methods. It introduces sentiment word weight adjustment and text contextualization to make the contextualized results more focused on sentiment expression. Furthermore, it introduces interaction terms to capture the effect of negation words reversing sentiment. Through dual-branch feature sharing and joint optimization, it processes sentiment target extraction and sentiment tendency prediction in parallel, improving the accuracy of sentiment target boundary and sentiment type recognition, thereby enhancing the reliability of sentiment analysis.
[0050] Example 6, see Figure 1 This embodiment is based on the above embodiment. In step S4, establishing the sentiment analysis model further includes the following steps:
[0051] Step S42: Sentiment target prediction branch design; identify continuous sentiment target phrases from feature vectors and output the target set; adopt a bidirectional LSTM+CRF architecture to transform sentiment target extraction into a sequence labeling task, and capture contextual dependencies through bidirectional LSTM, represented as: ; ;in, and These are the forward hidden state and the backward hidden state of the i-th word position, respectively; and These are the forward hidden state and the backward hidden state of the (i-1)th word position, respectively; It is the feature vector of the i-th word; and These are forward LSTM and backward LSTM, respectively; concatenating them yields word-level features. , is represented as: ; through a fully connected layer Mapping each word to the state score of each label; and ensuring label consistency through a transition probability matrix, outputting the sentiment target extracted labels. , is represented as: ; where tag is the emotional target extraction label; It is the tag score; It is the label transfer score; and These are the sentiment target extraction labels for the (i-1)th and ith words, respectively; words consecutively labeled as the sentiment target start word + the sentiment target internal word are combined to form the sentiment target extraction result;
[0052] Step S43: Sentiment Tendency Prediction Branch Design; For each sentiment objective, output a probabilistic sentiment tendency; Specifically including:
[0053] Step S431: Emotional Gradual Subset Partitioning; The emotional feature space is divided into 3 gradual subsets to highlight the transition between emotional categories and cover all emotional categories, represented as: C is a set of subsets of gradual emotional changes. , and These are three specific gradient subsets;
[0054] Step S432: Calculate the fit function; quantify the degree to which the feature vector belongs to the gradient subset; construct the fit function, let the normalized sentiment score be s, 0 is the strongest negative, and 1 is the strongest positive; strong negative fit. Centered at 0, width 0.4; Mid-fit Strong positive fit ;
[0055] Step S433: Gradual rule generation; generate rules based on training data and calculate rule reliability; assume the samples covered by the rules are in category The total degree of fit is The largest matching category is By introducing a strength-weighted reliability rule, strong sentiment rules are made more trustworthy, as shown below: ; It is the average fit. yes The central scalar value; It is a smoothing term; It's about reliability;
[0056] Step S434: Sample classification; Based on the gradual rules in the feature matching rule set of the input samples, and combined with the rule reliability, calculate the comprehensive fit of the samples to each sentiment category, and finally output the optimal category. ; indicates as: ; It is a sample of sentiment category The overall fit; R is the set of gradient rules matched by the input sample, and r is the rule index; The reasoning result of rule r points to the sentiment category. ; It is the basic fit; the gradual change rule is the association pattern between language features and sentiment categories mined from training data, which is used to quantify the gradual change of natural language expression;
[0057] Step S44: Loss function design; simultaneously optimize the two branches to strengthen the correlation between emotional goals and emotional tendencies; construct the total loss function and introduce a goal-polarity co-occurrence penalty term. The irrational co-occurrence relationship between punitive affective goals and affective tendencies is represented as: ; ; ; ; obtain the set of emotional goals ;in, It is the total loss function. It is the loss in retrieving emotional goals. It is a loss of emotional polarity classification. This is the weight of the co-occurrence penalty term; i is the word index; Is it the true sentiment target label of the word? If it is, then... If not ; It is the predicted sentiment target label for the word; It is the regularization coefficient; These are model parameters. It is a set of model parameters; It is a label for predicting sentiment tendencies; M represents the actual sentiment bias label; M is the total number of sentiment targets extracted from the text. and These are actual and predicted emotional goals. In emotional tendencies The conditional probability distribution; It is the KL divergence;
[0058] Step S45: Model Evaluation; The model is evaluated using precision, recall, and F1 score. If the criteria are met, the sentiment analysis model is complete; otherwise, parameter optimization is performed. The parameters are updated using the gradient descent algorithm. Precision is the proportion of samples predicted as positive by the model that are actually positive. Recall is the proportion of samples that are actually positive that were correctly predicted as positive by the model. The F1 score is the harmonic mean of precision and recall.
[0059] Step S46: Parameter optimization; Initialize the search space based on model parameters; Initialize agent positions; Each agent position represents a set of model parameter settings; For each agent's weight vector, calculate the corresponding sentiment classification error as the fitness value; Update agent positions in stages, when the agent is far from the optimal position... , It is the distance between the current agent position and the optimal agent position; the step size is adjusted using dynamic perturbation values to expand the search range, expressed as: ; and These are the v-th proxy positions in the (k+1)-th and k-th iterations, respectively; m is the step size. and These are the random agent position and the individual's historical best agent position; when the agent is close to the best position... The weights are moved closer to the optimal weights, while being fine-tuned using dynamic perturbation values, as follows: ; ;in, It is the optimal proxy position; It is the angle coefficient; and It is a dynamic disturbance variable; It is a control parameter; it is truncated to 0 when it exceeds the range; when the maximum number of iterations is reached or the iteration converges, the optimal dynamic perturbation weight vector is output; and then the process proceeds to step S45.
[0060] By performing the above operations, this solution addresses the problems of rigid sentiment classification, neglect of the non-discrete nature of sentiment, weak correlation between sentiment goals and tendencies, and easy logical contradictions that lead to poor sentiment analysis results in general sentiment analysis methods. It introduces a sentiment gradation mechanism to solve the adaptation problem of discrete classification to non-discrete sentiment; it introduces a goal-polarity co-occurrence penalty term into the loss function to strengthen the logical consistency between sentiment goals and tendencies; and it combines staged dynamic perturbation parameter optimization to improve efficiency, thereby improving the sentiment analysis effect.
[0061] Example 7, see Figure 1 This embodiment is based on the above embodiment. In step S5, the sentiment analysis involves acquiring text data in real time, preprocessing the text, contextualizing the text, and extracting sentiment features, and then inputting it into the sentiment analysis model to obtain the sentiment tendency and sentiment target as the sentiment analysis result.
[0062] Example 8, see Figure 2 This embodiment is based on the above embodiments. The sentiment analysis system based on natural language processing provided by the present invention includes a data acquisition module, a text contextualization module, a sentiment feature extraction module, a sentiment analysis model building module, and a sentiment analysis module.
[0063] The data acquisition module acquires text data and performs text preprocessing and sentiment tagging.
[0064] The text contextualization module sets the text as a sequence of words, generates a fusion vector for each word, introduces sentiment word weight adjustment, and obtains a sequence of contextualized units.
[0065] The emotion feature extraction module extracts features from preprocessed text and contextualized unit sequences, and introduces feature interaction terms;
[0066] The sentiment analysis model building module constructs a deep neural network architecture with a single input, two branches, and joint output, and designs a total loss function with a co-occurrence penalty term;
[0067] The sentiment analysis module performs sentiment analysis on the real-time acquired text data based on a sentiment analysis model.
[0068] It should be noted that, in this document, the terms “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0069] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention.
[0070] The present invention and its embodiments have been described above. This description is not restrictive, and the accompanying drawings are only one embodiment of the present invention; the actual structure is not limited thereto. In conclusion, if those skilled in the art are inspired by this description and design similar structures and embodiments without departing from the spirit of the invention, such designs should fall within the protection scope of the present invention.
Claims
1. A sentiment analysis method based on natural language processing, characterized by: The method includes the following steps: Step S1: Data Acquisition; Obtain text data and perform text preprocessing and sentiment tagging; Step S2: Text contextualization; Assuming the text is a sequence of words, generate a fusion vector for each word, introduce sentiment word weight adjustment, and obtain a contextualized unit sequence; Step S3: Sentiment feature extraction; extract features from the preprocessed text and contextualized unit sequence, and introduce feature interaction terms; Step S4: Establish a sentiment analysis model; construct a deep neural network architecture with single input, dual branches, and joint output, and design a total loss function with a co-occurrence penalty term; Step S5: Sentiment Analysis; Based on the sentiment analysis model, perform sentiment analysis on the real-time acquired text data.
2. The sentiment analysis method based on natural language processing according to claim 1, characterized in that: In step S2, the text contextualization is to assume the text is... Generate a fusion vector for each word and introduce sentiment word weights; A contextualized unit sequence is obtained.
3. The sentiment analysis method based on natural language processing according to claim 2, characterized in that: In step S3, the emotion feature extraction involves extracting nine types of features from the contextualized unit sequence and integrating them into a feature vector, including the number of emojis. Number of exclamation marks and question marks Number of words in all capital letters Number of negative words TF-IDF value , Polarity score of sentiment words Word2Vec word vectors Co-occurrence distance between emotional target and emotional words Introducing feature interaction terms , to obtain the feature vector .
4. The sentiment analysis method based on natural language processing according to claim 3, characterized in that: The establishment of the sentiment analysis model specifically includes the following steps: Step S41: Model architecture design; Based on feature vectors, construct a deep neural network architecture with single input, dual branches, and joint output; The architecture is divided into 5 layers, including an input layer, a feature mapping layer, a dual-branch parallel layer, a loss fusion layer, and an output layer; Step S42: Design of the sentiment target prediction branch; adopt a bidirectional LSTM+CRF architecture to transform sentiment target extraction into a sequence labeling task, capture contextual dependencies through bidirectional LSTM; concatenate to obtain word-level features; map the word-level features to the state scores of each label corresponding to each word through a fully connected layer, and output the sentiment target extraction label; Step S43: Sentiment Tendency Prediction Branch Design; For each sentiment objective, output a probabilistic sentiment tendency; Specifically including: Step S431: Gradual subset partitioning of emotion; the emotion feature space is divided into 3 gradual subsets; Step S432: Calculate the fit function; quantify the degree to which the feature vector belongs to the gradient subset; Step S433: Gradual rule generation; generate rules based on training data and calculate rule reliability; Step S434: Sample classification; Based on the gradual rules in the feature matching rule set of the input sample, and combined with the rule reliability, calculate the comprehensive fit of the sample to each sentiment category, and finally output the optimal category; Step S44: Loss function design; simultaneous optimization of the two branches; construction of the total loss function, and introduction of a target-polarity co-occurrence penalty term; Step S45: Model evaluation; evaluate the model. If it meets the criteria, the sentiment analysis model is established; otherwise, optimize the parameters. Step S46: Parameter optimization.
5. The sentiment analysis method based on natural language processing according to claim 4, characterized in that: In step S4, the parameter optimization is based on initializing the search space using model parameters; initializing agent positions; each agent position represents a set of model parameter settings; calculating the corresponding sentiment classification error as the fitness value for the weight vector of each agent; and updating the agent positions in stages, when... , It is the distance between the current agent position and the optimal agent position; the step size is adjusted using dynamic perturbation values; when Move closer to the optimal weight while fine-tuning with dynamic perturbation values; when the maximum number of iterations is reached or the iteration converges, output the optimal dynamic perturbation weight vector; and proceed to step S45.
6. The sentiment analysis method based on natural language processing according to claim 5, characterized in that: In step S1, the data acquisition involves obtaining text data and performing text preprocessing, including text cleaning and contextual word segmentation; and adding standardized tags and performing sentiment tag annotation, including sentiment tendency tags and sentiment target tags.
7. The sentiment analysis method based on natural language processing according to claim 6, characterized in that: In step S5, the sentiment analysis involves acquiring text data in real time, preprocessing the text, contextualizing the text, and extracting sentiment features, and then inputting it into the sentiment analysis model to obtain sentiment tendency and sentiment target, which serve as the sentiment analysis results.
8. A sentiment analysis system based on natural language processing, used to implement the sentiment analysis method based on natural language processing as described in any one of claims 1-7, characterized in that: It includes a data acquisition module, a text contextualization module, a sentiment feature extraction module, a sentiment analysis model building module, and a sentiment analysis module; The data acquisition module acquires text data and performs text preprocessing and sentiment tagging. The text contextualization module sets the text as a sequence of words, generates a fusion vector for each word, introduces sentiment word weight adjustment, and obtains a sequence of contextualized units. The emotion feature extraction module extracts features from preprocessed text and contextualized unit sequences, and introduces feature interaction terms; The sentiment analysis model building module constructs a deep neural network architecture with a single input, two branches, and joint output, and designs a total loss function with a co-occurrence penalty term; The sentiment analysis module performs sentiment analysis on the real-time acquired text data based on a sentiment analysis model.