User emotion classification method and device, server, medium and program product
By constructing word vectors, sentence vectors, and syntactic dependency graphs from user corpora, and using graph convolutional neural networks and the BERT model for user sentiment classification, the problem of low accuracy in predicting user sentiment categories in existing technologies is solved, and higher classification accuracy is achieved.
Patent Information
- Application Number
- CN202210202923.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-02
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2042-03-02
AI Technical Summary
The problem of low accuracy in predicting user sentiment categories in existing technologies.
By acquiring word vectors, sentence vectors, and syntactic dependency graphs from user corpora, a heterogeneous graph is constructed. Then, a graph convolutional neural network and the BERT model are used for sentiment classification, combining global and local information to classify user sentiment.
It improves the accuracy of user sentiment classification by comprehensively considering the global information of the corpus and the syntactic information of sentences, reducing the interference of non-target words, and enhancing the accuracy of sentiment classification.
Smart Images

Figure CN114896961B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a user sentiment classification method and device, a server, a medium and a program product. BACKGROUND
[0002] With the rapid development of Internet technology, a large amount of subjective text about users is generated on the Internet, which expresses the positive or negative sentiment of the public about the users. Banks can collect relevant text data about users on the Internet, analyze these data, and complete user public opinion analysis, public opinion survey and other work. This work plays an important role in the process of banks issuing loans to users and recovering loans. Since a text often involves multiple users, the text will express different sentiments for each user.
[0003] In the traditional technology, user sentiment analysis is defined as a sentiment classification task of a word, and the context information of adjacent words in a sentence is encoded by a convolutional neural network (CNN) or a long short term memory (LSTM) to obtain an encoding result, and the sentiment category of the user is predicted based on the encoding result. However, the existing technology has the problem of low prediction accuracy of the sentiment category. SUMMARY
[0004] Therefore, it is necessary to provide a user sentiment classification method, device, server, medium and program product capable of improving the prediction accuracy of the sentiment category to solve the above technical problems.
[0005] In a first aspect, the present application provides a user sentiment classification method, which comprises:
[0006] obtaining a word vector, a sentence vector and a syntactic dependency relation graph of a corpus of a user;
[0007] obtaining a heterogeneous graph between words and sentences in the training corpus sample;
[0008] inputting the word vector, the sentence vector and the heterogeneous graph into a sentence sentiment classification model to obtain a first hidden state vector;
[0009] inputting the word vector and the syntactic dependency relation graph into a user sentiment classification model to obtain a second hidden state vector;
[0010] determining a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector.
[0011] In one of the embodiments, the determining the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector comprises:
[0012] filtering out sentence hidden state vectors in the first hidden state vector to obtain word hidden state vectors;
[0013] filtering out non-target words in the word hidden state vectors to obtain first target word hidden state vectors;
[0014] determining the sentiment classification result of the user according to the first target word hidden state vectors and the second hidden state vector.
[0015] In one of the embodiments, the determining the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector comprises:
[0016] inputting the second hidden state vector into a local sentiment classification model in the user sentiment classification model to obtain word hidden state vectors of syntactic information;
[0017] filtering out non-target words in the word hidden state vectors of syntactic information to obtain second target word hidden state vectors;
[0018] determining the sentiment classification result of the user according to the first hidden state vector, the second hidden state vector, and the second target word hidden state vector.
[0019] In one of the embodiments, the determining the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector comprises:
[0020] determining the sentiment classification result of the user according to the first target word hidden state vector, the second hidden state vector, and the second target word hidden state vector.
[0021] In one of the embodiments, the obtaining the heterogeneous graph between words and sentences in the training corpus sample comprises:
[0022] obtaining first edge weights between words in the training corpus sample and obtaining second edge weights between words and sentences in the training corpus sample;
[0023] obtaining the heterogeneous graph according to the first edge weights and the second edge weights.
[0024] In one of the embodiments, the method further comprises:
[0025] obtaining word vector samples and sentence vector samples of the training corpus sample;
[0026] The sentence sentiment initial classification model is trained by using the word vector sample, the sentence vector sample and the heterogeneous graph, and a sentence sentiment classification model is obtained.
[0027] In one of the embodiments, the method further comprises:
[0028] A syntax dependency graph sample of a sentence in the training corpus sample is obtained.
[0029] The user sentiment initial classification model is trained by using the word vector sample and the syntax dependency graph sample, and a user sentiment classification model is obtained.
[0030] In a second aspect, the application further provides a user sentiment classification device, which comprises:
[0031] A first obtaining module is configured to obtain a word vector, a sentence vector and a syntax dependency graph of a corpus of a user.
[0032] A second obtaining module is configured to obtain a heterogeneous graph between words and sentences in the training corpus sample.
[0033] A third obtaining module is configured to input the word vector, the sentence vector and the heterogeneous graph into a sentence sentiment classification model to obtain a first hidden state vector.
[0034] A fourth obtaining module is configured to input the word vector and the syntax dependency graph into a user sentiment classification model to obtain a second hidden state vector.
[0035] A determining module is configured to determine a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector.
[0036] In a third aspect, the application further provides a server, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0037] A word vector, a sentence vector and a syntax dependency graph of a corpus of a user are obtained.
[0038] A heterogeneous graph between words and sentences in the training corpus sample is obtained.
[0039] The word vector, the sentence vector and the heterogeneous graph are input into a sentence sentiment classification model to obtain a first hidden state vector.
[0040] The word vector and the syntax dependency graph are input into a user sentiment classification model to obtain a second hidden state vector.
[0041] determine the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector.
[0042] In a fourth aspect, the present application provides a computer readable storage medium, wherein the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the following steps:
[0043] obtain a word vector, a sentence vector and a syntactic dependency graph of a corpus of a user;
[0044] obtain a heterogeneous graph between words and sentences in the training corpus sample;
[0045] input the word vector, the sentence vector and the heterogeneous graph into a sentence sentiment classification model to obtain a first hidden state vector;
[0046] input the word vector and the syntactic dependency graph into a user sentiment classification model to obtain a second hidden state vector;
[0047] determine the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector.
[0048] In a fifth aspect, the present application provides a computer program product, wherein the computer program product comprises a computer program which, when executed by a processor, implements the following steps:
[0049] obtain a word vector, a sentence vector and a syntactic dependency graph of a corpus of a user;
[0050] obtain a heterogeneous graph between words and sentences in the training corpus sample;
[0051] input the word vector, the sentence vector and the heterogeneous graph into a sentence sentiment classification model to obtain a first hidden state vector;
[0052] input the word vector and the syntactic dependency graph into a user sentiment classification model to obtain a second hidden state vector;
[0053] determine the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector.
[0054] The user emotion classification method, device, server, medium and program product, the server obtains the word vector, sentence vector and syntactic dependency relation graph of the user corpus, obtains the heterogeneous graph between the words and sentences in the training corpus sample, can input the word vector, sentence vector and heterogeneous graph into the sentence emotion classification model to obtain the first hidden state vector, input the word vector and syntactic dependency relation graph into the user emotion classification model to obtain the second hidden state vector, so that the word vector and syntactic dependency relation graph can be input into the user emotion classification model to obtain the second hidden state vector. Through the sentence emotion classification model and the user emotion classification model, the first hidden state vector and the second hidden state vector are obtained, the first hidden state vector can reflect the global information of the user corpus, and the second hidden state vector can reflect the syntactic information of the sentence in the user corpus, thereby improving the accuracy of the user emotion classification result determined according to the first hidden state vector and the second hidden state vector. BRIEF DESCRIPTION OF DRAWINGS
[0055] Figure 1 An application environment diagram of the user emotion classification method in an embodiment;
[0056] Figure 2 A flowchart of the user emotion classification method in an embodiment;
[0057] Figure 3 A syntactic dependency relation graph of the user emotion classification method in an embodiment;
[0058] Figure 4 A heterogeneous graph of the user emotion classification method in another embodiment;
[0059] Figure 5 A flowchart of the user emotion classification method in an embodiment;
[0060] Figure 6 A flowchart of the user emotion classification method in an embodiment;
[0061] Figure 7 A flowchart of the user emotion classification method in an embodiment;
[0062] Figure 8 A flowchart of the user emotion classification method in an embodiment;
[0063] Figure 9 A flowchart of the user emotion classification method in an embodiment;
[0064] Figure 10 A flowchart of the user emotion classification method in an embodiment;
[0065] Figure 11 A flowchart of the user emotion classification method in an embodiment;
[0066] Figure 12 A structural schematic diagram of a user emotion classification device in an embodiment. DETAILED DESCRIPTION
[0067] For the purpose, technical solutions and advantages of the present application to be more clear and explicit, the present application is further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0068] It should be noted that the user emotion classification method, device, server, medium and program product of the present disclosure can be applied in the field of artificial intelligence, and can also be used in other technical fields other than artificial intelligence. The present disclosure does not limit the application field of the user emotion classification method, device, server, medium and program product.
[0069] The user emotion classification method provided by the embodiments of the present application can be applied in the application environment as shown in Figure 1 The server includes a processor, a memory and a network interface connected through a system bus. The processor of the server is used to provide computing and control capabilities. The memory of the server includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the server is used to store user emotion classification data. The network interface of the server is used to communicate with external terminals through network connection. The server can be implemented by an independent server or a server cluster composed of multiple servers.
[0070] In one embodiment, as shown in Figure 2 A user emotion classification method is provided, which is taken as an example to illustrate the server in Figure 1 The method includes the following steps:
[0071] S201, obtaining the word vector, sentence vector and syntactic dependency relation graph of the user's corpus.
[0072] The syntactic dependency relation graph refers to deriving the syntactic structure of the sentence by identifying the syntactic center of each word in the sentence, obtaining the dependency relation between the words in the sentence, and drawing the syntactic dependency relation graph corresponding to the sentence.
[0073] Specifically, the server can tag user names and periodically retrieve user corpora based on these tags at preset time intervals. Optionally, the server can convert the user's corpus information into word vectors according to preset conversion rules, or the server can input the user's corpus into a preset neural network model, and after calculation by the neural network model, output the word vectors corresponding to the user's corpus. This embodiment does not limit the method of retrieving word vectors from the user's corpus. The server can add the word vectors corresponding to sentences in the user's corpus to obtain the sentence vectors corresponding to the user's corpus. For example, after retrieving the user's corpus, the compiler initializes this corpus into a vector representation X, where X refers to the vector of each word and sentence in the sentence. w A vector representing a word, X d A vector representation of a sentence.
[0074] Furthermore, it is understandable that the server can invoke relevant syntactic dependency extractors to obtain the syntactic dependency graphs of sentences in the user's corpus. Each sentence corresponds to a syntactic dependency graph. For example, assuming the sentence in the user's corpus is "On the morning of September 9th, A defeated player D at B's place," the corresponding syntactic dependency graph would be as follows: Figure 3 As shown in Figure 3, the lines connecting any two words represent syntactic dependencies between the two words. The nodes in the figure are each word node in the sentence. When any two words have any syntactic dependency, there is an edge between the nodes corresponding to these two words.
[0075] S202, obtain the heterogeneity graph between words and sentences in the training corpus samples.
[0076] Specifically, the heterogeneity graph between words and sentences in the training corpus samples is as follows: Figure 4 As shown, Figure 4 In this diagram, 'w' represents a word and 'd' represents a sentence. Lines connecting words indicate a relationship between them, and lines connecting words and sentences indicate a relationship between them. The server can obtain a heterogeneous graph of words and sentences in the training corpus samples using relevant identifiers.
[0077] S203: Input word vectors, sentence vectors, and heterogeneous graphs into the sentence sentiment classification model to obtain the first hidden state vector.
[0078] The sentence sentiment classification model refers to the sentiment category of the whole sentence obtained by analyzing the sentiment of the whole sentence. The graph convolutional neural network is a method capable of deep learning of graph data. The traditional CNN can extract the features of the picture through the kernel. The kernel is a small window, which is translated on the picture and extracts the features through convolution. The structure of the features in the window must be invariant, but for graph data, the internal structure of the features at different positions is different, which leads to the CNN being unable to process the graph data, while the graph convolutional neural network (GCN) can extract the features of the graph data from the graph. Based on these graph data features, the graph data can be classified. In the field of natural language processing, many studies apply the graph convolutional neural network to the coding of syntactic dependency relations, thereby improving the effect of related tasks. Therefore, the initial graph convolutional neural network model can be trained through a large amount of data to obtain a global graph convolutional neural network model (Global-GCN), and the global graph convolutional neural network model is used as the sentence sentiment classification model.
[0079] Specifically, the server can input the word vector, the sentence vector and the heterogeneous graph as an input signal of the sentence sentiment classification model into the sentence sentiment classification model, and pass through a first hidden state vector of the sentence sentiment classification model. The first hidden state vector refers to a hidden state vector of global information, and the hidden state vector of global information includes a word hidden state vector of global information and a sentence hidden state vector of global information. The process can be represented as:
[0080]
[0081]
[0082] wherein, and are the hidden state vectors output by the first and second convolutional layers of the Global-GCN respectively; W0 and W1 are the parameter matrices of the first and second convolutional layers of the Global-GCN respectively; A1 is the adjacency matrix corresponding to the heterogeneous graph.
[0083] Both the word hidden state vector and the sentence hidden state vector are included, and the word hidden state vector is filtered out using the filter g-mask, the hidden state vector of the sentence is normalized to obtain the sentiment value of the hidden state vector of the sentence, and the sentiment category of the sentence is predicted according to the sentiment value. The process can be represented as:
[0084]
[0085]
[0086] wherein, is the filtered sentence hidden state vector; Z is the sentiment prediction result of the sentence.
[0087] After obtaining the numerical value of the sentence sentiment classification, the numerical value is subtracted from the standard value to obtain the difference between the numerical value of the sentence sentiment classification and the standard value. The value of the loss function is calculated according to the difference, and the related parameters in the sentence sentiment classification model are modified so that the numerical value of the sentence sentiment classification output by the modified sentence sentiment classification model is close to the standard value. When training the sentence sentiment classification model, the loss function can be expressed as:
[0088]
[0089] wherein, D is the number of expected sentences; F is the dimension size of the category prediction result; wherein, Y df represents the label matrix; Z df represents the prediction matrix of the sentence.
[0090] S204, input the word vector and the syntax dependency graph into the user sentiment classification model to obtain a second hidden state vector.
[0091] wherein, the user sentiment classification model refers to a language representation model (Bidirectional Encoder Representation from Transformers, BERT), which is used to convert the word vector and the syntax dependency into a word hidden state vector containing context information, and the word hidden state vector is taken as the second hidden state vector.
[0092] Specifically, the server can input the word vector and the syntax dependency graph as input signals of the user sentiment classification model into the user sentiment classification model. After feature extraction and dimension reduction processing of the user sentiment classification model, a word hidden state vector containing context information can be obtained, and the word hidden state vector is taken as the second hidden state vector.
[0093] S205, determine the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector.
[0094] Optionally, the server can score the first hidden state vector and the second hidden state vector according to a preset standard, calculate an average value of the score results of the first hidden state vector and the second hidden state vector, and take the average value as the emotional classification result of the user, or the server can calculate a weighted average value of the score results of the first hidden state vector and the second hidden state vector, and take the weighted average value as the emotional classification result of the user. The embodiment is not limited in terms of the manner of determining the emotional classification result of the user according to the first hidden state vector and the second hidden state vector.
[0095] In the above user emotional classification method, the server obtains the word vector, the sentence vector and the syntactic dependency relation graph of the user corpus, obtains the heterogeneous graph between the words and the sentences in the training corpus sample, inputs the word vector, the sentence vector and the heterogeneous graph into the sentence emotional classification model to obtain the first hidden state vector, inputs the word vector and the syntactic dependency relation graph into the user emotional classification model to obtain the second hidden state vector, and inputs the word vector and the syntactic dependency relation graph into the user emotional classification model to obtain the second hidden state vector. The first hidden state vector and the second hidden state vector are obtained through the sentence emotional classification model and the user emotional classification model. The first hidden state vector can reflect the global information of the user corpus, and the second hidden state vector can reflect the syntactic information of the sentences in the user corpus, thereby improving the accuracy of the emotional classification result of the user determined according to the first hidden state vector and the second hidden state vector.
[0096] Figure 5 A flowchart of a user emotional classification method provided by the embodiment is shown. The embodiment relates to an optional implementation manner of determining the emotional classification result of the user according to the first hidden state vector and the second hidden state vector. Figure 2 On the basis of the embodiment shown in Figure 5 The step S205 can include the following steps:
[0097] S501, filtering out the sentence hidden state vector in the first hidden state vector to obtain a word hidden state vector;
[0098] The first hidden state vector refers to a global information hidden state vector, and the global information hidden state vector includes a global information sentence hidden state vector and a global information word hidden state vector.
[0099] Specifically, the server can filter out the sentence hidden state vector in the global information hidden state vector through a related filter to obtain a global information word hidden state vector, and take the global information word hidden state vector as the word hidden state vector.
[0100] S502, filtering out non-target words in the word hidden state vector to obtain a first target word hidden state vector;
[0101] The word hidden state vector of global information includes the target word hidden state vector of global information and the non-target word hidden state vector of global information.
[0102] Specifically, the server can use relevant filters to filter the hidden state vectors of non-target words in the hidden state vectors of words in the global information, obtaining the hidden state vector of the target word in the global information, and using the hidden state vector of the target word in the global information as the first target word hidden state vector. The relevant filter can be s-mask2, and this process can be expressed by the formula:
[0103]
[0104] in, H is the word hidden state vector of global information. tg It is the target word hidden state vector containing global information, and
[0105] S503, determine the user's sentiment classification result based on the first target word hidden state vector and the second hidden state vector.
[0106] Optionally, the server can score the first target word hidden state vector and the second hidden state vector using preset criteria, calculate the average of the scores, and use this average as the user's sentiment classification result. Alternatively, the server can calculate a weighted average of the scores for the first target word hidden state vector and the second hidden state vector, and use this weighted average as the user's sentiment classification result. This embodiment does not limit the method for determining the user's sentiment classification result based on the first target word hidden state vector and the second hidden state vector.
[0107] In the aforementioned user sentiment classification method, the server obtains word hidden state vectors by filtering out sentence hidden state vectors from the first hidden state vector. This allows the server to filter out non-target words from the word hidden state vectors, resulting in the first target word hidden state vector. Furthermore, the server can determine the user's sentiment classification result based on the first target word hidden state vector and the second hidden state vector. Filtering out sentence hidden state vectors and non-target word hidden state vectors avoids interference from sentences and non-target words in sentiment classification, thus improving the accuracy of target word sentiment classification.
[0108] Figure 6 This is a flowchart illustrating the user sentiment classification method provided in an embodiment of this application. This embodiment relates to an optional implementation of determining the user's sentiment classification result based on a first hidden state vector and a second hidden state vector. Figure 2 Based on the illustrated embodiments, as Figure 3 As shown, the above S205 may include the following steps:
[0109] S601, input the second hidden state vector into a local sentiment classification model in the user sentiment classification model to obtain a word hidden state vector of syntactic information.
[0110] Specifically, the local sentiment classification model refers to obtaining the sentiment category of the target word by analyzing the sentiment of the target word in the sentence. The local sentiment classification model can train an initial graph convolutional neural network model through a large amount of data to obtain a local graph convolutional neural network model (Single-Graph Convolutional Network, Single-GCN), and use the local graph convolutional neural network model as the user sentiment classification model. The server inputs the second hidden state vector as an input signal of the local sentiment classification model into the local sentiment classification model, and obtains the word hidden state vector of syntactic information through training and dimension reduction of the local sentiment classification model. This process can be represented by the following formula:
[0111]
[0112]
[0113] wherein, and are the hidden state representations output by the first and second convolutional layers of Single-GCN respectively; W3 and W4 are the parameter matrices of the first and second graph convolutional neural network layers of Single-GCN respectively; A2 is the adjacency matrix corresponding to the syntactic dependency relation graph; T represents the second hidden state vector; and RELU represents an activation function commonly used in artificial neural networks.
[0114] S602, filter out the non-target word hidden state vector in the word hidden state vector of syntactic information to obtain a second target word hidden state vector.
[0115] wherein, the word hidden state vector of syntactic information includes the hidden state vector of the target word and the hidden state vector of the non-target word.
[0116] Specifically, the server can filter out the hidden state vector of the non-target word in the word hidden state vector of syntactic information through a related filter to obtain the hidden state vector of the target word of syntactic information, and the hidden state vector of the target word of syntactic information becomes the second target word hidden state vector. The related filter can be s-mask1, and this process can be represented by the following formula:
[0117]
[0118] wherein, is the word hidden state vector of syntactic information, and Hts is a target word hidden state vector containing syntactic information, and
[0119] S603, determining the emotional classification result of the user according to the first hidden state vector, the second hidden state vector, and the second target word hidden state vector.
[0120] In the above user emotional classification method, the server can input the second hidden state vector into a local emotional classification model in the user emotional classification model to obtain a word hidden state vector of syntactic information, so as to filter out non-target words in the word hidden state vector of syntactic information to obtain the second target word hidden state vector, and then determine the emotional classification result of the user according to the first hidden state vector, the second hidden state vector, and the second target word hidden state vector. The non-target word hidden state vector in the syntactic information is filtered out, which can avoid the interference of the non-target word hidden state vector in the syntactic information on the emotional classification, and improve the accuracy of the target word emotional classification.
[0121] The embodiment of the present application relates to an optional implementation mode of determining the emotional classification result of the user according to the first hidden state vector and the second hidden state vector. The above S205 can further include the following steps: determining the emotional classification result of the user according to the first target word hidden state vector, the second hidden state vector, and the second target word hidden state vector.
[0122] Specifically, the server can encode the second hidden state vector T, the first target word hidden state vector H tg and the second target word hidden state vector H ts through the attention mechanism (Attention) in the related formula to obtain the hidden state vector r of the target word. The process can be represented as:
[0123]
[0124]
[0125]
[0126] Wherein, β is an artificially set hyperparameter for adjusting the weight of global information and syntactic information; denotes the relationship matrix of the first tag hidden state vector, denotes the relationship matrix of the second target word hidden state vector.
[0127] The hidden state vector r of the target word is taken as the input of the normalization processing, and the numerical value of the target word emotional classification is obtained through the normalization processing. The process can be represented as:
[0128] p=softmax(W p r)
[0129] wherein W p represents a weight matrix.
[0130] When the numerical value of the target word sentiment classification is obtained, the numerical value is subtracted from the standard value to obtain the difference between the numerical value of the target word sentiment classification and the standard value, and the value of the loss function is calculated according to the difference, so that the relevant parameters in the user sentiment classification model are modified, so that the numerical value of the target word sentiment classification output by the modified user sentiment classification model is close to the standard value. When training the user sentiment classification model, the loss function can be expressed as:
[0131]
[0132] wherein Y df represents a label matrix; r f represents a target word prediction matrix.
[0133] In the above user sentiment classification method, the server can determine the user's sentiment classification result according to the first target word hidden state vector, the second hidden state vector and the second target word hidden state vector. This process comprehensively considers the target word hidden state vector of global information, the target word hidden state vector of local information and the word hidden state vector of context relationship, which can solve the problem that the user's sentiment category can only be inferred according to the sentiment categories of the adjacent two words in the prior art. At the same time, the specific sentiment value corresponding to the target word is calculated through the attention mechanism and normalization processing, which improves the accuracy of user sentiment classification. At the same time, the user sentiment classification model is continuously optimized through the loss function, which improves the accuracy of the user sentiment classification model.
[0134] Figure 7 The flowchart of the user sentiment classification method provided by the embodiments of the present application is shown. The embodiments of the present application relate to an optional implementation of obtaining a heterogeneous graph between words and sentences in a training corpus sample. In Figure 2 On the basis of the embodiment shown in Figure 7 The above S202 can include the following steps:
[0135] S701, obtaining a first edge weight between words in a training corpus sample, and obtaining a second edge weight between words and sentences in the training corpus sample.
[0136] Specifically, the server can calculate the first edge weight between words in the training corpus sample according to the relevant calculation formula, and also calculate the second edge weight between words and sentences in the training corpus sample. From Figure 4 As can be seen from the heterogeneous graph, the heterogeneous graph contains two types of nodes, sentence nodes and word nodes, and the total number of nodes in the graph is the sum of the number of all sentences in the corpus and the number of all words in the corpus. The weight of the edge in the heterogeneous graph can be represented as:
[0137]
[0138] wherein, when the nodes i and j are both word nodes, the first edge weight is the Purchasing Managers' Index (PMI); when the nodes i and j are a word node and a sentence node respectively, the second edge weight is the Term Frequency Inverse Document Frequency (TF-IDF); when the nodes i and j are equal, the edge weight is 1; and the rest of the cases, the edge weight is 0. In the calculation of PMI, a fixed size sliding window is used to count the word co-occurrence frequency in the whole corpus; in the calculation of TF-IDF, the influence degree of each word on the sentence is calculated.
[0139] S702, obtaining the heterogeneous graph according to the first edge weight and the second edge weight.
[0140] Specifically, the server can draw the connection between the words and the connection between the words and the sentences according to the numerical size of the first edge weight and the second edge weight, and can obtain the heterogeneous graph corresponding to the training corpus sample. When the edge weight value is larger, the corresponding connection is thicker, and when the edge weight value is smaller, the corresponding connection is thinner.
[0141] In the above user sentiment classification method, the server obtains the first edge weight between the words in the training corpus sample, and obtains the second edge weight between the words and the sentences in the training corpus sample, and obtains the heterogeneous graph according to the first edge weight and the second edge weight. By calculating the edge weight, the relationship between the words and the words and the relationship between the words and the sentences can be accurately obtained, so that the heterogeneous graph corresponding to the training corpus sample can be accurately drawn.
[0142] Figure 8 The flowchart of the user sentiment classification method provided by the embodiment of the application is shown. The embodiment of the application relates to an optional implementation mode of obtaining the heterogeneous graph between the words and the sentences in the training corpus sample. In the embodiment of the application, Figure 2 As shown in the embodiment, the above method further includes the following steps: Figure 8
[0143] S801, obtaining the syntactic dependency relation graph sample of the sentence.
[0144] Specifically, the server can obtain the syntactic dependency relation in each sentence in the training corpus sample according to a related algorithm or call a sentence dependency extractor, each sentence corresponds to a graph, the nodes in the graph are each word node in the sentence, when there is any syntactic dependency relation between any two words, there is an edge between the nodes corresponding to the two words, and the syntactic dependency relation graph is drawn through the syntactic dependency relation and the edge between the words.
[0145] S802, training the user emotion initial classification model by using the word vector sample and the syntax dependency graph sample, to obtain a user emotion classification model.
[0146] Specifically, the server can mark the word vector sample and the syntax dependency graph sample respectively, input the marked word vector sample and the syntax dependency graph sample into the user emotion initial classification model, and train the user emotion initial classification model by a large number of samples, so as to obtain the user emotion classification model. Meanwhile, in the actual application process, sample data can be dynamically added to enrich the user emotion corpus information library and retrain the user emotion classification model, so as to further improve the prediction accuracy of the model.
[0147] In the above user emotion classification method, the server obtains the syntax dependency graph sample of the sentence in the training corpus sample, so as to train the user emotion initial classification model by using the word vector sample and the syntax dependency graph sample, obtain the user emotion classification model, and train the user emotion initial classification model by using the word vector sample and the syntax dependency graph sample, so as to make the obtained user emotion initial classification model more accurate and improve the accuracy of user emotion classification.
[0148] In one embodiment, for the convenience of those skilled in the art, the user emotion classification method is described in detail as follows, as shown in the following figure, the method can include: Figure 9
[0149] S901, obtaining a word vector sample and a sentence vector sample of a training corpus sample;
[0150] S902, obtaining a first edge weight between words in the training corpus sample and a second edge weight between the words and the sentence in the training corpus sample;
[0151] S903, obtaining a heterogeneous graph according to the first edge weight and the second edge weight;
[0152] S904, training a sentence emotion initial classification model by using the word vector sample, the sentence vector sample and the heterogeneous graph, to obtain a sentence emotion classification model;
[0153] S905, obtaining a syntax dependency graph sample of a sentence in the training corpus sample;
[0154] S906, training the user emotion initial classification model by using the word vector sample and the syntax dependency graph sample, to obtain a user emotion classification model;
[0155] S907, obtaining a word vector, a sentence vector and a syntax dependency graph of a corpus of a user;
[0156] S908, obtain a heterogeneous graph between words and sentences in the training corpus sample;
[0157] S909, input the word vector, the sentence vector and the heterogeneous graph into the sentence sentiment classification model to obtain a first hidden state vector;
[0158] S910, filter out a sentence hidden state vector in the first hidden state vector to obtain a word hidden state vector;
[0159] S911, filter out a non-target word in the word hidden state vector to obtain a first target word hidden state vector;
[0160] S912, input the word vector and the syntactic dependency relation graph into the user sentiment classification model to obtain a second hidden state vector;
[0161] S913, input the second hidden state vector into a local sentiment classification model in the user sentiment classification model to obtain a word hidden state vector of syntactic information;
[0162] S914, filter out a non-target word in the word hidden state vector of syntactic information to obtain a second target word hidden state vector;
[0163] S915, determine a sentiment classification result of the user according to the first target word hidden state vector, the second hidden state vector and the second target word hidden state vector.
[0164] It should be noted that the description in S901-S915 can refer to the description of the related embodiments, and the effects are similar, and the embodiments will not be repeated here.
[0165] Further, Figure 10 and Figure 11 represent a flowchart of a user sentiment classification method, in which Figure 10In the method, corpus information of a user is input into an encoder to obtain a word vector and a sentence vector corresponding to the corpus information of the user, the heterogeneous graph, the sentence vector and the word vector are input into a sentence sentiment classification model to output a hidden state vector of global information, a word hidden state vector in the hidden state vector of global information is filtered through a filter 3 to obtain a sentence hidden state vector of global information, the sentence hidden state vector of global information is normalized to obtain a sentiment classification result of a global information sentence; the word vector and a sentence dependency relation graph are input into a user sentiment classification model, a word hidden state vector of context information is output through training, the word hidden state vector of context information is input into a local sentiment classification model to output a word hidden state vector of syntactic relation, a non-target word hidden state vector in the word hidden state vector of syntactic relation is filtered through a filter 1 to obtain a target word hidden state vector of syntactic relation, a sentence hidden state vector of global information and the non-target word hidden state vector in the hidden state vector of global information are filtered through a filter 2 to obtain a target word hidden state vector of global information, the target word hidden state vector of global information, the word hidden state vector of context information and the target word hidden state vector of syntactic relation are input into an attention mechanism for scoring, and the scoring result is normalized to obtain a sentiment classification result of the user. Figure 11 In the method, the sentence sentiment classification model and the target word sentiment classification model are iteratively trained through training corpus samples to obtain a more accurate target word sentiment classification model, and the model is used for predicting the sentiment of the user to obtain the sentiment classification result of the user.
[0166] In the above user sentiment classification method, the word vector sample and the sentence vector sample of the training corpus sample are obtained, the first edge weight between the words in the training corpus sample is obtained, and the second edge weight between the words and the sentences in the training corpus sample is obtained, the heterogeneous graph is obtained according to the first edge weight and the second edge weight, the sentence sentiment initial classification model is trained by using the word vector sample, the sentence vector sample and the heterogeneous graph, the sentence sentiment classification model is obtained, the syntactic dependency graph sample of the sentence in the training corpus sample is obtained, the user sentiment initial classification model is trained by using the word vector sample and the syntactic dependency graph sample, the user sentiment classification model is obtained, the word vector, the sentence vector and the syntactic dependency graph of the corpus of the user are obtained, the heterogeneous graph between the words and the sentences in the training corpus sample is obtained, the word vector, the sentence vector and the heterogeneous graph are input into the sentence sentiment classification model, the first hidden state vector is obtained, the sentence hidden state vector in the first hidden state vector is filtered out, the word hidden state vector is obtained, the non-target word in the word hidden state vector is filtered out, the first target word hidden state vector is obtained, the word vector and the syntactic dependency graph are input into the user sentiment classification model, the second hidden state vector is obtained, the second hidden state vector is input into the local sentiment classification model in the user sentiment classification model, the syntactic information word hidden state vector is obtained, the non-target word in the syntactic information word hidden state vector is filtered out, the second target word hidden state vector is obtained, and the sentiment classification result of the user is determined according to the first target word hidden state vector, the second hidden state vector and the second target word hidden state vector. Through the heterogeneous graph between the words and the sentences and the syntactic dependency graph, the word information and the syntactic information in the corpus can be encoded. At the same time, through the sentence sentiment classification model and the user sentiment classification model, the first hidden state vector and the second hidden state vector can combine the global information and the syntactic information of the user, so that the sentiment classification result of the user is more accurate and reasonable, and the target word sentiment classification task accuracy is improved.
[0167] It should be understood that, although each step in the flowchart involved in the above embodiments is shown in sequence according to the arrow, these steps are not necessarily executed in sequence according to the order of the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in the above embodiments can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be alternately executed with at least part of other steps or steps or stages in other steps.
[0168] Based on the same inventive concept, the embodiments of the present application also provide a user emotion classification device for implementing the above-mentioned user emotion classification method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more user emotion classification device embodiments provided below can refer to the limitations of the user emotion classification method in the above text, which will not be repeated here.
[0169] In one embodiment, as shown in Figure 12 a user emotion classification device is provided, comprising: a first acquisition module 11, a second acquisition module 12, a third acquisition module 13, a fourth acquisition module 14 and a determination module 15, wherein:
[0170] The first acquisition module 11 is configured to acquire the word vector, the sentence vector and the syntactic dependency graph of the user corpus;
[0171] The second acquisition module 12 is configured to acquire the heterogeneous graph between the word and the sentence in the training corpus sample;
[0172] The third acquisition module 13 is configured to input the word vector, the sentence vector and the heterogeneous graph into the sentence emotion classification model to obtain a first hidden state vector;
[0173] The fourth acquisition module 14 is configured to input the word vector and the syntactic dependency graph into the user emotion classification model to obtain a second hidden state vector;
[0174] The determination module 15 is configured to determine the emotion classification result of the user according to the first hidden state vector and the second hidden state vector.
[0175] The user emotion classification device provided in the embodiment can execute the above-mentioned method embodiments, and has similar implementation principles and technical effects, which will not be repeated here.
[0176] In one embodiment, the above-mentioned determination module 15 comprises: a first filtering unit, a second filtering unit and a first determination unit, wherein:
[0177] The first filtering unit is configured to filter out the sentence hidden state vector in the first hidden state vector to obtain a word hidden state vector;
[0178] The second filtering unit is configured to filter out the non-target word in the word hidden state vector to obtain a first target word hidden state vector;
[0179] The first determination unit is configured to determine the emotion classification result of the user according to the first target word hidden state vector and the second hidden state vector.
[0180] The user emotion classification device provided in the embodiment can execute the above-mentioned method embodiments, and has similar implementation principles and technical effects, which will not be repeated here.
[0181] In one embodiment, the determining module 15 comprises a first processing unit, a third filtering unit and a second determining unit, wherein:
[0182] The first processing unit is configured to input the second hidden state vector into a local sentiment classification model in the user sentiment classification model to obtain a word hidden state vector of the syntax information.
[0183] The third filtering unit is configured to filter out non-target words in the word hidden state vector of the syntax information to obtain a second target word hidden state vector.
[0184] The second determining unit is configured to determine a sentiment classification result of the user according to the first hidden state vector, the second hidden state vector and the second target word hidden state vector.
[0185] The user sentiment classification device provided in the embodiment can execute the method embodiments, and has similar implementation principles and technical effects, which will not be described here.
[0186] In one embodiment, the determining module 15 comprises a third determining unit, wherein:
[0187] The third determining unit is configured to determine a sentiment classification result of the user according to the first target word hidden state vector, the second hidden state vector and the second target word hidden state vector.
[0188] The user sentiment classification device provided in the embodiment can execute the method embodiments, and has similar implementation principles and technical effects, which will not be described here.
[0189] In one embodiment, the second obtaining module 12 comprises an obtaining unit and a fourth determining unit, wherein:
[0190] The obtaining unit is configured to obtain a first edge weight between words in a training corpus sample, and obtain a second edge weight between a word and a sentence in the training corpus sample.
[0191] The fourth determining unit is configured to obtain a heterogeneous graph according to the first edge weight and the second edge weight.
[0192] The user sentiment classification device provided in the embodiment can execute the method embodiments, and has similar implementation principles and technical effects, which will not be described here.
[0193] In one embodiment, the user sentiment classification device further comprises a fifth obtaining module and a sixth obtaining module, wherein:
[0194] The fifth obtaining module is configured to obtain a word vector sample and a sentence vector sample of a training corpus sample.
[0195] The sixth obtaining module is configured to train the sentence sentiment initial classification model by using the word vector sample, the sentence vector sample, and the heterogeneous graph, and obtain a sentence sentiment classification model.
[0196] The user sentiment classification apparatus provided in the embodiment can execute the method embodiments, and has similar implementation principles and technical effects, which will not be described here again.
[0197] In one embodiment, the user sentiment classification apparatus further includes a seventh obtaining module and a processing module.
[0198] The seventh obtaining module is configured to obtain a syntactic dependency graph sample of a sentence in the training corpus sample.
[0199] The processing module is configured to train the user sentiment initial classification model by using the word vector sample and the syntactic dependency graph sample, and obtain a user sentiment classification model.
[0200] The user sentiment classification apparatus provided in the embodiment can execute the method embodiments, and has similar implementation principles and technical effects, which will not be described here again.
[0201] The modules in the user sentiment classification apparatus can be all or partially implemented by software, hardware, or a combination thereof. The modules can be embedded in or independent of a processor in a server in a hardware form, or stored in a memory in the server in a software form, so as to be called and executed by a processor to perform operations corresponding to the modules.
[0202] In one embodiment, a server is provided, including a memory and a processor, the memory storing a computer program, and the processor implementing the following steps when executing the computer program:
[0203] Obtain a word vector, a sentence vector, and a syntactic dependency graph of corpus of a user;
[0204] Obtain a heterogeneous graph between words and sentences in a training corpus sample;
[0205] Input the word vector, the sentence vector, and the heterogeneous graph into a sentence sentiment classification model to obtain a first hidden state vector;
[0206] Input the word vector and the syntactic dependency graph into a user sentiment classification model to obtain a second hidden state vector;
[0207] Determine a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector.
[0208] In one embodiment, the processor further implements the following steps when executing the computer program: determining the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector, including:
[0209] filtering the sentence hidden state vector in the first hidden state vector to obtain a word hidden state vector;
[0210] filtering non-target words in the word hidden state vector to obtain a first target word hidden state vector;
[0211] determining a sentiment classification result of the user according to the first target word hidden state vector and the second hidden state vector.
[0212] In one embodiment, the processor further implements the following steps when executing the computer program: determining a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector, including:
[0213] inputting the second hidden state vector into a local sentiment classification model in the user sentiment classification model to obtain a word hidden state vector of syntactic information;
[0214] filtering non-target words in the word hidden state vector of syntactic information to obtain a second target word hidden state vector;
[0215] determining a sentiment classification result of the user according to the first hidden state vector, the second hidden state vector and the second target word hidden state vector.
[0216] In one embodiment, the processor further implements the following steps when executing the computer program: determining a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector, including:
[0217] determining a sentiment classification result of the user according to the first target word hidden state vector, the second hidden state vector and the second target word hidden state vector.
[0218] In one embodiment, the processor further implements the following steps when executing the computer program: obtaining a heterogeneous graph between words and sentences in a training corpus sample, including:
[0219] obtaining a first edge weight between words in the training corpus sample and a second edge weight between words and sentences in the training corpus sample;
[0220] obtaining the heterogeneous graph according to the first edge weight and the second edge weight.
[0221] In one embodiment, the processor further implements the following steps when executing the computer program:
[0222] obtaining a word vector sample and a sentence vector sample of the training corpus sample;
[0223] training a sentence sentiment initial classification model using the word vector sample, the sentence vector sample and the heterogeneous graph to obtain a sentence sentiment classification model.
[0224] In one embodiment, the processor further implements the following steps when executing the computer program:
[0225] Obtaining a syntax dependency graph sample of a sentence in the training corpus sample;
[0226] Training the user sentiment initial classification model by using the word vector sample and the syntax dependency graph sample, to obtain the user sentiment classification model.
[0227] In one embodiment, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the following steps:
[0228] Obtaining a word vector, a sentence vector and a syntax dependency graph of a corpus of a user;
[0229] Obtaining a heterogeneous graph between a word and a sentence in the training corpus sample;
[0230] Inputting the word vector, the sentence vector and the heterogeneous graph into the sentence sentiment classification model to obtain a first hidden state vector;
[0231] Inputting the word vector and the syntax dependency graph into the user sentiment classification model to obtain a second hidden state vector;
[0232] Determining a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector.
[0233] In one embodiment, the computer program is executed by the processor to further implement the following steps: determining the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector, including:
[0234] Filtering out a sentence hidden state vector in the first hidden state vector to obtain a word hidden state vector;
[0235] Filtering out a non-target word in the word hidden state vector to obtain a first target word hidden state vector;
[0236] Determining the sentiment classification result of the user according to the first target word hidden state vector and the second hidden state vector.
[0237] In one embodiment, the computer program is executed by the processor to further implement the following steps: determining the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector, including:
[0238] Inputting the second hidden state vector into a local sentiment classification model in the user sentiment classification model to obtain a word hidden state vector of syntax information;
[0239] Filtering out a non-target word in the word hidden state vector of syntax information to obtain a second target word hidden state vector;
[0240] According to the first hidden state vector, the second hidden state vector, and the second target word hidden state vector, a sentiment classification result of the user is determined.
[0241] In one embodiment, the computer program, when executed by the processor, further implements the following steps: according to the first hidden state vector and the second hidden state vector, determining a sentiment classification result of the user, comprising:
[0242] According to the first target word hidden state vector, the second hidden state vector, and the second target word hidden state vector, a sentiment classification result of the user is determined.
[0243] In one embodiment, the computer program, when executed by the processor, further implements the following steps: obtaining a heterogeneous graph between words and sentences in a training corpus sample, comprising:
[0244] Obtaining a first edge weight between words in the training corpus sample, and obtaining a second edge weight between words and sentences in the training corpus sample;
[0245] According to the first edge weight and the second edge weight, the heterogeneous graph is obtained.
[0246] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0247] Obtaining a word vector sample and a sentence vector sample of the training corpus sample;
[0248] Using the word vector sample, the sentence vector sample, and the heterogeneous graph, training a sentence sentiment initial classification model to obtain a sentence sentiment classification model.
[0249] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0250] Obtaining a syntactic dependency graph sample of a sentence in the training corpus sample;
[0251] Using the word vector sample and the syntactic dependency graph sample, training a user sentiment initial classification model to obtain a user sentiment classification model.
[0252] In one embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the following steps:
[0253] Obtaining a word vector, a sentence vector, and a syntactic dependency graph of a corpus of a user;
[0254] Obtaining a heterogeneous graph between words and sentences in a training corpus sample;
[0255] Inputting the word vector, the sentence vector, and the heterogeneous graph into the sentence sentiment classification model to obtain a first hidden state vector;
[0256] inputting the word vector and the syntax dependency graph into a user sentiment classification model to obtain a second hidden state vector;
[0257] determining a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector.
[0258] In one embodiment, the computer program, when executed by the processor, further implements the following steps: determining a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector, including:
[0259] filtering out the sentence hidden state vector in the first hidden state vector to obtain a word hidden state vector;
[0260] filtering out non-target words in the word hidden state vector to obtain a first target word hidden state vector;
[0261] determining a sentiment classification result of the user according to the first target word hidden state vector and the second hidden state vector.
[0262] In one embodiment, the computer program, when executed by the processor, further implements the following steps: determining a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector, including:
[0263] inputting the second hidden state vector into a local sentiment classification model in the user sentiment classification model to obtain a word hidden state vector of syntax information;
[0264] filtering out non-target words in the word hidden state vector of syntax information to obtain a second target word hidden state vector;
[0265] determining a sentiment classification result of the user according to the first hidden state vector, the second hidden state vector, and the second target word hidden state vector.
[0266] In one embodiment, the computer program, when executed by the processor, further implements the following steps: determining a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector, including:
[0267] determining a sentiment classification result of the user according to the first target word hidden state vector, the second hidden state vector, and the second target word hidden state vector.
[0268] In one embodiment, the computer program, when executed by the processor, further implements the following steps: obtaining a heterogeneous graph between words and sentences in a training corpus sample, including:
[0269] obtaining a first edge weight between words in the training corpus sample, and obtaining a second edge weight between words and sentences in the training corpus sample;
[0270] obtaining the heterogeneous graph according to the first edge weight and the second edge weight.
[0271] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0272] Obtaining a word vector sample and a sentence vector sample of a training corpus sample;
[0273] Using the word vector sample, the sentence vector sample, and the heterogeneous graph, training a sentence sentiment initial classification model to obtain a sentence sentiment classification model.
[0274] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0275] Obtaining a syntactic dependency graph sample of a sentence in the training corpus sample;
[0276] Using the word vector sample and the syntactic dependency graph sample, training a user sentiment initial classification model to obtain a user sentiment classification model.
[0277] It should be noted that the user information (including but not limited to user server information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.
[0278] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.
[0279] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.
[0280] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A user sentiment classification method, characterized by, The method comprises: obtaining word vectors, sentence vectors and syntactic dependency graphs of a corpus of a user; obtaining a heterogeneous graph between words and sentences in a training corpus sample; inputting the word vectors, the sentence vectors and the heterogeneous graph into a sentence sentiment classification model to obtain a first hidden state vector; inputting the word vectors and the syntactic dependency graph into a user sentiment classification model to obtain a second hidden state vector; determining a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector; The determining of the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector comprises: filtering out sentence hidden state vectors in the first hidden state vector to obtain word hidden state vectors; filtering out non-target words in the word hidden state vectors to obtain first target word hidden state vectors; and determining the sentiment classification result of the user according to the first target word hidden state vectors and the second hidden state vector.
2. The method of claim 1, wherein, The determining of the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector comprises: inputting the second hidden state vector into a local sentiment classification model in the user sentiment classification model to obtain word hidden state vectors of syntactic information; filtering out non-target words in the word hidden state vectors of syntactic information to obtain second target word hidden state vectors; and determining the sentiment classification result of the user according to the first hidden state vector, the second hidden state vector and the second target word hidden state vector.
3. The method of claim 2, wherein, The determining of the sentiment classification result of the user according to the first hidden state vector and the second hidden state vector comprises: determining the sentiment classification result of the user according to the first target word hidden state vectors, the second hidden state vector and the second target word hidden state vector.
4. The method of claim 1, wherein, The obtaining of the heterogeneous graph between words and sentences in the training corpus sample comprises: obtaining first edge weights between words in the training corpus sample and second edge weights between words and sentences in the training corpus sample; and obtaining the heterogeneous graph according to the first edge weights and the second edge weights.
5. The method according to any one of claims 1 to 4, characterized in that, The method further comprises: obtaining word vector samples and sentence vector samples of the training corpus sample; training a sentence sentiment initial classification model by using the word vector samples, the sentence vector samples and the heterogeneous graph to obtain the sentence sentiment classification model.
6. The method according to any one of claims 1 to 4, characterized in that, The method further comprises: obtaining syntactic dependency graph samples of sentences in the training corpus sample; training a user sentiment initial classification model by using the word vector samples and the syntactic dependency graph samples to obtain the user sentiment classification model.
7. A user emotion classification apparatus characterized by comprising: The apparatus comprises: a first obtaining module configured to obtain word vectors, sentence vectors and syntactic dependency graphs of a corpus of a user; a second obtaining module configured to obtain a heterogeneous graph between words and sentences in a training corpus sample; a third obtaining module configured to input the word vectors, the sentence vectors and the heterogeneous graph into a sentence sentiment classification model to obtain a first hidden state vector; a fourth obtaining module configured to input the word vectors and the syntactic dependency graph into a user sentiment classification model to obtain a second hidden state vector; and a determining module configured to determine a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector. The fourth obtaining module is configured to input the word vector and the syntax dependency graph into a user sentiment classification model to obtain a second hidden state vector; The determining module is configured to determine a sentiment classification result of the user according to the first hidden state vector and the second hidden state vector; The determining module comprises a first filtering unit, a second filtering unit and a first determining unit. The first filtering unit is configured to filter out a sentence hidden state vector in the first hidden state vector to obtain a word hidden state vector. The second filtering unit is configured to filter out a non-target word in the word hidden state vector to obtain a first target word hidden state vector. The first determining unit is configured to determine the sentiment classification result of the user according to the first target word hidden state vector and the second hidden state vector.
8. A server comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to implement the steps of the method in any one of claims 1 to 6.
9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.