Multi-granularity text sentiment analysis method and model based on sequential three-way decision
By introducing the idea of sequential three-branch decision-making and integrated learning in text sentiment analysis, the multi-grained layer granulation and classification of comment text data is solved, and the insufficient static two-branch decision-making and high cost of multi-grained three-branch decision-making in the existing technology is solved. Problem, achieving more efficient text sentiment analysis.
Patent Information
- Application Number
- CN202411483834.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-02-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When faced with the increasing amount of data, the existing text sentiment analysis methods have insufficient static two-branch decisions, making it difficult to extract feature information to the greatest extent, and the cost of making three-branch decisions is high.
A multi-grained text sentiment analysis method based on three sequential decisions was adopted. By pre-processing, granularity division, and sequential decision-making sentiment classification and reclassification of the three sequential decisions, the emotional categories of the boundary domain data were finally determined through voting.
It improves the classification effect of sentiment analysis, reduces the classification cost, and can more accurately extract feature information in text data.
Smart Images

Figure CN119415691A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of text sentiment analysis, and in particular relates to a multi-granularity text sentiment analysis method and model based on sequential three-branch decision making. Background Art
[0002] With the rapid development of science and technology, the Internet has entered thousands of households, and all aspects of daily life are inseparable from the Internet. The Internet is full of various comments, and common comments mainly include e-commerce comments, news comments and social comments, and the number of comment texts is showing an explosive growth trend. The rich comment texts in social networks contain users' opinions, attitudes and emotions. Mining user emotional information from social comments, namely text sentiment analysis, is one of the hot topics in natural language processing and is of great significance to public opinion monitoring, personalized recommendations and advertising.
[0003] Sentiment analysis is also called opinion mining. Traditional research methods mainly include dictionary-based and corpus-based. Dictionary-based sentiment analysis methods use sentiment dictionaries to calculate the sentiment value of the text to be analyzed. For example, Taboada M et al. proposed a dictionary-based method to extract sentiment from text. The Semantic Orientation CALculator (SO-CAL) uses a word dictionary with semantic direction annotations including polarity and intensity, combined with reinforcement and negation, to apply to polarity classification tasks. The effectiveness of this method has been proved through experiments. Corpus-based sentiment analysis can be divided into traditional machine learning-based and deep learning-based. Traditional machine learning methods first extract features from texts, and then use classifier models such as support vector machines to classify texts. For example, Li Chunlin et al. crawled the stock review data of the liquor sector and used 6 machine learning methods to perform sentiment analysis on them. Experiments have shown that SVM and KNN have higher accuracy in sentiment classification. Deep learning methods use neural network models to classify texts. For example, Xing Changzheng et al. used GRU, an important variant of LSTM, to build a sentiment analysis model Multi-GRU. Multi-layer stacked GRUs were used to reduce information loss. Experiments have shown that this model has better performance in terms of loss and other aspects. Most existing sentiment analysis research focuses on improving the classification accuracy of models, with less consideration of the misclassification costs caused by incorrect classification.
[0004] Faced with the ever-increasing amount of data, the shortcomings of the static two-branch decision in traditional text sentiment analysis are becoming more and more obvious, and the three-branch decision idea has emerged. The three-branch decision idea is a theory proposed by Yao that is more in line with human cognitive patterns and developed on the basis of the two-branch decision. It expands the two-branch decision idea of only accepting and rejecting decisions into the three-branch idea of accepting, delaying and rejecting decisions, that is, "three-way rule". When the existing information cannot make a decision, the decision process is postponed and the decision is made when the information is further supplemented. Although the existing research on the introduction of the three-branch decision idea for sentiment analysis has achieved good results, sentiment analysis for single granularity cannot extract feature information to the greatest extent, and the sentiment cost of multi-granular three-branch decision is high. Summary of the invention
[0005] The purpose of the embodiments of the present invention is to provide a multi-granularity text sentiment analysis method and model based on sequential three-branch decision-making, aiming to solve the technical problems existing in the prior art mentioned in the background technology.
[0006] The embodiment of the present invention is implemented as follows: a multi-granularity text sentiment analysis method based on sequential three-branch decision-making, the method comprising the following steps:
[0007] Preprocessing the comment text data set, wherein the preprocessing method at least includes segmenting the comment text data and removing stop words;
[0008] The preprocessed comment text dataset is divided into granularities using a preset language model to obtain sentiment representation data at multiple granularities.
[0009] For each granularity of sentiment representation data, sequential three-branch decision sentiment classification is performed until the boundary domain is empty or classification is no longer possible under the current conditions;
[0010] For the boundary domain data that cannot be classified any more, different classifiers are used to classify them, and finally the final sentiment category of the data in the boundary domain is obtained by voting.
[0011] Another object of an embodiment of the present invention is to provide a multi-granularity text sentiment analysis model based on sequential three-branch decision making, the model comprising:
[0012] A preprocessing module, used for preprocessing the comment text data set, wherein the preprocessing method at least includes segmenting the comment text data and removing stop words;
[0013] The granularity division module is used to divide the preprocessed comment text dataset into granularities using a preset language model to obtain sentiment representation data of multiple granularities;
[0014] The sentiment classification module is used to perform sequential three-branch decision sentiment classification for each granularity of sentiment representation data until the boundary domain is empty or classification is no longer possible under the current conditions;
[0015] The reclassification module is used to classify the boundary domain data that cannot be reclassified by different classifiers, and finally obtain the final sentiment category of the data in the boundary domain by voting.
[0016] The beneficial effects of the embodiments of the present invention are: by using a word segmentation tool to preprocess the data; secondly, using the N-gram language model to perform multi-granularity layer granulation; then using a skip-order sequential three-branch decision model to perform decision classification at each layer; finally, incorporating the idea of ensemble learning so that the classifier makes a single decision and then votes to determine the final decision result. The sequential three-branch decision that incorporates the idea of ensemble learning has a better classification effect for sentiment analysis tasks and reduces the classification cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 A flowchart of a multi-granularity text sentiment analysis method based on sequential three-branch decision-making provided by an embodiment of the present invention;
[0018] Figure 2 A flowchart of preprocessing a review text dataset provided by an embodiment of the present invention;
[0019] Figure 3 A flowchart of obtaining the final emotion category of data in the boundary domain provided by an embodiment of the present invention;
[0020] Figure 4 A schematic diagram of an integrated learning decision provided by an embodiment of the present invention;
[0021] Figure 5 A flowchart of obtaining emotion representation data of multiple granularities provided by an embodiment of the present invention;
[0022] Figure 6 A flowchart of sequential three-branch decision sentiment classification provided by an embodiment of the present invention;
[0023] Figure 7 A structural block diagram of a multi-granularity text sentiment analysis model based on sequential three-branch decision-making provided by an embodiment of the present invention;
[0024] Figure 8 A structural block diagram of a reclassification module provided in an embodiment of the present invention;
[0025] Fig. 9 A structural block diagram of a granularity division module provided in an embodiment of the present invention;
[0026] Fig.10A structural block diagram of a preprocessing module provided in an embodiment of the present invention;
[0027] Fig.11 A comparative bar graph of experimental results provided by an embodiment of the present invention;
[0028] Fig.12 FIG. 4 is a block diagram of the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0030] It is understood that the terms "first", "second", etc. used in this application may be used herein to describe various elements, but unless otherwise specified, these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, a first xx script may be referred to as a second xx script, and similarly, a second xx script may be referred to as a first xx script.
[0031] like Figure 1 As shown, in one embodiment, a multi-granularity text sentiment analysis method based on sequential three-branch decision is proposed, which may specifically include the following steps:
[0032] Step S100 , preprocessing the comment text data set, wherein the preprocessing method at least includes segmenting the comment text data and removing stop words.
[0033] In the embodiment of the present invention, if sentiment analysis is to be performed, the comment text dataset must first be preprocessed to facilitate the next step of processing. The purpose of the preprocessing operation is to remove noise to prevent it from interfering with the classification results. The data preprocessing work in this paper mainly includes word segmentation and stop word removal.
[0034] Step S200, the preprocessed comment text data set is divided into granularities using a preset language model to obtain sentiment representation data of multiple granularities.
[0035] In traditional text sentiment analysis methods, sentiment features are usually extracted based on a coarse or fine granularity, and then sentiment classification is performed using sentiment dictionaries, rules, or machine learning methods. However, this single-granularity extraction method often cannot fully extract feature information from text data, resulting in problems such as low data accuracy and high classification cost.
[0036] In the embodiment of the present invention, in order to reduce the classification cost and improve the accuracy of sentiment analysis, the text data is represented as multi-granularity information as the input of the sequential three-branch decision, and the receiving domain, boundary domain and rejection domain are divided by the sequential three-branch decision, and the integrated classifier is used to classify it after the decision, so as to obtain the final classification result. In the embodiment of the present invention, the N-gram language model is used as the method of text granularity representation.
[0037] Step S300, sequential three-branch decision sentiment classification is performed for the sentiment representation data of each granularity until the boundary domain is empty or classification is no longer possible under the current conditions.
[0038] In traditional text sentiment analysis methods, sentiment features are usually extracted based on a coarse or fine granularity, and then sentiment classification is performed using sentiment dictionaries, rules or machine learning methods. However, this extraction method using a single granularity often cannot completely extract the feature information in the text data, resulting in problems such as low data accuracy and high classification cost. In order to reduce the classification cost and improve the accuracy of sentiment analysis, the embodiment of the present invention uses a sequential three-branch decision sentiment classification method to represent text data as multi-granularity information as the input of the sequential three-branch decision, and divides the receiving domain, boundary domain and rejection domain of the text data through the sequential three-branch decision.
[0039] Step S400, the boundary domain data that cannot be further classified is classified by different classifiers, and finally the final sentiment category of the data in the boundary domain is obtained by voting.
[0040] In an embodiment of the present invention, in order to solve the problem that the current conditions are insufficient to judge the emotion category of the evaluation object in the final boundary domain, resulting in excessively high delay costs, the embodiment of the present invention uses the idea of ensemble learning to treat multiple classifiers as independent decision makers, each of which performs decision classification, and votes on the decision results. The one with the highest number of votes is the final emotion category.
[0041] In one embodiment, Figure 2 As shown, step S100 may specifically include the following steps:
[0042] Step S101, segmenting the comment text using a segmentation tool and a preset segmentation dictionary.
[0043] Step S102, removing stop words according to a preset word segmentation dictionary.
[0044] In the embodiment of the present invention, the word segmentation tool may be the Jieba word segmentation tool, the word segmentation dictionary may be an existing word segmentation dictionary, and a custom word segmentation may be added according to actual needs of the user, and stop word removal may be performed according to the word segmentation dictionary.
[0045] In one embodiment, Figure 3 and 4 As shown, step S400 may specifically include the following steps:
[0046] Step S401, obtaining boundary domain data that cannot be further classified.
[0047] Step S402: input the boundary domain data that cannot be further classified into a plurality of independent and different binary classifiers respectively to obtain classification results of the corresponding classifiers.
[0048] In one case of an embodiment of the present invention, the binary classifier may include a random forest, a decision tree, and a support vector machine, etc. In the embodiment of the present invention, the number of binary classifiers is 3, namely the above-mentioned random forest, decision tree, and support vector machine classifiers. In practical applications, other forms of classical linear classifiers may also be selected.
[0049] Step S403: The classification results of different classifiers are filtered out into the final emotion category through the maximum voting method.
[0050] In the embodiment of the present invention, the maximum voting method is usually used for classification problems. This method uses multiple models to predict each data point, and the prediction of each classifier is regarded as a "vote". The prediction obtained by the majority of classifiers is used as the final prediction result. The embodiment of the present invention is for boundary domain data that cannot be further classified. In this way, a more accurate final prediction result can be obtained.
[0051] In one embodiment, Figure 5 As shown, step S200 may specifically include the following steps:
[0052] Step S201, performing a sliding window operation of size M on the comment text dataset according to bytes to obtain a byte segment sequence of length M.
[0053] In the embodiment of the present invention, the expression of sentiment information can be in multiple granularities, the simplest of which are word granularity, phrase granularity, sentence granularity and comment granularity. The sentiment expression of text comments is specifically embodied by characters, words and phrases, and the sentiment information expressed at each granularity is not the same. The embodiment of the present invention adopts the N-gram language model as a method for text granularity representation. N-Gram is an algorithm based on a statistical language model, which constitutes a sequential expression of multi-granular sentiment information, which performs a sliding window operation of size M on the content of the text according to bytes, forming a sequence of byte fragments of length M.
[0054] Step S202, counting the occurrence frequencies of all byte segment sequences, and filtering them according to a preset threshold, to form a list of key byte segment sequences.
[0055] In the embodiment of the present invention, each byte segment sequence may be called a gram, and the occurrence frequencies of all the grams are counted and filtered according to a preset threshold to form a key gram list, that is, a vector feature space of the text, and each gram in the list is a feature vector dimension.
[0056] Step S203, predicting the probability of the whole sentence according to the formula, using unigram, bigram and unigram plus bigram as multi-granular text representation, using unigram as the candidate feature of the first granularity, bigram as the candidate feature of the second granularity, and unigram plus bigram as the candidate feature of the third granularity;
[0057] The formula is:
[0058] P(w i |w1,w2,...,w i-1 )=P(w i |w i-N+1 ,w i-N+2 ,...,w i-1 ), where P(w i |w1,w2,...,w i-1 )
[0059] is the probability of the whole sentence appearing, w i is the current word, and N is the number of words.
[0060] In the embodiment of the present invention, N-Gram predicts the Nth word based on the previous N-1 words, and the current word w i The probability of a word depends only on the first i-1 words, and the probability of the whole sentence is the product of the probability of each word appearing. These probabilities can be obtained by directly counting the number of times N words appear at the same time from the text. Commonly used are bi-grams of bigrams and tri-grams of trigrams. Common models include uni-gram, bigrams, and trigrams. Different from the English word segmentation method, in applications such as Chinese text classification and sentiment classification, the words after the text is segmented are usually used as text features. In an embodiment of the present invention, the text content is subjected to a sliding window operation of size M according to the words to form words or phrases of length M. Uni-gram, bigrams, and uni-gram plus bigrams are used as multi-granular text representations, uni-grams are used as candidate features of the first granularity, bigrams are used as candidate features of the second granularity, and uni-gram plus bigrams are used as candidate features of the third granularity.
[0061] In one embodiment, step S300 may specifically include the following steps:
[0062] First, define the multi-granularity structure;
[0063] G={g1,g2,…,gi,…,gh},(1≤i≤h), where gi represents the i-th particle layer and h is the finest particle layer.
[0064] Get n sub-datasets from the data set U, The dataset U is the preprocessed review text dataset X.
[0065] In the embodiments of the present invention, due to the limited information that can be obtained at a single granularity, it is often impossible to directly obtain accurate classification results. Three-branch decision can divide texts whose sentiment categories cannot be fully determined into boundary domains, and sequential three-branch decision as a dynamic three-branch decision method performs step-by-step calculations on decisions on boundary domain data, adding important information related to the decision at each step, that is, converting a single granularity into a finer granularity to continue making decisions until the final decision is made. As the granularity becomes finer, the cost of obtaining information and making decisions will also increase, so it is necessary to obtain the final sentiment classification result at an appropriate granularity.
[0066] At each granular layer gk (1≤k≤n-1), through the three-branch sentiment classification method, according to the conditional probability P r (P|x) and the threshold pair (α i ,β i ) will classify the text to be classified x into the positive class POS k (P), Negative class NEG k (P) and delayed decision type BND k In (P), the classification result depends on the probability P that the text to be classified x belongs to the positive domain r (P kx ) and a domain-value pair (α k ,β k ), its mathematical expression is:
[0067]
[0068]
[0069]
[0070] Among them, BND k (P) represents the boundary domain in the kth granular layer.
[0071] The rules for the three sentiment classifications are shown in Table 1.
[0072] Table 1 Three sentiment classification rules
[0073]
[0074] The cost matrices of the three sentiment classifications are shown in Table 2.
[0075] Table 2 Three emotional cost matrices
[0076]
[0077] Generally speaking, the cost of correct classification is the smallest, delayed decision is the second, and the cost of wrong classification is the largest, that is:
[0078] λ PP ≤λ BP ≤λ NP
[0079] λ NN ≤λ BN ≤λ PN
[0080] According to the sentiment classification cost matrix and decision rules in Table 2, the total classification cost can be calculated as follows:
[0081] cost(D p x)=λ PP Pr(Px)+λ PN Pr(Nx)
[0082] cost(D B |x)=λ BP Pr(P|x)+λ BN Pr(N|x)
[0083] cost(D N |x)=λ BP Pr(P|x)+λ NN Pr(N|x)
[0084] Among them, cost(D p |x)、cost(D B |x) and cost(D N |x) represent the costs incurred when the to-be-classified text x is classified into the positive class, the delayed decision class, and the negative class. According to the Bayesian decision criterion, the action set with the smallest expected loss is selected as the best action plan, and the following three decision rules can be obtained:
[0085] (P): If Pr(P|x)≥α, then classify x into the positive class;
[0086] (B): If Then x is classified into the delayed decision class;
[0087] (N): If Pr(P|x)≤β, then classify x into the negative class.
[0088] In the binary classification problem of sentiment, the real sentiment polarity is only positive and negative, so there are:
[0089] Pr(N|x)=1-Pr(P|x)
[0090] Based on the above formula, the decision cost can be calculated by selecting the optimal decision, that is, choosing the decision that causes the least cost. This selection rule can be expressed as:
[0091] SD x = arg min cos t(D x |x)
[0092] Optimal decision SD x Depends on the misclassification cost and conditional probability Pr(P|x). Accordingly, the threshold pair:
[0093]
[0094] S k =POS k (P)∪BND k (P)∪NEG k (P)
[0095] When the finest layer still fails to classify the text x into positive and negative domains, the corresponding domain value pair (α k ,β k ) k and α k The value of is set to be the same, denoted as γ h , and then make two decisions.
[0096] The formula for the two-way decision is:
[0097] POS h ={x∈S h |P r (P|x)≥γ h}
[0098] NEG h ={x∈S h |P r (P|x)<γ h}
[0099] Here, h represents the finest particle layer.
[0100] As more information is obtained at finer levels, the boundary domain BND k (α i , β i )(P) gradually decreases, and the text will gradually be divided into the positive domain or the negative domain. If there are still samples in the boundary domain in the finest layer h that have not been judged, a two-branch decision can be made.
[0101] The above two decisions, α n =βn , in general, these two values are usually set to 0.5. They can be adjusted according to the importance of precision and recall. The classification result of each particle layer gi is subject to the conditional probability P r (P|x) and threshold pair (α i ,β i ). Thus, the threshold α of each particle layer can be calculated. i and β i :
[0102]
[0103] in,
[0104] In one embodiment, Figure 6 As shown, the strategies for the three sentiment classifications are:
[0105] Step S301, when the granularity is greater than the set granularity threshold, objects whose decision risk exceeds the set risk threshold are classified into the boundary domain according to the cost loss matrix to reduce misclassification;
[0106] Step S302, as the granularity of the granularity increases, objects in the boundary region are divided until the boundary region is empty or classification is no longer possible under the current conditions;
[0107] In the three-branch sentiment classification, the cost loss matrix of each granular layer is given as:
[0108] 0≤β1<β2<…<β h-1 <γ h <α h-1 <…<α2<α1≤1.
[0109] In the embodiment of the present invention, for the setting of the three-branch decision thresholds at different granularity levels, the following strategies can be adopted: at the coarse-grained granularity level, due to the small amount of information that can be obtained, a conservative decision-making attitude can be adopted, and objects with greater decision risks can be classified into the boundary domain to reduce misclassification. As the granularity increases, the decision information that can be obtained also gradually increases, and the number of uncertain objects in the boundary domain gradually decreases, and the decision-making attitude becomes more relaxed at this time.
[0110] like Figure 7 As shown, in one embodiment, a multi-granularity text sentiment analysis model based on sequential three-branch decision making is provided, and the model includes a preprocessing module 100, a granularity division module 200, a sentiment classification module 300 and a reclassification module 400.
[0111] The preprocessing module 100 is used to preprocess the comment text data set, and the preprocessing method at least includes segmenting the comment text data and removing stop words;
[0112] The granularity division module 200 is used to divide the preprocessed comment text data set into granularities by using a preset language model to obtain sentiment representation data of multiple granularities;
[0113] The sentiment classification module 300 is used to perform sequential three-branch decision sentiment classification for sentiment representation data of each granularity until the boundary domain is empty or classification is no longer possible under the current conditions;
[0114] The reclassification module 400 is used to classify the boundary domain data that cannot be reclassified by using different classifiers, and finally obtain the final sentiment category of the data in the boundary domain by voting.
[0115] like Figure 8 As shown, in one embodiment, the reclassification module 400 specifically includes a data acquisition unit 401 , a binary classifier processing unit 402 and a screening unit 403 .
[0116] The data acquisition unit 401 is used to acquire boundary domain data that cannot be further classified;
[0117] The binary classifier processing unit 402 is used to input the boundary domain data that cannot be further classified into multiple independent and different binary classifiers to obtain classification results of the corresponding classifiers;
[0118] The screening unit 403 is used to screen the classification results of different classifiers into the final emotion category through the maximum voting method.
[0119] like Fig. 9 As shown, in one embodiment, the granularity division module 200 specifically includes a sliding operation unit 201 , a frequency statistics unit 202 and a text representation unit 203 .
[0120] The sliding operation unit 201 is used to perform a sliding window operation of size M on the comment text dataset according to bytes to obtain a byte segment sequence of length M;
[0121] The frequency counting unit 202 is used to count the occurrence frequencies of all byte segment sequences and filter them according to a preset threshold to form a key byte segment sequence list;
[0122] The text representation unit 203 is used to predict the probability of the whole sentence according to the formula, using unigram, bigram and unigram plus bigram as multi-granular text representation, using unigram as the candidate feature of the first granularity, bigram as the candidate feature of the second granularity, and unigram plus bigram as the candidate feature of the third granularity;
[0123] The formula is:
[0124] P(wi |w1,w2,...,w i-1 )=P(w i |w i-N+1 ,w i-N+2 ,...,w i-1 ), where P(w i |w1,w2,...,w i-1 )
[0125] is the probability of the whole sentence appearing, w i is the current word, and N is the number of words.
[0126] like Fig.10 As shown, in one embodiment, the preprocessing module 100 specifically includes a word segmentation unit 101 and a stop word removal processing unit 102 .
[0127] The word segmentation unit 101 is used to segment the comment text using a word segmentation tool and a preset word segmentation dictionary.
[0128] The stop word removal processing unit 102 is used to remove stop words according to a preset word segmentation dictionary.
[0129] The following are the experimental data and results of the embodiments of the present invention:
[0130] Experimental environment
[0131] The experiment was completed under the Windows 11 operating system, the CPU was Intel(R) Core(TM) i5-10501CPU@3.20GHz 3.20GHZ, the GPU was NVIDIA GetForce FT 730, the memory was 8GB, and the algorithm programming was performed using Python 3.9.11 version of python.
[0132] Experimental Dataset
[0133] To verify the performance of the proposed method, this experiment uses the classic film review dataset IMDB, which provides 50,000 film reviews with significant sentiment, including 25,000 positive and negative reviews, with a training set and test set ratio of 1:1, and unlabeled data is available. IMDB is a dataset dedicated to sentiment binary classification, and contains richer data than previous benchmark datasets.
[0134] Evaluation Metrics
[0135] For the problem of positive and negative emotional classification, the corresponding confusion matrix is constructed according to the predicted emotional category and the true emotional category. TP represents the number of samples predicted as positive, FP represents the number of samples predicted as negative, FN represents the number of samples predicted as positive, and TN represents the number of samples predicted as negative. After statistics of the confusion matrix results, the accuracy (Acc), precision (P), recall (R), and the harmonic mean of precision and recall (F1) can be calculated. This study uses this method to evaluate the model effect, and the calculation formula is:
[0136]
[0137] Among them, F1 is the harmonic value of precision P and accuracy R.
[0138] Comparison of algorithms and parameter settings
[0139] In order to verify the effectiveness of the proposed method, this paper uses TextCNN and TextRNN, two commonly used algorithms in text sentiment analysis, as benchmark classifiers to conduct comparative analysis of experimental results. The performance of neural networks is closely related to parameter settings, and the experimental parameters are shown in Table 3.
[0140] Table 3. Benchmark classifier parameter settings
[0141]
[0142]
[0143] Experimental analysis
[0144] The experimental results of each model on the IMDB dataset are shown in Table 4, and the bar chart comparison results are shown in Fig.11 shown.
[0145] Table 4 Experimental results comparison table
[0146]
[0147] From Table 4 and Fig.11 It can be seen that the sequential three-branch decision method Mliti-S3DSC, ESTWSC and the method of the embodiment of the present invention have improved precision, accuracy and F1-score compared with the traditional sentiment analysis methods TextCNN and TextRNN. In particular, the multi-granularity text sentiment analysis method based on skip-order sequential three-branch decision in the embodiment of the present invention has improved in various numerical values.
[0148] Therefore, the following conclusions can be drawn: (1) The introduction of sequential three-branch decision-making has a significant effect on sentiment analysis tasks, and its "three-way rule" idea is of great significance to the field of multi-granularity sentiment analysis; (2) Compared with the single sequential three-branch decision-making, the sequential three-branch decision-making integrated with the idea of ensemble learning has a better effect on sentiment analysis tasks; (3) After integrating the idea of ensemble learning, the uncertainty-based skip-order sequential three-branch decision-making effectively improves the sentiment analysis classification effect and reduces the classification cost.
[0149] Fig.12 The internal structure diagram of a computer device in one embodiment is shown. The computer device includes a processor, a memory, a network interface, an input device and a display screen connected through a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement a multi-granularity text sentiment analysis method based on sequential three-branch decision-making. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor can execute a multi-granularity text sentiment analysis method based on sequential three-branch decision-making. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a button, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
[0150] Those skilled in the art will understand that Fig.12 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0151] In one embodiment, the multi-granular text sentiment analysis model based on sequential three-branch decision-making provided by the present application can be implemented in the form of a computer program. The computer program can be used in Fig.12 The computer device is run on the computer device shown. The memory of the computer device can store various program modules that constitute the multi-granularity text sentiment analysis model based on sequential three-branch decision, for example, Figure 7 The preprocessing module 100, granularity division module 200, sentiment classification module 300 and reclassification module 400 are shown. The computer program composed of each program module enables the processor to execute the steps of the multi-granularity text sentiment analysis method based on sequential three-branch decision-making in each embodiment of the present application described in this specification.
[0152] For example, Fig.12 The computer device shown can be Figure 7 The preprocessing module 100 in the multi-granularity text sentiment analysis model based on sequential three-branch decision-making performs step S100. The computer device can perform step S200 through the granularity division module 200. The computer device can perform step S300 through the sentiment classification module 300.
[0153] In one embodiment, a computer device is provided, the computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:
[0154] Step S100, preprocessing the comment text data set, wherein the preprocessing method at least includes segmenting the comment text data and removing stop words;
[0155] Step S200, dividing the preprocessed comment text data set into granularity using a preset language model to obtain sentiment representation data of multiple granularities;
[0156] Step S300, performing sequential three-branch decision sentiment classification for sentiment representation data of each granularity until the boundary domain is empty or classification is no longer possible under the current conditions;
[0157] Step S400, the boundary domain data that cannot be further classified is classified by different classifiers, and finally the final sentiment category of the data in the boundary domain is obtained by voting.
[0158] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the processor performs the following steps:
[0159] Step S100, preprocessing the comment text data set, wherein the preprocessing method at least includes segmenting the comment text data and removing stop words;
[0160] Step S200, dividing the preprocessed comment text data set into granularity using a preset language model to obtain sentiment representation data of multiple granularities;
[0161] Step S300, performing sequential three-branch decision sentiment classification for sentiment representation data of each granularity until the boundary domain is empty or classification is no longer possible under the current conditions;
[0162] Step S400, the boundary domain data that cannot be further classified is classified by different classifiers, and finally the final sentiment category of the data in the boundary domain is obtained by voting.
[0163] It should be understood that, although each step in the flow chart of each embodiment of the present invention is shown in sequence according to the indication of the arrow, these steps are not necessarily performed in sequence according to the order indicated by the arrow. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in each embodiment may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of other steps or sub-steps or stages of other steps.
[0164] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0165] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0166] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
[0167] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A multi-granularity text sentiment analysis method based on sequential three-branch decision making, characterized in that: The method comprises the following steps: Preprocessing the comment text data set, wherein the preprocessing method at least includes segmenting the comment text data and removing stop words; The preprocessed comment text dataset is divided into granularities using a preset language model to obtain sentiment representation data at multiple granularities. For each granularity of sentiment representation data, sequential three-branch decision sentiment classification is performed until the boundary domain is empty or classification is no longer possible under the current conditions; For the boundary domain data that cannot be classified any more, different classifiers are used to classify them, and finally the final sentiment category of the data in the boundary domain is obtained by voting.
2. The method according to claim 1, characterized in that The step of preprocessing the comment text dataset includes: Segment the comment text using the word segmentation tool and the preset word segmentation dictionary; Remove stop words according to the preset word segmentation dictionary.
3. The method according to claim 1, characterized in that: The step of classifying the boundary domain data that cannot be further classified by different classifiers, and finally obtaining the final sentiment category of the data in the boundary domain by voting, comprises: Obtain boundary domain data that cannot be classified any more; Inputting the boundary domain data that cannot be further classified into multiple independent and different binary classifiers respectively to obtain classification results of the corresponding classifiers; The classification results of different classifiers are filtered out into the final emotion category through the maximum voting method.
4. The method according to claim 1, characterized in that: The step of dividing the preprocessed comment text dataset into granularities by using a preset language model to obtain sentiment representation data of multiple granularities includes: Perform a sliding window operation of size M on the comment text dataset according to bytes to obtain a byte segment sequence of length M; The occurrence frequencies of all byte fragment sequences are counted and filtered according to the preset threshold to form a list of key byte fragment sequences; The probability of the whole sentence is predicted according to the formula, and the unigram, bigram, and unigram plus bigram combination are used as multi-granular text representations. Unigrams are used as candidate features of the first granularity, bigrams are used as candidate features of the second granularity, and unigrams plus bigrams are used as candidate features of the third granularity. The formula is: P(w i | w1, w2,..., w i-1 ) = P(w i | w i-N+1 , w i-N+2 ,..., w i-1 ), where P(w i | w1, w2,..., w i-1 ) is the probability of the whole sentence appearing, w i is the current word, and N is the number of words.
5. The method according to claim 1, characterized in that: The step of performing sequential three-branch decision sentiment classification on the sentiment representation data of each granularity until the boundary domain is empty or classification is no longer possible under the current conditions includes: Define multi-granularity structures; G={g1,g2,…,gi,…,gh},(1≤i≤h), where gi represents the i-th particle layer and h is the finest particle layer; Get n sub-datasets from the data set U, Dataset U is a preprocessed review text dataset; At each granular layer gk (1≤k≤n-1), through the three-branch sentiment classification method, according to the conditional probability P r (P|x) and the threshold pair (α i ,β i ) will classify the text to be classified x into the positive class POS k (P), Negative class NEG k (P) and delayed decision type BND k In (P), the classification result depends on the probability P that the text to be classified x belongs to the positive domain r (P kx ) and a domain-value pair (α k ,β k ), its mathematical expression is: Among them, BND k (P) represents the boundary domain in the kth granular layer; S k =POS k (P)∪BND k (P)∪NEG k (P) When the finest layer still fails to classify the text x into the positive domain and the negative domain, the corresponding domain value pair (α k ,β k ) k and α k The value of is set to be the same, denoted as γ h , and then make two decisions; The formula for the two-way decision is: POS h ={x∈S h |P r (P|x)≥γ h } NEGATIVE h ={x∈S h |P r (P|x)<γ h } Here, h represents the finest particle layer.
6. The method according to claim 5, characterized in that The three sentiment classification strategies are: When the granularity is greater than the set granularity threshold, objects whose decision risk exceeds the set risk threshold are classified into the boundary domain according to the cost loss matrix to reduce misclassification; As the granularity of the granular layer increases, the objects in the boundary domain are divided until the boundary domain is empty or classification is no longer possible under the current conditions; In the three-branch sentiment classification, the cost loss matrix of each granular layer is given as: 0≤β1<β2<…<β h-1 <γ h <α h-1 <…<α2<α1≤1。 7. A multi-granular text sentiment analysis model based on sequential three-branch decision making, characterized in that: The model includes: A preprocessing module, used for preprocessing the comment text data set, wherein the preprocessing method at least includes segmenting the comment text data and removing stop words; The granularity division module is used to divide the preprocessed comment text dataset into granularities using a preset language model to obtain sentiment representation data of multiple granularities; The sentiment classification module is used to perform sequential three-branch decision sentiment classification for each granularity of sentiment representation data until the boundary domain is empty or classification is no longer possible under the current conditions; The reclassification module is used to classify the boundary domain data that cannot be reclassified by different classifiers, and finally obtain the final sentiment category of the data in the boundary domain by voting.
8. The multi-granularity text sentiment analysis model based on sequential three-branch decision making according to claim 7 is characterized in that: The reclassification module comprises: A data acquisition unit, used for acquiring boundary domain data that cannot be classified any more; A binary classifier processing unit, used for inputting the boundary domain data that cannot be further classified into a plurality of independent and different binary classifiers respectively, to obtain classification results of the corresponding classifiers; The screening unit is used to screen the classification results of different classifiers into the final emotion category through the maximum voting method.
9. The multi-granularity text sentiment analysis model based on sequential three-branch decision making according to claim 7 is characterized in that: The granularity division module includes: A sliding operation unit, used to perform a sliding window operation of size M on the comment text dataset according to bytes, to obtain a byte segment sequence of length M; A frequency statistics unit is used to count the occurrence frequencies of all byte segment sequences and filter them according to a preset threshold to form a list of key byte segment sequences; A text representation unit is used to predict the probability of the whole sentence according to a formula, and uses unigrams, bigrams, and a combination of unigrams and bigrams as multi-granular text representations, with unigrams as candidate features of the first granularity, bigrams as candidate features of the second granularity, and unigrams plus bigrams as candidate features of the third granularity; The formula is: P(w i | w1, w2,..., w i-1 ) = P(w i | w i-N+1 , w i-N+2 ,..., w i-1 ), where P(w i | w1, w2,..., w i-1 ) is the probability of the whole sentence appearing, w i is the current word, and N is the number of words.
10. The multi-granularity text sentiment analysis model based on sequential three-branch decision making according to claim 7, characterized in that: The preprocessing module comprises: A word segmentation unit is used to segment the comment text using a word segmentation tool and a preset word segmentation dictionary; The stop word removal processing unit is used to remove stop words according to a preset word segmentation dictionary.