Text sentiment analysis method and device, equipment, storage medium and product

By generating semantic feature data from multiple perspectives and in-depth feature extraction, combined with collaborative learning of features between perspectives, the problem of insufficient accuracy of text sentiment analysis in network public opinion in the prior art is solved, and more efficient text sentiment classification is achieved.

CN119884366APending Publication Date: 2025-04-25CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411908481.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The existing text sentiment analysis methods are difficult to meet the needs of rapidly developing networks and diverse scenarios when dealing with online public opinion, which affects the accuracy of sentiment analysis.

Method used

By obtaining the text feature data to be analyzed, semantic feature data from at least two perspectives are generated and deep feature extraction is performed respectively. Then, based on the collaborative learning of features between perspectives, combined feature data of multi-view weighted depth features are obtained, and finally input to a pre-trained text emotion discriminator for emotion classification.

Benefits of technology

Through collaborative learning of features between multiple perspectives, the semantic expression of text feature data is enhanced, the accuracy of emotional classification results is effectively improved, and the needs of text sentiment analysis such as online public opinion are met.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119884366A_ABST
    Figure CN119884366A_ABST
Patent Text Reader

Abstract

The invention discloses a text sentiment analysis method and device, equipment, a storage medium and a product. The method comprises the steps of obtaining to-be-analyzed text feature data; generating semantic feature data of at least two visual angles based on the text feature data; performing depth feature extraction on the semantic feature data of each view angle to obtain depth feature data of each view angle; based on the depth feature data of each view angle, collaborative learning of features between view angles is carried out to obtain combined feature data representing multi-view weighted depth features; and inputting the combined feature data into a pre-trained text emotion discriminator to obtain an emotion classification result of the text feature data. Therefore, semantic expression of the text feature data can be enhanced through collaborative learning of features among multiple perspectives, so that the accuracy of the sentiment classification result of the text feature data can be effectively improved, and the text sentiment analysis requirements of network public opinions and the like can be better met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing, and in particular to a text sentiment analysis method, apparatus, device, storage medium and product. Background Art

[0002] Text sentiment analysis is an important branch of natural language processing. It targets text data and is the process of analyzing, processing, summarizing and reasoning subjective texts with emotional colors. Internet public opinion sentiment analysis is one of the main research directions of text sentiment analysis. Sentiment analysis of text information related to public opinion events can be broadly divided into methods based on sentiment dictionaries, traditional machine learning methods and deep learning methods.

[0003] However, when conducting sentiment analysis on online public opinion, the above methods are difficult to meet the sentiment analysis needs under new situations such as rapid network development, rich fields or scenarios, and affect the accuracy of text sentiment analysis. Summary of the invention

[0004] In view of this, the embodiments of the present application provide a text sentiment analysis method, apparatus, device, storage medium and product, which aim to improve the accuracy of text sentiment analysis and meet the needs of text sentiment analysis such as online public opinion.

[0005] The technical solution of the embodiment of the present application is implemented as follows:

[0006] In a first aspect, the present application provides a text sentiment analysis method, comprising:

[0007] Obtain text feature data to be analyzed;

[0008] Generate semantic feature data of at least two perspectives based on the text feature data;

[0009] Performing deep feature extraction on the semantic feature data of each perspective respectively to obtain deep feature data of each perspective;

[0010] Based on the deep feature data of each view, collaborative learning of features between views is performed to obtain combined feature data representing multi-view weighted deep features;

[0011] The combined feature data is input into a pre-trained text sentiment discriminator to obtain a sentiment classification result of the text feature data.

[0012] In the above solution, the semantic feature data of at least two perspectives is generated based on the text feature data, including at least two of the following:

[0013] Generate first semantic feature data based on word frequency and inverse document frequency encoding of the text feature data;

[0014] Generate second semantic feature data based on text vector encoding of the text feature data;

[0015] Generating third semantic feature data for the text feature data based on a pre-trained language model.

[0016] In the above scheme, the deep feature extraction is performed on the semantic feature data of each perspective to obtain the deep feature data of each perspective, including:

[0017] Based on the semantic feature data of each perspective, local depth feature data representing local depth information is obtained based on a convolutional neural network;

[0018] For each of the local depth feature data, long-range dependencies are captured based on a self-attention network to obtain depth feature data of each perspective.

[0019] In the above scheme, for each of the local deep feature data, the long-range dependency is captured based on the self-attention network to obtain the deep feature data of each perspective, including:

[0020] For any of the local depth feature data, a pooling operation is performed on the channel dimension, and a convolution operation is performed on the data after the pooling operation, and the data after the convolution operation is normalized to obtain the depth feature data of the corresponding viewing angle.

[0021] In the above scheme, the collaborative learning of inter-view features based on the depth feature data of each view to obtain combined feature data representing multi-view weighted depth features includes:

[0022] Based on the shared regression network, common features are extracted from the deep feature data of each perspective to obtain shared perspective feature data;

[0023] Based on the shared view feature data, spatial position information is fused with the depth feature data of each view in pairs to obtain cross-view weighted feature data;

[0024] The weighted feature data across each perspective are concatenated to obtain combined feature data representing multi-perspective weighted depth features.

[0025] In the above scheme, the common features of the depth feature data of each perspective are extracted based on the shared regression network to obtain the shared perspective feature data, including:

[0026] The deep feature data of each perspective is spliced, and the spliced ​​data is processed by convolution and feature migration in sequence to obtain the initial shared data;

[0027] Performing a regression operation on the initial shared data to obtain high-order local shared data;

[0028] Capturing long-range dependencies of the high-order local shared data based on a self-attention network to obtain deep high-order shared data;

[0029] Based on the initial shared data and the deep high-order shared data, shared viewing angle feature data is obtained.

[0030] In the above scheme, the spatial position information is fused in pairs based on the shared view feature data and the depth feature data of each view to obtain cross-view weighted feature data, including:

[0031] Performing a pooling operation in a spatial dimension and a convolution operation on the data after the pooling operation on the shared viewing angle feature data and the depth feature data of each viewing angle respectively, to obtain spatial position information of the shared viewing angle feature data and spatial position information of the depth feature data of each viewing angle;

[0032] The spatial position information of the shared view feature data is fused with the spatial position information of the depth feature data of each view in pairs to obtain weighted feature data across each view.

[0033] In the above solution, the step of obtaining the text feature data to be analyzed includes:

[0034] Obtain text data related to online public opinion;

[0035] The text data is preprocessed to obtain text feature data to be analyzed; wherein the preprocessing includes one or more of the following: word segmentation and stop word filtering.

[0036] In a second aspect, an embodiment of the present application provides a text sentiment analysis device, the device further comprising:

[0037] An acquisition module, used to acquire text feature data to be analyzed;

[0038] A first processing module, configured to generate semantic feature data of at least two perspectives based on the text feature data;

[0039] The second processing module is used to extract the depth feature of the semantic feature data of each perspective respectively to obtain the depth feature data of each perspective;

[0040] A third processing module is used to perform collaborative learning of features between perspectives based on the depth feature data of each perspective to obtain combined feature data representing multi-perspective weighted depth features;

[0041] The detection module is used to input the combined feature data into a pre-trained text sentiment discriminator to obtain a sentiment classification result of the text feature data.

[0042] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory for storing a computer program that can be run on the processor, wherein the processor, when used to run the computer program, executes the steps of the method described in the first aspect of the embodiment of the present application.

[0043] In a fourth aspect, an embodiment of the present application provides a computer storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the first aspect of the embodiment of the present application are implemented.

[0044] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the method described in the first aspect of the embodiment of the present application.

[0045] The technical solution provided by the embodiment of the present application obtains the text feature data to be analyzed; generates semantic feature data of at least two perspectives based on the text feature data; performs deep feature extraction on the semantic feature data of each perspective respectively to obtain the deep feature data of each perspective; performs collaborative learning of inter-perspective features based on the deep feature data of each perspective to obtain combined feature data representing multi-perspective weighted deep features; inputs the combined feature data into a pre-trained text sentiment discriminator to obtain the sentiment classification result of the text feature data. In this way, the semantic expression of the text feature data can be enhanced through the collaborative learning of features between multiple perspectives, thereby effectively improving the accuracy of the sentiment classification results of the text feature data, and better meeting the needs of text sentiment analysis such as network public opinion. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 This is a flow chart of the text sentiment analysis method according to the embodiment of the present application;

[0047] Figure 2 This is a schematic diagram of the principle of the text sentiment analysis method of the application embodiment of this application;

[0048] Figure 3 This is a schematic diagram of the structure of the text sentiment analysis device of the embodiment of the present application;

[0049] Figure 4 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0050] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0051] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0052] With the popularization of mobile Internet, the relatively relaxed Internet environment has promoted the rapid development of e-commerce, short videos, music, content communities and other platforms, providing a variety of voice channels for netizens. At the same time, the massive emotional catharsis has also brought huge challenges to the management of online public opinion. Therefore, how to conduct sentiment analysis on huge public opinion text data and accurately extract the emotional tendencies of the public is of great significance to the prevention and control of public opinion risks.

[0053] Among the related technologies, the technology of text sentiment analysis is relatively mature. According to different usage methods, text sentiment analysis technology mainly includes the following three methods:

[0054] Method 1: Sentiment analysis method based on sentiment dictionary. The sentiment analysis method based on sentiment dictionary is to judge the sentiment polarity of the input text through the sentiment polarity of the keywords in the existing sentiment dictionary. Its basic process is to first perform pre-processing such as denoising and word segmentation on the input text, and then send it to the sentiment classifier, and obtain the corresponding sentiment type judgment result according to the sentiment judgment rules.

[0055] Method 2: Sentiment analysis method based on traditional machine learning. Sentiment analysis method based on traditional machine learning is to extract the features of a large amount of text corpus through various machine learning algorithms to obtain the results of sentiment analysis. According to the degree of label correspondence of the text corpus sample set, sentiment classification methods based on machine learning can be divided into three categories: supervised, semi-supervised and unsupervised methods. Supervised methods require that samples must have corresponding sentiment polarity labels, which requires a lot of time for data processing and manual labeling. Semi-supervised methods effectively reduce the dependence on sentiment polarity labels by extracting features from unlabeled text samples. Unsupervised methods completely get rid of the dependence on sentiment polarity labels and complete the classification of text sentiment only through the similarity between texts.

[0056] Method 3: Sentiment analysis method based on deep learning. Sentiment analysis method based on deep learning is to further extract the features of contextual semantics in the text through neural networks to complete the classification of text sentiment. With the emergence of massive data sets and the improvement of various deep learning models, sentiment analysis method based on deep learning has become the mainstream of sentiment analysis of public opinion texts. It can realize the self-learning of sample data sets by neural networks through training. This method optimizes the learning efficiency and greatly saves manual time. Common deep learning neural networks include CNN (Convolutional Neural Network), RNN (Recurrent Neural Network) and other networks.

[0057] However, the above three text sentiment analysis methods all have some shortcomings and problems in practical applications:

[0058] 1) Sentiment analysis methods based on sentiment dictionaries (i.e., the above-mentioned method 1) rely heavily on the construction of sentiment dictionaries. However, with the rapid development of the Internet and the promotion of cultural exchanges, many new words and hot words with special meanings have emerged, which puts very high demands on the expansion speed of sentiment dictionaries. At the same time, the same sentiment word may have different meanings and emotional characteristics in different time and space scenes and semantic environments. These inherent bottlenecks of sentiment dictionaries will cause inaccurate text sentiment analysis.

[0059] 2) Sentiment analysis methods based on machine learning (i.e., the second method mentioned above) use machine learning algorithms to perform sentiment analysis on texts. However, in different fields or scenarios, the sensitivity of different machine learning algorithms to text sentiment analysis varies significantly, so they need to be adjusted and optimized according to specific situations. At the same time, when the amount of data is large, the efficiency of this type of method will decrease.

[0060] 3) Sentiment analysis methods based on deep learning (i.e., the third method mentioned above) use deep neural network models to perform sentiment analysis on texts. Compared with sentiment analysis methods based on machine learning, deep learning models have stronger adaptability and robustness, and can better cope with sentiment analysis needs in different fields and scenarios. However, with the development of deep learning technology, a variety of neural network structures have been proposed, such as CNN, LSTM (Long Short-Term Memory) and RNN. These network structures have significantly different analytical capabilities for public opinion texts. Therefore, designing an efficient deep learning model for sentiment analysis based on public opinion texts has become a difficult problem.

[0061] In addition, in the specific implementation of the above method, analysis is often performed only from a single text feature, and text features from multiple perspectives are not analyzed. However, research has shown that collaborative learning of features from multiple perspectives can significantly improve model performance. Based on this, the present application embodiment proposes a text sentiment analysis method based on multi-perspective collaborative learning, which can effectively improve the accuracy of text sentiment analysis such as online public opinion.

[0062] The embodiment of the present application provides a text sentiment analysis method, which can be independently applied to electronic devices with data processing capabilities, such as terminal devices, servers, etc., or can be implemented by the cooperation between terminal devices and servers; wherein the terminal device can specifically be a computer, a smart phone, a personal digital assistant (PDA), etc.; the server can specifically be an application server or a Web server. In actual deployment, the server can be an independent server or a cluster server. Figure 1 As shown, the method includes:

[0063] Step 101: Obtain text feature data to be analyzed.

[0064] Here, the acquired text data may be preprocessed by word segmentation, stop word filtering, etc. to obtain text feature data to be analyzed.

[0065] Step 102: Generate semantic feature data of at least two perspectives based on the text feature data.

[0066] Here, the text feature data may be encoded using a variety of encoding perspectives to obtain semantic feature data from at least two perspectives, thereby enriching the semantic representation of the text feature data.

[0067] Exemplarily, the generating of semantic feature data of at least two perspectives based on the text feature data includes at least two of the following:

[0068] Encoding the text feature data based on term frequency and inverse document frequency (TF-IDF, Term Frequency-Inverse Document Frequency) to generate first semantic feature data;

[0069] Generate second semantic feature data based on text vector encoding of the text feature data;

[0070] Generating third semantic feature data for the text feature data based on a pre-trained language model.

[0071] Here, TF-IDF encoding is a bag-of-words model representation technology in the field of text analysis. Its core idea is to weight the features of each sample according to their importance. Among them, TF refers to term frequency, which is used to quantify the ability of a word to summarize the subject content of the text, while IDF refers to inverse document frequency, which is used to quantify the ability of a word to distinguish different categories of text. The encoding process is as follows: first, the text sample is segmented, a dictionary is constructed, and the word frequency is counted; then the TF value and IDF value of each word are calculated respectively, and finally the product of the TF value and the IDF value is used as the corresponding weight. The word vector obtained by this method has a good ability to summarize the subject content of the text.

[0072] Here, the text vector (Word2Vec) encoding principle is to map each word in the vocabulary into a k-dimensional real vector by training a unique network model, and use the real vector of the word to construct the initial feature matrix of the text sample. The training process of the network model is as follows: (a) Perform word segmentation operations on the text sample, construct a dictionary, count the word frequency, construct a Huffman tree according to the probability of word occurrence, and generate the binary code of each word; (b) Build a three-layer network model, input the binary codes of adjacent words as features and labels into the model for training; (c) Obtain the model hidden layer parameters and calculate the word vector of each word in the vocabulary. The Huffman coding based on word frequency can make the contents of the hidden layer activation of words with similar word frequency basically consistent, and the higher the frequency of the word, the fewer the number of hidden layer nodes they activate, effectively learning the distance distribution of words in high-dimensional space with low computational complexity. The word vector trained by this method not only has the advantage of low dimension, but also contains its context information in the text sample, which can provide good help for feature extraction.

[0073] Here, the pre-trained language model refers to a model with strong generalization ability that is trained in advance with a large-scale general data set. Then, by adaptively incrementally training the model and fine-tuning the weights, better results can be achieved in different tasks. For example, the ALBERT (A lite Bidirectional Encoder Representationsfrom Transformer, a lightweight bidirectional semantic encoding representation built on a transformer) model can be used as a pre-trained language model, which can extract the contextual semantic information of the target document and generate semantic features in combination with the contextual semantic information. ALBERT has been improved on the basis of the original BERT model, effectively reducing the parameters of the model. For example, in order to make it better applied to the sentiment analysis task of public opinion text, the ALBERT model can be fine-tuned on the online_shopping_10_cats dataset, and the fine-tuned model can be used as a pre-trained language model for semantic information extraction of text feature data.

[0074] It should be noted that the above three encoding perspectives are only for illustration. Those skilled in the art may also introduce other theoretical encoding technologies to process text feature data to obtain semantic feature data from more perspectives, which is not limited in the embodiments of the present application.

[0075] Step 103 , extracting depth features from the semantic feature data of each viewing angle to obtain depth feature data of each viewing angle.

[0076] Here, deep feature extraction is performed on the semantic feature data of each perspective in step 102, so that deep feature data with rich context information of the corresponding perspective can be obtained, which can enhance the semantic representation at each perspective.

[0077] Step 104 , based on the depth feature data of each perspective, collaborative learning of features between perspectives is performed to obtain combined feature data representing multi-perspective weighted depth features.

[0078] Here, by collaboratively learning the inter-perspective features of the deep feature data of each perspective, we can obtain combined feature data that characterize the multi-perspective weighted deep features. We can utilize the collaborative learning of the inter-perspective features to achieve information gain based on information interaction between perspectives, thereby enhancing the emotional expression ability of the combined feature data.

[0079] Step 105: input the combined feature data into a pre-trained text sentiment discriminator to obtain a sentiment classification result of the text feature data.

[0080] It is understandable that through the collaborative learning of features between multiple perspectives, the semantic expression of text feature data can be enhanced, which can effectively improve the accuracy of sentiment classification results of text feature data and better meet the needs of text sentiment analysis such as online public opinion.

[0081] Exemplarily, the extracting the deep features of the semantic feature data of each perspective to obtain the deep feature data of each perspective includes:

[0082] Based on the semantic feature data of each perspective, local depth feature data representing local depth information is obtained based on a convolutional neural network;

[0083] For each of the local depth feature data, long-range dependencies are captured based on a self-attention network to obtain depth feature data of each perspective.

[0084] Here, the convolutional neural network can obtain the local depth information of the semantic feature data of each perspective. On this basis, the embodiment of the present application also introduces a self-attention network, and captures the long-range dependency of the local deep feature data based on the self-attention network, and then obtains the deep feature data under the corresponding perspective. In this way, the deep feature data can take into account the semantic representation of depth and breadth, which is convenient for subsequent sentiment classification. Among them, the long-range dependency can be understood as the ability to capture the dependency between long-distance phrase fragments in the document compared to the context.

[0085] Exemplarily, for each of the local depth feature data, capturing long-range dependencies based on a self-attention network to obtain depth feature data of each perspective includes:

[0086] For any of the local depth feature data, a pooling operation is performed on the channel dimension, and a convolution operation is performed on the data after the pooling operation, and the data after the convolution operation is normalized to obtain the depth feature data of the corresponding viewing angle.

[0087] Here, the pooling operation can perform global average pooling and global maximum pooling operations on the local deep feature data in the channel dimension, the convolution operation can be performed using a single-layer convolutional neural network, and the normalization processing can be performed using a sigmoid function to normalize the attention results. In this way, the semantic representation of the deep feature data of each perspective can be enhanced based on the self-attention network.

[0088] Exemplarily, the collaborative learning of inter-view features based on the depth feature data of each view to obtain combined feature data representing multi-view weighted depth features includes:

[0089] Based on the shared regression network, common features are extracted from the deep feature data of each perspective to obtain shared perspective feature data;

[0090] Based on the shared view feature data, spatial position information is fused with the depth feature data of each view in pairs to obtain cross-view weighted feature data;

[0091] The weighted feature data across each perspective are concatenated to obtain combined feature data representing multi-perspective weighted depth features.

[0092] Here, considering the correlation between the deep feature data under each perspective, that is, performing common feature extraction, it is helpful to better improve the feature quality. It should be noted that the keywords and contextual information in the document determine the emotions that the document may have, and in the neural network, the deep semantic information is often regarded as the content after removing the irrelevant edge features, which is directly related to the prediction task. Based on this, the embodiment of the present application introduces a shared regression network, based on which the common features of the deep feature data of each perspective are extracted to obtain shared perspective feature data, which can be used as the main view of the core view mode, and then based on the shared perspective feature data, the spatial position information is fused in pairs with the deep feature data of each perspective to obtain cross-perspective weighted feature data, and the cross-perspective weighted feature data are spliced ​​to obtain the combined feature data representing the multi-perspective weighted deep features, which is used to improve the classification effect of the subsequent text sentiment discriminator.

[0093] Exemplarily, the extracting common features from the depth feature data of each perspective based on the shared regression network to obtain shared perspective feature data includes:

[0094] The deep feature data of each perspective is spliced, and the spliced ​​data is processed by convolution and feature migration in sequence to obtain the initial shared data;

[0095] Performing a regression operation on the initial shared data to obtain high-order local shared data;

[0096] Capturing long-range dependencies of the high-order local shared data based on a self-attention network to obtain deep high-order shared data;

[0097] Based on the initial shared data and the deep high-order shared data, shared viewing angle feature data is obtained.

[0098] Here, the initial shared data can be understood as the aggregation of deep feature data from each perspective; in order to better refine the initial shared data, regression operations are performed through the convolutional network to obtain high-order local shared data; in addition, considering the limitations of the layout pattern of the convolutional network, the self-attention mechanism is reintroduced into the high-order local shared data to learn the long-range dependencies between words and sentences at a longer distance to obtain deep high-order shared data; the initial shared data is connected to the deep high-order shared data through jump connections to obtain shared perspective feature data, so that the shared perspective feature data can accurately reflect the common information of the deep feature data from multiple perspectives, which is conducive to achieving information gain.

[0099] Exemplarily, the step of fusing spatial position information based on the shared view feature data with the depth feature data of each view in pairs to obtain cross-view weighted feature data includes:

[0100] Performing a pooling operation in a spatial dimension and a convolution operation on the data after the pooling operation on the shared viewing angle feature data and the depth feature data of each viewing angle respectively, to obtain spatial position information of the shared viewing angle feature data and spatial position information of the depth feature data of each viewing angle;

[0101] The spatial position information of the shared view feature data is fused with the spatial position information of the depth feature data of each view in pairs to obtain weighted feature data across each view.

[0102] Here, based on the perspective-pair collaborative attention mechanism, the shared perspective feature data can be interactively linked with the depth feature data of each perspective in turn, that is, the spatial position correlation between perspectives can be established, and then the weighted feature data across perspectives can be obtained, thereby achieving information gain from information interaction between perspectives.

[0103] Exemplarily, the obtaining of text feature data to be analyzed includes:

[0104] Obtain text data related to online public opinion;

[0105] The text data is preprocessed to obtain text feature data to be analyzed; wherein the preprocessing includes one or more of the following: word segmentation and stop word filtering.

[0106] Here, by obtaining text data related to online public opinion and preprocessing the text data, the text feature data to be analyzed is obtained. In this way, based on the text sentiment analysis method of the embodiment of the present application, text sentiment analysis related to online public opinion can be implemented, thereby meeting the needs of network risk management and control.

[0107] The present application is further described in detail below in conjunction with application examples.

[0108] This application embodiment relates to a method for analyzing network public opinion text sentiment based on multi-perspective collaborative learning. Figure 2 , which includes the following steps: data acquisition and preprocessing, multi-view initial feature extraction, deep feature extraction, collaborative learning of inter-view features and sentiment discrimination. The following is a detailed description of each step:

[0109] 1. Data acquisition and preprocessing

[0110] Here, the acquired text data related to online public opinion may be preprocessed by word segmentation, stop word filtering, etc. to obtain text feature data.

[0111] For example, a crawler script written in Python can be used to crawl text data related to online public opinion such as Weibo, WeChat public accounts, Zhihu, major news websites, Baidu Tieba, Douyin Kuaishou, etc., and save it in a database. You can use jieba Chinese word segmentation and stop word filtering to preprocess. Specifically, unlike English texts that use spaces to separate words, Chinese texts are generally continuous, which requires a special Chinese word segmentation tool to divide a whole sentence into multiple independent words. For example, use the Chinese word segmentation tool jieba to segment the crawled public opinion text; in addition, based on the Chinese word segmentation results, further eliminating stop words such as definite articles, conjunctions, prepositions, and numerals that have little impact on text sentiment classification can reduce the amount of text calculations.

[0112] 2. Multi-view initial feature extraction

[0113] Here, we can use TF-IDF encoding, Word2Vec encoding, and fine-tuning based pre-trained language model encoding to extract a multi-perspective feature set of the public opinion text, that is, to obtain semantic feature data from multiple perspectives.

[0114] 3. Deep feature extraction

[0115] Here, after obtaining the initial multi-perspective semantic feature data set of the public opinion text, the deep feature extraction module can be applied in parallel to the semantic feature data of each perspective to obtain the deep feature data with rich contextual information of the corresponding perspective. Specifically, for the semantic feature data of any perspective, a multi-layer cascaded convolutional neural network is first used for processing to extract the deep local information of the perspective feature. The convolutional neural network extracts local depth information by sliding the convolution kernel on the current input feature x. For the nth step of convolution, the expression is as follows:

[0116] h n =g(W c *x n:n+k-1 +b c )

[0117] Among them, h n Represents the feature corresponding to the n-th convolution step, W c and b c are the weight and bias of the convolution kernel, k is the size of the convolution kernel, and g(·) is a nonlinear function.

[0118] Then, self-attention is injected based on the deep local features to further capture the long-range dependencies between long-distance phrase fragments in the document. For the output feature F of the convolutional neural network, the self-attention mechanism can be expressed as:

[0119] Attention(F)=Sigmoid(CNN(AvgPool(F))+CNN(MaxPool(F)))

[0120] Among them, AvgPool and MaxPool refer to the global average pooling and global maximum pooling operations on the deep local features in the channel dimension respectively. CNN(·) is a single-layer convolutional neural network, and the Sigmoid function is used to further normalize the attention results.

[0121] 4. Collaborative Learning of Inter-view Features

[0122] Here, since multiple semantic perspective information of public opinion text data is obtained, it is easy to see that merging the correlation between different perspective features helps to better improve the feature quality. As we all know, the keywords and contextual information in the document determine the emotions that the document may have, and in neural networks, deep semantic information is often regarded as the content after removing irrelevant edge features, which is directly related to the prediction task. In this regard, in order to capture the common information that may be expressed in semantic features of different perspectives, this application embodiment proposes a multi-perspective collaborative learning module based on the core view mode. The module includes two parts: a shared regression network and a perspective pair collaborative attention mechanism. Among them, the shared regression network is used to capture common information from a multi-perspective deep feature set, and the acquired common information features are used as the main view of the core view mode; the perspective pair collaborative attention mechanism module is used to transmit the common information between the main view and the remaining sub-views, and finally the interactive deep feature set is merged by splicing, and used for the classification of the subsequent sentiment discriminator.

[0123] Among them, the working principle of the shared regression network is as follows:

[0124] In the field of natural language processing, the encoder-decoder (Seq2Seq) model is often used to process text sequences. In the Seq2Seq model, the encoder has the ability to extract a fixed-size feature state vector from the initial features, and by learning the feature vector, the decoder has the ability to complete the prediction task of the corresponding scene. This shows that the state vector obtained by the encoder can learn enough recognition feature information. Inspired by this, the embodiment of the present application proposes a shared regression network to establish a global shared perspective based on multiple perspective features.

[0125] In the shared regression network, all the perspective features are first aggregated through a splicing operation, and then a 1×1 convolution layer is used to refine the feature. After a feature migration layer, the initial shared data S1 can be obtained. Then, in order to better refine the initial shared data, another standard 1×1 convolution layer is used to regress it to obtain high-order local shared data S2. However, considering the limitations of the local pattern of the convolutional network, the self-attention mechanism is also introduced to the high-order local shared data to learn the long-range dependencies between words and sentences at a longer distance, and obtain deep high-order shared data S3. Finally, the initial shared data and deep high-order shared data are fused through jump connections to obtain the final shared perspective feature data S final ,The whole process can be described by the following formula:

[0126] S1=T(CNN 1×1 ([f1,f2,f3]))

[0127] S2=CNN 1×1 (S1)

[0128]

[0129] S final =S1+S3

[0130] Among them, CNN 1×1 (·) represents a single-layer convolutional neural network with a convolution kernel size of 1×1, T(·) represents a feature transfer layer consisting of a BatchNorm layer and a Relu layer, and Attention(·) represents an attention layer.

[0131] Among them, the working principle of the perspective-to-cooperative attention mechanism is as follows:

[0132] After obtaining the global shared semantic information (i.e., shared view feature data) of the multi-view feature set through the shared regression network, the output semantic information will be used as the core view to establish interactive connections with other view semantic information in turn. In addition, in order to model the view pair semantic relationship between the shared view and the remaining views, a view pair collaborative attention mechanism is proposed based on the spatial position correlation between the views.

[0133] The first step of the perspective pair collaborative attention mechanism is to determine the perspective pair information to be processed, usually the shared perspective feature data S final And the depth feature data f of each viewing angle mentioned above i (1≤i≤3), and perform global average pooling and global maximum pooling of the view information in the spatial dimension to obtain a global information feature map used to describe the spatial position information, and then aggregate the global position information of the view through a standard 1×1 convolutional layer to share the view feature data S final For example, the spatial position information extraction process can be expressed as follows:

[0134] M s (S final )=CNN 1×1 (SpatialAvgPool(S final ); SpatialMaxPool(S final ))

[0135] Among them, SpatialAvgPool and SpatialMaxPool refer to performing global average pooling and global maximum pooling operations on the current input features in the spatial dimension respectively. Similarly, the depth feature data f of each perspective i Do the same process and get M s (f i ).

[0136] The second step is to fuse the spatial position information of the shared view and the sub-view to generate the collaborative attention of the view dominated by the common information. The expression is as follows:

[0137] M s->i =Sigmoid(CNN([M s (S final );M s (f i )]))

[0138]

[0139] Among them, M s->i is the view-to-view co-attention, f i ′ is the depth feature data f i Corresponding cross-view weighted feature data.

[0140] Afterwards, collaborative attention between the shared perspective and other perspective features is established in turn to obtain cross-perspective weighted feature data {f1′, f2′, f3′} of each depth feature data dominated by common information.

[0141] Finally, the weighted feature data of the collaborative attention containing multi-view common information is concatenated into a vector [f1′, f2′, f3′], i.e., the combined feature data, which is passed as the output of the multi-view collaborative learning module to the text sentiment discriminator for outputting sentiment analysis results.

[0142] 5. Emotional discrimination

[0143] Here, the combined feature data can be input into a pre-trained text sentiment discriminator to obtain the sentiment classification result of the text feature data. The text sentiment discriminator can include a fully connected layer, which uses a Softmax activation function to output the sentiment classification result of the public opinion text. Exemplarily, the sentiment classification result of the public opinion text can be divided into three categories: positive, negative, and neutral. Therefore, the loss function used by the text sentiment discriminator during model training can be a multivariate cross entropy loss function, as shown below:

[0144]

[0145] Where N is the number of samples included in the training process, M is the total number of classification categories (in this application embodiment, M=3), y ic is the label of the i-th sample, p ic is the probability that the i-th sample is classified as category c.

[0146] It can be understood that the method of this application embodiment extracts deep feature data of multiple perspectives through a deep feature extraction module, extracts common information of multiple perspectives through a shared regression network, and uses a perspective pair collaborative attention mechanism to inject common information into the deep feature data of each perspective to enhance the perspective semantic information; finally, the multi-perspective weighted feature data is combined to obtain feature combination data and input into the text sentiment discriminator, so that it has better performance in the sentiment analysis of public opinion text. Among them, the introduction of a variety of semantic perspective information based on different theories can fully express the semantic information of the text and enhance the semantic expression ability; in addition, on the basis of multi-perspective text semantic information, a convolutional neural network and an attention mechanism are introduced as the downstream network structure of the overall solution, and the feature representation is further enhanced through the interaction between local and contextual features, so that high-order semantic information combining local and long-range information can be extracted; again, on the basis of multi-perspective public opinion text features, a multi-perspective deep feature collaborative learning mechanism is introduced to achieve information gain through information interaction between perspectives, thereby effectively improving the accuracy of sentiment analysis of public opinion text.

[0147] In order to implement the method of the embodiment of the present application, the embodiment of the present application also provides a text sentiment analysis device, which corresponds to the above-mentioned text sentiment analysis method, and each step in the above-mentioned text sentiment analysis method embodiment is also fully applicable to the present text sentiment analysis device embodiment.

[0148] Reference Figure 3 , the text sentiment analysis device includes: an acquisition module 301, a first processing module 302, a second processing module 303, a third processing module 304 and a detection module 305. The acquisition module 301 is used to acquire text feature data to be analyzed; the first processing module 302 is used to generate semantic feature data of at least two perspectives based on the text feature data; the second processing module 303 is used to perform deep feature extraction on the semantic feature data of each perspective respectively to obtain deep feature data of each perspective; the third processing module 304 is used to perform collaborative learning of inter-perspective features based on the deep feature data of each perspective to obtain combined feature data representing multi-perspective weighted deep features; the detection module 305 is used to input the combined feature data into a pre-trained text sentiment discriminator to obtain the sentiment classification result of the text feature data.

[0149] Exemplarily, the first processing module 302 generates semantic feature data of at least two perspectives based on the text feature data, including at least two of the following:

[0150] Generate first semantic feature data based on word frequency and inverse document frequency encoding of the text feature data;

[0151] Generate second semantic feature data based on text vector encoding of the text feature data;

[0152] Generating third semantic feature data for the text feature data based on a pre-trained language model.

[0153] Exemplarily, the second processing module 303 is specifically used for:

[0154] Based on the semantic feature data of each perspective, local depth feature data representing local depth information is obtained based on a convolutional neural network;

[0155] For each of the local depth feature data, long-range dependencies are captured based on a self-attention network to obtain depth feature data of each perspective.

[0156] Exemplarily, the second processing module 303 captures the long-range dependency relationship based on the self-attention network for each of the local depth feature data to obtain the depth feature data of each perspective, including:

[0157] For any of the local depth feature data, a pooling operation is performed on the channel dimension, and a convolution operation is performed on the data after the pooling operation, and the data after the convolution operation is normalized to obtain the depth feature data of the corresponding viewing angle.

[0158] Exemplarily, the third processing module 304 is specifically used for:

[0159] Based on the shared regression network, common features are extracted from the deep feature data of each perspective to obtain shared perspective feature data;

[0160] Based on the shared view feature data, spatial position information is fused with the depth feature data of each view in pairs to obtain cross-view weighted feature data;

[0161] The weighted feature data across each perspective are concatenated to obtain combined feature data representing multi-perspective weighted depth features.

[0162] Exemplarily, the third processing module 304 extracts common features from the depth feature data of each perspective based on the shared regression network to obtain shared perspective feature data, including:

[0163] The deep feature data of each perspective is spliced, and the spliced ​​data is processed by convolution and feature migration in sequence to obtain the initial shared data;

[0164] Performing a regression operation on the initial shared data to obtain high-order local shared data;

[0165] Capturing long-range dependencies of the high-order local shared data based on a self-attention network to obtain deep high-order shared data;

[0166] Based on the initial shared data and the deep high-order shared data, shared viewing angle feature data is obtained.

[0167] Exemplarily, the third processing module 304 performs spatial position information fusion based on the shared view feature data and the depth feature data of each view in pairs to obtain cross-view weighted feature data, including:

[0168] Performing a pooling operation in a spatial dimension and a convolution operation on the data after the pooling operation on the shared viewing angle feature data and the depth feature data of each viewing angle respectively, to obtain spatial position information of the shared viewing angle feature data and spatial position information of the depth feature data of each viewing angle;

[0169] The spatial position information of the shared view feature data is fused with the spatial position information of the depth feature data of each view in pairs to obtain weighted feature data across each view.

[0170] Exemplarily, the acquisition module 301 is specifically used for:

[0171] Obtain text data related to online public opinion;

[0172] The text data is preprocessed to obtain text feature data to be analyzed; wherein the preprocessing includes one or more of the following: word segmentation and stop word filtering.

[0173] In actual application, the acquisition module 301, the first processing module 302, the second processing module 303, the third processing module 304 and the detection module 305 can be implemented by a processor in the electronic device. Of course, the processor needs to run the computer program in the memory to implement its functions.

[0174] It should be noted that: the text sentiment analysis device provided in the above embodiment only uses the division of the above program modules as an example when performing text sentiment analysis. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the text sentiment analysis device provided in the above embodiment and the text sentiment analysis method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0175] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device. Figure 4 Only an exemplary structure of the electronic device is shown, not all structures, and it can be implemented as needed. Figure 4 Partial or complete structure shown.

[0176] like Figure 4 As shown, the electronic device 400 provided in the embodiment of the present application includes: at least one processor 401, a memory 402, a user interface 403 and at least one network interface 404. The various components in the electronic device 400 are coupled together through a bus system 405. It can be understood that the bus system 405 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 405 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, in Figure 4 Various buses are labeled as bus system 405 .

[0177] The user interface 403 may include a display, a keyboard, a mouse, a trackball, a click wheel, keys, buttons, a touch pad or a touch screen.

[0178] The memory 402 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0179] The text sentiment analysis method disclosed in the embodiment of the present application can be applied to the processor 401, or implemented by the processor 401. The processor 401 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the text sentiment analysis method can be completed by the hardware integrated logic circuit in the processor 401 or the instructions in the form of software. The above-mentioned processor 401 can be a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 401 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiment of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 402. The processor 401 reads the information in the memory 402 and completes the steps of the text sentiment analysis method provided in the embodiment of the present application in combination with its hardware.

[0180] In an exemplary embodiment, the electronic device may be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA), general processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned method.

[0181] It can be understood that the memory 402 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), direct memory bus random access memory (DRRAM). The memory described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memory.

[0182] In an exemplary embodiment, the present application also provides a computer storage medium, which can be a computer-readable storage medium, for example, a memory 402 storing a computer program, and the computer program can be executed by a processor 401 of an electronic device to complete the steps described in the method of the present application embodiment. The computer-readable storage medium can be a memory such as a ROM, a PROM, an EPROM, an EEPROM, a Flash Memory, a magnetic surface memory, an optical disk, or a CD-ROM.

[0183] In an exemplary embodiment, the embodiment of the present application further provides a computer program product, including a computer program, which can be executed by the processor 401 of the electronic device 400 to complete the steps described in the method of the embodiment of the present application.

[0184] It should be noted that: "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0185] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.

[0186] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A text sentiment analysis method, characterized in that: include: Obtain text feature data to be analyzed; Generate semantic feature data of at least two perspectives based on the text feature data; Performing deep feature extraction on the semantic feature data of each perspective respectively to obtain deep feature data of each perspective; Based on the deep feature data of each view, collaborative learning of features between views is performed to obtain combined feature data representing multi-view weighted deep features; The combined feature data is input into a pre-trained text sentiment discriminator to obtain a sentiment classification result of the text feature data.

2. The method according to claim 1, characterized in that The generating of semantic feature data of at least two perspectives based on the text feature data includes at least two of the following: Generate first semantic feature data based on word frequency and inverse document frequency encoding of the text feature data; Generate second semantic feature data based on text vector encoding of the text feature data; Generating third semantic feature data for the text feature data based on a pre-trained language model.

3. The method according to claim 1, characterized in that: The extracting of deep features from the semantic feature data of each perspective to obtain the deep feature data of each perspective includes: Based on the semantic feature data of each perspective, local depth feature data representing local depth information is obtained based on a convolutional neural network; For each of the local depth feature data, long-range dependencies are captured based on a self-attention network to obtain depth feature data of each perspective.

4. The method according to claim 3, characterized in that For each of the local depth feature data, capturing long-range dependencies based on the self-attention network to obtain depth feature data of each perspective includes: For any of the local depth feature data, a pooling operation is performed on the channel dimension, and a convolution operation is performed on the data after the pooling operation, and the data after the convolution operation is normalized to obtain the depth feature data of the corresponding viewing angle.

5. The method according to claim 1, characterized in that The collaborative learning of inter-view features based on the depth feature data of each view to obtain combined feature data representing multi-view weighted depth features includes: Based on the shared regression network, common features are extracted from the deep feature data of each perspective to obtain shared perspective feature data; Based on the shared view feature data, spatial position information is fused with the depth feature data of each view in pairs to obtain cross-view weighted feature data; The weighted feature data across each perspective are concatenated to obtain combined feature data representing multi-perspective weighted depth features.

6. The method according to claim 5, characterized in that The common feature extraction of the depth feature data of each perspective based on the shared regression network to obtain shared perspective feature data includes: The deep feature data of each perspective is spliced, and the spliced ​​data is processed by convolution and feature migration in sequence to obtain the initial shared data; Performing a regression operation on the initial shared data to obtain high-order local shared data; Capturing long-range dependencies of the high-order local shared data based on a self-attention network to obtain deep high-order shared data; Based on the initial shared data and the deep high-order shared data, shared viewing angle feature data is obtained.

7. The method according to claim 5, characterized in that The step of fusing the spatial position information based on the shared view feature data with the depth feature data of each view in pairs to obtain cross-view weighted feature data includes: Performing a pooling operation in a spatial dimension and a convolution operation on the data after the pooling operation on the shared viewing angle feature data and the depth feature data of each viewing angle respectively, to obtain spatial position information of the shared viewing angle feature data and spatial position information of the depth feature data of each viewing angle; The spatial position information of the shared view feature data is fused with the spatial position information of the depth feature data of each view in pairs to obtain weighted feature data across each view.

8. The method according to claim 1, characterized in that The obtaining of the text feature data to be analyzed includes: Obtain text data related to online public opinion; The text data is preprocessed to obtain text feature data to be analyzed; wherein the preprocessing includes one or more of the following: word segmentation and stop word filtering.

9. A text sentiment analysis device, characterized in that: The device also includes: An acquisition module, used to acquire text feature data to be analyzed; A first processing module, configured to generate semantic feature data of at least two perspectives based on the text feature data; The second processing module is used to extract the depth feature of the semantic feature data of each perspective respectively to obtain the depth feature data of each perspective; A third processing module is used to perform collaborative learning of features between perspectives based on the depth feature data of each perspective to obtain combined feature data representing multi-perspective weighted depth features; The detection module is used to input the combined feature data into a pre-trained text sentiment discriminator to obtain a sentiment classification result of the text feature data.

10. An electronic device, characterized in that: include: A processor and a memory for storing a computer program that can be executed on the processor, wherein: The processor is used to execute the steps of the method according to any one of claims 1 to 8 when running a computer program.

11. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Text sentiment classification method and device, electronic equipment, medium and product

    CN121681834A