Nothing Special   »   [go: up one dir, main page]

CN116150367A - Emotion analysis method and system based on aspects - Google Patents

Emotion analysis method and system based on aspects Download PDF

Info

Publication number
CN116150367A
CN116150367A CN202310066627.6A CN202310066627A CN116150367A CN 116150367 A CN116150367 A CN 116150367A CN 202310066627 A CN202310066627 A CN 202310066627A CN 116150367 A CN116150367 A CN 116150367A
Authority
CN
China
Prior art keywords
emotion
task
module
sentence
emotion analysis
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
CN202310066627.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.)
Xian Jiaotong University
Original Assignee
Xian Jiaotong University
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 Xian Jiaotong University filed Critical Xian Jiaotong University
Priority to CN202310066627.6A priority Critical patent/CN116150367A/en
Publication of CN116150367A publication Critical patent/CN116150367A/en
Pending legal-status Critical Current

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
    • 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
    • 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
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/088Non-supervised learning, e.g. competitive learning
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The invention discloses an emotion analysis method and system based on aspects, which comprises the steps of firstly, preparing data and processing a data set; inputting the processed data set into a multi-task learning model for feature extraction; training a multi-task learning model, utilizing an aspect term extraction task to assist in carrying out an aspect emotion classification task, and outputting the extracted aspect term and emotion polarity; the multitask learning model relates to two typical subtasks, namely an aspect term extraction task and an aspect polarity classification task, and takes the aspect term extraction task as an auxiliary task to assist in aspect emotion polarity classification so as to promote aspect polarity classification. And the dependency relation sequence is related to aspect extraction by utilizing a multi-head attention mechanism, so that the model can pay more attention to words closely related to the aspects, and the performance of aspect polarity classification is greatly enhanced. The emotion prediction method can be applied to emotion analysis of evaluation of food and beverage commodity sceneries and the like, and can provide more accurate and finer emotion prediction service.

Description

Emotion analysis method and system based on aspects
Technical Field
The invention belongs to the technical field of emotion analysis, and particularly relates to an emotion analysis method and system based on aspects.
Background
Emotion analysis is one of the important areas of natural language processing, and aspect-level emotion analysis is a fine-grained emotion analysis task that requires models to automatically extract aspects and predict emotion polarities of all aspects, as compared to traditional emotion analysis. For example, in the example of "I like the services of a restaurant, but the environment is not good," the terms of aspects are "services" and "environment. The polarity of the output emotion in these two aspects is positive and negative, respectively. Aspect-level emotion analysis mainly includes two subtasks: aspect term extraction and aspect emotion classification.
As a subtask of aspect-level emotion analysis, the task of aspect term extraction is to identify the different aspects mentioned in a given sentence. Aspect terms refer to specific features or attributes of a product or service discussed in the review. The extraction of aspect terms may be regarded as a text entity. Aspect term extraction methods go through a stage of development from traditional methods to deep learning methods.
Aspect emotion classification is effectively a text classification task: given a sentence and an aspect of the sentence, its corresponding emotion polarity is predicted. Compared with the task of extracting the terms of aspects, the task of classifying the emotion of the aspects has a great deal of research, and is also an important basic research in the field of natural language processing. Methods to address the task of emotion classification have evolved from feature engineering to deep learning-based methods, with the most common being models based on recurrent neural network RNNs and convolutional neural network CNNs. In recent years, with the development of pre-training models, a great deal of research is done on the basis of an unsupervised pre-training language model (Bidirectional Encoder Representation from Transformers BERT) for natural language processing tasks, and good results are obtained on many tasks, and the BERT model is also suitable for the aspect emotion classification task. Furthermore, a sentence contains not only semantic information but also syntactic structure information, such as the dependency tree structure of the sentence. Such a syntactic structure is helpful for the task of face emotion classification because the syntactic structure can capture emotion words that are relevant to the face.
In the above method, most of researches focus on the task of classifying the aspects of emotion, but neglect the importance of the task of extracting the terms of the aspects, and especially when the models are migrated to a new corpus, most of the models cannot be well applied to the new corpus due to the lack of the capability of extracting the aspects. At this time, the single aspect emotion classification model firstly needs to extract aspects in sentences by means of other models and then classifies the aspects, but the method does not utilize characteristics in the aspect extraction process.
In recent years, many emotion analysis methods consider a dependency tree as an adjacent matrix, and then encode the entire adjacent matrix with a graph neural network to extract features in the dependency, but most of researches directly input the dependency of sentences into the graph neural network, but the dependency is not considered, and important dependency cannot be highlighted.
Disclosure of Invention
Aiming at the defects in the prior art, the invention provides an emotion analysis method and an emotion analysis system based on aspects, which can utilize an aspect term extraction task to assist in carrying out aspect emotion classification tasks, realize information interaction of subtasks, provide more accurate emotion polarity prediction by utilizing a multi-head attention highlighting important dependency relationship, and are used for solving the technical problems that the information interaction among subtasks in the field of fine-granularity emotion analysis is insufficient, the important dependency relationship cannot be highlighted, and the aspect emotion polarity classification performance is deficient.
The invention adopts the following technical scheme:
an aspect-based emotion analysis method, comprising the steps of:
s1, preprocessing data with emotion polarity labels;
s2, inputting the data preprocessed in the step S1 into a multi-task learning model facing emotion analysis for feature extraction;
s3, training a multi-task learning model facing emotion analysis by using the features extracted in the step S2, obtaining a trained multi-task learning model, performing an aspect emotion classification task by using the assistance of the aspect term extraction task, and outputting the extracted aspect term and emotion polarity to complete emotion analysis.
Specifically, in step S1, for the aspect term extraction task, text is preprocessed with IOB tags, each word in a sentence is identified as a different tag, B is used asp First word of identification aspect, I asp The internal words of the aspect are identified, and the remaining words in the sentence are identified with O.
Specifically, in step S1, for the task of classifying an aspect emotion, use is made of<T,P>Binary representation aspect and corresponding emotion polarity, t= (w) i ,w i+1 ,…,w j ) Representing an aspect, i, j represents the start and end positions of the aspect in the sentence, p=p, P e { posivenegative, neutral }, respectively, including three emotion polarities, positive, negative and neutral.
Specifically, in step S2, the emotion analysis-oriented multitask learning model includes:
the global feature extraction module is used for extracting global features of sentences and aspects based on the BERT model;
a relationship graph attention module that encodes the dependency labels to extract dependency features;
an aspect term extraction module that extracts aspects in the sentence using the BERT model and provides features for calculating multi-headed attentiveness with the dependency sequence;
the multi-head attention module is used for associating two subtasks of aspect term extraction and aspect emotion classification, fusing dependency relationship labels into the features extracted by the BERT-ATE module to calculate the multiplication attention of a plurality of zoom points, and obtaining a feature h mha
Further, in the global feature extraction module, the global features for extracting sentences and aspects based on the BERT model are specifically:
the sentence and the aspect are integrally input into the model, and the sentence and the aspect are integrally input into the model by [ SEP ]]Character separation sentences and aspects using [ CLS ]]+sentence+[SEP]+aspect+[SEP]The form is used as input, after the features are extracted by the BERT model, a feature sequence h is obtained, each feature in the sequence corresponds to each word input, and h= (h) cls ,h 1 ,h 2 ,…,h n ,h sep ,h i ,h i+1 ,…,h j ,h sep ),h cls Pooling vectors for whole sentences, i.e. h apc To characterize the overall input.
Further, in the relationship diagram attention module, extracting the dependency relationship feature specifically includes:
for a sentence S, firstly, obtaining a dependency relationship by using a parser, obtaining a dependency relationship label between words according to a tree reconstruction algorithm, constructing a dependency tree, representing by using a graph of n nodes, wherein each node represents a word in the sentence, and extracting a final dependency relationship feature h by using an RGAT module rgat Obtaining a dependency relation sequence of sentences and a final dependency relation characteristic h rgat The following are provided:
Figure BDA0004062433340000041
wherein M is the number of attention heads in RGAT, h j For the feature vector corresponding to word j, W m As a weight matrix, a ij For elements ranging between (0, 1) calculated using the softmax function, N i The domain word node is word node i.
Further, in the aspect term extraction module, the sentence sequence s= (w 1 ,w 2 ,…,w n ) Tag sequence y= (t) after processing the sentence sequence S with IOB tag 1 ,t 2 ,…,t n ),t i ∈{O,B asp ,I asp ,[CLS],[SEP]Will [ CLS ]]+W+[SEP]Inputting the characteristic sequence F into the BERT model, and obtaining a characteristic sequence F after the BERT model codes, wherein each characteristic in the sequence corresponds to the input word one by one: f= (F cls ,F 1 ,F 2 ,…,F n ,F sep ),F cls I.e. h ate
Specifically, the trained multi-task learning model comprises two outputs of an aspect term and an aspect emotion polarity, and in the aspect term task, a linear layer is used for classifying to obtain the probability p (l) that each word belongs to various labels l; in the emotion polarity task aspect, final characteristics h are obtained by splicing f The probability p (c) of belonging to each emotion category c is obtained by classifying with a linear layer.
Further, in step S3, the probability p (l) that each word belongs to each type of tag l and the probability p (c) that each emotion category c are calculated as follows:
Figure BDA0004062433340000042
Figure BDA0004062433340000043
wherein W is l And b l Is a model parameter, L is an IOB tag set, W f And h f Is a model parameter, C is an emotion type set;
loss function of trained multitask learning model
Figure BDA0004062433340000045
The method comprises the following steps:
Figure BDA0004062433340000044
wherein alpha is a super parameter,
Figure BDA0004062433340000051
loss function for task of classifying emotion in aspect +.>
Figure BDA0004062433340000052
The loss function of the task is extracted for the facet term.
In a second aspect, an embodiment of the present invention provides an emotion analysis system based on the aspect, including:
the preprocessing module is used for preprocessing the data with the emotion polarity marks;
the feature module inputs the data preprocessed by the preprocessing module into a multi-task learning model facing emotion analysis for feature extraction;
the analysis module is used for training the multi-task learning model facing emotion analysis by utilizing the features extracted by the feature module, obtaining a trained multi-task learning model, assisting in carrying out an aspect emotion classification task by utilizing an aspect term extraction task, outputting the extracted aspect term and emotion polarity, and completing emotion analysis.
Compared with the prior art, the invention has at least the following beneficial effects:
according to the emotion analysis method based on the aspects, information interaction between tasks is achieved through multi-task learning and simultaneous learning of two subtasks of aspect term extraction and aspect emotion polarity classification, the aspect term extraction task is introduced into the aspect emotion polarity classification task as an aid, global features and local features are considered, a multi-head attention mechanism is utilized to link a dependency relationship sequence with aspect extraction, so that a model can pay more attention to words closely related to the aspects, the local features are further enhanced, and the performance of aspect emotion classification is greatly improved. Further, in the aspect term extraction task, text is preprocessed with IOB tags, identifying each word in a sentence as a different tag. With B asp First word of identification aspect, I asp The internal words of the aspect are identified, and the remaining words in the sentence are identified with O. The aspect term extraction task is regarded as a sequence labeling task and is combined with the aspect emotion classification task to realize information interaction among subtasks, so that the performance of the aspect emotion classification task can be remarkably improved. Further, in the task of classifying emotion in aspect, use<T,P>Binary representation aspect and corresponding emotion polarity, t= (w) i ,w i+1 ,…,w j ) Represents an aspect, wherein i, j represent the start and stop bits, respectively, of the aspect in a sentenceAnd (5) placing. P=p, P e { Positive, negative, neutral }, three emotional polarities in total. And taking the aspect emotion classification task as a main task, and utilizing an auxiliary task to improve the accuracy of emotion polarity of the aspect emotion classification task prediction.
Further, the aspect-based emotion analysis multitasking model includes four parts, BERT-APC (Global feature extraction Module), RGAT (relational graph Attention Module), BERT-ATE (aspect term extraction Module) and Multi-head Attention Module. The four modules can comprehensively extract the characteristics of sentences in multiple directions, and the global characteristics and the local characteristics are taken into account, so that the fusion and enhancement of the characteristics are realized. Further, the BERT-APC global feature extraction module is used for extracting global features of sentences and aspects based on the BERT model, inputting the sentences and the aspects into the model in a whole, and obtaining the whole sentence and the whole sentence by [ SEP ]]Character separation sentences and aspects using [ CLS ]]+sentence+[SEP]+aspect+[SEP]The form is used as input, after BERT extraction of the features, a feature sequence h is obtained, each feature in the sequence corresponds to each word input, h= (h) cls ,h 1 ,h 2 ,…,h n ,h sep ,h i ,h i+1 ,…,h j ,h sep ),h cld Is the pooling vector of the whole sentence, namely h apc The method is used for representing global features of the whole input so as to facilitate the subsequent enhancement and fusion of the features and improve the performance of the emotion classification task.
Further, the RGAT relationship graph attention module may encode the dependency relationship label to extract the dependency relationship feature, for a sentence D, obtain the dependency relationship with the parser first, and obtain the dependency relationship label between words according to the tree reconstruction algorithm, construct the dependency tree, and represent with the graph of n nodes, where each node represents a word in the sentence, and then extract the final dependency relationship feature h with the RGAT module rgat The dependency relation sequence of the sentences is obtained, the relation diagram attention module can focus on words which are more relevant to aspects, important dependency relations are emphasized, and local features of the sentences are extracted so as to facilitate the subsequent enhancement fusion of the features.
Further, the BERT-ATE aspect term extraction module uses primarily aspects of the BERT extraction sentence and provides a feature for calculating multi-head attention with the dependency sequence; for sentence sequence s= (w 1 ,w 2 ,…,w n ) Processing using IOB tags to obtain tag sequence y= (t) 1 ,t 2 ,…,t n ),t i ∈{O,B asp ,I asp ,[CLS],[SEP]Will "[ CLS ]]++[SEP]"input into BERT, get a characteristic sequence F after BERT code, every characteristic and word input one-to-one in the sequence correspond to: f= (F cls ,F 1 ,F 2 ,…,F n ,F sep ),F cls I.e. h ate The method comprises the steps of carrying out a first treatment on the surface of the The BERT-ATE aspect term extraction module can extract aspects in sentences to realize an aspect term extraction task and provide an aspect-based feature.
Further, the multi-task learning model comprises two outputs of an aspect term and an aspect emotion polarity, and in the aspect term task, a linear layer is used for classifying to obtain the probability p (l) that each word belongs to various labels l; in the emotion polarity task aspect, final characteristics h are obtained by splicing f ,h f =[h apc ;h ate ;h mh ;h rgat ;]The probability p (c) of belonging to each emotion category c is obtained by classifying with a linear layer. By carrying out output prediction on the face terms and the aspect emotion polarities, the performance of the model can be verified, quantized results are produced, and the model is optimized.
Furthermore, the prediction output of the aspect term extraction and the aspect emotion classification can be obtained through probability calculation, the prediction output can be compared with the correct output, and the model is continuously optimized through calculation of the loss function, so that the aspect emotion classification task is helped to achieve better performance, and the accuracy of polarity classification is improved.
It will be appreciated that the advantages of the second aspect may be found in the relevant description of the first aspect, and will not be described in detail herein.
In summary, the method and the device can utilize the aspect term extraction task to assist in carrying out the aspect emotion classification task, realize interaction between aspects and the dependency relationship, and provide more accurate emotion polarity prediction.
The technical scheme of the invention is further described in detail through the drawings and the embodiments.
Drawings
FIG. 1 is a schematic flow chart of the method of the present invention;
fig. 2 is a schematic diagram of a model structure in an embodiment of the invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the description of the present invention, it will be understood that the terms "comprises" and "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
It should be understood that although the terms first, second, third, etc. may be used to describe the preset ranges, etc. in the embodiments of the present invention, these preset ranges should not be limited to these terms. These terms are only used to distinguish one preset range from another. For example, a first preset range may also be referred to as a second preset range, and similarly, a second preset range may also be referred to as a first preset range without departing from the scope of embodiments of the present invention.
Depending on the context, the word "if" as used herein may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to detection". Similarly, the phrase "if determined" or "if detected (stated condition or event)" may be interpreted as "when determined" or "in response to determination" or "when detected (stated condition or event)" or "in response to detection (stated condition or event), depending on the context.
Various structural schematic diagrams according to the disclosed embodiments of the present invention are shown in the accompanying drawings. The figures are not drawn to scale, wherein certain details are exaggerated for clarity of presentation and may have been omitted. The shapes of the various regions, layers and their relative sizes, positional relationships shown in the drawings are merely exemplary, may in practice deviate due to manufacturing tolerances or technical limitations, and one skilled in the art may additionally design regions/layers having different shapes, sizes, relative positions as actually required.
The invention provides an emotion analysis method based on aspects, which realizes information interaction between tasks by simultaneously learning two subtasks of aspect term extraction and aspect emotion classification through multitask learning, wherein the aspect term extraction task is introduced into the aspect emotion classification task as an aid, and in the aspect extraction process, a model can pay more attention to words relevant to aspects, which is helpful for aspect emotion classification. The invention adopts four modules to comprehensively extract the characteristics of sentences in multiple directions, can remarkably improve the accuracy of emotion classification, can be applied to evaluation of food and beverage commodity sceneries and the like, and can provide more accurate emotion prediction service.
Referring to fig. 1, the emotion analysis method based on aspects of the present invention includes the following steps:
s1, preprocessing data with emotion polarity labels;
extracting labels, dependency relations, emotion polarities and position information, reconstructing a training set and a testing set, wherein the training set is used when training a multi-task learning model facing emotion analysis, and the testing set is used when verifying the model.
In the aspect term extraction task, text is preprocessed with IOB tags, each word in a sentence is identified as a different tag, B is used asp First word of identification aspect, I asp The internal words of the aspect are identified, and the remaining words in the sentence are identified with O.
In the task of classifying emotion<T,P>Binary representation aspect and corresponding emotion polarity, t= (w) i ,w i+1 ,…,w j ) Representing an aspect, where i, j represent the start and end positions of the aspect in the sentence, p=p, P e { positive, negative, nruaral }, respectively, for a total of three emotional polarities, positive, negative, and neutral.
S2, inputting the preprocessed data into a multi-task learning model facing emotion analysis for feature extraction;
referring to fig. 2, the emotion analysis-oriented multitask learning model includes four modules, BERT-APC (global feature extraction module), RGAT (relationship graph Attention module), BERT-ATE (aspect term extraction module) and Multi-head Attention module.
The BERT-APC global feature extraction module is used for extracting global features of sentences and aspects from the BERT model, and firstly inputting the sentences and the aspects into the model in a whole way, and obtaining the whole sentence and the whole sentence by [ SEP ]]Character separation sentences and aspects, use "[ CLS ]]+sentence+[SEP]+aspect+[SEP]"form is used as input, after BERT extraction of the features, a feature sequence h is obtained, each feature in the sequence corresponds to each word input, h= (h) cls ,h 1 ,h 2 ,…,h n ,h sep ,h i ,h i+1 ,…,h j ,h sep ),h cls Is the pooling vector of the whole sentence, namely h apc To characterize the overall input.
The RGAT relationship diagram attention module can encode the dependency relationship label to extract the dependency relationship characteristic, for a sentence S, firstly, the parser is used for obtaining the dependency relationship of the sentence S, the dependency relationship label between words is obtained according to the tree reconstruction algorithm, and then the RGAT module is used for extracting the final dependency relationship characteristic h rgat Obtaining a dependency relation sequence of sentences, and calculating final dependency relation characteristics according to the following formula:
g jj =σ(relu(r ij W m1 +b m1 )W m2 +b m2 )
Figure BDA0004062433340000101
Figure BDA0004062433340000102
wherein W is m1 And W is m2 Respectively is a weight matrix b m1 And b m2 Respectively are bias terms, r ij Is the relational tag between words i and j, h j The feature vector corresponding to the word j is calculated by the BERT-APC module, M is the number of attention heads in RGAT,
Figure BDA0004062433340000103
splicing M calculation results, and h rgat Is a feature extracted by the relationship graph attention module.
The BERT-ATE aspect term extraction module primarily uses BERT to extract aspects of sentences and provides a feature for calculating multi-head attention with a dependency sequence. Assume that there is a sentence sequence s= (w 1 ,w 2 ,…,w n ) Tag sequence y= (t) after processing it with IOB tag 1 ,t 2 ,…,t n ),t i ∈{O,B asp ,I asp ,[CLS],[SEP]Will "[ CLS ]]+W+[SEP]"input into BERT, get a characteristic sequence F after BERT code, every characteristic and word input one-to-one in the sequence correspond to: f= (F cls ,F 1 ,F 2 ,…,F n ,F sep ),F cls I.e. h ate
The Multi-head Attention module is used for associating two subtasks of aspect term extraction and aspect emotion classification, and fusing dependency relationship labels into features extracted by the BERT-ATE module to calculate the multiplication Attention of a plurality of zoom points, so as to obtain a feature h mha Important dependency labels are better highlighted.
In order to correlate the two subtasks of the aspect term extraction and the aspect emotion classification and highlight important dependency relationship, a multi-head attention mechanism is used, so that the model can better pay attention to the words related to the aspects, and the performance of the aspect emotion classification is improved.
S3, training a multi-task learning model facing emotion analysis, completing information interaction of an aspect term extraction task and an aspect emotion classification task, utilizing the aspect term extraction task to assist in carrying out the aspect emotion classification task, and outputting the extracted aspect term and emotion polarity;
the multi-task learning model facing emotion analysis has two outputs of aspect terms and aspect emotion polarities; in the aspect term ATE task, a BERT-ATE aspect term extraction module acquires a feature sequence corresponding to each word, and then classifies the feature sequence by using a linear layer to obtain the probability that each word belongs to various labels l:
Figure BDA0004062433340000111
wherein W is l And b l Is a model parameter, L is the IOB tag set, l= { O, B asp ,I asp ,[CLS],[SEP]}。
Four modules of the multi-task learning model facing emotion analysis extract one feature, and in the emotion polarity APC task, the four features are extractedThe characteristics are spliced to obtain a final characteristic h f ,h f =[h apc ;h ate ;h mha ;h rgat ;]Classifying by using a linear layer to obtain the probability of the emotion classification c:
Figure BDA0004062433340000112
wherein W is f And h f Is a model parameter, C is an emotion classification set, c=positive, negative, neutral.
The multi-task learning model is to optimize the loss functions of two tasks simultaneously, wherein the two subtasks adopt cross entropy loss functions, and the loss functions of the task are extracted by terms:
Figure BDA0004062433340000113
where N is the number of categories of the sequence labeling tag and k is the number of characters of the input sequence.
The loss function of the emotion classification task is as follows:
Figure BDA0004062433340000114
where C is the emotion classification set.
The final loss function is:
Figure BDA0004062433340000121
where α is a hyper-parameter representing the proportional relationship between the losses of the two tasks.
S4, verifying the model, wherein Accuracy Accuracy and macro average F1 are adopted, and the higher the Accuracy and macro average F1 value, the better the performance of the model.
The accuracy is calculated as follows:
Figure BDA0004062433340000122
wherein T is pre Representing the total number of predictions, C pre Indicating the number of correct predictions.
Calculating the macro average F1 first requires calculating the F1 value for each class and then averaging it. For multiple classifications, the precision, recall, and F1 values are for one class. The precision, recall, and F1 score for each class are first calculated as follows:
Figure BDA0004062433340000123
Figure BDA0004062433340000124
Figure BDA0004062433340000125
wherein A is { Positive, negative, neutral }, C A Representing the number of correctly predicted class A, T A1 Represents the total number of predicted class A, T A2 Representing the total number of classes a in fact.
The macro average F1 calculation method comprises the following steps:
Figure BDA0004062433340000126
wherein n is the number of categories, F1 i F1 values for each category.
In still another embodiment of the present invention, an aspect-based emotion analysis system is provided, which can be used to implement the above aspect-based emotion analysis method, and specifically, the aspect-based emotion analysis system includes a preprocessing module, a feature module, and an analysis module.
The preprocessing module is used for preprocessing the data with the emotion polarity labels;
the feature module inputs the data preprocessed by the preprocessing module into a multi-task learning model facing emotion analysis for feature extraction;
the analysis module is used for training the multi-task learning model facing emotion analysis by utilizing the features extracted by the feature module, obtaining a trained multi-task learning model, assisting in carrying out an aspect emotion classification task by utilizing an aspect term extraction task, outputting the extracted aspect term and emotion polarity, and completing emotion analysis.
In yet another embodiment of the present invention, a terminal device is provided, the terminal device including a processor and a memory, the memory for storing a computer program, the computer program including program instructions, the processor for executing the program instructions stored by the computer storage medium. The processor may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processor, digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc., which are the computational core and control core of the terminal adapted to implement one or more instructions, in particular to load and execute one or more instructions to implement the corresponding method flow or corresponding functions; the processor according to the embodiment of the invention can be used for the operation of the emotion analysis method based on aspects, and comprises the following steps:
preprocessing the data with emotion polarity labels; inputting the preprocessed data into a multitask learning model facing emotion analysis for feature extraction; training a multi-task learning model facing emotion analysis by using the extracted features to obtain a trained multi-task learning model, carrying out an aspect emotion classification task by using the aspect term extraction task assistance, and outputting the extracted aspect term and emotion polarity to complete emotion analysis.
In a further embodiment of the present invention, the present invention also provides a storage medium, in particular, a computer readable storage medium (Memory), which is a Memory device in a terminal device, for storing programs and data. It will be appreciated that the computer readable storage medium herein may include both a built-in storage medium in the terminal device and an extended storage medium supported by the terminal device. The computer-readable storage medium provides a storage space storing an operating system of the terminal. Also stored in the memory space are one or more instructions, which may be one or more computer programs (including program code), adapted to be loaded and executed by the processor. The computer readable storage medium may be a high-speed RAM Memory or a Non-Volatile Memory (Non-Volatile Memory), such as at least one magnetic disk Memory.
One or more instructions stored in a computer-readable storage medium may be loaded and executed by a processor to implement the respective steps of the above-described embodiments with respect to an aspect-based emotion analysis method; one or more instructions in a computer-readable storage medium are loaded by a processor and perform the steps of:
preprocessing the data with emotion polarity labels; inputting the preprocessed data into a multitask learning model facing emotion analysis for feature extraction; training a multi-task learning model facing emotion analysis by using the extracted features to obtain a trained multi-task learning model, carrying out an aspect emotion classification task by using the aspect term extraction task assistance, and outputting the extracted aspect term and emotion polarity to complete emotion analysis.
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. The components of the embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the invention, as presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The proposal of the method is proved by experiments, and experiments are carried out on three common public data sets, including a resueurant 14, a Laptop14 and a Twitter. The resueurant 14 and the Laptop14 comprise emotion comments in the fields of restaurants and notebook computers, and the Twitter dataset mainly comprises a tweet. The emotional polarity in these datasets includes three categories: positive (Positive), negative (Negative) and Neutral (Neutral).
Comparing the invention with the current home and abroad most advanced correlation model, and adopting Accuracy Accuracy and macro average F1 as evaluation indexes, wherein the comparison result is shown in Table 1:
table 1 results of comparative experiments
Figure BDA0004062433340000151
In Table 1, w/o BERT represents the witout BERT, no BERT is used in the model, w BERT represents the with BERT, and a pre-trained model BERT is used in the model.
As can be seen from Table 1, the two evaluation indexes Accurcry and macroaveraging on the three data sets of Restarant 14, laptop14 and Twitter are superior to other models, so that the effectiveness of the invention is proved, and the relation between aspect term extraction and aspect emotion classification can be established better, thereby enhancing the performance of aspect emotion classification.
In summary, the emotion analysis method and system based on aspects of the present invention relate to two typical subtasks, namely, aspect term extraction and aspect polarity classification, and the aspect term extraction task is used as an auxiliary task to assist in aspect emotion polarity classification so as to promote aspect polarity classification. The dependency relation sequence is related to aspect extraction by utilizing a multi-head attention mechanism, so that the model can pay more attention to words closely related to the aspect, and the polarity classification performance of the aspect is greatly enhanced; the emotion prediction method can be applied to emotion analysis of evaluation of food and beverage commodity sceneries and the like, and can provide more accurate and finer emotion prediction service.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal and method may be implemented in other manners. For example, the apparatus/terminal embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present invention may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RandomAccess Memory, RAM), an electrical carrier wave signal, a telecommunications signal, a software distribution medium, etc., it should be noted that the computer readable medium may contain content that is appropriately increased or decreased according to the requirements of jurisdictions and patent practices, such as in certain jurisdictions, according to the jurisdictions and patent practices, the computer readable medium does not contain electrical carrier wave signals and telecommunications signals.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above is only for illustrating the technical idea of the present invention, and the protection scope of the present invention is not limited by this, and any modification made on the basis of the technical scheme according to the technical idea of the present invention falls within the protection scope of the claims of the present invention.

Claims (10)

1. An emotion analysis method based on aspects, comprising the steps of:
s1, preprocessing data with emotion polarity labels;
s2, inputting the data preprocessed in the step S1 into a multi-task learning model facing emotion analysis for feature extraction;
s3, training a multi-task learning model facing emotion analysis by using the features extracted in the step S2, obtaining a trained multi-task learning model, performing an aspect emotion classification task by using the assistance of the aspect term extraction task, and outputting the extracted aspect term and emotion polarity to complete emotion analysis.
2. The method of aspect-based emotion analysis as recited in claim 1, wherein in step S1, for the aspect term extraction task, text is preprocessed with IOB tags, each word in a sentence is identified as a different tag, B is used asp First word of identification aspect, I asp The internal words of the aspect are identified, and the remaining words in the sentence are identified with O.
3. The method according to claim 1, wherein in step S1, for the aspect emotion classification task, using<T,P>Binary representation aspect and corresponding emotion polarity, t= (w) i ,w i+1 ,...,w j ) Representing an aspect, i, j represent the start and end positions of the aspect in the sentence, p=p, P e { Positive, negative, neutral }, respectively, including Positive, negativePolarity and neutral three emotional polarities.
4. The emotion analysis method based on aspect of claim 1, characterized in that in step S2, the emotion analysis-oriented multitasking learning model includes:
the global feature extraction module is used for extracting global features of sentences and aspects based on the BERT model;
a relationship graph attention module that encodes the dependency labels to extract dependency features;
an aspect term extraction module that extracts aspects in the sentence using the BERT model and provides features for calculating multi-headed attentiveness with the dependency sequence;
the multi-head attention module is used for associating two subtasks of aspect term extraction and aspect emotion classification, fusing dependency relationship labels into the features extracted by the BERT-ATE module to calculate the multiplication attention of a plurality of zoom points, and obtaining a feature h mha
5. The emotion analysis method based on aspect of claim 4, wherein in the global feature extraction module, extracting the global features of sentences and aspects based on the BERT model is specifically:
the sentence and the aspect are integrally input into the model, and the sentence and the aspect are integrally input into the model by [ SEP ]]Character separation sentences and aspects using [ CLS ]]+sentence+[SEP]+aspect+[SEP]The form is used as input, after the features are extracted by the BERT model, a feature sequence h is obtained, each feature in the sequence corresponds to each word input, and h= (h) cls ,h 1 ,h 2 ,...,h n ,h sep ,h i ,h i+1 ,...,h j ,h sep ),h cls Pooling vectors for whole sentences, i.e. h apc To characterize the overall input.
6. The method for emotion analysis based on an aspect of claim 4, wherein the extracting dependency relationship features in the relationship graph attention module is specifically:
for one ofSentence S, firstly obtaining dependency relationship by using a parser, obtaining dependency relationship labels among words according to a tree reconstruction algorithm, constructing a dependency tree, representing by using a graph of n nodes, wherein each node represents one word in the sentence, and extracting final dependency relationship characteristics h by using an RGAT module rgat Obtaining a dependency relation sequence of sentences and a final dependency relation characteristic h rgat The following are provided:
Figure FDA0004062433330000021
wherein M is the number of attention heads in RGAT, h j For the feature vector corresponding to word j, W m As a weight matrix, a ij For elements ranging between (0, 1) calculated using the softmax function, N i The domain word node is word node i.
7. The emotion analysis method based on aspect of claim 4, wherein in the aspect term extraction module, sentence sequence s= (w) 1 ,w 2 ,...,w n ) Tag sequence y= (t) after processing the sentence sequence S with IOB tag 1 ,t 2 ,...,t n ),t i ∈{O,B asp ,I asp ,[CLS],[SEP]Will [ CLS ]]+W+[SEP]Inputting the characteristic sequence F into the BERT model, and obtaining a characteristic sequence F after the BERT model codes, wherein each characteristic in the sequence corresponds to the input word one by one: f= (F cls ,F 1 ,F 2 ,...,F n ,F sep ),F cls I.e. h ate
8. The emotion analysis method based on aspects of claim 1, characterized in that in step S3, the trained multitask learning model includes two outputs of aspect terms and aspect emotion polarities, and in the aspect term task, probability p (l) of each word belonging to various labels l is obtained by classifying with a linear layer; in the emotion polarity task aspect, final characteristics h are obtained by splicing f The probability p (c) of belonging to each emotion category c is obtained by classifying with a linear layer.
9. The aspect-based emotion analysis method according to claim 8, characterized in that in step S3, the probability p (l) of each word belonging to each type of label l and the probability p (c) of each emotion category c are calculated as follows:
Figure FDA0004062433330000031
Figure FDA0004062433330000032
wherein W is l And b l Is a model parameter, L is an IOB tag set, W f And h f Is a model parameter, C is an emotion type set;
loss function of trained multitask learning model
Figure FDA0004062433330000033
The method comprises the following steps:
Figure FDA0004062433330000034
wherein alpha is a super parameter,
Figure FDA0004062433330000035
loss function for task of classifying emotion in aspect +.>
Figure FDA0004062433330000036
The loss function of the task is extracted for the facet term.
10. An aspect-based emotion analysis system, comprising:
the preprocessing module is used for preprocessing the data with the emotion polarity marks;
the feature module inputs the data preprocessed by the preprocessing module into a multi-task learning model facing emotion analysis for feature extraction;
the analysis module is used for training the multi-task learning model facing emotion analysis by utilizing the features extracted by the feature module, obtaining a trained multi-task learning model, assisting in carrying out an aspect emotion classification task by utilizing an aspect term extraction task, outputting the extracted aspect term and emotion polarity, and completing emotion analysis.
CN202310066627.6A 2023-01-16 2023-01-16 Emotion analysis method and system based on aspects Pending CN116150367A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310066627.6A CN116150367A (en) 2023-01-16 2023-01-16 Emotion analysis method and system based on aspects

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310066627.6A CN116150367A (en) 2023-01-16 2023-01-16 Emotion analysis method and system based on aspects

Publications (1)

Publication Number Publication Date
CN116150367A true CN116150367A (en) 2023-05-23

Family

ID=86357777

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310066627.6A Pending CN116150367A (en) 2023-01-16 2023-01-16 Emotion analysis method and system based on aspects

Country Status (1)

Country Link
CN (1) CN116150367A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116562305A (en) * 2023-07-10 2023-08-08 江西财经大学 Aspect emotion four-tuple prediction method and system
CN116595992A (en) * 2023-07-19 2023-08-15 江西师范大学 Single-step extraction method for terms and types of binary groups and model thereof

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116562305A (en) * 2023-07-10 2023-08-08 江西财经大学 Aspect emotion four-tuple prediction method and system
CN116562305B (en) * 2023-07-10 2023-09-12 江西财经大学 Aspect emotion four-tuple prediction method and system
CN116595992A (en) * 2023-07-19 2023-08-15 江西师范大学 Single-step extraction method for terms and types of binary groups and model thereof
CN116595992B (en) * 2023-07-19 2023-09-19 江西师范大学 Single-step extraction method for terms and types of binary groups and model thereof

Similar Documents

Publication Publication Date Title
Dahouda et al. A deep-learned embedding technique for categorical features encoding
CN112434535B (en) Element extraction method, device, equipment and storage medium based on multiple models
CN112966074A (en) Emotion analysis method and device, electronic equipment and storage medium
CN109598387A (en) Forecasting of Stock Prices method and system based on two-way cross-module state attention network model
CN110046356B (en) Label-embedded microblog text emotion multi-label classification method
CN116150367A (en) Emotion analysis method and system based on aspects
CN113297379A (en) Text data multi-label classification method and device
CN117151222B (en) Domain knowledge guided emergency case entity attribute and relation extraction method thereof, electronic equipment and storage medium
Thattinaphanich et al. Thai named entity recognition using Bi-LSTM-CRF with word and character representation
CN115687610A (en) Text intention classification model training method, recognition device, electronic equipment and storage medium
CN112784580A (en) Financial data analysis method and device based on event extraction
CN114742016B (en) Chapter-level event extraction method and device based on multi-granularity entity different composition
CN115795038A (en) Intention identification method and device based on localization deep learning framework
CN118171149B (en) Label classification method, apparatus, device, storage medium and computer program product
CN114428860A (en) Pre-hospital emergency case text recognition method and device, terminal and storage medium
CN114548325B (en) Zero sample relation extraction method and system based on dual contrast learning
CN117235605A (en) Sensitive information classification method and device based on multi-mode attention fusion
CN113743118B (en) Entity relation extraction method in legal document based on fusion relation information coding
CN116089605A (en) Text emotion analysis method based on transfer learning and improved word bag model
CN115099235A (en) Text generation method based on entity description
CN111046934B (en) SWIFT message soft clause recognition method and device
CN115358817A (en) Intelligent product recommendation method, device, equipment and medium based on social data
CN114595329A (en) Few-sample event extraction system and method for prototype network
CN116757159B (en) End-to-end multitasking joint chapter level event extraction method and system
CN112507126B (en) Entity linking device and method based on recurrent neural network

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