Text sentiment analysis method and device combined with graph regularization

By combining the text sentiment analysis method with regularized graphs, the correlation information between training samples is extracted and the cross-entropy loss function is constructed, which solves the problem of low accuracy of text sentiment classification in social networks, and achieves high accuracy of unstructured text Rate recognition and high recognition rate under a small amount of data are suitable for a variety of application scenarios.

CN119179785AActive Publication Date: 2024-12-24ZHEJIANG LAB

Patent Information

Application Number
CN202411678117.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2024-12-24
Estimated Expiration
2044-11-22

AI Technical Summary

Technical Problem

The prior art has low accuracy in text emotion classification in social networks, especially due to irregular expression methods such as unstructured text, network terms, special symbols and typos, which lead to emotional dictionary being unable to effectively solve the emotional distribution problem, and it is necessary to use machine learning methods. Overfitting occurs when a large amount of training data is performed.

Method used

Using a text sentiment analysis method combined with graph regularization, a cross-entropy loss function is constructed by obtaining the correlation information of the training samples, and a graph regularization term is introduced to minimize the predicted label gap of the associated training samples, and a text sentiment classification model is trained. This method extracts the correlation information between training samples, considers social network environment factors, reduces dependence on large amounts of labeled data, and improves the recognition accuracy.

Benefits of technology

Accurate recognition of unstructured text, improve the accuracy of emotional classification, reduce dependence on training data, avoid overfitting problems, and maintain high recognition rate in a small amount of data, suitable for social media supervision , marketing and financial analysis scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119179785A_ABST
    Figure CN119179785A_ABST
Patent Text Reader

Abstract

The invention relates to a text sentiment analysis method and device combined with graph regularization. The method comprises the steps of obtaining a training sample and a real label of the training sample; extracting association information between the training samples; constructing a cross entropy loss function based on the association information, wherein the cross entropy loss function is used for measuring a gap between a prediction label and a real label of the training sample; on the basis of the cross entropy loss function, a graph regularization item is introduced, and a text sentiment classification model is obtained through training by taking minimization of a gap between prediction tags corresponding to two associated training samples as a training target; and analyzing the to-be-recognized text through the text sentiment classification model, and determining a classification result. Through the method and the device, the problem of insufficient recognition accuracy of emotion classification of texts appearing in a social network in related technologies is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of text recognition, and in particular to a text sentiment analysis method and device combined with graph regularization. Background Art

[0002] In recent years, with the rapid development of Internet technology, many social networks have emerged, becoming an important platform for users to spread information, understand current affairs, and express their opinions. A large number of opinions are flooding in them, and social networks have become a huge resource library, attracting the attention of scholars, enterprises, and governments. For example, companies can use a large amount of data on social networks to understand users' attitudes towards their products and improve their products. By mining the emotions in social networks, emergencies in the network can be detected, providing opportunities for the government to guide public opinion. Faced with the massive and complex texts in social networks, how to perform sentiment analysis on them and provide a data foundation for important applications such as recommendation systems and public opinion guidance has become an important demand.

[0003] Sentiment analysis is a branch of natural language processing, which aims to classify text information into positive, negative, neutral, or emotions such as joy, anger, sadness, and happiness. At present, there are two main methods for sentiment analysis. One is the dictionary-based sentiment analysis method, which assigns different sentiment scores to words in the text through dictionaries such as WordNet and SenticNet, and then obtains the final sentiment category of the text by combining the sentiment scores of all words. However, these methods perform poorly in the sentiment classification of text in social networks. This is because most of the text in social networks is unstructured text, containing a large number of network terms, special symbols, abbreviations, typos and other non-standard expressions. Sentiment dictionaries cannot solve the problem of sentiment assignment of non-standard expressions in text, and cannot handle the problem that the same word has different emotions in different contexts. Another method is the sentiment analysis method based on machine learning. This method maps text into vectors through different feature extraction methods such as word bags and word vectors, and inputs them into machine learning models such as SVM, CNN, LSTM, and Transformer. However, sentiment analysis methods based on machine learning require a large amount of training data, and when there is less training data, overfitting and other phenomena will occur.

[0004] It can be seen that the current sentiment classification of texts appearing in social networks has the problem of insufficient recognition accuracy. Summary of the invention

[0005] The embodiments of the present application provide a text sentiment analysis method and device combined with graph regularization to solve the technical problem of low accuracy in sentiment classification of texts appearing in social networks in the prior art.

[0006] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions: In a first aspect, an embodiment of the present application provides a text sentiment analysis method combined with graph regularization, the method comprising: Obtaining training samples and true labels of the training samples; Extracting association information between the training samples; Constructing a cross entropy loss function based on the association information to measure the gap between the predicted label of the training sample and the true label; On the basis of the cross entropy loss function, a graph regularization term is introduced, and the training goal is to minimize the gap between the predicted labels corresponding to the two associated training samples, so as to obtain a text sentiment classification model through training; The text to be recognized is analyzed by the text sentiment classification model to determine the classification result.

[0007] In combination with the first aspect, in a possible design, the method further includes: obtaining a test sample and a true label of the test sample; After the text sentiment classification model is obtained through training, the method further includes: Using the text sentiment classification model, predicting the sentiment category probability of the test sample; An MSE loss function between the target probability and the emotion category probability is constructed. On the basis of the MSE loss function, a graph regularization term is introduced again, and the text emotion classification model is optimized and tested with the goal of minimizing the gap between the target probabilities of two associated test samples.

[0008] In combination with the first aspect, in a possible design, the optimization test of the text sentiment classification model with the goal of minimizing the gap between the target probabilities of two associated test samples includes: The MSE loss function is represented by a matrix, and the Lagrange multiplier method is applied to the matrixed MSE loss function to obtain a Lagrangian function; The FISTA algorithm is used to optimize the Lagrangian function, and the search point is iteratively updated to obtain an optimized MSE loss function. Based on the model parameters in the optimized MSE loss function, an optimized and tested text sentiment classification model is obtained.

[0009] In combination with the first aspect, in a possible design manner, constructing a cross entropy loss function based on the association information includes: Determining whether the two training samples are associated based on the association information; According to the first gap between the predicted labels corresponding to the two associated training samples being smaller than the first gap between the predicted labels corresponding to the two unassociated training samples, a cross entropy loss function is constructed.

[0010] In combination with the first aspect, in a possible design manner, the extracting the association information between the training samples includes: Extracting comparison results between users corresponding to the training samples; The association information between the training samples is determined according to the comparison result.

[0011] In combination with the first aspect, in a possible design manner, extracting the comparison results between users corresponding to the training samples includes: For any two training samples: determine a comparison result based on whether the two training samples are published by the same user and whether the users corresponding to the two training samples are similar.

[0012] In combination with the first aspect, in a possible design manner, determining the association information between the training samples according to the comparison result includes: If the comparison result indicates that the two users are the same or similar, the association information indicates that there is an association between the two training samples. If the comparison result indicates that the two users are not similar, the association information indicates that there is no association between the two training samples.

[0013] In a second aspect, an embodiment of the present application provides a text sentiment analysis device combined with graph regularization, comprising: A sample acquisition module, used to acquire training samples and true labels of the training samples; A correlation information extraction module, used to extract correlation information between the training samples; A function construction module, used to construct a cross entropy loss function based on the association information, used to measure the gap between the predicted label of the training sample and the true label; A model training module is used to introduce a graph regularization term based on the cross entropy loss function, and to train a text sentiment classification model by minimizing the gap between the predicted labels corresponding to two associated training samples as a training goal; The model application module is used to analyze the text to be identified through the text sentiment classification model to determine the classification result.

[0014] In a third aspect, an embodiment of the present application provides a terminal, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the method of the first aspect and possible design methods thereof.

[0015] In a fourth aspect, an embodiment of the present application provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the method of the first aspect and its possible design manner when running.

[0016] Compared with the prior art, the present invention obtains training samples and the real labels of the training samples; extracts the correlation information between the training samples; constructs a cross entropy loss function based on the correlation information to measure the gap between the predicted labels and the real labels of the training samples; introduces a graph regularization term on the basis of the cross entropy loss function, and takes minimizing the gap between the predicted labels corresponding to two related training samples as the training goal to obtain a text sentiment classification model through training; analyzes the text to be recognized through the text sentiment classification model to determine the classification result. The present application extracts the correlation information between the two training samples, considers the influence of the correlation information on the sentiment analysis during model training, and trains the model with minimizing the gap between the predicted labels corresponding to the related texts as the training goal. Therefore, the trained text sentiment classification model can recognize unstructured texts, and can achieve a high recognition accuracy without relying on a large number of samples, thereby solving the problem of insufficient recognition accuracy in the current sentiment classification of texts.

[0017] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 A hardware structure block diagram of a terminal provided in an embodiment of the present application is shown; Figure 2 A flowchart of a text sentiment analysis method combined with graph regularization provided in an embodiment of the present application is shown; Figure 3 A flowchart of a method for testing a text sentiment classification model provided in an embodiment of the present application is shown; Figure 4 A schematic diagram of a microblog sentiment analysis system combined with graph regularization provided in an embodiment of the present application is shown; Figure 5 A flowchart of a service execution method based on emotion classification provided by an embodiment of the present application is shown; Figure 6 A flowchart of a method for extracting association relationships provided by an embodiment of the present application is shown; Figure 7A schematic diagram of a text sentiment analysis method combined with graph regularization provided in an embodiment of the present application is shown; Figure 8 A structural block diagram of a text sentiment analysis device combined with graph regularization provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0019] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0020] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with general skills in the technical field to which this application belongs. The words "one", "a", "the", "these" and the like in this application do not indicate a quantitative limitation, and they may be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" may mean: A exists alone, A and B exist at the same time, and B exists alone. Generally, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0021] Sentiment analysis technology stems from the demand for efficient use of massive texts and technological progress. With the rapid development of Internet technology, social networks have become a huge resource library. Mining the emotions in social networks provides a data foundation for important applications such as recommendation systems and public opinion guidance. Most of the texts appearing in social networks are unstructured texts, containing a large number of network terms, special symbols, abbreviations, typos, and other irregularities. This leads to the problem of low recognition accuracy whether it is through sentiment dictionary recognition or machine learning recognition.

[0022] Social networks have their own unique environmental factors. For example, if the texts posted by one user tend to be consistent in sentiment, the texts posted by similar users tend to be consistent in sentiment. However, related technologies ignore the impact of social network environmental factors on text sentiment, resulting in poor sentiment analysis results.

[0023] In view of this, an embodiment of the present application provides a text sentiment analysis method combined with graph regularization. By extracting the correlation information between training samples, a text sentiment classification model is trained with the goal that the predicted labels corresponding to two related training samples should be consistent. In this way, the identified sentiment classification is more accurate, and the data analysis based on the classification results is more effective.

[0024] This method can be applied to social media regulation, such as companies and governments can use this method to detect public sentiment on social media and respond to social hot spots and crisis events in a timely manner. This method can also be applied to marketing, such as companies use this method to analyze consumers' emotional reactions to marketing activities to optimize advertising and promotion strategies. This method can also be applied to sentiment analysis of competitors' social media activities to gain market competitive advantages. In addition, this method can also be applied to financial analysis, such as financial institutions can analyze sentiment on social media about stocks, currencies or other financial products to assist investment decisions. When the classification accuracy of text sentiment is high, the effect of applying it to the above scenarios is better.

[0025] The method can be executed in a terminal, a computer or a similar test system. Taking running on a terminal as an example, Figure 1 FIG. 1 shows a hardware structure block diagram of a terminal provided in an embodiment of the present application. Figure 1 As shown, the terminal may include one or more ( Figure 1 The terminal may further include a transmission device 106 and an input / output device 108 for communication functions. It will be appreciated by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0026] The memory 104 can be used to store computer programs, for example, software programs and modules of application software. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, that is, the above-mentioned method is realized. The memory 104 can be used to store data, for example, training samples, true labels, etc. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0027] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0028] Figure 2 A flowchart of a text sentiment analysis method combined with graph regularization provided in an embodiment of the present application is shown. Figure 2 As shown, the method includes steps S201 to S205.

[0029] Step S201: Obtain training samples and true labels of the training samples.

[0030] Among them, the training samples can be pre-processed texts. Specifically, the training samples are generated by converting the original text symbols into English symbols, removing URL information, filtering out connection symbols and user names from Weibo, removing words such as "reply", "forward Weibo" and forwarded content, etc.

[0031] Among them, the real label can be an emotion category marked manually or automatically, such as sad, happy, excited, calm, etc. These emotion categories can be represented by characters, such as sad corresponds to the number 1, happy corresponds to the number 2, excited corresponds to the number 3, and calm corresponds to the number 4.

[0032] The training samples and true labels obtained in step S201 are used to train the model to obtain a text sentiment classification model that can identify classification results based on a text. The specific training process can be referred to the following description.

[0033] Step S202: extract association information between training samples.

[0034] The association information between training samples refers to the set of association information between any two training samples in all training samples.

[0035] This step uses the sentiment labels corresponding to the associated texts to train the model so that it can learn richer features, such as those subtle sentiment differences that are difficult to extract directly from a single text, to strengthen feature learning. Not only that, by effectively utilizing the correlation between texts and borrowing label information between associated texts, the reliance on a large amount of labeled data can be reduced. In other words, sentiment analysis methods based on machine learning require a large amount of training data, and when there is less training data, overfitting and other phenomena will occur. This step helps to reduce the annotation cost by extracting the correlation information between training samples, and there will be no overfitting problem, so the recognition accuracy of the trained model is high. In addition, when the number of samples of different emotion categories is unbalanced, the distribution of emotion labels can be balanced during the training process by extracting the correlation between training samples, thereby enhancing the model's recognition ability for a few categories and improving the model's generalization ability.

[0036] The following is a further explanation of the method of extracting related information. When training the model, the impact of related information on sentiment analysis is considered: if there is related information between two training samples, the sentiment labels predicted by the model tend to be similar. Based on this, the related information between the training samples is represented, such as manual or automatic labeling. If there is a correlation between the two training samples, it is labeled as 1, and if there is no correlation between the two training samples, it is labeled as 0.

[0037] Specifically, the extracting of association information between one of the training samples and another of the training samples includes: extracting a comparison result between a user corresponding to one of the training samples and a user corresponding to another of the training samples; and determining association information between the two training samples according to the comparison result. For example, the comparison result between users includes the same user, similar users, and users in the same social organization (such as family members, students, office workers), etc.

[0038] In some of the embodiments, based on the emotion consistency theory, whether two training samples are related is determined by whether they are posted by the same user, and the emotion labels of two related training samples tend to be consistent.

[0039] Specifically, if two training samples are published by the same user, it is determined that there is a correlation between the two training samples, so the sentiment labels of the training samples published by the same user tend to be consistent; conversely, if the two training samples are published by different users, it is determined that there is no correlation between the two training samples.

[0040] More specifically, the training samples come from social platforms. Therefore, the user emotions corresponding to the training samples posted by the same user collected in a short period of time tend to be consistent. For example, a user posts multiple Weibo posts about an event on a certain day. Each Weibo post is equivalent to a training sample. The correlation of these training samples comes from the fact that they are posted by the same user. The emotions of the user when posting these Weibo posts tend to be consistent, so the emotional labels corresponding to these Weibo posts tend to be consistent.

[0041] In other embodiments, based on the theory of emotional contagion, whether two training samples are related is determined by whether they are posted by similar users, and the emotional labels of two related training samples tend to be consistent.

[0042] Specifically, if two training samples are published by similar users, it is determined that there is a correlation between the two training samples, so the sentiment labels of the training samples published by similar users tend to be consistent; conversely, if the two training samples are published by dissimilar users, it is determined that there is no correlation between the two training samples.

[0043] More specifically, social platforms have their own unique environmental factors, that is, a group of people will post similar opinions on the same event or hot topic. For example, two students in the same class posted a Weibo about tutoring on the same day on the Weibo platform. These two Weibo posts are equivalent to two training samples. Since the two students in the same class are similar, and the correlation between these two training samples comes from the fact that they are posted by similar users, and the emotions of similar users when posting Weibo posts tend to be consistent, then the emotional labels corresponding to these Weibo posts tend to be consistent.

[0044] In some embodiments, a user relationship matrix can be established to represent the comparison results between users, and the training model can be used to achieve: if the comparison result represents that the two users are the same or the two users are similar, then the association information represents that there is a relationship between the two training samples; if the comparison result represents that the two users are not similar, then the association information represents that there is no relationship between the two training samples. The model trained in this way borrows the label information of the texts posted by similar or the same users, and can maintain a high recognition rate with a small amount of annotated data, thereby reducing the dependence on the number and distribution of annotated data, and the model performance will be better.

[0045] It should be noted that the above example of microblogs published within one day is only an exemplary description. In practice, the collection time can be one hour, one minute, six hours, half a month, one month, etc. Text (including input samples, test samples, and real-time text data) can be collected from social networks such as Weibo platforms and Twitter platforms, and this application does not limit this.

[0046] Step S203: construct a cross entropy loss function based on the association information to measure the gap between the predicted label and the true label of the training sample.

[0047] The true label refers to the annotated emotion category, and the predicted label refers to the probability of the training samples recognized by the model under each emotion category. For example, the predicted label of a text emotion recognized by the model is: sad 70%, happy 10%, excited and happy 10%, calm 10%.

[0048] It can be understood that the smaller the gap between the predicted label and the true label, the closer the model's prediction is to the true label, and vice versa, the larger the gap between the predicted label and the true label, the closer the model's prediction is to the true label. During the training process, by minimizing the cross entropy loss, the model parameters are continuously adjusted to enable the model to better fit the training data.

[0049] Step S204: Based on the cross entropy loss function, a graph regularization term is introduced, and the training goal is to minimize the gap between the predicted labels corresponding to two associated training samples, so as to obtain a text sentiment classification model through training.

[0050] Part of the cross entropy loss function is the gap between the predicted labels corresponding to two related training samples, so minimizing the cross entropy loss function can be seen as minimizing the gap between the predicted labels corresponding to two related training samples. As mentioned above, the impact of associated information on sentiment analysis is considered during model training: if there is associated information between two training samples, the sentiment labels predicted by the model tend to be similar, so in this step, the model is trained with the goal of minimizing the gap between the predicted labels corresponding to the related texts, so that the trained model can maintain a high recognition accuracy when the number of samples is insufficient or the number of samples is biased.

[0051] Among them, on the basis of the cross entropy loss function, introducing the graph regularization term means that the cross entropy loss function used to train the model includes the graph regularization term. For the construction method of the cross entropy loss function, please refer to the description of step S505 below.

[0052] Step S205: Analyze the text to be recognized through the text sentiment classification model to determine the classification result.

[0053] The classification result refers to the probability of the training samples recognized by the model in each emotion category. For example, the model recognizes the predicted labels of a text emotion as: sad 70%, happy 10%, excited and happy 10%, and calm 10%.

[0054] The trained text sentiment classification model has a good recognition accuracy, and the classification result obtained by sentiment classification of the text to be recognized is closer to the real label of the text.

[0055] In the embodiment recorded in the above steps S201 to S205, by obtaining training samples and the real labels of the training samples; extracting the correlation information between the training samples; constructing a cross entropy loss function based on the correlation information to measure the gap between the predicted labels and the real labels of the training samples; on the basis of the cross entropy loss function, introducing a graph regularization term, and taking minimizing the gap between the predicted labels corresponding to two related training samples as the training goal, training to obtain a text sentiment classification model; analyzing the text to be recognized by the text sentiment classification model to determine the classification result. The present application extracts the correlation information between the two training samples, and considers the influence of the correlation information on the sentiment analysis during model training, and trains the model with minimizing the gap between the predicted labels corresponding to the related texts as the training goal. Therefore, the trained text sentiment classification model can recognize unstructured texts, and can achieve a high recognition accuracy without relying on a large number of samples, which solves the problem of insufficient recognition accuracy in the current sentiment classification of texts.

[0056] In some of the embodiments, a test sample and a true label of the test sample are also obtained. After the above step S204, the text sentiment classification model is tested based on the test sample to further improve the recognition accuracy of the text sentiment classification model. Figure 3 A flowchart of a method for testing a text sentiment classification model provided by an embodiment of the present application is shown. Figure 3 As shown, the method includes step S301 and step S302.

[0057] Step S301: Use the text sentiment analysis model to predict the sentiment category probability of the test sample.

[0058] Step S302: construct an MSE loss function between the target probability and the emotion category probability. Based on the MSE loss function, introduce the graph regularization term again, and optimize the text emotion classification model with the goal of minimizing the gap between the target probabilities of two related test samples.

[0059] Among them, the MSE loss function is used to characterize the sum of the first distance and the second distance. The first distance refers to the difference between the predicted label output by each test sample in the test phase and the predicted label output in the training phase. The second distance refers to the difference between the predicted labels corresponding to two related test samples.

[0060] Specifically, the impact of the correlation information between texts on the sentiment analysis results is also considered in the test phase. Specifically, if there is a correlation between two texts, the predicted labels output by the text sentiment classification model should be similar. Therefore, the sum of the first distance and the second distance is minimized as the optimization goal to further optimize the model parameters of the text sentiment classification model, so that the recognition results of the text sentiment classification model after the test optimization are more accurate.

[0061] It is understandable that in the related art, minimizing the first distance is often used as the optimization goal, that is, when the gap between the predicted label output by each test sample in the test phase and the predicted label output in the training phase is small, the model optimization is considered to be completed, which is not accurate enough for sentiment classification of texts in social networks. This embodiment considers the impact of the association information between texts on the sentiment analysis results, introduces the second distance into the MSE loss function, and minimizes the sum of the first distance and the second distance as the optimization goal, so that the model obtained by the optimization test can still maintain high accuracy and generalization when the number of samples is small and the distribution is uneven.

[0062] In some of the embodiments, the second distance in the above step S301 is represented by a quadratic loss function with a first weight and a regularization term with a second weight; step S302 further includes: optimizing the MSE loss function with a regularization term based on the FISTA algorithm, with the goal of minimizing the regularization term in the MSE loss function, to obtain an optimized MSE loss function; based on the optimized MSE loss function, testing the text sentiment classification model.

[0063] Specifically, the MSE loss function is represented by a matrix, and the Lagrangian multiplier method is applied to the matrixed MSE loss function to obtain the Lagrangian function; the FISTA algorithm is used to optimize the Lagrangian function, and the search point is iteratively updated to obtain the optimized MSE loss function.

[0064] In this embodiment, the MSE loss function is optimized by the FISTA algorithm. FISTA uses the previous iteration results in each iteration, so that the convergence to the optimal solution is faster, thereby significantly improving the convergence speed. In addition, in each iteration, FISTA forces certain coefficients to be zero through a thresholding step, thereby directly achieving a sparse solution, that is, reducing unnecessary features and improving the generalization ability of the model to unseen data, thereby avoiding overfitting of the trained model and improving the recognition accuracy of the model.

[0065] The following uses a microblog as an example to further illustrate the method of the embodiment of the present application. Figure 4 A schematic diagram of a microblog sentiment analysis system combined with graph regularization provided in an embodiment of the present application is shown. Figure 4 As shown, including: The text preprocessing module 41 preprocesses the collected original microblogs to obtain microblog samples (hereinafter referred to as microblogs). For the preprocessing steps, please refer to the description of step S201 above.

[0066] The microblog association extraction module 42 calculates the microblog association information from the user microblog relationship matrix and the user relationship matrix through the emotion consistency and emotion contagion theory. For the steps of extracting the association information, please refer to the description of step S202 above.

[0067] Model training module 43 based on graph regularization: Combined with the text content of microblogs, the model optimization target is regularized by utilizing the fact that related microblogs tend to have the same sentiment labels, and the model is trained. For the process of training the model, please refer to the description of steps S203 to S204 above.

[0068] Model testing module 44 based on graph regularization: during testing, the correlation between test data is considered to further optimize the test set sentiment labels output by the model. For the test steps, please refer to the description of steps S301 to S302 above.

[0069] The above is a brief description of the analysis system. The following will continue to describe and illustrate the method of using the analysis system to perform sentiment analysis using Weibo as an example.

[0070] Figure 5 A flowchart of a service execution method based on emotion classification provided by an embodiment of the present application is shown. Figure 5 As shown, the method includes: Step S501: pre-process the microblog.

[0071] Among them, the preprocessed data set is expressed as X dataset , and the sentiment label corresponding to the dataset is represented as Y dataset , No. i The preprocessed data corresponding to the text is x i , No. i The sentiment label corresponding to the text is expressed as y i .

[0072] Extract the preprocessed microblog text features, expressed asF dataset , No. i The feature representation of the text extraction is f i .

[0073] Step S502: extracting correlation information between microblogs.

[0074] Among them, the correlation information is expressed in the matrix C express, C ij = 1 means if and only if i The text of Article j There is a relationship between the texts. Figure 6 A flowchart of a method for extracting association relationships provided by an embodiment of the present application is shown. Figure 6 , step S502 may further include: S502a. Extract correlation relationships based on the emotion consistency theory in sociology.

[0075] Specifically, if two microblogs are posted by the same user on the same topic, then the sentiment labels of the two microblogs are more likely to be consistent. Assume that the user microblog relationship matrix is U , the microblog relationship matrix is ​​obtained from the emotion consistency theory C sc = U T U , If and only if i The text of Article j The texts were posted by the same user.

[0076] S502b. Extract correlation relationships based on the emotional contagion theory in sociology.

[0077] Specifically, if two microblogs are posted by similar users on the same topic, the sentiment labels of the two microblogs are more likely to be consistent. Assume that the user microblog relationship matrix is U , the user relationship matrix is F , the matrix is ​​obtained from the emotional contagion theory C ec =U T FU , If and only if i The text of Article j Posts were posted by similar users.

[0078] S502c, combining the emotion consistency theory and the emotion contagion theory to obtain the microblog related information matrix.

[0079] The microblog related information matrix is ​​calculated based on the theory of emotional consistency and emotional contagion, that is, C=C ec +C sc .

[0080] The extraction of correlation relationships is described above. After the correlation relationships are obtained, the influence of the correlation relationships on sentiment analysis is considered during model training. Specifically, if two microblogs are correlated, the sentiment labels predicted by the machine model should be similar, so modeling is performed. Please refer to the following description for details.

[0081] S503: construct a model based on the association information matrix.

[0082] The optimization goals of building a relational model are: ,in represents the sentiment label predicted by the machine, c Indicates the category of the sentiment label.

[0083] S504: Modeling based on microblog content.

[0084] S505: Train a text sentiment analysis model by combining the relationship model and the microblog content model.

[0085] Specifically, the objective function of the model is: in, α represents the weight of graph regularization, N Indicates the number of microblogs. θ Parameters representing the machine model S506. Test the text sentiment analysis model by combining the relationship model and the microblog content model.

[0086] Similar to step S503, if there is correlation information between the two microblogs, the sentiment tags predicted by the model should be similar. The optimization goal of this process is: In the testing phase, in order to simultaneously utilize text content information, a linear optimizer is constructed. The optimization goal of this process is: in, α , β represents the weights of different graph regularizations, represents the final output sentiment label of the test phase, The sentiment label predicted by the machine refers to the sentiment label obtained by testing only the model obtained in the training phase.

[0087] S507. Optimize model test results.

[0088] Specifically, this step is used to optimize the function proposed in S506 by using the FISTA algorithm, and specifically includes the following steps: The function mentioned in S506 is expressed in matrix form, and we get: in, , N nz Represents the microblog relationship matrix C The number of non-zero elements in . Assume C ij Non-zero, and in C If it ranks nth among all elements of A ni =C ij , A nj =﹣C ij , A All other elements in the nth row of are 0.

[0089] Then transform the matrix function to get: Applying the Lagrange multiplier method to the transformed function gives the Lagrange function: in, μ is the Lagrange multiplier vector, ρ is a positive penalty factor.

[0090] Furthermore, in order to improve the optimization speed, the Lagrangian function is split into f(z) and g(z) Two parts, including: The function becomes min z f(z)+g(z) .

[0091] Then the FISTA algorithm is used to optimize the function and iteratively update the search point: w k+1 =z k +θ k (z k -z k-1) in, θ k Represents the linear combination coefficients in the iterative process. Approximate search point z By formula Update, 1 / L k >0 Represents the step size of gradient descent, and we get: because , the approximate search point can be transformed into: .

[0092] Gradient descent step size 1 / L k By satisfying the following formula: To choose.

[0093] Then pass renew v t ,in S is the soft threshold function.

[0094] Finally passed u t =u t-1 +AX t -v t renew u t .

[0095] The embodiment of the present application provides a method for sentiment analysis by combining graph regularization and correlation between microblogs. The method improves the effect of sentiment analysis on microblogs by improving the model training and testing stages by utilizing the correlation information of microblogs. At the same time, the optimization of the regularization term by the FISTA algorithm improves the iteration speed, accelerates convergence and increases the generalization of the model.

[0096] Continue to refer Figure 4 The above-mentioned text preprocessing module 41 is used to execute the above-mentioned step S501.

[0097] The microblog association relationship extraction module 42 is used to execute the above step S502.

[0098] The above-mentioned graph regularization-based model training module 43 is used to execute the above steps S503 to S505.

[0099] The above-mentioned graph regularization-based model testing module 44 is used to execute the above steps S506 to S507.

[0100] Figure 7 A schematic diagram of a text sentiment analysis method combined with graph regularization provided in an embodiment of the present application is shown, Figure 7 As shown, the method provided in the embodiment of the present application preprocesses text features and extracts microblog text relationships, models microblog text relationships, inputs text features and text relationships into sentiment classifier training, tests the sentiment classifier with the text to be tested, and then optimizes the test results based on the text relationships, and finally outputs the sentiment analysis results. Through this method, the problem of insufficient recognition accuracy in sentiment classification of texts appearing in social networks is solved.

[0101] The present application also provides a text sentiment analysis device combined with graph regularization in an embodiment, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. The terms "module", "unit", "sub-unit", etc. used below may implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation in hardware, or a combination of software and hardware, is also possible and conceivable.

[0102] Figure 8 A structural block diagram of a text sentiment analysis device combined with graph regularization provided in an embodiment of the present application is shown. Figure 8 As shown, the device comprises: The sample acquisition module 81 is used to acquire training samples and true labels of the training samples.

[0103] The correlation information extraction module 82 is used to extract the correlation information between training samples.

[0104] The function construction module 83 is used to construct a cross entropy loss function based on the association information, which is used to measure the gap between the predicted label and the true label of the training sample.

[0105] The model training module 84 is used to introduce a graph regularization term based on the cross entropy loss function, and to train a text sentiment classification model by minimizing the gap between the predicted labels corresponding to two associated training samples as the training goal.

[0106] The model application module 85 is used to analyze the text to be recognized through the text sentiment classification model to determine the classification result.

[0107] In some embodiments, the association information extraction module 82 is also used to determine whether two training samples are associated based on the association information; and construct a cross entropy loss function based on the first gap between the predicted labels corresponding to the two associated training samples being smaller than the first gap between the predicted labels corresponding to the two unassociated training samples.

[0108] In some embodiments, the association information extraction module 82 is further used to extract the comparison results between users corresponding to the training samples; and determine the association information between the training samples according to the comparison results.

[0109] In some embodiments, the associated information extraction module 82 is further used to determine the comparison result according to whether the two training samples are posted by the same user and whether the users corresponding to the two training samples are similar.

[0110] In some embodiments, the association information extraction module 82 is also used to, if the comparison result indicates that the two users are the same or the two users are similar, then the association information indicates that there is an association between the two training samples; if the comparison result indicates that the two users are not similar, then the association information indicates that there is no association between the two training samples.

[0111] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0112] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0113] In this embodiment, an electronic device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0114] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0115] Optionally, in this embodiment, the processor may be configured to execute the following steps S1 to S5 through a computer program.

[0116] S1. Obtain training samples and the true labels corresponding to the training samples.

[0117] S2. Extract the correlation information between training samples.

[0118] S3. Construct a cross entropy loss function based on the association information to measure the gap between the predicted label and the true label of the training sample.

[0119] S4. Based on the cross entropy loss function, a graph regularization term is introduced, and the training goal is to minimize the gap between the predicted labels corresponding to two related training samples, and the text sentiment classification model is trained.

[0120] S5. Analyze the text to be identified through the text sentiment classification model to determine the classification result.

[0121] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.

[0122] In addition, in combination with the method provided in the above embodiment, a storage medium may be provided in this embodiment to implement the method. The storage medium stores a computer program; when the computer program is executed by a processor, any one of the text sentiment analysis methods combined with graph regularization in the above embodiment is implemented.

[0123] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer executes each function or step executed by the processor in the above method embodiment.

[0124] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.

[0125] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.

[0126] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.

[0127] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.

Claims

1. A text sentiment analysis method combined with graph regularization, characterized in that: The method comprises: Obtaining training samples and true labels of the training samples; Extracting association information between the training samples; Constructing a cross entropy loss function based on the association information to measure the gap between the predicted label of the training sample and the true label; On the basis of the cross entropy loss function, a graph regularization term is introduced, and the training goal is to minimize the gap between the predicted labels corresponding to the two associated training samples, so as to obtain a text sentiment classification model through training; The text to be recognized is analyzed by the text sentiment classification model to determine the classification result.

2. The text sentiment analysis method combined with graph regularization according to claim 1, characterized in that: The method further includes: obtaining a test sample and a true label of the test sample; After the text sentiment classification model is obtained through training, the method further includes: Using the text sentiment classification model, predicting the sentiment category probability of the test sample; An MSE loss function between the target probability and the emotion category probability is constructed. On the basis of the MSE loss function, a graph regularization term is introduced again, and the text emotion classification model is optimized and tested with the goal of minimizing the gap between the target probabilities of two associated test samples.

3. The text sentiment analysis method combined with graph regularization according to claim 2, characterized in that: The optimization test of the text sentiment classification model is performed with the goal of minimizing the gap between the target probabilities of two associated test samples, including: The MSE loss function is represented by a matrix, and the Lagrange multiplier method is applied to the matrixed MSE loss function to obtain a Lagrangian function; The FISTA algorithm is used to optimize the Lagrangian function, and the search point is iteratively updated to obtain an optimized MSE loss function. Based on the model parameters in the optimized MSE loss function, an optimized and tested text sentiment classification model is obtained.

4. The text sentiment analysis method combined with graph regularization according to claim 1, characterized in that: The constructing a cross entropy loss function based on the association information includes: Determining whether the two training samples are associated based on the association information; According to the first gap between the predicted labels corresponding to the two associated training samples being smaller than the first gap between the predicted labels corresponding to the two unassociated training samples, a cross entropy loss function is constructed.

5. The text sentiment analysis method combined with graph regularization according to any one of claims 1 to 4, characterized in that: The extracting the association information between the training samples includes: Extracting comparison results between users corresponding to the training samples; The association information between the training samples is determined according to the comparison result.

6. The text sentiment analysis method combined with graph regularization according to claim 5, characterized in that: The extracting the comparison results between users corresponding to the training samples includes: For any two training samples: determine a comparison result based on whether the two training samples are published by the same user and whether the users corresponding to the two training samples are similar.

7. The text sentiment analysis method combined with graph regularization according to claim 5, characterized in that: The determining the association information between the training samples according to the comparison result includes: If the comparison result indicates that the two users are the same or similar, the association information indicates that there is an association between the two training samples. If the comparison result indicates that the two users are not similar, the association information indicates that there is no association between the two training samples.

8. A text sentiment analysis device combined with graph regularization, characterized in that: include: A sample acquisition module, used to acquire training samples and true labels of the training samples; A correlation information extraction module, used to extract correlation information between the training samples; A function construction module, used to construct a cross entropy loss function based on the association information, used to measure the gap between the predicted label of the training sample and the true label; A model training module is used to introduce a graph regularization term based on the cross entropy loss function, and to train a text sentiment classification model by minimizing the gap between the predicted labels corresponding to two associated training samples as a training goal; The model application module is used to analyze the text to be identified through the text sentiment classification model to determine the classification result.

9. A terminal comprising a memory, a processor and a display screen, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the text sentiment analysis method combined with graph regularization according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the text sentiment analysis method combined with graph regularization according to any one of claims 1 to 7 when running.

Citation Information

Patent Citations

  • Emotion data classifying method and system

    CN104199829A

  • Text sentiment analysis method and system

    CN111324739A

  • Social media text denoising method based on space-time burst features

    CN113822048A

  • Text data analysis method and device, model training method and device and computer equipment

    CN114386436A

  • Multi-class sentiment classification method and device and computer storage medium

    CN114706986A

Cited By

  • Picture author affiliation analysis method and device, electronic equipment and storage medium

    CN121350247A