A deep learning method for Chinese sentence text sentiment analysis based on knowledge graph
By combining knowledge graphs and semantic dependencies to construct an emotional knowledge graph, the problem of insufficient interpretability in Chinese text sentiment analysis is solved, and a more interpretable and accurate sentiment analysis method is realized.
Patent Information
- Application Number
- CN202410851711.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2044-06-27
AI Technical Summary
The prior art has the problem of insufficient interpretability of deep learning networks in Chinese text sentiment analysis, especially when faced with complex network comments, it is difficult to provide effective explanations and accurate analysis results.
Combining the knowledge graph and semantic dependence relationship, an emotional knowledge graph is constructed, and deep learning models are trained through the BERT encoder and cross-entropy loss function to improve the interpretability and accuracy of the model.
It improves the interpretability and accuracy of Chinese text sentiment analysis, supports the expansion of local sentiment dictionary, and is suitable for emotion enhancement analysis in multiple text application scenarios.
Smart Images

Figure CN118747220B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text sentiment analysis, and in particular to a deep learning Chinese sentence text sentiment analysis method based on knowledge graph. Background Art
[0002] Text sentiment analysis, a key research task in natural language processing, focuses on identifying and interpreting emotional tendencies in text data. It is crucial for understanding users' true feelings and opinions. It has widespread application across a wide range of text types, including service reviews, movie reviews, product discussions, hot news, social media, and personal blogs. By deeply exploring the emotional undertones within these texts, we can uncover user preferences, evaluate product performance, and gain insights into the dynamics of public opinion. Sentiment analysis can be categorized into three levels: aspect-level, sentence-level, and paragraph-level. The aspect-level focuses on the emotional nuances of specific words in a text; the sentence-level, as the most common unit of sentiment expression, is often found in online comments and public opinion discussions; and the paragraph-level provides a holistic interpretation of sentiment across longer texts, such as news and blogs. Combining these levels of analysis provides valuable information and insights for market insights, product optimization, and public opinion analysis.
[0003] Sentence-level sentiment analysis of Chinese text primarily involves three approaches: sentiment lexicon-based analysis, machine learning-based analysis, and the rapidly developing deep learning-based analysis method. Sentiment lexicon-based approaches for Chinese text sentiment analysis primarily rely on the NTUSD and HowNet sentiment lexicons, with some researchers also using bilingual sentiment lexicons for supplementary analysis. Sentiment lexicon-based analysis places high demands on the quality and scalability of the lexicon library. In the ever-changing online text environment, sentiment analysis based solely on sentiment lexicons requires the use of a self-built sentiment analysis library to supplement analysis and address the slow iteration and update times of traditional sentiment lexicons.
[0004] With the development of machine learning research, sentiment analysis methods based on machine learning have seen more related research. The research mainly focuses on supervised learning methods such as SVM (Supported Vector Machine), K-nearest neighbor, decision tree, naive Bayes and random forest, and unsupervised learning methods such as K-Means, combined with related technologies such as sentiment words, Chinese syntactic analysis and syntactic structure dependency, to perform sentiment analysis on Chinese texts.
[0005] In recent years, research in the field of deep learning has advanced rapidly. This technological advancement has provided new insights and significantly boosted research in various fields, including text sentiment analysis in natural language processing, achieving impressive results in both accuracy and training efficiency. The method of embedding knowledge graphs and knowledge bases into deep learning networks has been effectively validated in the field of sentiment analysis of emotional text. A common approach is to integrate graph neural networks, the WordNet knowledge base, or the knowledge graph's independent triple-relationship representation space into a neural network for learning. This strengthens the semantic concepts and entity relationships of word segmentation in text, improving the effectiveness of sentiment analysis of Chinese text.
[0006] Chinese text sentiment analysis based on deep learning, due to the particularity of deep learning network models, its learning parameters are like a black box. Although the learning accuracy is high, in some cases, people cannot explain its results. To address the problem of insufficient interpretability of deep learning networks, this invention combines the self-supervised Chinese text sentiment word relationships to construct a sentiment knowledge graph. For iteratively developing network terms, the accuracy and interpretability can be improved by supplementing the sentiment word relationships in the sentiment knowledge graph. At the same time, it retains a fast text sequence learning method, without the need to build a complex graph neural network model and training steps.
[0007] Therefore, it is an urgent problem for those skilled in the art to propose a deep learning Chinese sentence text sentiment analysis method based on knowledge graph to solve the difficulties existing in the existing technology. Summary of the Invention
[0008] In view of this, the present invention provides a deep learning method for Chinese sentence text sentiment analysis based on knowledge graphs, using a knowledge enhancement technical solution that combines knowledge graphs with semantic dependencies. In response to the complex situation of online comments, it combines an interpretable knowledge graph library with Chinese semantic structure and deep learning technology, and proposes a more interpretable and effective method in the field of deep learning for Chinese text sentiment analysis.
[0009] In order to achieve the above object, the present invention adopts the following technical solutions:
[0010] A deep learning Chinese sentence text sentiment analysis method based on knowledge graph includes the following steps:
[0011] S1. Data acquisition step: obtaining Chinese text sequences;
[0012] S2, data preprocessing step: perform data cleaning, Chinese word segmentation, part-of-speech analysis, and syntactic dependency analysis on the Chinese text sequence obtained in S1 to obtain a part-of-speech data set and a syntactic dependency relationship set;
[0013] S3, build emotional knowledge graph: Based on the part-of-speech data set and syntactic dependency relationship set obtained in S2, build an emotional knowledge base and establish an emotional knowledge relationship structure;
[0014] S4, text encoding step: combine the sentiment knowledge relationship structure obtained in S3 with the original text, and use the BERT encoder to encode the combined text;
[0015] S5. Pooling layer optimization step: Construct a BERT deep learning framework with a binary classification classifier for the pooling output layer. Use the cross-entropy loss function to train the BERT deep learning framework to obtain a sentiment analysis model based on the sentiment semantic relationship of the knowledge graph.
[0016] S6, performance testing step: input the test Chinese sequence into the sentiment analysis model based on the knowledge graph sentiment semantic relationship obtained in S5, match and enhance the text sequence segmentation with sentiment words according to the constructed knowledge graph library, and then identify and analyze the sentiment polarity of the input sentence.
[0017] In the above method, optionally, the specific steps in S2 include:
[0018] S201, setting a filtering regular expression to filter non-informative special symbols in the text of the sentence and performing data cleaning on the Chinese text sequence obtained in S1 to obtain a cleaned Chinese text sequence;
[0019] S202, performing Chinese word segmentation on the cleaned Chinese text sequence obtained in S201, retaining the text comment content;
[0020] S203, using the LTP word segmentation tool to perform part-of-speech analysis on the text comment content obtained in S202 to obtain a set of sentiment segmentation words with part-of-speech information:
[0021] S l ={LTP.seg adj (S),LTP.seg verb (S),LTP.seg adverb (S)}
[0022] Among them, S l is a set of sentiment segmentation words with part-of-speech information, LTP.seg adj (S) is the sentiment segmentation set of adjectives, LTP.seg verb (S) is the sentiment segmentation set of verbs, LTP.seg adverb (S) is the set of sentiment participles of adverbs;
[0023] S204, extracting the eSUCC subsequent relationship, mDEPD dependency tag relationship, and party role relationship EXP by analyzing the dependency relationship between words or characters;
[0024] S sdpg ={LTP.sdpg(S)}
[0025] Among them, S sdpg is the word dependency set of sentence S, and LTP.sdpg(S) is the word dependency analysis of sentence S using the LTP word segmentation platform (public).
[0026] In the above method, optionally, the specific steps in S3 include:
[0027] S301: For the part-of-speech data set and the syntactic dependency relationship set obtained in S3, extract phrase entities and set the relationship between phrase entities according to the algorithm rules:
[0028] S302: Based on the phrase entity obtained in S301 and the relationship between the phrase entities, set the sentiment relationship between the phrase entities and output it to a csv file;
[0029] S303. Based on the csv file stored in S302, construct the triple knowledge relationship of the phrases, and optimize the set of triple relationships of the emotional phrases in the locally constructed emotional knowledge graph to obtain the emotional knowledge graph library.
[0030] In the above method, optionally, the algorithm for extracting the relationship between phrase entities in S301 is as follows:
[0031]
[0032] in, Represents the relationship between two words in the constructed knowledge graph, Indicates a word or phrase w i The i-th word in the dependency set, S l (a, v, wp) represent the three parts of speech in the part-of-speech set, namely adjective, verb and adverb, pos(w i ) indicates a word or phrase w i Position in the sentence.
[0033] The above method optionally includes the following relationship set of sentiment phrase triples in the sentiment knowledge graph:
[0034]
[0035] F(x)=count(x)
[0036] in, It represents the i-th triple relationship in the sentiment triple preprocessing CSV file, and the F(x) function represents the statistical quantity of the triple relationship.
[0037] In the above method, optionally, the specific contents of S4 include:
[0038] S401, fuse the original sentence text sequence with the corresponding triples matched from the sentiment knowledge graph library, then use the encoder of the BERT model to encode the fused triples, and use Concat combination to combine the encodings of the two input data, Among them E s Encode the original text sequence, Encode the enhanced information after fusion of sentiment knowledge graph;
[0039] S402: Input the code obtained in S401 into the feature encoding layer of the pre-trained model BERT, use the multi-head attention mechanism to perform parallel calculations, and use the sentiment knowledge graph to enhance and capture the correlation coefficient of the sentiment word combination relationship between words;
[0040] S403. Perform a 10% Dropout operation on the attention output, and set p (loss rate) to 0.1.
[0041] In the above method, optionally, the specific contents of S5 include:
[0042] S501, using the output of S403 to learn the Chinese text sentiment features through a Chinese pre-training model;
[0043] S502: Modify the output classifier of the Chinese pre-training model and set it to a binary linear classifier to represent two sentiment polarities;
[0044] S503. Compare the result of the previous step input with the sentiment polarity labeling corresponding to the training sample, use cross entropy as the loss function, and perform backpropagation on the model:
[0045] L=-[y·log(p)+(1-y)·log(1-p)]
[0046] Where y is the classification category marked in the training data set, p is the classification category predicted by the model, y,p∈{0,1};
[0047] S504: Perform epoch training on the result in S503.
[0048] Through the above technical solution, it can be seen that compared with the existing technology, the deep learning Chinese sentence text sentiment analysis method based on knowledge graph of the present invention has the following beneficial effects:
[0049] 1. No existing technical solution uses knowledge graphs and semantic dependencies to enhance knowledge for Chinese text sentiment analysis. This invention combines an interpretable knowledge graph with Chinese semantic structure and deep learning technology to address the complexities of online reviews. This method proposes a more interpretable and effective method in the field of deep learning for Chinese text sentiment analysis.
[0050] 2. The present invention is universal and can use other deep neural networks to replace the current pre-trained neural network model to improve the model effect;
[0051] 3. The present invention supports the expansion of local sentiment dictionaries and supports sentiment enhancement analysis in multiple text application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0053] Figure 1 A flowchart of a deep learning Chinese sentence text sentiment analysis method based on knowledge graph provided by the present invention;
[0054] Figure 2 Flowchart of the data cleaning method provided by the present invention;
[0055] Figure 3 The Chinese text sentiment embedding coding structure diagram enhanced by the knowledge graph provided by the present invention;
[0056] Figure 4 This is a diagram of the multi-head attention learning structure provided by the present invention. DETAILED DESCRIPTION
[0057] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only 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 making creative efforts are within the scope of protection of the present invention.
[0058] In this application, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. The terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or apparatus comprising the element.
[0059] The present invention can be used in a variety of general-purpose or special-purpose computing device environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multi-processor devices, and distributed computing environments including any of the above.
[0060] Reference Figure 1 As shown, the present invention discloses a deep learning Chinese sentence text sentiment analysis method based on knowledge graph, comprising the following steps:
[0061] S1. Data acquisition step: obtaining Chinese text sequences;
[0062] S2, data preprocessing step: perform data cleaning, Chinese word segmentation, part-of-speech analysis, and syntactic dependency analysis on the Chinese text sequence obtained in S1 to obtain a part-of-speech data set and a syntactic dependency relationship set;
[0063] S3, build emotional knowledge graph: Based on the part-of-speech data set and syntactic dependency relationship set obtained in S2, build an emotional knowledge base and establish an emotional knowledge relationship structure;
[0064] S4, text encoding step: combine the sentiment knowledge relationship structure obtained in S3 with the original text, and use the BERT encoder to encode the combined text;
[0065] S5. Pooling layer optimization step: Construct a BERT deep learning framework with a binary classification classifier for the pooling output layer. Use the cross-entropy loss function to train the BERT deep learning framework to obtain a sentiment analysis model based on the sentiment semantic relationship of the knowledge graph.
[0066] S6, performance testing step: input the test Chinese sequence into the sentiment analysis model based on the knowledge graph sentiment semantic relationship obtained in S5, match and enhance the text sequence segmentation with sentiment words according to the constructed knowledge graph library, and then identify and analyze the sentiment polarity of the input sentence.
[0067] Specifically, data cleaning is an essential process. Poor data cleaning can significantly affect training accuracy and even cause the model to overfit. Text sequences enhanced with sentiment knowledge graphs can improve the interpretability of deep learning sentiment analysis results for Chinese sentences. First, the words and phrases in the sentence must be queried and matched against the sentiment dictionary, which necessitates word segmentation of the input Chinese text sequence. This text segmentation is performed using the small offline model version of LTP (Language Technology Platform) V4.0 (with 40M parameters).
[0068] In the above method, optionally, the specific steps in S2 include:
[0069] S201, setting a filtering regular expression to filter non-informative special symbols in the text of the sentence and performing data cleaning on the Chinese text sequence obtained in S1 to obtain a cleaned Chinese text sequence;
[0070] S202, performing Chinese word segmentation on the cleaned Chinese text sequence obtained in S201, retaining the text comment content;
[0071] S203, using the LTP word segmentation tool to perform part-of-speech analysis on the text comment content obtained in S202 to obtain a set of sentiment segmentation words with part-of-speech information:
[0072] S l ={LTP.seg adj (S),LTP.seg verb (S),LTP.seg adverb (S)}
[0073] Among them, S l is a set of sentiment segmentation words with part-of-speech information, LTP.seg adj (S) is the sentiment segmentation set of adjectives, LTP.seg verb (S) is the sentiment segmentation set of verbs, LTP.seg adverb (S) is the set of sentiment participles of adverbs;
[0074] S204, extracting the eSUCC subsequent relationship, mDEPD dependency tag relationship, and party role relationship EXP by analyzing the dependency relationship between words or characters;
[0075] S sdpg ={LTP.sdpg(S)}
[0076] Among them, S sdpgis the word dependency set of sentence S, and LTP.sdpg(S) is the word dependency analysis of sentence S using the LTP word segmentation platform (public).
[0077] Specifically, such as Figure 2 As shown, S201, set a filtering regular expression to filter non-information special symbols in the text of the sentence, such as HTML tag symbols and emoticons, etc. The special symbols are stored in a txt file to facilitate update and iteration.
[0078] S202. The data set used in the present invention is microblog sentiment for multi-level comments, such as " / / @user A content A / / @user B content B...". In order to focus on the key content of the comments, it is necessary to intercept this type of data and only retain the latest text comment content to prevent the impact of multi-level comment sentences on the overall content.
[0079] S203, input the Chinese text sentence sequence to be learned S = {w1, w2, ..., w n}.
[0080] Part-of-speech analysis uses the LTP word segmentation tool to extract adjectives (a), verbs (v), and adverbs (d). The sentiment segmentation set with part-of-speech information is as follows:
[0081] S l ={LTP.seg adj (S),LTP.seg verb (S),LTP.seg adverb (S)}
[0082] S204: Through word / character dependency analysis, extract the key eSUCC follow-up relationship, mDEPD dependency tag relationship, and party role relationship EXP.
[0083] S sdpg ={LTP.sdpg(S)}
[0084] The eSUCC successor relationship is shown in Table 1
[0085] Table 1: Description of the semantic dependency relationships of the present invention
[0086]
[0087]
[0088] In the above method, optionally, the specific steps in S3 include:
[0089] S301: For the part-of-speech data set and the syntactic dependency relationship set obtained in S3, extract phrase entities and set the relationship between phrase entities according to the algorithm rules:
[0090] S302: Based on the phrase entity obtained in S301 and the relationship between the phrase entities, set the sentiment relationship between the phrase entities and output it to a csv file;
[0091] S303. Based on the csv file stored in S302, construct the triple knowledge relationship of the phrases, and optimize the set of triple relationships of the emotional phrases in the locally constructed emotional knowledge graph to obtain the emotional knowledge graph library.
[0092] Specifically, in S302, the default sentiment relationship of the word combination entity is automatically set according to the input training set, and the knowledge graph relationship construction information is output to the CSV file in the form of appending:
[0093]
[0094] Among them, tag(s) is the sentiment label of the sentence sequence corresponding to the training dataset.
[0095] In the above method, optionally, the algorithm for extracting the relationship between phrase entities in S301 is as follows:
[0096]
[0097] in, Represents the relationship between two words in the constructed knowledge graph, Indicates a word or phrase w i The i-th word in the dependency set, S l (a, v, wp) represent the three parts of speech in the part-of-speech set, namely adjective, verb and adverb, pos(w i ) indicates a word or phrase w i Position in the sentence.
[0098] Specifically, the relationship between phrase entities and phrase entities is extracted and set according to the algorithm rules. For verb (v), its successor relationship and dependency relationship phrase dependency must be a relationship between the previous and next words. If there are other words in the middle, the relationship combination is filtered out.
[0099] The above method optionally includes the following relationship set of sentiment phrase triples in the sentiment knowledge graph:
[0100]
[0101] F(x)=count(x)
[0102] in, It represents the i-th triple relationship in the sentiment triple preprocessing CSV file, and the F(x) function represents the statistical quantity of the triple relationship.
[0103] Specifically, the triple knowledge relationship of the phrase is loaded and constructed from the csv file stored in S302, and the set of emotional phrase triple relationships in the locally constructed emotional knowledge graph is loaded. When summarizing all emotional triplets, duplications may occur, and even the same phrase combination may have different emotional polarity relationships. In this case, it is necessary to set the emotional polarity with a high proportion as the combined polarity of the emotional entity relationship based on quantitative statistics. For emotional entity relationship combinations with similar frequencies, the emotional entity combination is discarded to avoid noise interference to the model.
[0104] In the above method, optionally, the specific contents of S4 include:
[0105] S401, fuse the original sentence text sequence with the corresponding triples matched from the sentiment knowledge graph library, then use the encoder of the BERT model to encode the fused triples, and use Concat combination to combine the encodings of the two input data, Among them E s Encode the original text sequence, Encode the enhanced information after fusion of sentiment knowledge graph;
[0106] S402: Input the code obtained in S401 into the feature encoding layer of the pre-trained model BERT, use the multi-head attention mechanism to perform parallel calculations, and use the sentiment knowledge graph to enhance and capture the correlation coefficient of the sentiment word combination relationship between words;
[0107] S403. Perform a 10% Dropout operation on the attention output, and p is set to 0.1.
[0108] Specifically, the BERT model can process long sequence inputs. It does not need to use other neural networks to encode the sentiment polarity labeling data set matched with the sentiment dictionary. The deep learning neural network structure is mainly composed of multiple Transformer structures. The current model uses a 12-layer Transformer structure, such as Figure 3 shown.
[0109] S401: The original sentence text sequence is merged with the corresponding <emotion word 1, emotion word 2, emotion polarity> triples found after word segmentation and matched in the emotional knowledge graph library. Then, the BERT model encoder BertTokenizer is used to encode the data, and the Concat combination is used to combine the encodings of the two input data. Among them E s Encode the original text sequence, Enhanced information encoding for sentiment knowledge graphs.
[0110] S402: Input the encoding from the previous step into the feature encoding layer of the pre-trained model BERT. First, the input is divided into three equal parts Q, K, and V, and enters the attention layer: like Figure 4 As shown in the figure, multi-head attention is used to calculate multiple data in parallel, and with the help of sentiment knowledge graph enhancement, the correlation coefficients of more sentiment word combinations between words are captured:
[0111] MultiHead Q,K,V =Concat(h1,h2,…,h n )W o
[0112]
[0113] in Represents the independent parameter matrices for linear changes in Q, K, and V inputs respectively.
[0114] S403: Perform a 10% Dropout operation on the attention output, with p set to 0.1:
[0115]
[0116] In the above method, optionally, the specific contents of S5 include:
[0117] S501, using the output of S403 to learn the Chinese text sentiment features through a Chinese pre-training model;
[0118] S502: Modify the output classifier of the Chinese pre-training model and set it to a binary linear classifier to represent two sentiment polarities;
[0119] S503. Compare the result of the previous step input with the sentiment polarity labeling corresponding to the training sample, use cross entropy as the loss function, and perform backpropagation on the model:
[0120] L=-[y·log(p)+(1-y)·log(1-p)]
[0121] Where y is the classification category marked in the training data set, p is the classification category predicted by the model, y,p∈{0,1};
[0122] S504: Perform epoch training on the result in S503.
[0123] Specifically, we use pre-trained models such as BERT to perform feature learning and sentiment analysis on the input text encoding:
[0124] S501: Input the output of step 3-3 into the Chinese pre-trained model BERT-WWM (BERT WholeWord Mask) or other Chinese pre-trained models to learn the sentiment features of Chinese text. After multiple rounds of experimental verification, the present invention can adapt to a variety of Chinese pre-trained models and achieve significant accuracy improvements. The model parameter settings are shown in Table 2:
[0125] Table 2 Description of main parameter settings of pre-training model
[0126]
[0127]
[0128] S502: Modify the output classifier of the pre-trained model and set it to a binary linear classifier to represent two emotional polarities. In the classification result, if the first value is greater than the second value, it means that the emotional polarity is negative, otherwise it means positive emotional polarity:
[0129] h pooling =BERT.decoder(h atten )
[0130] h classify =h pooling W1+b1
[0131]
[0132] Where W1∈R 768×2 , b1∈R 1×2 .
[0133] S503: Compare the result of the previous step input with the sentiment polarity labeling corresponding to the training sample, use cross entropy as the loss function, and perform backpropagation on the model:
[0134] L=-[y·log(p)+(1-y)·log(1-p)]
[0135] S504: Perform training for no less than 50 epochs.
[0136] This paper focuses on sentiment analysis of Chinese online comment text sequences. Addressing the incompleteness and imprecision of online comment texts, as well as the characteristics of internet jargon, we perform data augmentation by combining a sentiment knowledge graph with a locally expanded set of sentiment phrase triples. Based on this, and leveraging a pre-trained deep learning model, we propose an innovative knowledge graph-based deep learning method for Chinese text sentiment analysis.
[0137] To validate the effectiveness of this method, we conducted extensive testing on two Chinese text sentiment review datasets publicly available on Kaggle: weibo_senti_100k and waimai_10k. The distribution of positive and negative sentiment polarity in these two datasets is detailed in Table 3. In the experiments, we used the Bert_wwm (BERT Whole Word Mask) model and the Bert-Chinese-base (Google) model as base models for comparison. A comparative analysis of the experimental results is summarized in Table 4.
[0138] Table 3 Dataset sample distribution statistics
[0139]
[0140] Table 4 Comparative experimental results Top-1 (%)
[0141]
[0142] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple. For relevant parts, refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without expending creative work.
[0143] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein may be implemented by electronic hardware, computer software, or a combination of both.
[0144] To clearly illustrate the interchangeability of hardware and software, the above descriptions have generally described the components and steps of each example by function. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Professionals may use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of the present invention.
[0145] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A deep learning Chinese sentence text sentiment analysis method based on knowledge graph, characterized by: The following steps are involved: S1. Data acquisition step: obtaining Chinese text sequences; S2, data preprocessing step: perform data cleaning, Chinese word segmentation, part-of-speech analysis, and syntactic dependency analysis on the Chinese text sequence obtained in S1 to obtain a part-of-speech data set and a syntactic dependency relationship set; S3, build emotional knowledge graph: Based on the part-of-speech data set and syntactic dependency relationship set obtained in S2, build an emotional knowledge base and establish an emotional knowledge relationship structure; S4, text encoding step: combine the sentiment knowledge relationship structure obtained in S3 with the original text, and use the BERT encoder to encode the combined text; S5. Pooling layer optimization step: Construct a BERT deep learning framework with a binary classification classifier for the pooling output layer. Use the cross-entropy loss function to train the BERT deep learning framework to obtain a sentiment analysis model based on the sentiment semantic relationship of the knowledge graph. S6, performance testing step: input the test Chinese sequence into the sentiment analysis model based on the knowledge graph sentiment semantic relationship obtained in S5, perform sentiment word matching and enhancement on the text sequence segmentation according to the constructed knowledge graph library, and then identify and analyze the sentiment polarity of the input sentence; The specific steps in S2 include: S201, setting a filtering regular expression to filter non-informative special symbols in the text of the sentence and performing data cleaning on the Chinese text sequence obtained in S1 to obtain a cleaned Chinese text sequence; S202, performing Chinese word segmentation on the cleaned Chinese text sequence obtained in S201, retaining the text comment content; S203, using the LTP word segmentation tool to perform part-of-speech analysis on the text comment content obtained in S202 to obtain a set of sentiment segmentation words with part-of-speech information: S l ={LTP.seg adj (S),LTP.seg verb (S),LTP.seg adverb (S)} Among them, S l is a set of sentiment segmentation words with part-of-speech information, LTP.seg adj (S) is the sentiment segmentation set of adjectives, LTP.seg verb (S) is the sentiment segmentation set of verbs, LTP.seg adverb (S) is the set of sentiment participles of adverbs; S204, extracting the eSUCC subsequent relationship, mDEPD dependency tag relationship, and party role relationship EXP by analyzing the dependency relationship between words or characters; S sdpg ={LTP.sdpg(S)} Among them, S sdpg is the word dependency set of sentence S, and LTP.sdpg(S) is the word dependency analysis of sentence S using the LTP word segmentation platform; The specific steps in S3 include: S301: For the part-of-speech data set and the syntactic dependency relationship set obtained in S2, extract phrase entities and set the relationship between phrase entities according to the algorithm rules: S302: Based on the phrase entity obtained in S301 and the relationship between the phrase entities, set the sentiment relationship between the phrase entities and output it to a csv file; S303. Based on the csv file stored in S302, construct the triple knowledge relationship of the phrases, and optimize the set of triple relationships of the emotional phrases in the locally constructed emotional knowledge graph to obtain the emotional knowledge graph library.
2. A method for sentiment analysis of Chinese sentences based on deep learning of knowledge graph according to claim 1, characterized in that: The algorithm for extracting the relationship between phrase entities in S301 is as follows: in, Represents the relationship between two words in the constructed knowledge graph, Indicates a word or phrase w i The i-th word in the dependency set, S l (a, v, wp) represent the three parts of speech in the part-of-speech set, namely adjective, verb and adverb, pos(w i ) indicates a word or phrase w i Position in the sentence.
3. The method for sentiment analysis of Chinese sentences based on deep learning of knowledge graph according to claim 1 is characterized in that: The set of sentiment phrase triple relationships in the sentiment knowledge graph: F(x)=count(x) in, It represents the i-th triple relationship in the sentiment triple preprocessing CSV file, and the F(x) function represents the statistical quantity of the triple relationship.
4. The method for sentiment analysis of Chinese sentences based on deep learning of knowledge graph according to claim 1 is characterized in that: The specific contents of S4 include: S401, fuse the original sentence text sequence with the corresponding triples matched from the sentiment knowledge graph library, then use the encoder of the BERT model to encode the fused triples, and use Concat combination to combine the encodings of the two input data, Among them E s Encode the original text sequence, Encode the enhanced information after fusion of sentiment knowledge graph; S402: Input the code obtained in S401 into the feature encoding layer of the pre-trained model BERT, use the multi-head attention mechanism to perform parallel calculations, and use the sentiment knowledge graph to enhance and capture the correlation coefficient of the sentiment word combination relationship between words; S403. Perform a 10% Dropout operation on the attention output, and p is set to 0.
1.
5. The method for sentiment analysis of Chinese sentences based on deep learning of knowledge graph according to claim 2 is characterized in that: The specific contents of S5 include: S501, using the output of S403 to learn the Chinese text sentiment features through a Chinese pre-training model; S502: Modify the output classifier of the Chinese pre-training model and set it to a binary linear classifier to represent two sentiment polarities; S503. Compare the result of the previous step input with the sentiment polarity labeling corresponding to the training sample, use cross entropy as the loss function, and perform backpropagation on the model: L=-[y·log(p)+(1-y)·log(1-p)] Where y is the classification category marked in the training data set, p is the classification category predicted by the model, y,p∈{0,1}; S504: Perform 20 epochs of training on the result in S503.