A method and system for analyzing sentiment tendency of social text based on heterogeneous graph

By constructing heterogeneous graphs and combining deep learning models, semantic representation vectors of words and expressions in social texts are extracted, which solves the problem of emotional tendency in the prior art that it is difficult to analyze social texts containing expressions, and achieves high-precision emotion analysis.

CN113343712BActive Publication Date: 2025-03-14ANHUI UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110730515.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-29
Publication Date
2025-03-14
Estimated Expiration
2041-06-29

AI Technical Summary

Technical Problem

It is difficult for the prior art to effectively utilize heterogeneous graphs and deep learning models for emotional tendency analysis of social texts, especially when processing texts containing expressions.

Method used

By constructing heterogeneous graphs, semantic representation vectors of words and expressions are extracted using metapathic paths and embedding techniques, and sentiment analysis is performed in combination with attention mechanisms and BiLSTM network.

Benefits of technology

It improves the accuracy of sentiment analysis in social text, can deeply explore the inner connection between expressions and text, and enhances the performance of sentiment analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113343712B_ABST
    Figure CN113343712B_ABST
Patent Text Reader

Abstract

A social text sentiment tendency analysis method and system based on heterogeneous graph, belonging to the field of data processing technology, the technical problem to be solved is how to use heterogeneous graph and combine with deep learning model to perform sentiment tendency analysis of social text; based on the co-occurrence information of words and expressions in social text, meta-paths and heterogeneous graphs are constructed by exchanging matrices of each meta-path, and semantic representation vectors containing the intrinsic connection between words and expressions are obtained by using adjacency matrix, and finally the sentiment semantic vectors are analyzed by attention mechanism and BiLSTM network to obtain high-precision sentiment tendency labels; the present invention comprehensively considers the expression of emotion by expression and text, deeply mines the intrinsic connection between expression and text, and improves the performance of sentiment analysis; in data processing, the expression and important punctuation marks in the text are retained, and the sentiment information contained in the text content is improved; the present invention can obtain richer semantic information and make the sentiment analysis result more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data processing and relates to a method and system for analyzing sentiment tendency of social text based on heterogeneous graphs. Background Art

[0002] Emotions are part of people's lives. Everyone has different emotional states at different times and when facing different things. However, emotional states can reflect a person's psychological state changes and can affect a person's various behaviors. In the past two decades, researchers have been trying to analyze people's emotional states more accurately.

[0003] With the development of social networks, people can not only communicate in real life, but also express their opinions and views on the Internet, the most common of which is text content. People express their thoughts and emotions through comments and posts. The mutual communication, emotional expression and public opinion of people on the Internet will affect the development of a certain event or product in reality. Based on the relevant user comments on the Internet, sentiment analysis of texts and giving corresponding sentiment labels have become a research hotspot in recent years.

[0004] In the prior art, the Chinese invention patent application "A Text Sentiment Analysis Method and System" with publication number CN111324739A and publication date June 23, 2020 discloses a text sentiment analysis method, including: obtaining a text to be analyzed and at least one entity to be analyzed; using an analysis model to process the text to be analyzed and the entity to be analyzed to obtain the sentiment of the text to be analyzed facing the entity to be analyzed; wherein the analysis model includes a graph neural network model and a judgment model, and the processing of the analysis model includes: based on the graph neural network model, the relationship between the entity to be analyzed and its associated entity, and the vector of the entity to be analyzed, obtaining a fusion vector of the entity to be analyzed; the judgment model determines the sentiment of the text to be analyzed facing the entity to be analyzed based on the vector of the text to be analyzed and the fusion vector of the entity to be analyzed.

[0005] In recent years, the emerging emoji (expression) has become popular in social networks, and people have begun to like using emoji to express their attitudes and emotions. Emoji is simple, vivid, and has rich emotional semantics, which makes it popular among users. However, expressions have rich emotions, and when combined with content of different emotional polarities, they will reflect different emotional semantics, making it difficult to give expressions a definite semantic emotion. Therefore, most of the existing sentiment analysis is based on pure text comments, and there is relatively little research on text containing expressions. However, expressions are extremely strong in expressing emotions, and emotional expression in social networks is inseparable from the use of expressions.

[0006] Heterogeneous graphs are graphs containing multiple types of nodes and relationships. Compared with homogeneous graphs containing only one type of node / relationship, heterogeneous graphs are more complex and contain more information. The emergence of heterogeneous graphs can more deeply explore the relationship between expressions and text words, and can more accurately analyze the emotions expressed by expressions in different texts. Considering expressions and words as heterogeneous nodes, meta-paths are constructed. The embedding technology of heterogeneous graphs depends on meta-paths, which are widely used structures to capture the semantics of different heterogeneous nodes. Common heterogeneous graph embedding methods include metapath2vec, HERec, and Han. Metapath2vec performs random walks based on meta-paths and learns the potential representation of nodes through the skip-gram model; inspired by metapath2vec, HERec uses some symmetric meta-paths to filter node sequences through a type restriction strategy to capture the semantic information of heterogeneous graphs; HAN applies graph neural networks to heterogeneous graphs and uses semantic-level attention and node-level attention to simultaneously learn the importance of meta-paths and node neighbors. However, in sentiment analysis, no one has introduced heterogeneous graphs and combined them with relevant deep learning models for sentiment analysis. Summary of the invention

[0007] The technical problem to be solved by the present invention is how to use heterogeneous graphs in combination with deep learning models to perform sentiment analysis of social texts.

[0008] The present invention solves the above technical problems through the following technical solutions:

[0009] A social text sentiment tendency analysis method based on heterogeneous graph includes the following steps:

[0010] S1. Determine the basic information of the information collection object, and collect, clean and sentimentally annotate its related social text content;

[0011] S2. Based on the co-occurrence information of words and expressions in social texts, meta-paths containing different semantic relationships are constructed. By using the exchange matrix of each meta-path as the adjacency matrix, words and expressions respectively constitute heterogeneous graphs;

[0012] S3, based on the trained Word2Vec dictionary, embed the cleaned and segmented words and expressions into vectors;

[0013] S4, retraining the embedding vector based on the meta-path information of the constructed heterogeneous graph to obtain the final embedding vector;

[0014] S5. Use the updated embedding vector based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network to obtain the sentiment semantic label and the trained sentiment analysis model;

[0015] S6. Input the text data to be tested into the trained sentiment model and output the final sentiment classification result.

[0016] The present invention is based on the co-occurrence information of words and expressions in social texts. It constructs meta-paths and heterogeneous graphs through the exchange matrices of each meta-path, uses the adjacency matrix to obtain semantic representation vectors containing the intrinsic connections between words and expressions, and finally analyzes the sentiment semantic vectors through the attention mechanism and BiLSTM network to obtain highly accurate sentiment tendency labels. The present invention comprehensively considers the expression of emotions by expressions and texts, and deeply explores the intrinsic connections between expressions and texts to improve the performance of sentiment analysis. In data processing, the expressions and important punctuation marks in the text are retained to improve the emotional information contained in the text content.

[0017] As a further improvement of the technical solution of the present invention, the form of the co-occurrence information of words and expressions in step S2 includes: word-word, word-expression and expression-expression; constructing A of |W|×|W| according to the word-word co-occurrence information WW Matrix, where |W| is the total number of words in the text data, and for the number of co-occurring words n, in A WW The corresponding position in the matrix is ​​set to n; construct A of |W|×|E| based on the word-expression co-occurrence information WE matrix, where |E| is the total number of expressions in the text data, and for the number of co-occurring words and expressions n, in A WE The corresponding position in the matrix is ​​n; construct A of |E|×|E| based on the expression-expression co-occurrence information EE Matrix, for co-occurring expressions-expression times n, in A EE The corresponding position in the matrix is ​​n;

[0018] The meta-paths containing different semantic relations are constructed as follows: 1 :WWW means that two words have co-occurred with the same word; meta-path P 2 :WEW: indicates that two words have co-occurred with the same expression; meta-path P 3 :EWE:indicates that two expressions have co-occurred with the same word; meta-path P 4 :EEE: indicates that two expressions have co-occurred with the same expression;

[0019] The calculation formula of the switching matrix of each element path is:

[0020] W P1 =A WW A WW

[0021] W P2 =AWE A WE T

[0022] W P3 =A EE A EE

[0023] W P4 =A WE T A WE

[0024] Among them, W P1 , W P2 , W P3 , W P4 , respectively, are the meta-paths P 1 , meta-path P 2 , meta-path P 3 , meta-path P 4 The corresponding switching matrix.

[0025] As a further improvement of the technical solution of the present invention, the trained Word2Vec dictionary described in step S3 performs vector embedding on the cleaned words and expressions as follows: the segmented words and expressions are trained on the segmented text using the Word2Vec method, and finally the embedded vectors of all the words and expressions that have appeared in the text are obtained; during training, the expression is regarded as a special word and is embedded into the vector space together with the word.

[0026] As a further improvement of the technical solution of the present invention, the specific method of retraining the embedding vector based on the meta-path information of the constructed heterogeneous graph in step S4 to obtain the final embedding vector is:

[0027] S41. For words and expressions, use the attention mechanism to calculate the influence weight of the neighbors on each meta-path on the word or expression, and update the input initial vector through the adjacency matrix;

[0028] The influence weight of word m is calculated as follows:

[0029]

[0030]

[0031] The influence weight of expression n is calculated as follows:

[0032]

[0033]

[0034] Among them, Nei(m) and Nei(n) represent the neighbors of nodes m and n in the graph composed of the corresponding meta-path, respectively, and W is a randomly initialized weight parameter;

[0035] For words and expressions, update their embedding representations respectively:

[0036]

[0037]

[0038]

[0039]

[0040] Among them, A represents the weight matrix composed of the above weights, and W is the randomly initialized weight parameter;

[0041] S42. Get the final embedding vectors of words and expressions by averaging:

[0042]

[0043]

[0044] As a further improvement of the technical solution of the present invention, the specific method of using the embedded vector updated based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network to obtain the sentiment semantic label and the trained sentiment analysis model in step S5 is:

[0045] S51, input the updated word and expression embedding vectors into the BiLSTM neural network for training, wherein for each LSTM, the number of internal neurons is set to half of the initial vector embedding dimension;

[0046] S52, use forward LSTM and reverse LSTM to analyze the forward semantics and reverse semantics of the text content respectively, and output the forward hidden layer output vector at each moment i and the inverse hidden layer output vector Concatenate to get the hidden layer output vector h of BiLSTM at each moment i , the result is as follows:

[0047]

[0048]

[0049]

[0050] in, and Represent the forward and reverse LSTM networks respectively, and is the hidden layer vector output by the forward and reverse LSTM networks at time i, and is the hidden layer vector output by the forward and reverse LSTM networks at time i-1, d s is the vector dimension of the LSTM network output, v i is the d-dimensional input vector;

[0051] S53, using the attention mechanism to learn the importance of the hidden layer output vector of BiLSTM at each moment, and performing weighted summation to obtain the final sentiment analysis model, obtaining the trained sentiment analysis model through iterative training, inputting the text data to be tested into the sentiment model, and obtaining the sentiment semantic label; the formula of the sentiment analysis model is as follows:

[0052] score(h i )=tanh(W α h i +b α )

[0053]

[0054]

[0055] in, is the parameter to be learned, b α is the deviation, L w is the length of the input vector.

[0056] A social text sentiment tendency analysis system based on heterogeneous graph, comprising:

[0057] The first module is used to determine the basic information of the information collection object, and collect, clean and sentimentally annotate the relevant social text content;

[0058] The second module is used to construct a meta-path containing different semantic relationships according to the co-occurrence information of words and expressions in the social text, and the words and expressions respectively constitute a heterogeneous graph by using the exchange matrix of each meta-path as an adjacency matrix;

[0059] The third module is used to embed the cleaned and segmented words and expressions into vectors based on the trained Word2Vec dictionary;

[0060] A fourth module, wherein the fourth module is used to retrain the embedding vector based on the meta-path information of the constructed heterogeneous graph to obtain a final embedding vector;

[0061] The fifth module is used to use the embedded vector updated based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network, so as to obtain the sentiment semantic label and the trained sentiment analysis model;

[0062] The sixth module is used to input the text data to be tested into the trained sentiment model and output the final sentiment classification result.

[0063] As a further improvement of the technical solution of the present invention, the forms of the co-occurrence information of words and expressions in the second module include: word-word, word-expression and expression-expression; constructing A of |W|×|W| according to the word-word co-occurrence information WW Matrix, where |W| is the total number of words in the text data, and for the number of co-occurring words n, in A WW The corresponding position in the matrix is ​​set to n; construct A of |W|×|E| based on the word-expression co-occurrence information WE matrix, where |E| is the total number of expressions in the text data, and for the number of co-occurring words and expressions n, in A WE The corresponding position in the matrix is ​​n; construct A of |E|×|E| based on the expression-expression co-occurrence information EE Matrix, for co-occurring expressions-expression times n, in A EE The corresponding position in the matrix is ​​n;

[0064] The meta-paths containing different semantic relations are constructed as follows: 1 :WWW means that two words have co-occurred with the same word; meta-path P 2 :WEW: indicates that two words have co-occurred with the same expression; meta-path P 3 :EWE:indicates that two expressions have co-occurred with the same word; meta-path P 4 :EEE: indicates that two expressions have co-occurred with the same expression;

[0065] The calculation formula of the switching matrix of each element path is:

[0066] W P1 =A WW A WW

[0067] W P2 =A WE A WE T

[0068] W P3 =A EE A EE

[0069] W P4 =A WE T A WE

[0070] Among them, W P1 , W P2 , W P3 , W P4 , respectively, are the meta-paths P 1 , meta-path P 2 , meta-path P 3 , meta-path P 4 The corresponding switching matrix.

[0071] As a further improvement of the technical solution of the present invention, the training-based Word2Vec dictionary described in the third module performs vector embedding on the cleaned words and expressions as follows: the segmented words and expressions are trained on the segmented text using the Word2Vec method, and finally the embedding vectors of all the words and expressions that have appeared in the text are obtained; during training, the expression is regarded as a special word and is embedded into the vector space together with the word.

[0072] As a further improvement of the technical solution of the present invention, the specific method of retraining the embedding vector based on the meta-path information of the constructed heterogeneous graph described in the fourth module to obtain the final embedding vector is:

[0073] 1) For words and expressions, the attention mechanism is used to calculate the influence weight of its neighbors on each meta-path on the word or expression, and the initial input vector is updated through the adjacency matrix;

[0074] The influence weight of word m is calculated as follows:

[0075]

[0076]

[0077] The influence weight of expression n is calculated as follows:

[0078]

[0079]

[0080] Among them, Nei(m) and Nei(n) represent the neighbors of nodes m and n in the graph composed of the corresponding meta-path, respectively, and W is a randomly initialized weight parameter;

[0081] For words and expressions, update their embedding representations respectively:

[0082]

[0083]

[0084]

[0085]

[0086] Among them, A represents the weight matrix composed of the above weights, and W is the randomly initialized weight parameter;

[0087] 2) Get the final embedding vectors of words and expressions by averaging:

[0088]

[0089]

[0090] As a further improvement of the technical solution of the present invention, the specific method described in the fifth module of using the updated embedding vector based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network to obtain the sentiment semantic label and the trained sentiment analysis model is:

[0091] 1) Input the updated word and expression embedding vectors into the BiLSTM neural network for training. For each LSTM, the number of internal neurons is set to half the embedding dimension of the initial vector;

[0092] 2) Use forward LSTM and reverse LSTM to analyze the forward semantics and reverse semantics of the text content respectively, and output the forward hidden layer output vector at each moment i and the inverse hidden layer output vector Concatenate to get the hidden layer output vector h of BiLSTM at each moment i , the result is as follows:

[0093]

[0094]

[0095]

[0096] in, and Represent the forward and reverse LSTM networks respectively, and is the hidden layer vector output by the forward and reverse LSTM networks at time i, and is the hidden layer vector output by the forward and reverse LSTM networks at time i-1, d sis the vector dimension of the LSTM network output, v i is the d-dimensional input vector;

[0097] 3) Use the attention mechanism to learn the importance of the hidden layer output vector of BiLSTM at each moment, and perform weighted summation to obtain the final sentiment analysis model. The trained sentiment analysis model is obtained through iterative training. The text data to be tested is input into the sentiment model to obtain the sentiment semantic label. The formula of the sentiment analysis model is as follows:

[0098] score(h i )=tanh(W α h i +b α )

[0099]

[0100]

[0101] in, is the parameter to be learned, b α is the deviation, L w is the length of the input vector.

[0102] The advantages of the present invention are:

[0103] The present invention is based on the co-occurrence information of words and expressions in social texts. It constructs meta-paths and heterogeneous graphs through the exchange matrices of each meta-path, uses the adjacency matrix to obtain semantic representation vectors containing the intrinsic connections between words and expressions, and finally analyzes the sentiment semantic vectors through the attention mechanism and BiLSTM network to obtain highly accurate sentiment tendency labels. The present invention comprehensively considers the expression of emotions by expressions and texts, and deeply explores the intrinsic connections between expressions and texts to improve the performance of sentiment analysis. In data processing, the expressions and important punctuation marks in the text are retained to improve the emotional information contained in the text content. BRIEF DESCRIPTION OF THE DRAWINGS

[0104] Figure 1 This is a flowchart of a method for analyzing sentiment tendency of social text based on a heterogeneous graph according to Embodiment 1 of the present invention. DETAILED DESCRIPTION

[0105] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in combination with the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0106] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and specific embodiments:

[0107] Embodiment 1

[0108] like Figure 1 As shown, a social text sentiment tendency analysis method based on heterogeneous graph includes the following steps:

[0109] S1. Determine the basic information of the information collection object, and collect, clean and sentimentally annotate its related social text content;

[0110] S11. Use questionnaires to find the information collection objects we need, record the relevant basic information of the information collection objects, including age, gender and occupation, and use crawler technology to collect relevant text information posted on their social networks with their permission, including capturing and saving emoticons in the text. When saving, the basic information of the text will be retained, such as: text ID, publishing time, publishing location, etc. Through manual methods, the saved data is screened and useless text data is deleted, including advertising posts and controversial posts. Use computers to clean the URL and email address in the text to ensure the availability of data.

[0111] S12. Perform sentiment annotation on the cleaned text data, discard controversial annotated data with different annotation results, and ensure the accuracy of data annotation.

[0112] S2, construct a heterogeneous graph based on the co-occurrence information of words and expressions in social texts;

[0113] S21. Segment the cleaned text, remove stop words, retain emoticons and four punctuation marks, namely, “?”, “~”, “!” and “...”, and regard these four punctuation marks as a special emoticon; query and record the occurrence of words and emoticons in the same post, count and record the co-occurrence information of words and emoticons in the text information, and for word-word co-occurrence, set the sliding window size to 5, and the words appearing in the sliding window are regarded as co-occurring words. For word-emoticon and emoticon-emoticon, as long as they appear in the same post, they are regarded as co-occurrence. Based on the low frequency of emoticons in text, in particular, we believe that words and emoticons appearing in the same post have co-occurrence information, and emoticons and emoticons also have co-occurrence information. The co-occurrence information of words and emoticons includes: word-word, word-emoticon and emoticon-emoticon.

[0114] S22. Construct A of |W|×|W| based on co-occurrence information WWMatrix, where |W| is the total number of words in the text data, and for the number of co-occurring words n, in A WW The corresponding position in the matrix is ​​set to n;

[0115] S23. Construct A of |W|×|E| based on co-occurrence information WE matrix, where |E| is the total number of expressions in the text data, and for the number of co-occurring words and expressions n, in A WE The corresponding position in the matrix is ​​n;

[0116] S24. Construct A of |E|×|E| based on co-occurrence information EE Matrix, for co-occurring expressions-expression times n, in A EE The corresponding position in the matrix is ​​n;

[0117] S25. Construct the following meta-paths containing different semantic relations:

[0118] Metapath P 1 : WWW means that two words have co-occurred with the same word;

[0119] Metapath P 2 :WEW: indicates that two words have co-occurred with the same expression;

[0120] Metapath P 3 : EWE: indicates that two expressions have co-occurred with the same word;

[0121] Metapath P 4 :EEE: indicates that two expressions have co-occurred with the same expression;

[0122] By using the exchange matrix of each meta-path as an adjacency matrix, words and expressions respectively constitute heterogeneous graphs; the exchange matrix calculation formula of each meta-path is:

[0123] W P1 =A WW A WW

[0124] W P2 =A WE A WE T

[0125] W P3 =A EE A EE

[0126] W P4 =A WE T A WE

[0127] S3, based on the trained Word2Vec dictionary, embed the cleaned words and expressions into vectors;

[0128] The Word2Vec method is used to train the segmented words and emoticons on the text, and finally the embedding vectors of all the words and emoticons that have appeared in the text are obtained; during training, emoticons are regarded as a special kind of words and are embedded into a high-dimensional vector space together with ordinary words.

[0129] S4, retraining the embedding vector based on the meta-path information of the constructed heterogeneous graph to obtain the final embedding vector;

[0130] S41. For words and expressions, use the attention mechanism to calculate the influence weight of the neighbors on each meta-path on the word or expression, and update the input initial vector through the adjacency matrix;

[0131] The influence weight of word m is calculated as follows:

[0132]

[0133]

[0134] The influence weight of expression n is calculated as follows:

[0135]

[0136]

[0137] Among them, Nei(m) and Nei(n) represent the neighbors of nodes m and n in the graph composed of the corresponding meta-path, respectively, and W is a randomly initialized weight parameter;

[0138] For words and expressions, update their embedding representations respectively:

[0139]

[0140]

[0141]

[0142]

[0143] Among them, A represents the weight matrix composed of the above weights, and W is the randomly initialized weight parameter.

[0144] S42. Get the final embedding vectors of words and expressions by averaging:

[0145]

[0146]

[0147] S5. Use the updated embedding vector based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network to obtain the sentiment semantic label and the trained sentiment analysis model;

[0148] S51. Input the updated word and expression embedding vectors into the BiLSTM neural network for training, where for each LSTM, the number of internal neurons is set to half the initial vector embedding dimension.

[0149] S52, use forward LSTM and reverse LSTM to analyze the forward semantics and reverse semantics of the text content respectively, and output the forward hidden layer output vector at each moment i and the inverse hidden layer output vector Concatenate to get the hidden layer output vector h of BiLSTM at each moment i , the result is as follows:

[0150]

[0151]

[0152]

[0153] in, and Represent the forward and reverse LSTM networks respectively, and is the hidden layer vector output by the forward and reverse LSTM networks at time i, and is the hidden layer vector output by the forward and reverse LSTM networks at time i-1, d s is the vector dimension of the LSTM network output, v i is the d-dimensional input vector.

[0154] BiLSTM consists of a forward LSTM network denoted by and a reverse LSTM network denoted as The forward LSTM network is responsible for fitting the forward semantic information of the text, that is, the semantic connection between the first word and the subsequent word in the same text; the reverse LSTM network is responsible for fitting the reverse semantic information of the text, that is, the semantic connection between the later word and the earlier word; each LSTM has a hidden output vector in each state, where and is the hidden layer vector output by the forward and reverse LSTM networks.

[0155] S53, using the attention mechanism to learn the importance of the hidden layer output vector of BiLSTM at each moment, and performing weighted summation to obtain the final sentiment analysis model, obtaining the trained sentiment analysis model through iterative training, inputting the text data to be tested into the sentiment model, and obtaining the sentiment semantic label; the formula of the sentiment analysis model is as follows:

[0156] score(h i )=tanh(W α h i +b α )

[0157]

[0158]

[0159] in, is the parameter to be learned, b α is the deviation, L w is the length of the input vector.

[0160] S6. Input the text data to be tested into the trained sentiment model and output the final sentiment classification result.

[0161] Embodiment 2

[0162] A social text sentiment tendency analysis system based on heterogeneous graph, comprising:

[0163] The first module is used to determine the basic information of the information collection object, and collect, clean and sentimentally annotate the relevant social text content;

[0164] The second module is used to construct a meta-path containing different semantic relationships according to the co-occurrence information of words and expressions in the social text, and the words and expressions respectively constitute a heterogeneous graph by using the exchange matrix of each meta-path as an adjacency matrix;

[0165] The third module is used to embed the cleaned and segmented words and expressions into vectors based on the trained Word2Vec dictionary;

[0166] A fourth module, wherein the fourth module is used to retrain the embedding vector based on the meta-path information of the constructed heterogeneous graph to obtain a final embedding vector;

[0167] The fifth module is used to use the embedded vector updated based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network, so as to obtain the sentiment semantic label and the trained sentiment analysis model;

[0168] The sixth module is used to input the text data to be tested into the trained sentiment model and output the final sentiment classification result.

[0169] The forms of the co-occurrence information of words and expressions described in the second module include: word-word, word-expression and expression-expression; constructing A of |W|×|W| based on the word-word co-occurrence information WW Matrix, where |W| is the total number of words in the text data, and for the number of co-occurring words n, in A WW The corresponding position in the matrix is ​​set to n; construct A of |W|×|E| based on the word-expression co-occurrence information WE matrix, where |E| is the total number of expressions in the text data, and for the number of co-occurring words and expressions n, in A WE The corresponding position in the matrix is ​​n; construct A of |E|×|E| based on the expression-expression co-occurrence information EE Matrix, for co-occurring expressions-expression times n, in A EE The corresponding position in the matrix is ​​n;

[0170] The meta-paths containing different semantic relations are constructed as follows: 1 :WWW means that two words have co-occurred with the same word; meta-path P 2 :WEW: indicates that two words have co-occurred with the same expression; meta-path P 3 :EWE:indicates that two expressions have co-occurred with the same word; meta-path P 4 :EEE: indicates that two expressions have co-occurred with the same expression;

[0171] The calculation formula of the switching matrix of each element path is:

[0172] W P1 =A WW A WW

[0173] W P2 =A WE A WE T

[0174] W P3 =A EE A EE

[0175] WP4 =A WE T A WE

[0176] Among them, W P1 , W P2 , W P3 , W P4 , respectively, are the meta-paths P 1 , meta-path P 2 , meta-path P 3 , meta-path P 4 The corresponding switching matrix.

[0177] The trained Word2Vec dictionary described in the third module embeds the cleaned words and expressions into vectors as follows: the Word2Vec method is used to train the segmented text for the words and expressions, and finally the embedding vectors of all the words and expressions that appear in the text are obtained; during training, expressions are regarded as a special word and embedded into the vector space together with the words.

[0178] The specific method described in the fourth module for retraining the embedding vector based on the meta-path information of the constructed heterogeneous graph to obtain the final embedding vector is:

[0179] 1) For words and expressions, the attention mechanism is used to calculate the influence weight of its neighbors on each meta-path on the word or expression, and the initial input vector is updated through the adjacency matrix;

[0180] The influence weight of word m is calculated as follows:

[0181]

[0182]

[0183] The influence weight of expression n is calculated as follows:

[0184]

[0185]

[0186] Among them, Nei(m) and Nei(n) represent the neighbors of nodes m and n in the graph composed of the corresponding meta-path, respectively, and W is a randomly initialized weight parameter;

[0187] For words and expressions, update their embedding representations respectively:

[0188]

[0189]

[0190]

[0191]

[0192] Among them, A represents the weight matrix composed of the above weights, and W is the randomly initialized weight parameter;

[0193] 2) Get the final embedding vectors of words and expressions by averaging:

[0194]

[0195]

[0196] The specific method described in the fifth module of using the updated embedding vector based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network to obtain the sentiment semantic label and the trained sentiment analysis model is:

[0197] 1) Input the updated word and expression embedding vectors into the BiLSTM neural network for training. For each LSTM, the number of internal neurons is set to half the embedding dimension of the initial vector;

[0198] 2) Use forward LSTM and reverse LSTM to analyze the forward semantics and reverse semantics of the text content respectively, and output the forward hidden layer output vector at each moment i and the inverse hidden layer output vector Concatenate to get the hidden layer output vector h of BiLSTM at each moment i , the result is as follows:

[0199]

[0200]

[0201]

[0202] in, and Represent the forward and reverse LSTM networks respectively, and is the hidden layer vector output by the forward and reverse LSTM networks at time i, and is the hidden layer vector output by the forward and reverse LSTM networks at time i-1, d s is the vector dimension of the LSTM network output, v i is the d-dimensional input vector;

[0203] 3) Use the attention mechanism to learn the importance of the hidden layer output vector of BiLSTM at each moment, and perform weighted summation to obtain the final sentiment analysis model. The trained sentiment analysis model is obtained through iterative training. The text data to be tested is input into the sentiment model to obtain the sentiment semantic label. The formula of the sentiment analysis model is as follows:

[0204] score(h i )=tanh(W α h i +b α )

[0205]

[0206]

[0207] in, is the parameter to be learned, b α is the deviation, L w is the length of the input vector.

[0208] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A social text sentiment tendency analysis method based on heterogeneous graph, characterized in that: The following steps are involved: S1. Determine the basic information of the information collection object, and collect, clean and sentimentally annotate its related social text content; S2. Based on the co-occurrence information of words and expressions in social texts, meta-paths containing different semantic relationships are constructed. By using the exchange matrix of each meta-path as the adjacency matrix, words and expressions respectively constitute heterogeneous graphs; The co-occurrence information of words and expressions includes: word-word, word-expression and expression-expression; constructing A of |W|×|W| according to the word-word co-occurrence information WW Matrix, where |W| is the total number of words in the text data, and for the number of co-occurring words n, in A WW The corresponding position in the matrix is ​​set to n; construct A of |W|×|E| based on the word-expression co-occurrence information WE matrix, where |E| is the total number of expressions in the text data, and for the number of co-occurring words and expressions n, in A WE The corresponding position in the matrix is ​​n; construct A of |E|×|E| based on the expression-expression co-occurrence information EE Matrix, for co-occurring expressions-expression times n, in A EE The corresponding position in the matrix is ​​n; The meta-paths containing different semantic relations are constructed as follows: 1 :WWW means that two words have co-occurred with the same word; meta-path P 2 :WEW: indicates that two words have co-occurred with the same expression; meta-path P 3 :EWE:indicates that two expressions have co-occurred with the same word; meta-path P 4 :EEE: indicates that two expressions have co-occurred with the same expression; The calculation formula of the switching matrix of each element path is: W P1 =A WW A WW W P2 =A WE A WE T W P3 =A EE A EE W P4 =A WE T A WE Among them, W P1 , W P2 , W P3 , W P4 , respectively, are the meta-paths P 1 , meta-path P 2 , meta-path P 3 , meta-path P 4 The corresponding switching matrix; S3, based on the trained Word2Vec dictionary, embed the cleaned and segmented words and expressions into vectors; S4, retraining the embedding vector based on the meta-path information of the constructed heterogeneous graph to obtain the final embedding vector; S5. Use the updated embedding vector based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network to obtain the sentiment semantic label and the trained sentiment analysis model; S6. Input the text data to be tested into the trained sentiment model and output the final sentiment classification result.

2. According to the method for analyzing social text sentiment tendency based on heterogeneous graphs in claim 1, it is characterized in that: The step S3 described in which the cleaned words and expressions are embedded with vectors based on the trained Word2Vec dictionary is as follows: the segmented words and expressions are trained on the segmented text using the Word2Vec method, and finally the embedding vectors of all the words and expressions that have appeared in the text are obtained; During training, expressions are treated as a special kind of words and embedded into the vector space together with the words.

3. According to the method for analyzing social text sentiment tendency based on heterogeneous graph in claim 2, it is characterized in that: The specific method of retraining the embedding vector based on the meta-path information of the constructed heterogeneous graph in step S4 to obtain the final embedding vector is: S41. For words and expressions, use the attention mechanism to calculate the influence weight of its neighbors on each meta-path on the word or expression, and update the input initial vector through the adjacency matrix; The influence weight of word m is calculated as follows: The influence weight of expression n is calculated as follows: Among them, Nei(m) and Nei(n) represent the neighbors of nodes m and n in the graph composed of the corresponding meta-path, respectively, and W is a randomly initialized weight parameter; For words and expressions, update their embedding representations respectively: Among them, A represents the weight matrix composed of the above weights, and W is the randomly initialized weight parameter; S42. Get the final embedding vectors of words and expressions by averaging:

4. According to the method for analyzing social text sentiment tendency based on heterogeneous graphs according to claim 3, it is characterized in that: The specific method described in step S5 of using the updated embedding vector based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network to obtain the sentiment semantic label and the trained sentiment analysis model is: S51, input the updated word and expression embedding vectors into the BiLSTM neural network for training, wherein for each LSTM, the number of internal neurons is set to half of the initial vector embedding dimension; S52, use forward LSTM and reverse LSTM to analyze the forward semantics and reverse semantics of the text content respectively, and output the forward hidden layer output vector at each moment i and the inverse hidden layer output vector Concatenate to get the hidden layer output vector h of BiLSTM at each moment i , the result is as follows: in, and Represent the forward and reverse LSTM networks respectively, and is the hidden layer vector output by the forward and reverse LSTM networks at time i, and is the hidden layer vector output by the forward and reverse LSTM networks at time i-1, d s is the vector dimension of the LSTM network output, v i is the d-dimensional input vector; S53, using the attention mechanism to learn the importance of the hidden layer output vector of BiLSTM at each moment, and performing weighted summation to obtain the final sentiment analysis model, obtaining the trained sentiment analysis model through iterative training, inputting the text data to be tested into the sentiment model, and obtaining the sentiment semantic label; the formula of the sentiment analysis model is as follows: score(h i )=tanh(W α h i +b α ) in, is the parameter to be learned, b α is the deviation, L w is the length of the input vector.

5. A social text sentiment analysis system based on heterogeneous graph, characterized in that: include: The first module is used to determine the basic information of the information collection object, and collect, clean and sentimentally annotate the relevant social text content; The second module is used to construct a meta-path containing different semantic relationships according to the co-occurrence information of words and expressions in the social text, and the words and expressions respectively constitute a heterogeneous graph by using the exchange matrix of each meta-path as an adjacency matrix; The co-occurrence information of words and expressions includes: word-word, word-expression and expression-expression; constructing A of |W|×|W| according to the word-word co-occurrence information WW Matrix, where |W| is the total number of words in the text data, and for the number of co-occurring words n, in A WW The corresponding position in the matrix is ​​set to n; construct A of |W|×|E| based on the word-expression co-occurrence information WE matrix, where |E| is the total number of expressions in the text data, and for the number of co-occurring words and expressions n, in A WE The corresponding position in the matrix is ​​n; construct A of |E|×|E| based on the expression-expression co-occurrence information EE Matrix, for co-occurring expressions-expression times n, in A EE The corresponding position in the matrix is ​​n; The meta-paths containing different semantic relations are constructed as follows: 1 :WWW means that two words have co-occurred with the same word; meta-path P 2 :WEW: indicates that two words have co-occurred with the same expression; meta-path P 3 :EWE:indicates that two expressions have co-occurred with the same word; meta-path P 4 :EEE: indicates that two expressions have co-occurred with the same expression; The calculation formula of the switching matrix of each element path is: W P1 =A WW A WW W P2 =A WE A WE T W P3 =A EE A EE W P4 =A WE T A WE Among them, W P1 , W P2 , W P3 , W P4 , respectively, are the meta-paths P 1 , meta-path P 2 , meta-path P 3 , meta-path P 4 The corresponding switching matrix; The third module is used to embed the cleaned and segmented words and expressions into vectors based on the trained Word2Vec dictionary; A fourth module, wherein the fourth module is used to retrain the embedding vector based on the meta-path information of the constructed heterogeneous graph to obtain a final embedding vector; The fifth module is used to use the embedded vector updated based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network, so as to obtain the sentiment semantic label and the trained sentiment analysis model; The sixth module is used to input the text data to be tested into the trained sentiment model and output the final sentiment classification result.

6. A social text sentiment tendency analysis system based on heterogeneous graph according to claim 5, characterized in that: The trained Word2Vec dictionary described in the third module embeds the cleaned words and expressions into vectors, specifically: the Word2Vec method is used to train the segmented text for the words and expressions, and finally the embedding vectors of all the words and expressions that have appeared in the text are obtained; During training, expressions are treated as a special kind of words and embedded into the vector space together with the words.

7. A social text sentiment tendency analysis system based on heterogeneous graph according to claim 6, characterized in that: The specific method described in the fourth module for retraining the embedding vector based on the meta-path information of the constructed heterogeneous graph to obtain the final embedding vector is: 1) For words and expressions, the attention mechanism is used to calculate the influence weight of its neighbors on each meta-path on the word or expression, and the initial input vector is updated through the adjacency matrix; The influence weight of word m is calculated as follows: The influence weight of expression n is calculated as follows: Among them, Nei(m) and Nei(n) represent the neighbors of nodes m and n in the graph composed of the corresponding meta-path, respectively, and W is a randomly initialized weight parameter; For words and expressions, update their embedding representations respectively: Among them, A represents the weight matrix composed of the above weights, and W is the randomly initialized weight parameter; 2) Get the final embedding vectors of words and expressions by averaging:

8. The social text sentiment tendency analysis system based on heterogeneous graph according to claim 7 is characterized in that: The specific method described in the fifth module of using the updated embedding vector based on the heterogeneous graph as the input of the classification model based on the attention mechanism and the BiLSTM network to obtain the sentiment semantic label and the trained sentiment analysis model is: 1) Input the updated word and expression embedding vectors into the BiLSTM neural network for training. For each LSTM, the number of internal neurons is set to half the embedding dimension of the initial vector; 2) Use forward LSTM and reverse LSTM to analyze the forward semantics and reverse semantics of the text content respectively, and output the forward hidden layer output vector at each moment i and the inverse hidden layer output vector Concatenate to get the hidden layer output vector h of BiLSTM at each moment i , the result is as follows: in, and Represent the forward and reverse LSTM networks respectively, and is the hidden layer vector output by the forward and reverse LSTM networks at time i, and is the hidden layer vector output by the forward and reverse LSTM networks at time i-1, d s is the vector dimension of the LSTM network output, v i is the d-dimensional input vector; 3) Use the attention mechanism to learn the importance of the hidden layer output vector of BiLSTM at each moment, and perform weighted summation to obtain the final sentiment analysis model. The trained sentiment analysis model is obtained through iterative training. The text data to be tested is input into the sentiment model to obtain the sentiment semantic label. The formula of the sentiment analysis model is as follows: score(h i )=tanh(W α h i +b α ) in, is the parameter to be learned, b α is the deviation, L w is the length of the input vector.

Citation Information

Patent Citations

  • Text sentiment analysis method and system

    CN111324739A

  • Emotional dialogue generation method and device, and emotional dialogue model training method and device

    CN111966800A

  • Social media user account classification method based on information fusion

    CN112084335A