CN113849651A - Document-level emotional tendency-based emotion classification method, device, equipment and medium - Google Patents

Document-level emotional tendency-based emotion classification method, device, equipment and medium Download PDF

Info

Publication number
CN113849651A
CN113849651A CN202111158076.3A CN202111158076A CN113849651A CN 113849651 A CN113849651 A CN 113849651A CN 202111158076 A CN202111158076 A CN 202111158076A CN 113849651 A CN113849651 A CN 113849651A
Authority
CN
China
Prior art keywords
sentence
target
vector
emotion classification
coding
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.)
Granted
Application number
CN202111158076.3A
Other languages
Chinese (zh)
Other versions
CN113849651B (en
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202111158076.3A priority Critical patent/CN113849651B/en
Publication of CN113849651A publication Critical patent/CN113849651A/en
Application granted granted Critical
Publication of CN113849651B publication Critical patent/CN113849651B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • G06F16/353Clustering; Classification into predefined classes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2415Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on parametric or probabilistic models, e.g. based on likelihood ratio or false acceptance rate versus a false rejection rate
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/25Fusion techniques
    • G06F18/253Fusion techniques of extracted features
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars

Abstract

The application relates to the technical field of artificial intelligence, and discloses a document level emotional tendency-based emotion classification method, device, equipment and medium, wherein the method comprises the following steps: determining a sentence set for the target evaluation text; extracting a target entity attribute pair corresponding to the evaluation object from the sentence set; determining a target question according to the target question template and the target entity attribute pair; splicing each sentence in the sentence set with a target question sentence to obtain a target sentence pair set; performing emotion classification probability prediction on the target entity attribute pair and the target sentence pair set input emotion classification model to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained based on the combination of an attention mechanism, internal aspect consistency and aspect tendency; and obtaining target emotion classification according to the emotion classification probability vector. And 4, predicting the emotion classification probability by using a model obtained by combined modeling of an attention mechanism, internal aspect consistency and aspect tendency, and improving the accuracy of emotion analysis.

Description

Document-level emotional tendency-based emotion classification method, device, equipment and medium
Technical Field
The present application relates to the field of artificial intelligence technologies, and in particular, to a method, an apparatus, a device, and a medium for classifying emotion based on document-level emotional tendencies.
Background
According to the existing emotion analysis based on evaluation content, aspect-level emotion classification is always regarded as an independent aspect-by-aspect sentence-level classification problem, document-level emotion preference information is ignored to a great extent, and therefore aspect-level emotion classification information is lost. In fact, sentences in the evaluation content do not appear independently, but several sentences with concentrated meanings and consistent emotions appear together, the sentence structure in the evaluation content occasion is often random, sometimes the sentences cannot provide enough information, the emotion of the sentences can be understood only by referring to the content of other sentences or even emotion tendencies, and the accuracy of emotion analysis is reduced by considering aspect-level emotion classification as an independent aspect-level sentence-level classification problem.
Disclosure of Invention
The method, the device, the equipment and the medium aim to solve the technical problems that in the emotion analysis based on evaluation content in the prior art, aspect-level emotion classification is regarded as an independent aspect-by-aspect sentence-level classification problem, document-level emotion preference information is ignored, aspect-level emotion classification information is lost, and the accuracy of emotion analysis is reduced.
In order to achieve the above object, the present application provides an emotion classification method based on document level emotional tendency, the method comprising:
acquiring a target evaluation text and an aspect emotion extraction rule, wherein the aspect emotion extraction rule comprises an evaluation object and an evaluation direction;
extracting sentences from the target evaluation text to obtain a sentence set;
extracting a target entity attribute pair corresponding to the evaluation object from the sentence set;
acquiring a target question template corresponding to the evaluation direction, and constructing a question according to the target question template and the target entity attribute to obtain a target question;
splicing each sentence in the sentence set with the target question sentence respectively to obtain a target sentence pair set;
performing emotion classification probability prediction on the target entity attribute pair and the target sentence pair set input emotion classification model to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained by jointly modeling based on an attention mechanism, internal aspect consistency and aspect tendency;
and carrying out emotion classification determination according to the emotion classification probability vector to obtain target emotion classification.
The application also provides an emotion classification device based on document level emotional tendency, the device includes:
the system comprises a data acquisition module, a processing module and a display module, wherein the data acquisition module is used for acquiring a target evaluation text and an aspect emotion extraction rule, and the aspect emotion extraction rule comprises an evaluation object and an evaluation direction;
a sentence set determining module, configured to perform sentence extraction on the target evaluation text to obtain a sentence set;
a target entity attribute pair determining module, configured to extract a target entity attribute pair corresponding to the evaluation object from the sentence set;
the target question sentence determining module is used for acquiring a target question sentence template corresponding to the evaluation direction, and constructing question sentences according to the target question sentence template and the target entity attribute to obtain target question sentences;
a target sentence pair set determining module, configured to splice each sentence in the sentence set with the target question sentence, respectively, to obtain a target sentence pair set;
the emotion classification probability vector determination module is used for carrying out emotion classification probability prediction on the target entity attribute pair and the target sentence pair set input emotion classification model to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained by jointly modeling based on an attention mechanism, internal aspect consistency and aspect tendency;
and the target emotion classification determining module is used for carrying out emotion classification determination according to the emotion classification probability vector to obtain target emotion classification.
The present application further proposes a computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the steps of any of the above methods when executing the computer program.
The present application also proposes a computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the steps of the method of any of the above.
The method comprises the steps of firstly carrying out sentence extraction on a target evaluation text to obtain a sentence set, extracting a target entity attribute pair corresponding to an evaluation object from the sentence set, obtaining a target question template corresponding to an evaluation direction, carrying out question construction according to the target question template and the target entity attribute pair to obtain a target question, splicing each sentence in the sentence set with the target question respectively to obtain a target sentence pair set, inputting the target entity attribute pair and the target sentence pair set into an emotion classification model to carry out emotion classification probability prediction to obtain an emotion classification probability vector, wherein the emotion classification model is based on attention mechanism, The method comprises the steps of obtaining a model obtained by internal aspect consistency and aspect tendency combined modeling, finally carrying out emotion classification determination according to the emotion classification probability vector to obtain target emotion classification, realizing emotion classification probability prediction by adopting the model obtained by the attention mechanism, internal aspect consistency and aspect tendency combined modeling, utilizing related sentence characterization in the learning aspect of the attention mechanism to improve prediction accuracy, utilizing internal aspect consistency to give correct judgment through other sentences, and utilizing aspect tendency to give the emotion of an object through integral emotion judgment in a obscure text which is difficult to judge, thereby improving emotion analysis accuracy.
Drawings
FIG. 1 is a flowchart illustrating a document-level emotional tendency-based emotion classification method according to an embodiment of the present application;
FIG. 2 is a block diagram of an emotion classification apparatus based on document level emotional tendencies according to an embodiment of the present application;
fig. 3 is a block diagram illustrating a structure of a computer device according to an embodiment of the present application.
The implementation, functional features and advantages of the objectives of the present application will be further explained with reference to the accompanying drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Referring to fig. 1, an embodiment of the present application provides an emotion classification method based on document-level emotional tendencies, including:
s1: acquiring a target evaluation text and an aspect emotion extraction rule, wherein the aspect emotion extraction rule comprises an evaluation object and an evaluation direction;
s2: extracting sentences from the target evaluation text to obtain a sentence set;
s3: extracting a target entity attribute pair corresponding to the evaluation object from the sentence set;
s4: acquiring a target question template corresponding to the evaluation direction, and constructing question sentences according to the target question template and the target entity attributes to obtain target question sentences;
s5: splicing each sentence in the sentence set with a target question sentence respectively to obtain a target sentence pair set;
s6: performing emotion classification probability prediction on the target entity attribute pair and the target sentence pair set input emotion classification model to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained by jointly modeling based on an attention mechanism, internal aspect consistency and aspect tendency;
s7: and carrying out emotion classification determination according to the emotion classification probability vector to obtain target emotion classification.
The embodiment comprises the steps of firstly carrying out sentence extraction on a target evaluation text to obtain a sentence set, extracting a target entity attribute pair corresponding to an evaluation object from the sentence set, obtaining a target question template corresponding to an evaluation direction, carrying out question construction according to the target question template and the target entity attribute pair to obtain a target question, splicing each sentence in the sentence set with the target question respectively to obtain a target sentence pair set, then inputting the target entity attribute pair and the target sentence pair set into an emotion classification model to carry out emotion classification probability prediction to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained by jointly modeling based on an attention machine, internal aspect consistency and aspect tendency, and finally carrying out emotion classification determination according to the emotion classification probability vector to obtain a target emotion classification, the emotion classification probability prediction is carried out by the aid of a model obtained by combined modeling based on an attention mechanism, internal aspect consistency and aspect tendency, prediction accuracy is improved by means of related sentence representation in the aspect of attention mechanism learning, correct judgment is given through other sentences by means of internal aspect consistency, and emotion of an object can be given through overall emotion judgment in a obscure text which is difficult to judge by means of the aspect tendency, so that emotion analysis accuracy is improved.
For S1, the target rating text input by the user may be obtained, the target rating text may be obtained from a database, or the target rating text may be obtained from a third-party application system.
And the target evaluation text is a evaluation text needing emotion classification. Evaluation texts include, but are not limited to: medical service evaluation content, commodity purchase evaluation content, and insurance purchase evaluation content.
It is understood that the rating text is a text of one rating of one rater for one rating object.
The evaluation object includes: an entity.
And the aspect emotion extraction rule is the extraction rule of the aspect emotion when the target evaluation text is subjected to emotion classification. The aspect emotion extraction rule comprises the following steps: the evaluation object and the evaluation direction. For example, when the target evaluation text is the medical service evaluation content, the facet emotion extraction rule is to extract the area where the doctor (i.e., the evaluation object) is adept at treating the disease, that is, (the evaluation direction) as the facet emotion, and the example is not particularly limited herein.
For S2, sentence extraction is performed on the target evaluation text, and all the extracted sentences are taken as a sentence set.
The method for extracting sentences from the target evaluation text is not described herein.
For S3, according to the evaluation object in the aspect emotion extraction rule, extracting the entity from the sentence set as the target entity, and then extracting the attribute corresponding to the target entity from the sentence set as the target attribute; and adopting a preset splicing format to splice the target entity and the target attribute by entity attribute pair, and taking the spliced data as the target entity attribute pair.
That is, aspects of the present application include entities and attributes.
It can be understood that the splicing format of the target entity attribute pair is:
[CLS]eentity[SEP]eattribute[SEP]
wherein e isentityIs a target entity, eattributeIs the target attribute, [ CLS]Is a flag bit, [ SEP]Are the separators.
For example, the entity is "a insurance", the attribute is "company", and the target entity attribute pair is: [ CLS ] A insurance [ SEP ] Inc. [ SEP ], which is exemplified herein without specific limitation.
It can be understood that the sentence set includes a plurality of entities and attributes, a target entity attribute pair corresponding to the evaluation object is extracted from the sentence set, and only the entities and attributes corresponding to the evaluation object are spliced. The sentences in the sentence sets may or may not include entities and attributes.
Specifically, a step of extracting a target entity attribute pair corresponding to an evaluation object from the sentence set is performed, classification searching is performed from a knowledge graph according to the evaluation object, each entity corresponding to the searched classification is used as a reference entity set, entity identification is performed on the sentence set to obtain a candidate entity set, entities corresponding to the reference entity set are obtained from the candidate entity set, and each obtained entity is used as a target entity.
For S4, a target question template corresponding to the evaluation direction in the aspect emotion extraction rule may be obtained from the database, or a target question template corresponding to the evaluation direction may be obtained from a third-party application system.
And searching the evaluation direction in the aspect emotion extraction rule in a database, and taking the question template corresponding to the searched evaluation direction as a target question template.
For example, the evaluation direction is the service attitude, and the target question sentence template is: what the service attitudes of [ entity replacement position ] and [ attribute replacement position ] you feel is, for example, not limited specifically here.
And replacing the entity replacement bit in the target question template according to the entity in the target entity attribute pair, replacing the attribute replacement bit in the target question template according to the attribute in the target entity attribute pair, and taking the target question template after replacement as the target question.
For example, the target entity in the target entity attribute pair is "zhang san", the target attribute in the target entity attribute pair is "doctor", and the target question sentence template is: if you feel how good the service attitudes of [ entity replacement position ] and [ attribute replacement position ], then the question construction is performed according to the target question template and the target entity attribute to obtain the target question, "how you feel Zhang three and how good the service attitudes of doctors", which is not specifically limited in this example.
And S5, respectively splicing the target question sentence and each sentence in the sentence set by adopting a preset sentence splicing rule, and taking each sentence obtained by splicing as a target sentence pair set.
It can be understood that the concatenation format of the target sentence pairs in the target sentence pair set is:
[CLS]si[SEP]question(ak)[SEP]
wherein s isiIs the ith sentence in the sentence set, query (a)k) Is a target question, [ CLS]Is a flag bit, [ SEP]Are the separators.
That is, the sentences in the sentence sets correspond one-to-one to the target sentence pairs in the target sentence pair sets.
For S6, the target entity attribute pair and the target sentence pair are input into the emotion classification model in a set, firstly, coding is carried out on the internal aspect consistency in combination with the attention mechanism, coding is carried out on the aspect tendency in combination with the attention mechanism, then the two codes are subjected to sentence fusion, and finally emotion classification probability prediction is carried out according to the sentence fusion result, so that the emotion classification probability prediction is carried out on the aspect emotion extraction rule in the target evaluation text by adopting the model obtained based on the attention mechanism, the internal aspect consistency and the aspect tendency combined modeling, and the vector obtained by the emotion classification probability prediction is used as the emotion classification probability vector.
For step S7, the maximum probability is found from the emotion classification probability vector, and the emotion classification corresponding to the found maximum probability is determined as the target emotion classification.
And the target emotion classification is emotion classification of the target evaluation text aiming at the aspect emotion extraction rule.
Optionally, the step of classifying and determining the emotion according to the emotion classification probability vector to obtain a target emotion classification includes: finding out the maximum probability from the emotion classification probability vector, and taking the found maximum probability as a candidate probability; acquiring a preset probability threshold, and taking the candidate probability as a target probability when the candidate probability is greater than or equal to the preset probability threshold; and determining the emotion classification corresponding to the target probability as a target emotion classification. Therefore, the emotion classification corresponding to the too low probability is prevented from being determined as the target emotion classification, and the accuracy of the determined target emotion classification is improved.
The emotion classification is a process of analyzing and reasoning subjective texts with emotional colors, namely analyzing attitudes of speakers and tending to be positive or negative.
In an embodiment, before the step of performing emotion classification probability prediction on the target entity attribute pair and the target sentence pair set input emotion classification model to obtain an emotion classification probability vector, the method further includes:
s61: obtaining a plurality of training samples, each training sample comprising: entity attribute is to sample, sentence is to sample set and emotion classification probability calibration value;
s62: taking one training sample in the plurality of training samples as a training sample to be trained;
s63: inputting the entity attribute of a training sample to be trained into a coding layer of an initial model for coding to obtain a directional coding vector;
s64: respectively inputting sentences of training samples to be trained into a coding layer for coding each sentence pair sample in a sample set to obtain a sentence coding vector set;
s65: adopting an internal aspect consistency coding layer of an initial model, and respectively carrying out attention weight calculation and coding between sentence vertexes and sentence vertexes on sentence coding vectors in a sentence coding vector set according to direction coding vectors to obtain a first sentence vector set;
s66: adopting an aspect tendency coding layer of an initial model, and respectively calculating and coding attention weights between sentence vertexes according to sentence coding vectors in the sentence coding vector sets to obtain a second sentence vector set;
s67: performing feature extraction and feature fusion according to the first sentence vector set and the second sentence vector set by adopting a sentence fusion layer of the initial model to obtain a target sentence vector set;
s68: respectively predicting emotion classification probability according to each target sentence vector in the target sentence vector set by adopting an emotion classification layer of the initial model to obtain an emotion classification probability predicted value;
s69: training an initial model according to the emotion classification probability calibration value and the emotion classification probability prediction value of the training sample to be trained;
s610: and repeatedly executing the step of taking one training sample in the plurality of training samples as a training sample to be trained until a preset model training end condition is reached, and determining the initial model reaching the preset model training end condition as the emotion classification model.
The embodiment is based on an emotion classification model obtained by the combined modeling of an attention mechanism, internal aspect consistency coding and aspect tendency coding, so that the accuracy of prediction is improved by utilizing the characteristics of related sentences in the aspect of attention mechanism learning, correct judgment is given through other sentences by utilizing the internal aspect consistency, the emotion of an object can be given through overall emotion judgment in a obscure and difficult-to-judge text by utilizing the aspect tendency, and the accuracy of emotion classification probability prediction of the emotion classification model is improved.
For S61, a plurality of training samples input by the user may be obtained, a plurality of training samples may be obtained from a database, or a plurality of training samples may be obtained from a third-party application system.
The concatenation format of the entity attribute to the sample is:
[CLS]eentity[SEP]eattribute[SEP]。
the concatenation format of each sentence pair sample in the sentence pair sample set is:
[CLS]si[SEP]question(ak)[SEP]。
in the same training sample, an entity attribute pair sample and a sentence pair sample set are data obtained from the same evaluation text, and the emotion classification probability calibration value is a correct result of emotion classification calibration on the entity attribute pair sample and the sentence pair sample set.
The sentence-to-sample set is data obtained from a set of all sentences in an evaluation text.
For S62, a training sample is obtained from a plurality of training samples, and the obtained training sample is used as the training sample to be trained.
For S63, the coding layer of the initial model is a coding layer obtained based on a bert (bidirectional Encoder retrieval from transforms) model.
And inputting the entity attribute of the training sample to be trained into the coding layer of the initial model for coding, and acquiring an output vector of a zone bit [ CLS ] corresponding to the coding layer as a direction coding vector.
For S64, respectively inputting each sentence pair sample in the sentence pair sample set of the training sample to be trained into the coding layer for coding, and obtaining each corresponding output vector of the flag bit [ CLS ] in the coding layer as a sentence coding vector set.
And the sentence coding vectors in the sentence coding vector set correspond to the sentence pair samples in the sentence pair sample set of the training samples to be trained one by one.
For S65, using the internal aspect consistency coding layer of the initial model, first taking the sentence coding vectors in the sentence coding vector set whose aspects (i.e. evaluation objects) are the same as the directional coding vectors as sentence vertices, then calculating the attention weights of the aspects where the sentence vertices correspond to the directional coding vectors, coding each sentence coding vector in the sentence coding vector set according to the calculated attention weights, taking each vector obtained by coding as a first sentence vector, and taking all the first sentence vectors as the first sentence vector set.
That is, the first sentence vector in the first set of sentence vectors corresponds one-to-one to the sentence-coding vectors in the set of sentence-coding vectors.
It is understood that sentence vertices are expressed as sentence coding vectors.
For S66, an aspect tendency encoding layer of the initial model is used to calculate attention weights between sentence vertices according to the direction encoding vectors and the sentence encoding vector sets, encode each sentence encoding vector in the sentence encoding vector set according to the calculated attention weights, use each vector obtained by encoding as a second sentence vector, and use all the second sentence vectors as a second sentence vector set.
That is, the second sentence vectors in the second set of sentence vectors correspond one-to-one to the sentence-coding vectors in the set of sentence-coding vectors.
For step S67, a sentence fusion layer of an initial model is adopted, sentence vectors corresponding to each sentence-to-sample are spliced according to a first sentence vector set and a second sentence vector set, then feature extraction and feature fusion are carried out on each vector obtained by splicing, each vector obtained by feature fusion is used as a target sentence vector, and all target sentence vectors are used as a target sentence vector set.
That is, the target sentence vectors in the target sentence vector set correspond one-to-one to the sentence-coding vectors in the sentence-coding vector set.
And S68, adopting an emotion classification layer of the initial model, respectively performing emotion classification probability prediction according to each target sentence vector in the target sentence vector set, and taking data obtained by emotion classification probability prediction as an emotion classification probability prediction value.
And the emotion classification layer adopts a softmax regression classifier. The softmax regression classifier is a classifier that employs a softmax function (normalized exponential function).
And S69, training the initial model according to the emotion classification probability calibration value and the emotion classification probability prediction value of the training sample to be trained.
For S610, steps S62 to S610 are repeatedly executed until a preset model training end condition is reached, where the initial model reaching the preset model training end condition is a model meeting an expected target, and thus the initial model reaching the preset model training end condition may be determined as the emotion classification model.
The preset model training end condition is that the loss value of the initial model reaches a first convergence condition or the iteration number reaches a second convergence condition.
The first convergence condition means that the magnitude of the loss values of the initial models calculated two times in the neighborhood satisfies the lipschitz condition (lipschitz continuous condition).
The number of iterations refers to the number of times the initial model is trained, that is, once the initial model is trained, the number of iterations is increased by 1.
The second convergence condition is a specific numerical value.
In an embodiment, the step of using the internal aspect consistency coding layer of the initial model to perform the internal aspect consistency coding on the sentence coding vector according to the direction coding vector and the sentence coding vector set to obtain the first sentence vector set includes:
s651: determining sentence vertexes of the sentence coding vector set by adopting an internal aspect consistency coding layer according to the direction coding vectors to obtain a sentence vertex set;
s652: constructing a sentence vertex and aspect consistency graph according to the direction coding vector and the sentence vertex set by adopting an internal aspect consistency coding layer to obtain a target aspect consistency graph;
s653: adopting an internal aspect consistency coding layer, and calculating attention weight between sentence vertexes and aspects according to a target aspect consistency graph to obtain a first attention weight set;
s654: and respectively coding each sentence vertex according to the first attention weight set and the sentence vertex set by adopting an internal aspect consistency coding layer to obtain a first sentence vector set.
In the embodiment, firstly, an internal aspect consistency coding layer of an initial model is adopted, sentence vertex determination is firstly carried out according to a direction coding vector and a sentence coding vector set, secondly, a sentence vertex and aspect consistency graph is constructed, secondly, attention weight calculation between the sentence vertex and the aspect is carried out, finally, each sentence vertex is coded, an attention mechanism is utilized to learn aspect related sentence representations so as to improve prediction accuracy, and correct judgment is given through other sentences by utilizing internal aspect consistency, so that the accuracy of emotion classification probability prediction of an emotion classification model is improved.
For S651, the inside of the internal aspect agreement means in the same evaluation text.
Internal aspect consistency means that sentence vertexes in the same evaluation text share one aspect vertex, and the sentence vertexes are considered to have the same emotion in the aspect vertex.
It will be appreciated that the aspect vertices are expressed as direction-coded vectors.
The method comprises the steps of adopting an internal aspect consistency coding layer, finding sentence coding vectors with the same aspect as a direction coding vector from a sentence coding vector set, taking each found sentence coding vector as a sentence vertex, and taking all sentence vertices as a sentence vertex set.
That is, the sentence vertices at which the sentence vertex set shares the corresponding aspect of the directional encoding vector.
For step S652, an internal aspect consistency coding layer is adopted, a sentence vertex and aspect consistency graph is constructed according to the direction coding vector and the sentence vertex set, and the constructed aspect consistency graph is used as a target aspect consistency graph.
The direction coding vector is used as a node of the target aspect consistency graph, each sentence vertex in the sentence vertex set is used as a node of the target aspect consistency graph, and the node corresponding to each sentence vertex is connected with the node corresponding to the direction coding vector.
For S653, the internal aspect consistency coding layer is adopted to measure the preference degree based on the graph attention force mechanism, so as to perform attention weight calculation between each sentence vertex and the aspect according to the target aspect consistency graph, and each calculated attention weight is taken as a first attention weight, and all the calculated attention weights are taken as a first attention weight set.
That is, the first attention weight in the first attention weight set corresponds one-to-one to the node corresponding to the sentence vertex in the target aspect consistency graph.
For S654, an internal aspect consistency coding layer is used, and according to the first attention weight set, each sentence vertex in the sentence vertex set is coded into an aspect-related sentence vector, each vector obtained by coding is used as a first sentence vector, and all the first sentence vectors are combined as first sentence vectors.
That is, the first sentence vectors in the first sentence vector set correspond one-to-one to the nodes corresponding to the sentence vertices in the target aspect consistency graph.
In one embodiment, the formula a for calculating the first attention weight in the first attention weight set is as described aboveikComprises the following steps:
Figure BDA0003285011820000111
wherein, aikIs the attention weight between the ith sentence vertex in the set of sentence vertices and the directional code vector, viIs the ith sentence vertex in the set of sentence vertices, ekIs a directional code vector, exp () is an exponential function with the natural constant e as the base, f () is a LeakyReLU activation function, w1、wvAnd weCoding the parameters of the layer to be trained for intra aspect consistency, I is the number of sentence vertices in the set of sentence vertices, T is the vector transpose calculation, [ w [ [ w ]vvi;week]Is to convert the vector wvviAnd weekSplicing is carried out;
formula for calculating first sentence vector in first sentence vector set
Figure BDA0003285011820000121
Comprises the following steps:
Figure BDA0003285011820000122
wherein the content of the first and second substances,
Figure BDA0003285011820000123
is a first sentence vector corresponding to the ith sentence vertex in the sentence vertex set, ajkIs the attention weight between the jth sentence vertex in the set of sentence vertices and the directional code vector, vjIs the jth sentence vertex in the set of sentence vertices, tanh () is a hyperbolic tangent function, w2、b1Are parameters of the intra-aspect conformance coding layer that need to be trained.
According to the embodiment, the internal aspect consistency coding layer is adopted, the attention weight calculation between the sentence vertexes and the aspect is carried out according to the target aspect consistency graph to obtain the first attention weight set, the internal aspect consistency coding layer is adopted, the coding of each sentence vertex is respectively carried out according to the first attention weight set and the sentence vertex set to obtain the first sentence vector set, the fact that related sentence representation in the aspect of attention mechanism learning is utilized to improve the accuracy of prediction is achieved, the internal aspect consistency is utilized to give correct judgment through other sentences, and the accuracy of emotion classification probability prediction of the emotion classification model is improved.
In an embodiment, the step of using the aspect tendency coding layer of the initial model to perform the aspect tendency coding of each sentence coding vector according to the sentence coding vector set to obtain the second sentence vector set includes:
s661: constructing an aspect tendency graph according to the sentence vertex set by adopting an aspect tendency coding layer to obtain a target aspect tendency graph;
s662: adopting an aspect tendency coding layer, and calculating attention weight among sentence vertexes according to a target aspect tendency graph to obtain a second attention weight vector set;
s663: and (4) adopting an aspect tendency coding layer, and respectively coding each sentence vertex according to the second attention weight vector set and the sentence vertex set to obtain a second sentence vector set.
According to the method and the device, the construction of the tendency graph of the aspect is firstly carried out, then the attention weight calculation among the sentence vertexes is carried out, and finally the coding of each sentence vertex is carried out, so that the emotion of the object can be given through the whole emotion judgment in the obscure and difficult-to-judge text by utilizing the tendency of the aspect, and the accuracy of emotion analysis is improved.
For S661, the term "aspect tendency" refers to an emotional tendency between a sentence vertex and an adjacent sentence vertex in the same evaluation text.
And adopting an aspect tendency coding layer, constructing sentence vertexes and a tendency graph of the sentence vertexes according to the sentence vertex set, and taking the constructed aspect tendency graph as a target aspect tendency graph.
Each sentence vertex in the sentence vertex set is used as a node of the target aspect tendency graph, and nodes corresponding to adjacent sentence vertices are connected.
For S662, the aspect tendency encoding layer is adopted to measure the preference degree based on the graph attention force mechanism, so as to perform attention weight calculation between sentence vertices according to the target aspect tendency graph, and all the attention weights calculated for each sentence vertex are taken as a second attention weight vector, and all the second attention weight vectors are taken as a second attention weight vector set. That is, each vector element in the second attention weight vector represents an attention weight between two sentence vertices.
That is, the second attention weight vector in the second attention weight vector set corresponds to the node corresponding to the sentence vertex in the target aspect tendency graph in a one-to-one manner.
For S663, an aspect tendency encoding layer is used, and according to the second attention weight set, each sentence vertex in the sentence vertex set is encoded into a sentence vector, each vector obtained by encoding is used as a second sentence vector, and all the second sentence vectors are combined as second sentence vectors.
That is, the second sentence vectors in the second set of sentence vectors correspond one-to-one to the sentence vertices in the set of sentence vertices.
In one embodiment, the first attention weight a of the first set of attention weights is aikThe calculation formula of (2) is as follows:
Figure BDA0003285011820000131
wherein, aijIs the attention weight between the ith sentence vertex and the jth sentence vertex in the set of sentence vertices, viIs the ith sentence top in the sentence vertex setPoint, vjIs the jth sentence vertex in the sentence vertex set, exp () is an exponential function with the natural constant e as the base, f () is the LeakyReLU activation function, w3、w4And w5The parameters to be trained for the aspect-oriented coding layer, I is the number of sentence vertices in the set of sentence vertices, T is the vector transpose calculation, [ w [ [ w ]4vi;w5vj]Is to convert the vector w4viAnd w5vjSplicing is carried out;
formula for calculating second sentence vector in second sentence vector set
Figure BDA0003285011820000132
Comprises the following steps:
Figure BDA0003285011820000141
wherein the content of the first and second substances,
Figure BDA0003285011820000142
is a second sentence vector corresponding to the ith sentence vertex in the sentence vertex set, tanh () is a hyperbolic tangent function, w6、b2Are parameters of the aspect oriented coding layer that need training.
According to the embodiment, the attention weight calculation among sentence vertexes is carried out, and finally each sentence vertex is coded, so that the object emotion can be given through the whole emotion judgment in a text which is obscure and difficult to judge by utilizing the aspect tendency, and the accuracy of emotion analysis is improved.
In an embodiment, the step of performing sentence vector fusion according to the first sentence vector set and the second sentence vector set by using the sentence fusion layer of the initial model to obtain the target sentence vector set includes:
s671: adopting a vector splicing sublayer of the sentence fusion layer, and respectively carrying out sentence vector splicing on sentences corresponding to the samples according to the first sentence vector set and the second sentence vector set to obtain a sentence vector splicing result set;
s672: extracting features according to each sentence vector splicing result of the sentence vector splicing result set by adopting a plurality of feature extraction sublayers of the sentence fusion layer to obtain a sentence vector set to be fused corresponding to each sentence vector splicing result;
s673: respectively fusing each sentence vector set to be fused by adopting a self-adaptive fusion sublayer of the sentence fusion layer to obtain a target sentence vector set;
wherein, the calculation formula of the sentence vector to be fused in the sentence vector set to be fused
Figure BDA0003285011820000143
Comprises the following steps:
Figure BDA0003285011820000144
formula r for calculating target sentence vector corresponding to ith sentence vertex in sentence vertex setiComprises the following steps:
Figure BDA0003285011820000145
Figure BDA0003285011820000146
is the mth sentence vector to be fused of the sentence vector set to be fused corresponding to the ith sentence vertex in the sentence vertex set, M is the mth layer of the plurality of feature extraction sublayers, M is the total number of layers of the plurality of feature extraction sublayers, tanh is a hyperbolic tangent function, wm、bm、Wr、brAnd q isiThe parameters of the sentence fusion layer which need to be trained.
In the embodiment, the sentence vectors corresponding to the sample of each sentence are spliced according to the first sentence vector set and the second sentence vector set, and then the feature extraction and the feature fusion are performed on each vector obtained by splicing, so that the purpose that the internal aspect consistency is correctly judged through other sentences is realized, the aspect tendency can be used for fusing the emotion of the object through the integral emotion judgment in the obscure text which is difficult to judge is realized, and a basis is provided for accurately classifying the emotion.
For S671, acquiring a sentence pair sample from a sentence pair sample set of training samples to be trained as a target sentence pair sample; taking a first sentence vector corresponding to the target sentence pair sample in the first sentence vector set as a target first sentence vector; taking a second sentence vector corresponding to the target sentence pair sample in the second sentence vector set as a target second sentence vector; splicing the target first sentence vector and the target second sentence vector to obtain a sentence vector splicing result corresponding to the target sentence to the sample; repeatedly executing the step of obtaining a sentence pair sample from the sentence pair sample set of the training sample to be trained as a target sentence pair sample until the sentence pair sample in the sentence pair sample set of the training sample to be trained is obtained; and taking all sentence vector splicing results as a sentence vector splicing result set. It is understood that the above steps are implemented as vector concatenation sub-layers of the sentence fusion layer.
For S672, the plurality of feature extraction sublayers constitute a pyramid. And inputting each sentence vector splicing result of the sentence vector splicing result set into the bottom of a pyramid formed by a plurality of feature extraction sublayers.
Obtaining a sentence vector splicing result from the sentence vector splicing result set as a target sentence vector splicing result; inputting the target sentence vector splicing result into a plurality of feature extraction sublayers for feature extraction, and taking the feature vector extracted by each feature extraction sublayer as a sentence vector to be fused in a sentence vector set to be fused corresponding to the target sentence vector splicing result; and repeatedly executing the step of obtaining a sentence vector splicing result from the sentence vector splicing result set as a target sentence vector splicing result until the sentence vector splicing result in the sentence vector splicing result set is obtained. That is, the sentence vector to be fused is a feature vector extracted by a feature extraction sublayer.
That is to say, the sentence vectors to be fused in the sentence vector set to be fused correspond to the sentence vector splicing results in the sentence vector splicing result set one to one.
For S673, a self-adaptive fusion sublayer of a sentence fusion layer is adopted to perform fusion processing on each sentence vector to be fused in the sentence vector set to be fused, each vector obtained through the fusion processing is used as a target sentence vector, and all the target sentence vectors are used as a target sentence vector set.
Referring to fig. 2, the present application further proposes an emotion classification apparatus based on document-level emotional tendencies, the apparatus comprising:
the data acquisition module 100 is configured to acquire a target evaluation text and an aspect emotion extraction rule, where the aspect emotion extraction rule includes an evaluation object and an evaluation direction;
a sentence set determining module 200, configured to perform sentence extraction on the target evaluation text to obtain a sentence set;
a target entity attribute pair determining module 300, configured to extract a target entity attribute pair corresponding to the evaluation object from the sentence set;
a target question determining module 400, configured to obtain a target question template corresponding to the evaluation direction, and construct a question according to the target question template and the target entity attribute to obtain a target question;
a target sentence pair set determining module 500, configured to splice each sentence in the sentence set with the target question sentence, respectively, to obtain a target sentence pair set;
the emotion classification probability vector determination module 600 is configured to perform emotion classification probability prediction on a set of input emotion classification models including a target entity attribute pair and a target sentence pair to obtain an emotion classification probability vector, where the emotion classification model is a model obtained by jointly modeling based on an attention mechanism, internal aspect consistency and aspect tendency;
and the target emotion classification determining module 700 is configured to perform emotion classification determination according to the emotion classification probability vector to obtain a target emotion classification.
The embodiment comprises the steps of firstly carrying out sentence extraction on a target evaluation text to obtain a sentence set, extracting a target entity attribute pair corresponding to an evaluation object from the sentence set, obtaining a target question template corresponding to an evaluation direction, carrying out question construction according to the target question template and the target entity attribute pair to obtain a target question, splicing each sentence in the sentence set with the target question respectively to obtain a target sentence pair set, then inputting the target entity attribute pair and the target sentence pair set into an emotion classification model to carry out emotion classification probability prediction to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained by jointly modeling based on an attention machine, internal aspect consistency and aspect tendency, and finally carrying out emotion classification determination according to the emotion classification probability vector to obtain a target emotion classification, the emotion classification probability prediction is carried out by the aid of a model obtained by combined modeling based on an attention mechanism, internal aspect consistency and aspect tendency, prediction accuracy is improved by means of related sentence representation in the aspect of attention mechanism learning, correct judgment is given through other sentences by means of internal aspect consistency, and emotion of an object can be given through overall emotion judgment in a obscure text which is difficult to judge by means of the aspect tendency, so that emotion analysis accuracy is improved.
Referring to fig. 3, a computer device, which may be a server and whose internal structure may be as shown in fig. 3, is also provided in the embodiment of the present application. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer designed processor is used to provide computational and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The 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 computer equipment is used for storing data such as emotion classification methods based on document-level emotional tendency. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a document level emotional propensity based emotion classification method. The emotion classification method based on the document level emotional tendency comprises the following steps: acquiring a target evaluation text and an aspect emotion extraction rule, wherein the aspect emotion extraction rule comprises an evaluation object and an evaluation direction; extracting sentences from the target evaluation text to obtain a sentence set; extracting a target entity attribute pair corresponding to the evaluation object from the sentence set; acquiring a target question template corresponding to the evaluation direction, and constructing question sentences according to the target question template and the target entity attributes to obtain target question sentences; splicing each sentence in the sentence set with a target question sentence respectively to obtain a target sentence pair set; performing emotion classification probability prediction on the target entity attribute pair and the target sentence pair set input emotion classification model to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained by jointly modeling based on an attention mechanism, internal aspect consistency and aspect tendency; and carrying out emotion classification determination according to the emotion classification probability vector to obtain target emotion classification.
The embodiment comprises the steps of firstly carrying out sentence extraction on a target evaluation text to obtain a sentence set, extracting a target entity attribute pair corresponding to an evaluation object from the sentence set, obtaining a target question template corresponding to an evaluation direction, carrying out question construction according to the target question template and the target entity attribute pair to obtain a target question, splicing each sentence in the sentence set with the target question respectively to obtain a target sentence pair set, then inputting the target entity attribute pair and the target sentence pair set into an emotion classification model to carry out emotion classification probability prediction to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained by jointly modeling based on an attention machine, internal aspect consistency and aspect tendency, and finally carrying out emotion classification determination according to the emotion classification probability vector to obtain a target emotion classification, the emotion classification probability prediction is carried out by the aid of a model obtained by combined modeling based on an attention mechanism, internal aspect consistency and aspect tendency, prediction accuracy is improved by means of related sentence representation in the aspect of attention mechanism learning, correct judgment is given through other sentences by means of internal aspect consistency, and emotion of an object can be given through overall emotion judgment in a obscure text which is difficult to judge by means of the aspect tendency, so that emotion analysis accuracy is improved.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements a method for emotion classification based on document-level emotional tendencies, including the steps of: acquiring a target evaluation text and an aspect emotion extraction rule, wherein the aspect emotion extraction rule comprises an evaluation object and an evaluation direction; extracting sentences from the target evaluation text to obtain a sentence set; extracting a target entity attribute pair corresponding to the evaluation object from the sentence set; acquiring a target question template corresponding to the evaluation direction, and constructing question sentences according to the target question template and the target entity attributes to obtain target question sentences; splicing each sentence in the sentence set with a target question sentence respectively to obtain a target sentence pair set; performing emotion classification probability prediction on the target entity attribute pair and the target sentence pair set input emotion classification model to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained by jointly modeling based on an attention mechanism, internal aspect consistency and aspect tendency; and carrying out emotion classification determination according to the emotion classification probability vector to obtain target emotion classification.
The implemented emotion classification method based on document-level emotion tendencies comprises the steps of firstly carrying out sentence extraction on a target evaluation text to obtain a sentence set, extracting a target entity attribute pair corresponding to an evaluation object from the sentence set, obtaining a target question template corresponding to an evaluation direction, carrying out question construction according to the target question template and the target entity attribute pair to obtain a target question, splicing each sentence in the sentence set with the target question respectively to obtain a target sentence pair set, then inputting the target entity attribute pair and the target sentence pair set into an emotion classification model to carry out emotion classification probability prediction to obtain emotion classification probability vectors, wherein the emotion classification model is a model obtained by jointly modeling based on an attention machine, internal aspect consistency and aspect tendencies, and finally carrying out emotion classification determination according to the emotion classification probability vectors, the target emotion classification is obtained, emotion classification probability prediction is carried out by using a model obtained through combined modeling based on an attention mechanism, internal aspect consistency and aspect tendency, prediction accuracy is improved by using related sentence representations in the aspect of attention mechanism learning, correct judgment is given through other sentences by using the internal aspect consistency, and the emotion of an object can be given through integral emotion judgment in a obscure and difficult-to-judge text by using the aspect tendency, so that the accuracy of emotion analysis is improved.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.

Claims (10)

1. A method for classifying emotion based on document level emotional tendencies, the method comprising:
acquiring a target evaluation text and an aspect emotion extraction rule, wherein the aspect emotion extraction rule comprises an evaluation object and an evaluation direction;
extracting sentences from the target evaluation text to obtain a sentence set;
extracting a target entity attribute pair corresponding to the evaluation object from the sentence set;
acquiring a target question template corresponding to the evaluation direction, and constructing a question according to the target question template and the target entity attribute to obtain a target question;
splicing each sentence in the sentence set with the target question sentence respectively to obtain a target sentence pair set;
performing emotion classification probability prediction on the target entity attribute pair and the target sentence pair set input emotion classification model to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained by jointly modeling based on an attention mechanism, internal aspect consistency and aspect tendency;
and carrying out emotion classification determination according to the emotion classification probability vector to obtain target emotion classification.
2. The method of claim 1, wherein before the step of predicting the emotion classification probability of the target entity attribute pair and the target sentence pair for the set of input emotion classification models to obtain the emotion classification probability vector, the method further comprises:
obtaining a plurality of training samples, each of the training samples comprising: entity attribute is to sample, sentence is to sample set and emotion classification probability calibration value;
taking one training sample in a plurality of training samples as a training sample to be trained;
inputting the entity attribute of the training sample to be trained into a coding layer of an initial model for coding to obtain a directional coding vector;
respectively inputting the sentence pair samples of the training samples to be trained into the coding layer for coding to obtain a sentence coding vector set;
adopting an internal aspect consistency coding layer of the initial model, and respectively carrying out attention weight calculation and coding between sentence vertexes and sentence vertexes on sentence coding vectors in the sentence coding vector set according to the direction coding vectors to obtain a first sentence vector set;
adopting an aspect tendency coding layer of the initial model, and respectively calculating and coding attention weights between sentence vertexes according to sentence coding vectors in the sentence coding vector sets to obtain a second sentence vector set;
performing feature extraction and feature fusion according to the first sentence vector set and the second sentence vector set by adopting a sentence fusion layer of the initial model to obtain a target sentence vector set;
respectively predicting emotion classification probability according to each target sentence vector in the target sentence vector set by adopting an emotion classification layer of the initial model to obtain an emotion classification probability predicted value;
training the initial model according to the emotion classification probability calibration value and the emotion classification probability prediction value of the training sample to be trained;
and repeatedly executing the step of taking one of the training samples as a training sample to be trained until a preset model training end condition is reached, and determining the initial model reaching the preset model training end condition as the emotion classification model.
3. The method according to claim 2, wherein said step of using the internal aspect consistency coding layer of the initial model to respectively perform internal aspect consistency coding on sentence coding vectors according to the direction coding vectors and the sentence coding vector sets to obtain the first sentence vector sets comprises:
determining sentence vertexes of the sentence coding vector set by adopting the internal aspect consistency coding layer according to the direction coding vectors to obtain a sentence vertex set;
constructing a consistency graph of the sentence vertex and the aspect according to the direction coding vector and the sentence vertex set by adopting the internal aspect consistency coding layer to obtain a target aspect consistency graph;
adopting the internal aspect consistency coding layer to calculate attention weights between the sentence vertexes and aspects according to the target aspect consistency graph to obtain a first attention weight set;
and respectively coding each sentence vertex according to the first attention weight set and the sentence vertex set by adopting the internal aspect consistency coding layer to obtain the first sentence vector set.
4. The method of claim 3, wherein the first attention weight in the first set of attention weights is calculated according to formula aikComprises the following steps:
Figure FDA0003285011810000021
wherein, aikIs the attention weight, v, between the ith sentence vertex in the set of sentence vertices and the directional codevectoriIs the ith said sentence vertex in said set of sentence vertices, ekIs the directional code vector, exp () is an exponential function with the natural constant e as the base, f () is the LeakyReLU activation function, w1、wvAnd weCoding the parameters of the layer requiring training for the internal aspect consistency, I is the number of the sentence vertices in the set of sentence vertices, T is a vector transpose calculation, [ w [ [ w ] nvvi;week]Is to convert the vector wvviAnd weekSplicing is carried out;
a formula for calculating a first sentence vector of the set of first sentence vectors
Figure FDA0003285011810000031
Comprises the following steps:
Figure FDA0003285011810000032
wherein the content of the first and second substances,
Figure FDA0003285011810000033
is the first sentence vector, a, corresponding to the ith sentence vertex in the set of sentence verticesjkIs the attention weight, v, between the jth said sentence vertex in said set of sentence vertices and said directional codevectorjIs the jth said sentence vertex in said set of sentence vertices, tanh () is a hyperbolic tangent function, w2、b1Are the parameters of the internal aspect conformance coding layer that need to be trained.
5. The method according to claim 3, wherein said step of using an aspect orientation coding layer of the initial model to perform aspect orientation coding of each sentence coding vector according to the set of sentence coding vectors to obtain a second set of sentence vectors comprises:
constructing an aspect orientation graph according to the sentence vertex set by adopting the aspect orientation coding layer to obtain a target aspect orientation graph;
adopting the aspect tendency coding layer to calculate attention weights among sentence vertexes according to the target aspect tendency graph to obtain a second attention weight vector set;
and respectively coding each sentence vertex according to the second attention weight vector set and the sentence vertex set by adopting the aspect tendency coding layer to obtain the second sentence vector set.
6. The method of claim 5, wherein the first attention weight a in the first set of attention weights is aikThe calculation formula of (2) is as follows:
Figure FDA0003285011810000034
wherein, aijIs the attention weight, v, between the ith and jth sentence vertices in the set of sentence verticesiIs the ith said sentence vertex, v, in said set of sentence verticesjIs the jth sentence vertex in the sentence vertex set, exp () is an exponential function with a natural constant e as the base, f () is a LeakyReLU activation function, w3、w4And w5The parameters to be trained for the aspect-oriented coding layer, I is the number of sentence vertices in the set of sentence vertices, T is the vector transpose calculation, [ w [ w ] ]4vi;w5vj]Is to convert the vector w4viAnd w5vjSplicing is carried out;
the above-mentionedFormula for calculating second sentence vector in second sentence vector set
Figure FDA0003285011810000041
Comprises the following steps:
Figure FDA0003285011810000042
wherein the content of the first and second substances,
Figure FDA0003285011810000043
is the second sentence vector corresponding to the ith sentence vertex in the sentence vertex set, tanh () is a hyperbolic tangent function, w6、b2Are the parameters of the aspect oriented coding layer that need to be trained.
7. The method according to claim 5, wherein said sentence fusion layer using the initial model performs sentence vector fusion according to the first sentence vector set and the second sentence vector set to obtain the target sentence vector set, comprising:
adopting a vector splicing sublayer of the sentence fusion layer to respectively splice sentence vectors corresponding to each sentence pair sample according to the first sentence vector set and the second sentence vector set to obtain a sentence vector splicing result set;
extracting features according to each sentence vector splicing result of the sentence vector splicing result set by adopting a plurality of feature extraction sublayers of the sentence fusion layer to obtain a sentence vector set to be fused corresponding to each sentence vector splicing result;
respectively fusing each sentence vector set to be fused by adopting a self-adaptive fusion sublayer of the sentence fusion layer to obtain the target sentence vector set;
wherein, the calculation formula of the sentence vector to be fused in the sentence vector set to be fused
Figure FDA0003285011810000044
Comprises the following steps:
Figure FDA0003285011810000045
a calculation formula r of a target sentence vector corresponding to the ith sentence vertex in the sentence vertex setiComprises the following steps:
Figure FDA0003285011810000046
Figure FDA0003285011810000047
is the mth sentence vector to be fused of the sentence vector set to be fused corresponding to the ith sentence vertex in the sentence vertex set, M is the mth layer of the plurality of feature extraction sublayers, M is the total number of layers of the plurality of feature extraction sublayers, tanh is a hyperbolic tangent function, w is the number of the feature extraction sublayersm、bm、Wr、brAnd q isiAnd fusing parameters needing training of the layer for the sentences.
8. An emotion classification apparatus based on document-level emotional tendencies, the apparatus comprising:
the system comprises a data acquisition module, a processing module and a display module, wherein the data acquisition module is used for acquiring a target evaluation text and an aspect emotion extraction rule, and the aspect emotion extraction rule comprises an evaluation object and an evaluation direction;
a sentence set determining module, configured to perform sentence extraction on the target evaluation text to obtain a sentence set;
a target entity attribute pair determining module, configured to extract a target entity attribute pair corresponding to the evaluation object from the sentence set;
the target question sentence determining module is used for acquiring a target question sentence template corresponding to the evaluation direction, and constructing question sentences according to the target question sentence template and the target entity attribute to obtain target question sentences;
a target sentence pair set determining module, configured to splice each sentence in the sentence set with the target question sentence, respectively, to obtain a target sentence pair set;
the emotion classification probability vector determination module is used for carrying out emotion classification probability prediction on the target entity attribute pair and the target sentence pair set input emotion classification model to obtain an emotion classification probability vector, wherein the emotion classification model is a model obtained by jointly modeling based on an attention mechanism, internal aspect consistency and aspect tendency;
and the target emotion classification determining module is used for carrying out emotion classification determination according to the emotion classification probability vector to obtain target emotion classification.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202111158076.3A 2021-09-28 2021-09-28 Emotion classification method, device, equipment and medium based on document-level emotion tendencies Active CN113849651B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111158076.3A CN113849651B (en) 2021-09-28 2021-09-28 Emotion classification method, device, equipment and medium based on document-level emotion tendencies

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111158076.3A CN113849651B (en) 2021-09-28 2021-09-28 Emotion classification method, device, equipment and medium based on document-level emotion tendencies

Publications (2)

Publication Number Publication Date
CN113849651A true CN113849651A (en) 2021-12-28
CN113849651B CN113849651B (en) 2024-04-09

Family

ID=78977289

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111158076.3A Active CN113849651B (en) 2021-09-28 2021-09-28 Emotion classification method, device, equipment and medium based on document-level emotion tendencies

Country Status (1)

Country Link
CN (1) CN113849651B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108133038A (en) * 2018-01-10 2018-06-08 重庆邮电大学 A kind of entity level emotional semantic classification system and method based on dynamic memory network
CN108363753A (en) * 2018-01-30 2018-08-03 南京邮电大学 Comment text sentiment classification model is trained and sensibility classification method, device and equipment
WO2019174423A1 (en) * 2018-03-16 2019-09-19 北京国双科技有限公司 Entity sentiment analysis method and related apparatus
CN110472042A (en) * 2019-07-02 2019-11-19 桂林电子科技大学 A kind of fine granularity sensibility classification method
CN113297352A (en) * 2021-06-07 2021-08-24 苏州大学 Attribute-level emotion classification method and device based on multitask network

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108133038A (en) * 2018-01-10 2018-06-08 重庆邮电大学 A kind of entity level emotional semantic classification system and method based on dynamic memory network
CN108363753A (en) * 2018-01-30 2018-08-03 南京邮电大学 Comment text sentiment classification model is trained and sensibility classification method, device and equipment
WO2019174423A1 (en) * 2018-03-16 2019-09-19 北京国双科技有限公司 Entity sentiment analysis method and related apparatus
CN110472042A (en) * 2019-07-02 2019-11-19 桂林电子科技大学 A kind of fine granularity sensibility classification method
CN113297352A (en) * 2021-06-07 2021-08-24 苏州大学 Attribute-level emotion classification method and device based on multitask network

Also Published As

Publication number Publication date
CN113849651B (en) 2024-04-09

Similar Documents

Publication Publication Date Title
CN110765265B (en) Information classification extraction method and device, computer equipment and storage medium
CN110021439B (en) Medical data classification method and device based on machine learning and computer equipment
CN110377730B (en) Case-by-case classification method, apparatus, computer device, and storage medium
CN111950269A (en) Text statement processing method and device, computer equipment and storage medium
CN110826328A (en) Keyword extraction method and device, storage medium and computer equipment
CN110598206A (en) Text semantic recognition method and device, computer equipment and storage medium
CN112131890A (en) Method, device and equipment for constructing intelligent recognition model of conversation intention
CN112052684A (en) Named entity identification method, device, equipment and storage medium for power metering
CN115599901B (en) Machine question-answering method, device, equipment and storage medium based on semantic prompt
CN111783902A (en) Data augmentation and service processing method and device, computer equipment and storage medium
CN112131883A (en) Language model training method and device, computer equipment and storage medium
CN111178358A (en) Text recognition method and device, computer equipment and storage medium
CN113849648A (en) Classification model training method and device, computer equipment and storage medium
JP2018185771A (en) Sentence pair classification apparatus, sentence pair classification learning apparatus, method, and program
CN114357151A (en) Processing method, device and equipment of text category identification model and storage medium
CN113704436A (en) User portrait label mining method and device based on session scene
KR102190304B1 (en) preferred content recommending apparatus based on GPU computing Using deep learning and method therefor
CN115017879A (en) Text comparison method, computer device and computer storage medium
US8311961B2 (en) Effort estimation using text analysis
CN114064852A (en) Method and device for extracting relation of natural language, electronic equipment and storage medium
CN113849651B (en) Emotion classification method, device, equipment and medium based on document-level emotion tendencies
CN116257632A (en) Unknown target position detection method and device based on graph comparison learning
US11645363B2 (en) Automatic identification of misclassified elements of an infrastructure model
KR102517971B1 (en) Context sensitive spelling error correction system or method using Autoregressive language model
CN115238645A (en) Asset data identification method and device, electronic equipment and computer storage medium

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
GR01 Patent grant