CN114676692A - Comment sentence specific target keyword sentiment analysis method and system - Google Patents

Comment sentence specific target keyword sentiment analysis method and system Download PDF

Info

Publication number
CN114676692A
CN114676692A CN202111574366.6A CN202111574366A CN114676692A CN 114676692 A CN114676692 A CN 114676692A CN 202111574366 A CN202111574366 A CN 202111574366A CN 114676692 A CN114676692 A CN 114676692A
Authority
CN
China
Prior art keywords
target keyword
matrix
sentence
mapping
coding matrix
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111574366.6A
Other languages
Chinese (zh)
Inventor
刘新元
王昆
祝轲轲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianyi Cloud Technology Co Ltd
Original Assignee
Tianyi Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tianyi Cloud Technology Co Ltd filed Critical Tianyi Cloud Technology Co Ltd
Priority to CN202111574366.6A priority Critical patent/CN114676692A/en
Publication of CN114676692A publication Critical patent/CN114676692A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/216Parsing using statistical methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • Biomedical Technology (AREA)
  • Evolutionary Computation (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Biophysics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Probability & Statistics with Applications (AREA)
  • Machine Translation (AREA)

Abstract

The invention discloses a comment sentence specific target keyword emotion analysis method and a comment sentence specific target keyword emotion analysis system, wherein the comment sentence specific target keyword emotion analysis method comprises the following steps: the method comprises the steps of obtaining sentences to be subjected to target keyword emotion analysis and at least one target keyword, obtaining a sentence mapping matrix and a target keyword mapping matrix based on the sentences and the target keyword, respectively coding the sentence mapping matrix and the target keyword mapping matrix by utilizing a preset coder to obtain a sentence mapping coding matrix and a target keyword coding matrix, carrying out multiple weighting operation by utilizing a multi-level attention mechanism based on the sentence mapping coding matrix and the target keyword coding matrix to obtain an attention vector, and calculating the judgment probability of each emotion polarity by utilizing a Softmax function according to the attention vector, so that the defect that the importance of the target keyword is ignored when the sentences are modeled in the prior art is overcome.

Description

Comment sentence specific target keyword emotion analysis method and system
Technical Field
The invention relates to the field of natural language processing and text classification, in particular to a comment sentence specific target keyword emotion analysis method and system.
Background
In an internet platform, comment sentences are an important embodying carrier for user experience, and the satisfaction degree of a user is embodied by the emotion polarity of a specific object in the comment sentences. The specific target keyword text sentiment classification is a fine-grained sentiment analysis task. Today, there are various methods proposed for this research problem. Most models use machine learning algorithms to classify text in a supervised learning manner. Algorithms such as naive bayes and Support Vector Machines (SVMs) are widely used for this problem. In recent years, neural networks have greatly facilitated the richness of emotion classification studies. Neural network models aim at automatically learning efficient low-dimensional representations from targets and contexts and are used for tasks such as prediction, recognition, etc.; there have been some studies using an attention mechanism to generate target-specific sentence representations based on target keywords, but these studies have not conducted any further intensive research into the association of target keyword words and sentences.
In recent academic research, various neural network-based approaches have been introduced to address the problem of sentiment classification for specific target keywords. Most methods are based on RNN-like neural networks. TD-LSTM solves this problem by using two oppositely directed LSTM networks to model the left and right context of the target key vocabulary in the aspect, but the LSTM-based deep learning model in the prior art is mainly modeling sentences and neglecting the importance of the target keywords.
Disclosure of Invention
Therefore, the invention provides a method and a system for analyzing emotion of a specific target keyword of a comment sentence, aiming at overcoming the defect that an LSTM-based deep learning model in the prior art mainly models the sentence and neglects the importance of the target keyword.
In order to achieve the purpose, the invention provides the following technical scheme:
in a first aspect, an embodiment of the present invention provides a comment statement specific target keyword emotion analysis method, including: obtaining a sentence to be subjected to target keyword emotion analysis and at least one target keyword; obtaining a sentence mapping matrix and a target keyword mapping matrix based on the sentences and the target keywords; respectively encoding the sentence mapping matrix and the target keyword mapping matrix by using a preset encoder to obtain a sentence mapping encoding matrix and a target keyword encoding matrix; based on the statement mapping coding matrix and the target keyword coding matrix, performing multiple weighted operation by using a multi-level attention mechanism to obtain an attention vector; and calculating the judgment probability of each emotion polarity by utilizing a Softmax function according to the attention vector.
In an embodiment, the process of obtaining the sentence mapping matrix and the target keyword mapping matrix based on the sentence and the target keyword includes: obtaining a sentence mapping matrix according to the first pre-training word vector table and the distance between each word in the sentence and the target keyword; and querying a second pre-training word vector table to obtain a target keyword mapping matrix corresponding to the target keyword.
In an embodiment, the process of obtaining the sentence mapping matrix according to the first pre-training word list and the distance between each word in the sentence and the target keyword includes: removing the target keywords from the sentences, and recording the distance between each word in the sentences and the target keywords to obtain the position information of the sentences from which the target keywords are removed; inquiring a first pre-training word vector table, acquiring a mapping vector corresponding to the sentence with the target keyword removed, and generating a word vector matrix; coding and expanding the position information of the sentence with the target keyword removed to obtain a position information matrix, and taking the product of the position information matrix and a preset position information mapping matrix as a position vector matrix; and splicing the word vector matrix and the position vector matrix to obtain a statement mapping matrix.
In one embodiment, the default encoder is a bidirectional GRU network encoder.
In an embodiment, the process of respectively encoding the sentence mapping matrix and the target keyword mapping matrix by using a bidirectional GRU network encoder to obtain the sentence mapping encoding matrix and the target keyword encoding matrix includes: learning the sentence mapping matrix by using a forward GRU network and a reverse GRU network respectively to obtain a forward sentence mapping coding matrix and a backward sentence mapping coding matrix; learning the target keyword mapping matrix by using a forward GRU network and a reverse GRU network respectively to obtain a forward target keyword coding matrix and a backward target keyword coding matrix; adding elements of the forward statement mapping coding matrix and the backward statement mapping coding matrix to obtain a statement mapping coding matrix; and adding elements of the forward target keyword coding matrix and the backward target keyword coding matrix to obtain a target keyword coding matrix.
In one embodiment, the multi-level attention mechanism comprises: a statement level attention mechanism, a target key word level attention mechanism and an interaction level attention mechanism.
In an embodiment, the process of performing a multi-weighted operation by using a multi-level attention mechanism based on a sentence mapping coding matrix and a target keyword coding matrix to obtain an attention vector includes: adding weights to the statement mapping coding matrix by using a statement level attention mechanism; adding weights to the target keyword coding matrix by using a target keyword level attention machine mechanism; mapping the product of the coding matrix of the statement with the weight value and the transposed matrix of the coding matrix of the target keyword with the weight value to be used as an interactive matrix; and adding weights to the interaction matrix by using an interaction level attention mechanism to obtain an attention vector.
In a second aspect, an embodiment of the present invention provides a comment sentence specific target keyword sentiment analysis system, including: the input layer module is used for acquiring sentences to be subjected to target keyword emotion analysis and at least one target keyword; the vector mapping layer module is used for obtaining a sentence mapping matrix and a target keyword mapping matrix based on sentences and target keywords; the coding layer module is used for respectively coding the sentence mapping matrix and the target keyword mapping matrix by using a preset coder to obtain a sentence mapping coding matrix and a target keyword coding matrix; the multi-level attention layer module is used for performing multi-weighting operation by utilizing a multi-level attention mechanism based on the statement mapping coding matrix and the target keyword coding matrix to obtain an attention vector; and the prediction layer module is used for calculating the discrimination probability of each emotion polarity by utilizing a Softmax function according to the attention vector.
In a third aspect, an embodiment of the present invention provides a computer device, including: at least one processor, and a memory communicatively coupled to the at least one processor, wherein the memory stores instructions executable by the at least one processor, the instructions being executable by the at least one processor to cause the at least one processor to perform the comment sentence specific target keyword emotion analysis method of the first aspect of the embodiment of the present invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where computer instructions are stored, and the computer instructions are configured to cause a computer to execute the comment sentence specific target keyword emotion analysis method according to the first aspect of the embodiment of the present invention.
The technical scheme of the invention has the following advantages:
1. the method and the system for analyzing the emotion of the specific target keyword of the comment and comment statement provided by the invention are used for acquiring the statement to be subjected to target keyword emotion analysis and at least one target keyword, obtaining a statement mapping matrix and a target keyword mapping matrix based on the statement and the target keyword, respectively encoding the statement mapping matrix and the target keyword mapping matrix by using a preset encoder to obtain a statement mapping encoding matrix and a target keyword encoding matrix, performing multiple weighting operation based on the statement mapping encoding matrix and the target keyword encoding matrix by using a multi-level attention mechanism to obtain attention vector, calculating the judgment probability of each emotion polarity by utilizing a Softmax function according to the attention vector, therefore, the defect that the importance of the target keyword is ignored when the sentence is modeled in the prior art is overcome.
2. The method and the system for analyzing the emotion of the specific target keyword of the comment and comment sentence, provided by the invention, use a multi-level attention mechanism and a bidirectional GRU network construction model for analysis, can pay attention to words which are related to the target keyword and have emotional colors in the comment and comment sentence, and enhance the emotion analysis capability.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following descriptions are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a diagram of a sentiment analysis model structure according to an embodiment of the present invention;
fig. 2 is a flowchart of a specific example of a method for analyzing emotion of a specific target keyword in a comment statement according to an embodiment of the present invention;
fig. 3 is a flowchart of another specific example of an emotion analysis method for a specific target keyword in a comment statement according to an embodiment of the present invention;
Fig. 4 is a flowchart of another specific example of an emotion analysis method for a specific target keyword in a comment statement according to an embodiment of the present invention;
fig. 5 is a flowchart of another specific example of an emotion analysis method for a specific target keyword in a comment statement according to an embodiment of the present invention;
fig. 6 is a flowchart of another specific example of an emotion analysis method for a specific target keyword in a comment statement according to an embodiment of the present invention;
fig. 7 is a flowchart of another specific example of an emotion analysis method for a specific target keyword in a comment statement according to an embodiment of the present invention;
fig. 8 is a block diagram of a specific example of a computer device according to an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
In the description of the present invention, it should be noted that unless otherwise explicitly stated or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; the two elements may be directly connected or indirectly connected through an intermediate medium, or may be connected internally, wirelessly or by wire. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
Furthermore, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as there is no conflict between them.
Example 1
The emotion analysis method for the specific target keyword of the comment sentence provided by the embodiment of the invention is realized by obtaining an emotion analysis model based on the combination of a bidirectional GRU neural network and a multi-level attention mechanism, wherein the GRU neural network is a variant of an LSTM, the GRU neural network greatly simplifies the LSTM and keeps almost the same effect as the LSTM, the structure diagram of the emotion analysis model is shown in FIG. 1, and the emotion analysis model shown in FIG. 1 comprises the following steps: input layer, vector mapping layer, coding layer, multi-layer attention layer, prediction layer.
The emotion analysis model of the embodiment of the invention has three different use modes, specifically as follows:
(1) a full training mode: and completely initializing the model, training and testing in a given training set, and finally using the trained model for prediction and actual tasks. The method is suitable for users with a large number of labeled data set resources, and the performance of the model is completely fitted to the service scene of the user.
Specifically, the full training module implementation step may include: dividing a data set into training data and testing data according to a certain proportion. And secondly, whether a word vector which is already subjected to Pre-training (Pre-trained) is required to be used as a mapping vector of a mapping layer is set, and a GloVe word vector can be used as a Pre-trained mapping in the model. And thirdly, completing the setting of model parameters. And fourthly, applying the model to the statement which needs to carry out specific target emotion analysis to carry out emotion polarity prediction, and putting the model into a production environment.
(2) Pre-training mode: and (4) using the model parameters trained by the model operation and maintenance designer, and directly using the model parameters in a business scene without training. The hardware condition required by the method is the lowest, the time cost of a large number of model training is reduced, but the performance of the model is completely determined by a model operation and maintenance designer, and whether the model is fit in the application scene of the model is unknown.
Specifically, the pre-training mode implementing step may include: firstly, obtaining a pre-trained model weight parameter provided by a model operation and maintenance designer. Secondly, setting a model hyper-parameter according to a given pre-trained model, and importing the pre-trained model weight. Step three: and applying the model to a business scene for emotion polarity analysis.
(3) A migration training mode: and (3) only training the final prediction layer on the data set specific to the own service by using the model parameters trained by the model operation and maintenance designer. The method is a combination of the first two methods, and can fit a model to data of an application scene of the model under the condition of low training cost.
Specifically, the step of implementing the migration training mode may include: firstly, obtaining a pre-trained model weight parameter provided by a model operation and maintenance designer. Secondly, setting model hyper-parameters according to a given pre-trained model, and importing pre-trained model weight. And thirdly, performing fine tuning training on the model on a training data set specific to the service scene of the model. And fourthly, applying the model which completes the fine tuning training to the service scene for emotion polarity analysis.
As shown in fig. 2, based on the emotion analysis model, the emotion analysis method for the comment sentence specific target keyword according to the embodiment of the present invention includes:
step S11: and obtaining a sentence to be subjected to target keyword emotion analysis and at least one target keyword.
Specifically, the input layer of the emotion analysis model of the embodiment of the present invention inputs a sentence to be subjected to emotion analysis of the target keyword and the target keyword into the model.
Step S12: and obtaining a sentence mapping matrix and a target keyword mapping matrix based on the sentences and the target keywords.
Specifically, in the embodiment of the invention, a sentence is mapped into a word vector matrix through a pre-training word list, the distance between each word and a target keyword in the sentence is mapped into a position vector matrix through a position information mapping list, and then the two matrixes are spliced according to columns to generate the sentence mapping matrix; the target keywords will be mapped to the target keyword mapping matrix only through the pre-training vocabulary.
Specifically, as shown in fig. 3, step S12 is implemented by steps S21 to S22 as follows:
step S12: and obtaining a sentence mapping matrix according to the first pre-training word vector table and the distance between each word in the sentence and the target keyword.
In particular, the sentence mapping is different from the target keyword mapping. The target keyword is generally a phrase consisting of a single word or a plurality of words such as "dining environment", "service", and the sentence contains the target keyword and is generally a complete sentence containing the main predicate element, and can completely represent an event such as "the dining environment is so bad". And not all words in the sentence are related to the target keyword, and the position relation between each word in the sentence and the target keyword should be considered; therefore, further vector mapping is required for the position information of each word of the sentence and the target keyword.
Specifically, as shown in fig. 4, step S12 is implemented by steps S31 to S34 as follows:
step S31: and removing the target keywords from the sentences, and recording the distance between each word in the sentences and the target keywords to obtain the position information of the sentences from which the target keywords are removed.
Specifically, when performing sentence processing, it is necessary to remove the target keyword from the sentence, and record the distance between each word in the sentence and the target keyword as sentence position information, for example: the keyword is "ding environment", the sentence is "the ding environment is so determined", the distance between the word "the" and the keyword "ding environment" is "1", the distance between the word "is" and the keyword "ding environment" is "1", the distance between the word "so" and the keyword "ding environment" is "2", and the distance between the word "determining" and the keyword "ding environment" is "3".
Step S32: and querying the first pre-training word vector table, acquiring a mapping vector corresponding to the sentence with the target keyword removed, and generating a word vector matrix.
Specifically, in the specific target emotion analysis, a sentence is usually a complete sentence including a subject, a predicate, and an object in addition to an emotion target word, and the emotion polarity is expressed centering on a target keyword, and the amount of included sentence information is large. When mapping each word vector of a sentence, the GloVe word vector model can be used for pre-training a large corpus containing a large number of complete comment sentences, such as Twitter and Google News corpora, to generate a first pre-training word vector table corresponding to each word and having a matrix form
Figure BDA0003424782930000101
Wherein d issExpressed as the size of the dimension, N, after each word mappingsExpressed as the number of all possible occurrences of the word.
Specifically, a sentence with a target keyword removed
Figure BDA0003424782930000102
(where n represents the number of words in the sentence and m represents the number of target keywords), by querying the first pre-training word vector table
Figure BDA0003424782930000103
Obtaining the mapping vector corresponding to the word, and generating a word vector matrix S of the sentencew
Step S33: and coding and expanding the position information of the statement with the target keyword removed to obtain a position information matrix, and taking the product of the position information matrix and a preset position information mapping matrix as a position vector matrix.
Specifically, position information p of the sentence from which the target keyword has been eliminated is set to { p ═ p1,p2,...,pn-mExpanding the position information matrix P (wherein n represents the number of words of a sentence, and m represents the number of target keywords) into one-hot coded position information matrix Ps=[p1,p2,...,pn-m]Wherein p isi(i-1, 2, …, n-m) represents one-hot vector corresponding to each position information, Ps∈R(n-m)×disWhere dis is the maximum distance.
Then, initializing the mapping matrix W of the preset position informationp,WpHas a matrix size of dp×dis,dpRepresenting the dimension of mapping of the position information; position information matrix P encoded by one-hots=[p1,p2,...,pn-m]Mapping matrix W with preset position information pMatrix multiplication is carried out to obtain a position vector matrix SpAs shown in formula (1), and setting a mapping matrix W of the preset position informationpThe weight parameters of (a) are updated during the training process.
Figure BDA0003424782930000111
Step S34: and splicing the word vector matrix and the position vector matrix to obtain a statement mapping matrix.
Specifically, the word vector matrix SwAnd a position vector matrix SpAnd splicing to obtain a statement mapping matrix S, wherein the calculation formula is as follows:
Figure BDA0003424782930000112
step S22: and querying a second pre-training word vector table to obtain a target keyword mapping matrix corresponding to the target keyword.
Specifically, by querying a second pre-training word vectorWatch (A)
Figure BDA0003424782930000113
Obtaining and targeting keywords
Figure BDA0003424782930000114
(where m is the number of target keywords) corresponding to the target keyword mapping matrix T ═ T1,t2,...,tm],ti(i ═ 1,2, …, m) where represents the mapped vector for each word in the target word, the matrix size of T is dt × m.
Specifically, the GloVe word vector model is used for pre-training in the corpus related to the target keywords, for example, the target words related to the catering can be pre-trained by restaurants in the Yelp database and food evaluation; then generating a second pre-training word vector table in a matrix form corresponding to each single word through a pre-training GloVe word vector model
Figure BDA0003424782930000115
Wherein d istRepresenting the dimension, N, of the mapped vector for each word of the target keywordtExpressed as the number of all possible occurrences of a word.
Step S13: and respectively encoding the sentence mapping matrix and the target keyword mapping matrix by using a preset encoder to obtain a sentence mapping encoding matrix and a target keyword encoding matrix.
Specifically, the default encoder according to the embodiment of the present invention is a bidirectional GRU network encoder, but this is only an example and not a limitation. The embodiment of the invention uses a Bi-directional threshold cycle network (Bi-GRU) to learn a statement mapping matrix and a target keyword mapping matrix generated by a mapping layer, and then outputs the hidden layer state of the Bi-GRU network to realize the coding of the mapping matrix.
Specifically, as shown in fig. 5, step S13 is implemented by steps S41 to S42 as follows:
step S41: learning the sentence mapping matrix by using a forward GRU network and a reverse GRU network respectively to obtain a forward sentence mapping coding matrix and a backward sentence mapping coding matrix; and respectively learning the target keyword mapping matrix by using a forward GRU network and a reverse GRU network to obtain a forward target keyword coding matrix and a backward target keyword coding matrix.
In particular, a forward statement maps the coding matrix
Figure BDA0003424782930000121
Backward statement mapping coding matrix
Figure BDA0003424782930000122
The calculation formulas of (A) and (B) are respectively shown as formula (3) and formula (4), and the forward target keyword coding matrix
Figure BDA0003424782930000123
Backward target keyword coding matrix
Figure BDA0003424782930000124
Are respectively shown as formula (5) and formula (6).
Figure BDA0003424782930000125
Figure BDA0003424782930000126
Figure BDA0003424782930000127
Figure BDA0003424782930000128
Step S42: adding elements of the forward statement mapping coding matrix and the backward statement mapping coding matrix to obtain a statement mapping coding matrix; and adding elements of the forward target keyword coding matrix and the backward target keyword coding matrix to obtain a target keyword coding matrix.
In particular, the statement mapping coding matrix ESAnd target keyword coding matrix EtThe calculation formulas are respectively shown as a formula (7) and a formula (8).
Figure BDA0003424782930000129
Figure BDA00034247829300001210
Step S14: based on the sentence mapping coding matrix and the target keyword coding matrix, performing multiple weighted operation by using a multi-level attention mechanism to obtain an attention vector.
Specifically, the multi-level attention mechanism of the embodiment of the invention comprises: a statement level attention mechanism, a target keyword level attention mechanism and an interaction level attention mechanism.
Specifically, as shown in fig. 6, step S14 is implemented by steps S51 to S53 as follows:
step S51: adding weights to the statement mapping coding matrix by using a statement level attention mechanism; and adding weights to the target keyword coding matrix by using a target keyword level attention mechanism.
In particular, the coding matrix E is mapped to sentences using a sentence-level attention mechanismSGenerating a sentence attention score vector f (E) as shown in equation (9)s) Wherein W isstFor a sentence attention weight vector, WstIs 1 xdGRU(ii) a Then pair f (E)s) Performing Softmax operation, as shown in equation (10), generating a sentence attention weight βi(i=1,2,…,n-m)。
f(Es)=tanh(Wst·tanh(Es)),f(Es)∈R1×(n-m) (9)
Figure BDA0003424782930000131
Attention weight of sentence betaiMapping the coding matrix E with the corresponding statementSObtaining a sentence mapping coding matrix E with weight valuesst
Figure BDA0003424782930000132
Specifically, the encoding matrix E is mapped to the target keyword by using the target keyword level attention mechanismtGenerating a target keyword attention score vector f (E) as shown in formula (12)t) Wherein W isαtIs a target keyword attention weight vector, WαtIs 1 xdGRU(ii) a Then pair f (E)t) Performing Softmax operation, as shown in equation (13), generating a target keyword attention weight alphai(i=1,2,…,m)。
f(Et)=tanh(Wαt·tanh(Et)),f(Et)∈R1×m (12)
Figure BDA0003424782930000141
Attention weighting alpha of target keywordsiMapping the coding matrix E with the corresponding target keywordstObtaining a target keyword mapping coding matrix E with a weight valueαt
Figure BDA0003424782930000142
Step S52: and taking the product of the statement mapping coding matrix with the weight value and the transposed matrix of the target keyword coding matrix with the weight value as an interactive matrix.
Specifically, the interaction matrix I is calculated by the following formula:
I=(Eαt)T·Est,I∈Rm·(n-m) (15)
Step S53: and adding weights to the interaction matrix by using an interaction level attention mechanism to obtain an attention vector.
Specifically, each vector I in the interaction matrix I is paired with an interaction level attention mechanismi(i-1, 2, …, n-m) to obtain a score vector f (i), as shown in formula (16), where W isHIs an interaction level attention weight vector with the size of 1 × m; then, Softmax operation is carried out on the score value vector f (I) to generate an interaction level attention weight value gamma corresponding to the interaction matrix Ii(i ═ 1,2, …, n-m), as shown in formula (17).
f(I)=tanh(WH·tanh(I)),f(I)∈R1×(n-m) (16)
Figure BDA0003424782930000143
According to the attention weight gamma of the interactive leveliFor corresponding vector I in interaction matrix IiAnd performing weighted summation to obtain a final attention vector Z, as shown in formula (18).
Figure BDA0003424782930000144
Step S15: and calculating the discrimination probability of each emotion polarity by utilizing a Softmax function according to the attention vector.
Specifically, the attention vector Z is input into the fully-connected layer of a prediction layer, and the probability vector P for each emotion polarity is finally obtained through the Softmax function, as shown in formula (19), where C is the number of emotion polarities (e.g., the number of emotion polarities is 3 when the emotion polarities are negative, neutral, and positive), and W is the number of emotion polaritiespreWeight matrix for the final prediction layer, W preHas a matrix size of C x m, bpreBias term (Bias) for final prediction layer, bpre∈R^C。
Figure BDA0003424782930000151
Example 2
The embodiment of the invention provides a comment sentence specific target keyword emotion analysis system, as shown in fig. 7, comprising:
the input layer module 1 is used for acquiring a sentence to be subjected to target keyword emotion analysis and at least one target keyword; this mode is actually the input layer of the emotion analysis model in the embodiment of the present invention, and this module executes the method described in step S11 in embodiment 1, which is not described herein again.
The vector mapping layer module 2 is used for obtaining a sentence mapping matrix and a target keyword mapping matrix based on sentences and target keywords; this mode is actually the vector mapping layer of the emotion analysis model in the embodiment of the present invention, and this module executes the method described in step S12 in embodiment 1, which is not described herein again.
The coding layer module 3 is used for respectively coding the sentence mapping matrix and the target keyword mapping matrix by using a preset coder to obtain a sentence mapping coding matrix and a target keyword coding matrix; this mode is actually the coding layer of the emotion analysis model in this embodiment of the present invention, and this module executes the method described in step S13 in embodiment 1, which is not described herein again.
The multi-level attention layer module 4 is used for performing multi-weighting operation by utilizing a multi-level attention mechanism based on the statement mapping coding matrix and the target keyword coding matrix to obtain an attention vector; this mode is the multi-level attention layer of the emotion analysis model in this embodiment of the present invention, and this module executes the method described in step S14 in embodiment 1, which is not described herein again.
The prediction layer module 5 is used for calculating the discrimination probability of each emotion polarity by utilizing a Softmax function according to the attention vector; this mode is actually a prediction layer of the emotion analysis model in the embodiment of the present invention, and this module executes the method described in step S15 in embodiment 1, which is not described herein again.
Example 3
An embodiment of the present invention provides a computer device, as shown in fig. 8, including: at least one processor 401, such as a CPU (Central Processing Unit), at least one communication interface 403, memory 404, and at least one communication bus 402. Wherein a communication bus 402 is used to enable connective communication between these components. The communication interface 403 may include a Display (Display) and a Keyboard (Keyboard), and the optional communication interface 403 may also include a standard wired interface and a standard wireless interface. The Memory 404 may be a RAM (random Access Memory) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The memory 404 may optionally be at least one storage device located remotely from the aforementioned processor 401. Wherein the processor 401 can execute the comment sentence specific target keyword emotion analysis method of embodiment 1. A set of program codes is stored in the memory 404, and the processor 401 calls the program codes stored in the memory 404 for executing the comment sentence specific target keyword emotion analysis method of embodiment 1.
The communication bus 402 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus 402 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one line is shown in FIG. 8, but that does not indicate only one bus or type of bus.
The memory 404 may include a volatile memory (RAM), such as a random-access memory (RAM); the memory may also include a non-volatile memory (english: non-volatile memory), such as a flash memory (english: flash memory), a hard disk (english: hard disk drive, abbreviated: HDD) or a solid-state drive (english: SSD); the memory 404 may also comprise a combination of memories of the kind described above.
The processor 401 may be a Central Processing Unit (CPU), a Network Processor (NP), or a combination of a CPU and an NP.
The processor 401 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof. The PLD may be a Complex Programmable Logic Device (CPLD), a field-programmable gate array (FPGA), a General Array Logic (GAL), or any combination thereof.
Optionally, the memory 404 is also used to store program instructions. The processor 401 may call a program instruction to implement the method for analyzing emotion of the comment sentence specific target keyword in embodiment 1.
The embodiment of the invention further provides a computer-readable storage medium, wherein computer-executable instructions are stored on the computer-readable storage medium, and the computer-executable instructions can execute the comment statement specific target keyword emotion analysis method in the embodiment 1. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, abbreviated as HDD), a Solid-State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
It should be understood that the above embodiments are only examples for clarity of description, and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. This need not be, and cannot be exhaustive of all embodiments. And obvious variations or modifications are contemplated as falling within the scope of the present invention.

Claims (10)

1. A comment sentence specific target keyword emotion analysis method is characterized by comprising the following steps:
obtaining a sentence to be subjected to target keyword emotion analysis and at least one target keyword;
obtaining a sentence mapping matrix and a target keyword mapping matrix based on the sentences and the target keywords;
respectively encoding the sentence mapping matrix and the target keyword mapping matrix by using a preset encoder to obtain a sentence mapping encoding matrix and a target keyword encoding matrix;
performing multiple weighted operation by using a multi-level attention mechanism based on the sentence mapping coding matrix and the target keyword coding matrix to obtain an attention vector;
and calculating the discrimination probability of each emotion polarity by utilizing a Softmax function according to the attention vector.
2. The emotion analysis method for the specific target keyword in the comment sentence according to claim 1, wherein the process of obtaining the sentence mapping matrix and the target keyword mapping matrix based on the sentence and the target keyword comprises:
obtaining a sentence mapping matrix according to a first pre-training word vector table and the distance between each word in the sentence and a target keyword;
and querying a second pre-training word vector table to obtain a target keyword mapping matrix corresponding to the target keyword.
3. The emotion analysis method for the comment sentence with the specific target keyword as claimed in claim 2, wherein the first process of obtaining the sentence mapping matrix according to the pre-training word list and the distance between each word in the sentence and the target keyword comprises:
removing the target keywords from the sentences, and recording the distance between each word in the sentences and the target keywords to obtain the position information of the sentences from which the target keywords are removed;
inquiring a first pre-training word vector table, acquiring a mapping vector corresponding to the sentence with the target keyword removed, and generating a word vector matrix;
coding and expanding the position information of the sentences from which the target keywords are removed to obtain a position information matrix, and taking the product of the position information matrix and a preset position information mapping matrix as a position vector matrix;
And splicing the word vector matrix and the position vector matrix to obtain a statement mapping matrix.
4. The sentiment analysis method for the specific target keyword in the comment sentence according to claim 2, wherein the preset encoder is a bidirectional GRU network encoder.
5. The method for analyzing emotion of a specific target keyword in a comment sentence according to claim 4, wherein the sentence mapping matrix and the target keyword mapping matrix are encoded by a bidirectional GRU network encoder, respectively, and a sentence mapping encoding matrix and a target keyword encoding matrix are obtained by a process comprising:
learning the sentence mapping matrix by using a forward GRU network and a reverse GRU network respectively to obtain a forward sentence mapping coding matrix and a backward sentence mapping coding matrix; learning the target keyword mapping matrix by using a forward GRU network and a reverse GRU network respectively to obtain a forward target keyword coding matrix and a backward target keyword coding matrix;
adding elements of the forward statement mapping coding matrix and the backward statement mapping coding matrix to obtain a statement mapping coding matrix; and adding elements of the forward target keyword coding matrix and the backward target keyword coding matrix to obtain a target keyword coding matrix.
6. The method for analyzing emotion of a keyword specific to a comment sentence in claim 1, wherein the multi-level attention mechanism comprises: a statement level attention mechanism, a target keyword level attention mechanism and an interaction level attention mechanism.
7. The method for analyzing emotion of a specific target keyword in a comment sentence according to claim 1, wherein the process of obtaining the attention vector by performing a multi-weighting operation using a multi-level attention mechanism based on the sentence mapping coding matrix and the target keyword coding matrix comprises:
adding weights to the statement mapping coding matrix using a statement level attention mechanism; adding weights to the target keyword coding matrix by using a target keyword level attention mechanism;
taking the product of the statement mapping coding matrix with the weight value and the transposed matrix of the target keyword coding matrix with the weight value as an interactive matrix;
and adding weights to the interaction matrix by using an interaction level attention mechanism to obtain an attention vector.
8. A comment sentence specific target keyword sentiment analysis system is characterized by comprising:
the input layer module is used for acquiring sentences to be subjected to target keyword emotion analysis and at least one target keyword;
The vector mapping layer module is used for obtaining a sentence mapping matrix and a target keyword mapping matrix based on the sentences and the target keywords;
the coding layer module is used for respectively coding the sentence mapping matrix and the target keyword mapping matrix by utilizing a preset coder to obtain a sentence mapping coding matrix and a target keyword coding matrix;
the multi-level attention layer module is used for performing multi-weighting operation by utilizing a multi-level attention mechanism based on the sentence mapping coding matrix and the target keyword coding matrix to obtain an attention vector;
and the prediction layer module is used for calculating the discrimination probability of each emotion polarity by utilizing a Softmax function according to the attention vector.
9. A computer device, comprising: at least one processor, and a memory communicatively coupled to the at least one processor, wherein the memory stores instructions executable by the at least one processor to cause the at least one processor to perform the comment sentence specific target keyword emotion analysis method recited in any one of claims 1 to 7.
10. A computer-readable storage medium characterized in that the computer-readable storage medium stores computer instructions for causing the computer to execute the comment sentence specific target keyword emotion analysis method described in any one of claims 1 to 7.
CN202111574366.6A 2021-12-21 2021-12-21 Comment sentence specific target keyword sentiment analysis method and system Pending CN114676692A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111574366.6A CN114676692A (en) 2021-12-21 2021-12-21 Comment sentence specific target keyword sentiment analysis method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111574366.6A CN114676692A (en) 2021-12-21 2021-12-21 Comment sentence specific target keyword sentiment analysis method and system

Publications (1)

Publication Number Publication Date
CN114676692A true CN114676692A (en) 2022-06-28

Family

ID=82070656

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111574366.6A Pending CN114676692A (en) 2021-12-21 2021-12-21 Comment sentence specific target keyword sentiment analysis method and system

Country Status (1)

Country Link
CN (1) CN114676692A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115392260A (en) * 2022-10-31 2022-11-25 暨南大学 Social media tweet emotion analysis method facing specific target
CN115994184A (en) * 2023-03-23 2023-04-21 深圳市宝腾互联科技有限公司 Operation and maintenance method and system based on big data automation operation and maintenance platform

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115392260A (en) * 2022-10-31 2022-11-25 暨南大学 Social media tweet emotion analysis method facing specific target
CN115994184A (en) * 2023-03-23 2023-04-21 深圳市宝腾互联科技有限公司 Operation and maintenance method and system based on big data automation operation and maintenance platform
CN115994184B (en) * 2023-03-23 2023-05-16 深圳市宝腾互联科技有限公司 Operation and maintenance method and system based on big data automation operation and maintenance platform

Similar Documents

Publication Publication Date Title
CN111368996B (en) Retraining projection network capable of transmitting natural language representation
CN107836000B (en) Improved artificial neural network method and electronic device for language modeling and prediction
US20220269707A1 (en) Method and system for analyzing entities
WO2019153737A1 (en) Comment assessing method, device, equipment and storage medium
US11227108B2 (en) Convolutional neural network architecture with adaptive filters
CN110362723B (en) Topic feature representation method, device and storage medium
CN109766557B (en) Emotion analysis method and device, storage medium and terminal equipment
CN110619044B (en) Emotion analysis method, system, storage medium and equipment
WO2020140073A1 (en) Neural architecture search through a graph search space
CN114676692A (en) Comment sentence specific target keyword sentiment analysis method and system
CN111160000B (en) Composition automatic scoring method, device terminal equipment and storage medium
CN112861522B (en) Aspect-level emotion analysis method, system and model based on dual-attention mechanism
JP2022145623A (en) Method and device for presenting hint information and computer program
US20220383119A1 (en) Granular neural network architecture search over low-level primitives
JP6743942B2 (en) Vocabulary table selection method, device, and computer-readable storage medium
CN109948163B (en) Natural language semantic matching method for dynamic sequence reading
David et al. Comparison of word embeddings in text classification based on RNN and CNN
US20220198274A1 (en) Method and system for unstructured information analysis using a pipeline of ml algorithms
US11941360B2 (en) Acronym definition network
JP6605997B2 (en) Learning device, learning method and program
US20240005131A1 (en) Attention neural networks with tree attention mechanisms
CN110851600A (en) Text data processing method and device based on deep learning
CN114997155A (en) Fact verification method and device based on table retrieval and entity graph reasoning
WO2021159099A1 (en) Searching for normalization-activation layer architectures
CN114036267A (en) Conversation method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination