CN112347258B - Short text aspect level emotion classification method - Google Patents
Short text aspect level emotion classification method Download PDFInfo
- Publication number
- CN112347258B CN112347258B CN202011277713.4A CN202011277713A CN112347258B CN 112347258 B CN112347258 B CN 112347258B CN 202011277713 A CN202011277713 A CN 202011277713A CN 112347258 B CN112347258 B CN 112347258B
- Authority
- CN
- China
- Prior art keywords
- vector
- word
- speech
- words
- vector set
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/35—Clustering; Classification
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/289—Phrasal analysis, e.g. finite state techniques or chunking
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Artificial Intelligence (AREA)
- Bioinformatics & Computational Biology (AREA)
- Evolutionary Computation (AREA)
- Evolutionary Biology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Health & Medical Sciences (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Databases & Information Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Machine Translation (AREA)
Abstract
本发明公开了一种短文本方面级情感分类方法,其步骤包括:1、将短文本分词后,通过短文本中的词生成词向量、标注所有方面向量、词性向量;2、使用XLNET模型判断短文本所拥有的方面,并将每个词的词向量、词性向量、所拥有的方面向量顺次拼接;3、将步骤2中每个词拼接过后的向量输入情感分类Bilstm模型,得到的每个词隐含向量再输入Attention机制,并返回每个词的隐含向量的权重;4、使用每个词所对应的隐含向量和权值做加权平均,结果进入softmax神经网络,得到对应情感,以较大概率值作为情感分类结果。本发明能识别短文本在不同方面所具有的不同情感,从而完成细粒度的情感分类。
The invention discloses an aspect-level sentiment classification method for short texts. The steps include: 1. After segmenting the short text into words, generating word vectors, marking all aspect vectors and part-of-speech vectors from words in the short text; 2. Using an XLNET model to judge The aspect possessed by the short text, and splicing the word vector, part of speech vector, and aspect vector of each word in sequence; 3. Input the vector after splicing each word in step 2 into the sentiment classification Bilstm model, and each obtained Then input the hidden vector of each word into the Attention mechanism, and return the weight of the hidden vector of each word; 4. Use the hidden vector and weight corresponding to each word to do a weighted average, and the result enters the softmax neural network to get the corresponding emotion , with a larger probability value as the sentiment classification result. The invention can identify different emotions in different aspects of short texts, so as to complete the fine-grained emotion classification.
Description
技术领域technical field
本发明属于人工智能中自然语言处理领域,具体的说是一种融合词向量与方面向量、词性向量,并加入Attention机制的Bilstm模型的情感分类方法。The invention belongs to the field of natural language processing in artificial intelligence, and specifically relates to a sentiment classification method of a Bilstm model incorporating a word vector, an aspect vector and a part-of-speech vector, and adding an Attention mechanism.
背景技术Background technique
随着电商平台的发展,短文本评论越来越成为一种用户表达自身情感观点的重要方式。而往往短文本中所涉及的方面不止一个,甚至对于不同的方面可能持相反的情感态度。目前对于短文本的情感分类大多属于粗粒度分类,即对于短文本只给出一个情感分类,不能细粒度的识别不同方面所分别对应的情感。With the development of e-commerce platforms, short text comments have increasingly become an important way for users to express their emotional opinions. Often, more than one aspect is involved in the short text, and even opposite emotional attitudes may be held for different aspects. At present, most sentiment classifications for short texts belong to coarse-grained classification, that is, only one sentiment classification is given for short texts, and the sentiments corresponding to different aspects cannot be identified in a fine-grained manner.
发明内容SUMMARY OF THE INVENTION
本发明是为了解决上述现有技术存在的不足之处,提出一种短文本方面级情感分类方法,以期能通过先识别短文本包含的方面,再识别方面下所对应的情感,从而识别短文本在不同方面所具有的不同情感,并完成对短文本细粒度的情感分类。In order to solve the above-mentioned shortcomings of the prior art, the present invention proposes an aspect-level sentiment classification method for short texts, in order to recognize the aspects contained in the short texts first, and then identify the emotions corresponding to the aspects, so as to identify the short texts. Different sentiments in different aspects, and complete the fine-grained sentiment classification of short texts.
本发明为达到上述发明目的,采用如下技术方案:The present invention adopts the following technical scheme in order to achieve the above-mentioned purpose of the invention:
本发明一种短文本方面级情感分类方法的特点是按如下步骤进行:The feature of a short text aspect-level emotion classification method of the present invention is to carry out the following steps:
步骤1、获取评论数据中的所有短文本并作为语料库,对所述语料库中的任意一个短文本进行分类、清洗、分词的预处理操作,得到相应短文本的词向量集合,记为t=(t1,t2,…,ti,…,tk),ti表示第i个词,i∈[1,k],k表示所述短文本的词总量;Step 1. Obtain all the short texts in the comment data and use them as corpus, and perform the preprocessing operations of classification, cleaning, and word segmentation on any short text in the corpus, and obtain the word vector set of the corresponding short text, which is denoted as t=( t 1 ,t 2 ,…,t i ,…,t k ), t i represents the ith word, i∈[1,k], k represents the total number of words in the short text;
步骤2、对所述词向量集合t=(t1,t2,…,ti,…,tk)进行词性识别,得到词性表征向量集合p″′=(p″′1,p″′2,…,p″′i,…,p″′k),p″′i表示第i个词ti所对应的词性;Step 2: Perform part-of-speech recognition on the word vector set t=(t 1 , t 2 ,...,t i ,...,t k ) to obtain a part-of-speech representation vector set p"'=(p"' 1 ,p"' 2 ,…,p″′ i ,…,p″′ k ), p″′ i represents the part of speech corresponding to the i-th word t i ;
步骤3、对所述语料库中所有短文本按照步骤1进行预处理操作,并删除重复的词后,得到一个字典,并为字典中的每个词进行编号,作为相应词的索引位置key;Step 3. Preprocess all the short texts in the corpus according to Step 1, and after deleting the repeated words, a dictionary is obtained, and each word in the dictionary is numbered as the index position key of the corresponding word;
步骤4、利用所述字典中各个词的索引位置key对所述词向量集合t=(t1,t2,…,ti,…,tk)进行索引处理,得到索引向量集合s″′=(s″′1,s″′2,…,s″′i,…,s″′k);s″′i表示第i个词ti所对应的索引位置;Step 4. Perform index processing on the word vector set t=(t 1 ,t 2 ,...,t i ,...,t k ) using the index position key of each word in the dictionary to obtain an index vector set s"' =(s″′ 1 ,s″′ 2 ,…,s″′ i ,…,s″′ k ); s″′ i represents the index position corresponding to the i-th word t i ;
步骤5、将所述语料库中包含词总数最多的短文本所对应的词总数记为max;根据所述词总数max将所述词性表征向量集合p″′和索引向量集合s″′分别以“0”补齐,使得所述词性表征向量集合p″′和索引向量集合s″′中的词总数等于max;将补齐后的词性表征向量集合记为p″和补齐后的索引向量集合记为s″;Step 5. Denote the total number of words corresponding to the short text with the largest total number of words in the corpus as max; according to the total number of words max, the part-of-speech representation vector set p"' and the index vector set s"' are respectively marked with " 0" to complete, so that the total number of words in the part-of-speech representation vector set p"' and the index vector set s"' is equal to max; denote the completed part-of-speech representation vector set as p" and the completed index vector set Denoted as s";
步骤6、利用预训练XLNET模型对所述补齐后的词性表征向量集合p″中第j个词性进行n维词向量的转化处理,得到第j个词性向量,记为pj=(pj,1,pj,2,…,pj,d,…,pj,n),pj,d表示第j个词性向量中第d个维度值,d∈[1,n];Step 6, use the pre-training XLNET model to carry out the transformation processing of the n-dimensional word vector on the jth part of speech in the completed part of speech representation vector set p", and obtain the jth part of speech vector, denoted as p j = (p j ,1 ,p j,2 ,…,p j,d ,…,p j,n ), p j,d represents the d-th dimension value in the j-th part-of-speech vector, d∈[1,n];
步骤7、利用预训练XLNET模型对所述补齐后的索引向量集合s″中第j个词进行n维词向量的转化处理,得到第j个词向量,记为sj=(sj,1,sj,2,…,sj,d,…,sj,n),sj,d表示第j个词向量中第d个维度值;Step 7, utilize the pre-training XLNET model to carry out the transformation processing of the n-dimensional word vector to the jth word in the index vector set s" after the completion, obtain the jth word vector, denoted as s j = (s j, 1 ,s j,2 ,…,s j,d ,…,s j,n ), s j,d represents the d-th dimension value in the j-th word vector;
步骤8、从所述语料库中选取F个方面词,将第f个方面词输入所述预训练XLNET模型中,得到第f个方面词对应的词向量af=(af,1,af,2,…,af,d,…,af,n),af,d表示第f个方面词所对应的第d个维度值;Step 8. Select F aspect words from the corpus, input the f aspect word into the pre-training XLNET model, and obtain the word vector a f =(a f,1 ,a f corresponding to the f aspect word ,2 ,…,a f,d ,…,a f,n ), a f,d represents the d-th dimension value corresponding to the f-th aspect word;
步骤9、分别对词性表征向量集合p″′和索引向量集合s″′中的元素进行逆序排列,并根据所述词总数max以“0”补齐;得到补齐后的逆序词性表征向量集合记为p″″和补齐后的逆序索引向量集合记为s″″;Step 9. Arrange the elements in the part-of-speech representation vector set p"' and the index vector set s"' respectively in reverse order, and fill them with "0" according to the total number of words max; obtain the reversed-order part-of-speech representation vector set after completion. Denote it as p"" and the set of reversed index vectors after the complement is denoted as s"";
步骤10、利用预训练XLNET模型对所述补齐后的逆序词性表征向量集合p″″中第j个词性进行n维词向量的转化处理,得到第j个逆序词性向量,记为p′j=(p′j,1,p′j,2,…,p′j,d,…,p′j,n),p′j,d表示第j个逆序词性向量中第d个维度值,d∈[1,n];Step 10. Use the pre-trained XLNET model to perform the transformation processing of the n-dimensional word vector on the jth part of speech in the complemented reverse order part of speech representation vector set p"" to obtain the jth reverse order part of speech vector, denoted as p'j =(p′ j,1 ,p′ j,2 ,…,p′ j,d ,…,p′ j,n ), p′ j,d represents the d-th dimension value in the j-th reversed part-of-speech vector, d∈[1,n];
步骤11、利用预训练XLNET模型对所述补齐后的逆序索引向量集合s″″中第j个词进行n维词向量的转化处理,得到第j个逆序词向量,记为s′j=(s′j,1,s′j,2,…,s′j,d,…,s′j,n),s′j,d表示第j个逆序词向量中第d个维度值;Step 11, use the pre-training XLNET model to carry out the transformation processing of the n-dimensional word vector on the jth word in the complemented reverse order index vector set s"" to obtain the jth reverse order word vector, denoted as s' j = (s′ j,1 ,s′ j,2 ,…,s′ j,d ,…,s′ j,n ), s′ j,d represents the d-th dimension value in the j-th reversed word vector;
步骤12、形成Bilstm模型的正向输入特征:Step 12. Form the forward input features of the Bilstm model:
将第j个词向量sj、第j个词性向量pj和F个方面词对应的词向量进行顺次拼接,得到特征向量fw_cellj并作为正向Bilstm模型的输入,所述特征向量fw_cellj的维度为2×n+n×F;The jth word vector s j , the jth part of speech vector p j and the word vectors corresponding to the F aspect words are sequentially spliced to obtain a feature vector fw_cell j and use it as the input of the forward Bilstm model, the feature vector fw_cell j The dimension of is 2×n+n×F;
步骤13、形成Bilstm模型的逆向输入特征:Step 13. Form the reverse input feature of the Bilstm model:
将第j个逆序词向量s′j、第j个逆序词性向量p′j和F个方面词对应的词向量进行顺次拼接,得到逆序特征向量bw_cellj,并作为逆向Bilstm模型的另一个输入;Splicing the jth reversed word vector s′ j , the jth reversed part-of-speech vector p′j and the word vectors corresponding to the F aspect words in sequence to obtain the reversed feature vector bw_cell j , which is used as another input of the reverse Bilstm model ;
步骤14、建立F个矫正矩阵并识别方面信息:Step 14. Establish F correction matrices and identify aspect information:
令任意第f个矫正矩阵为(2+F)行乘以3列的矩阵,其中,第一列第一行的元素为“1”,第二列第二行的元素为“1”,第三列第f+2行的元素为“1”,其余元素均设置为“0”;Let any f-th correction matrix be a matrix of (2+F) rows multiplied by 3 columns, where the element of the first column and the first row is "1", the element of the second column and the second row is "1", and the element of the first column is "1". The element in row f+2 of the third column is "1", and the rest of the elements are set to "0";
将所述词向量集合t=(t1,t2,…,ti,…,tk)输入预训练XLNET模型中,得到所述词向量集合t所包含的方面信息;Inputting the word vector set t=(t 1 , t 2 ,...,t i ,...,t k ) into the pre-training XLNET model to obtain the aspect information contained in the word vector set t;
通过所述词向量集合t所包含的方面信息获取相对应的方面词,从而根据方面词得到相对应的矫正矩阵;Obtain the corresponding aspect word through the aspect information contained in the word vector set t, so as to obtain the corresponding correction matrix according to the aspect word;
将所述特征向量fw_cellj与所述词向量集合t所对应的矫正矩阵相乘,得到输入向量Ij;Multiply the feature vector fw_cell j with the corresponding correction matrix of the word vector set t to obtain an input vector I j ;
将所述逆序特征向量bw_cellj与所述词向量集合t所对应的矫正矩阵相乘,得到逆序输入向量I′j;Multiply the inverse order feature vector bw_cell j and the correction matrix corresponding to the word vector set t to obtain an inverse order input vector I′ j ;
步骤15、利用F个方面词分别训练F个Bilstm模型,得到训练后的F个Bilstm模型;Step 15, using F aspect words to train F Bilstm models respectively, to obtain F Bilstm models after training;
将所述输入向量Ij分别输入相对应方面词的训练后的Bilstm模型中,从而得到所述词向量集合t所包含的方面信息所对应的输出向量hfj;The input vector I j is respectively input into the Bilstm model after the training of the corresponding aspect word, thereby obtaining the output vector hf j corresponding to the aspect information contained in the word vector set t;
将所述逆序输入向量I′j分别输入相对应方面词的训练后的Bilstm模型中,从而得到所述词向量集合t所包含的方面信息所对应的逆序输出向量hbj;Inputting the reverse-order input vectors I′ j into the trained Bilstm models of the corresponding aspect words, respectively, to obtain the reverse-order output vector hb j corresponding to the aspect information contained in the word vector set t;
将输出向量hfj和逆序输出向量hbj进行拼接形成隐含向量hj;Splicing the output vector hf j and the reverse-order output vector hb j to form an implicit vector h j ;
步骤16、将隐含向量hj、第j个词性向量pj以及和F个方面词对应的词向量进行顺次拼接,得到Attention机制的隐含向量h′j:Step 16: Splicing the implicit vector h j , the j-th part-of-speech vector p j and the word vectors corresponding to the F aspect words in sequence to obtain the implicit vector h′ j of the Attention mechanism:
步骤17、利用F个方面词对应的词向量训练Attention机制网络,得到训练后Attention机制网络;Step 17. Use the word vectors corresponding to the F aspect words to train the Attention mechanism network, and obtain the Attention mechanism network after training;
将Attention机制的隐含向量h′j输入训练后的Attention机制网络,得到第j个词向量sj对应的权重;Input the latent vector h′ j of the Attention mechanism into the trained Attention mechanism network to obtain the weight corresponding to the jth word vector s j ;
步骤18、预测分类结果:Step 18. Predict the classification result:
分别将各个隐含向量hj与其对应的权重相乘后求和,得到h*输入全连接层中,得到正向情感和负向情感所对应的分数;再将正向情感和负向情感所对应的分数输入softmax层中,得到正向情感和负向情感所对应的概率,并将概率较大的情感作为预测分类结果。Multiply each hidden vector h j and its corresponding weight and sum up, get h * input into the fully connected layer, and get the scores corresponding to positive emotion and negative emotion; The corresponding scores are input into the softmax layer, the probability corresponding to the positive emotion and the negative emotion is obtained, and the emotion with a larger probability is used as the predicted classification result.
与现有技术相比,本发明的有益效果在于:Compared with the prior art, the beneficial effects of the present invention are:
1、本发明通过采用XLNET模型细粒度的识别短文本所含有的方面,并将短文本转化为词向量、词性向量、与XLNET所识别的方面衍生的方面向量融合输入到不同方面所对应训练的具有注意力机制的Bilstm模型中,得到短文本在该方面下所对应的情感,并通过先进行标签处理,再进行情感分类处理,完成了细粒度情感分类,对短文本的情感分类也变得更加准确。同时,本发明通过词向量、词性向量、方面向量的融合,使得短文本在转化为向量的过程中,更全面的保留了所含有的信息,提高了方面识别,情感分类的准确度。1. The present invention uses the XLNET model to identify the aspects contained in the short text in a fine-grained manner, and converts the short text into word vectors, part-of-speech vectors, and aspect vectors derived from the aspects identified by XLNET. In the Bilstm model with the attention mechanism, the emotion corresponding to the short text in this aspect is obtained, and the fine-grained emotion classification is completed by performing label processing first and then emotion classification processing, and the emotion classification of the short text also becomes more precise. At the same time, through the fusion of word vector, part-of-speech vector, and aspect vector, the present invention more comprehensively retains the information contained in the short text in the process of converting it into a vector, and improves the accuracy of aspect recognition and sentiment classification.
2、自然语言处理的核心是将语言转化为机器语言进行识别、判断,而本发明通过词向量、词性向量、方面向量的三重拼接,既考虑了文本的内容,又考虑了文本词性对识别文本所带来的帮助,还考虑了方面向量以便将短文本进行细粒度的情感分类。2. The core of natural language processing is to convert language into machine language for recognition and judgment, and the present invention considers both the content of the text and the part-of-speech of the text to recognize text through triple splicing of word vector, part-of-speech vector, and aspect vector. As a result, aspect vectors are also considered for fine-grained sentiment classification of short texts.
3、在识别方面标签的过程中,本发明提出了矫正矩阵,通过使用矫正矩阵,生成与短文本相关的各个方面所分别对应的词向量、词性向量、方面向量顺次拼接的输入向量,通过使用矫正矩阵,自动将与方面相关的方面向量拼接到词向量、词性向量之后,将与方面不相关的方面向量自动舍弃,精简了输入向量,同时保留了所有与方面相关的内容,并降低了计算的复杂度。3. In the process of identifying aspect labels, the present invention proposes a correction matrix. By using the correction matrix, an input vector in which word vectors, part-of-speech vectors, and aspect vectors corresponding to various aspects related to short texts are generated in sequence is generated. Using the correction matrix, after automatically splicing aspect-related aspect vectors to word vectors and part-of-speech vectors, the aspect vectors that are not related to the aspect are automatically discarded, simplifying the input vector, while retaining all aspect-related content, and reducing the computational complexity.
附图说明Description of drawings
图1为本发明方法整体流程图。Fig. 1 is the overall flow chart of the method of the present invention.
具体实施方式Detailed ways
本实施例中,一种融合词向量与方面向量、词性向量,并加入Attention机制的Bilstm模型的情感分类方法是按如下步骤进行:In the present embodiment, a sentiment classification method of the Bilstm model that fuses word vectors, aspect vectors, and part-of-speech vectors and adds the Attention mechanism is carried out according to the following steps:
步骤1、获取评论数据中的所有短文本并作为语料库,对语料库中的任意一个短文本进行分类、清洗、分词的预处理操作,得到相应短文本的词向量集合,记为t=(t1,t2,…,ti,…,tk),ti表示第i个词,i∈[1,k],k表示短文本的词总量;Step 1. Obtain all the short texts in the comment data and use them as corpus, and perform preprocessing operations of classification, cleaning, and word segmentation on any short text in the corpus, and obtain the word vector set of the corresponding short text, which is denoted as t=(t 1 ,t 2 ,…,t i ,…,t k ), t i represents the ith word, i∈[1,k], k represents the total number of words in the short text;
步骤2、对词向量集合t=(t1,t2,…,ti,…,tk)进行词性识别,得到词性表征向量集合p″′=(p″′1,p″′2,…,p″′i,…,p″′k),p″′i表示第i个词ti所对应的词性;Step 2. Perform part-of-speech recognition on the word vector set t=(t 1 ,t 2 ,...,t i ,...,t k ), and obtain the part-of-speech representation vector set p″′=(p″′ 1 ,p″′ 2 , …,p″′ i ,…,p″′ k ), p″′ i represents the part of speech corresponding to the i-th word t i ;
步骤3、对语料库中所有短文本按照步骤1进行预处理操作,并删除重复的词后,得到一个字典,并为字典中的每个词进行编号,作为相应词的索引位置key;Step 3. Preprocess all the short texts in the corpus according to Step 1, and after deleting the repeated words, a dictionary is obtained, and each word in the dictionary is numbered as the index position key of the corresponding word;
步骤4、利用字典中各个词的索引位置key对词向量集合t=(t1,t2,…,ti,…,tk)进行索引处理,得到索引向量集合s″′=(s″′1,s″′2,…,s″′i,…,s″′k);s″′i表示第i个词ti所对应的索引位置;Step 4. Use the index position key of each word in the dictionary to index the word vector set t=(t 1 ,t 2 ,...,t i ,...,t k ) to obtain the index vector set s″′=(s″ ′ 1 ,s″′ 2 ,…,s″′ i ,…,s″′ k ); s″′ i represents the index position corresponding to the i-th word t i ;
步骤5、将语料库中包含词总数最多的短文本所对应的词总数记为max;根据词总数max将词性表征向量集合p″′和索引向量集合s″′分别以“0”补齐,使得词性表征向量集合p″′和索引向量集合s″′中的词总数等于max;将补齐后的词性表征向量集合记为p″和补齐后的索引向量集合记为s″;Step 5. Record the total number of words corresponding to the short text with the largest total number of words in the corpus as max; according to the total number of words max, the part-of-speech representation vector set p"' and the index vector set s"' are respectively filled with "0", so that The total number of words in the part-of-speech representation vector set p"' and the index vector set s"' is equal to max; the complemented part-of-speech representation vector set is denoted as p" and the complemented index vector set is denoted as s";
步骤6、如图1所示,利用预训练XLNET模型对补齐后的词性表征向量集合p″中第j个词性进行n维词向量的转化处理,得到第j个词性向量,记为pj=(pj,1,pj,2,…,pj,d,…,pj,n),pj,d表示第j个词性向量中第d个维度值,d∈[1,n];Step 6. As shown in Figure 1, use the pre-training XLNET model to convert the jth part of speech in the filled part of speech representation vector set p" to the n-dimensional word vector, and obtain the jth part of speech vector, denoted as p j =(p j,1 ,p j,2 ,…,p j,d ,…,p j,n ), p j,d represents the d-th dimension value in the j-th part-of-speech vector, d∈[1,n ];
步骤7、如图1所示,利用预训练XLNET模型对补齐后的索引向量集合s″中第j个词进行n维词向量的转化处理,得到第j个词向量,记为sj=(sj,1,sj,2,…,sj,d,…,sj,n),sj,d表示第j个词向量中第d个维度值;Step 7, as shown in Figure 1, use the pre-training XLNET model to perform the transformation of the n-dimensional word vector on the jth word in the index vector set s" after the completion, to obtain the jth word vector, denoted as s j = (s j,1 ,s j,2 ,…,s j,d ,…,s j,n ), s j,d represents the d-th dimension value in the j-th word vector;
步骤8、从语料库中选取F个方面词,将第f个方面词输入预训练XLNET模型中,如图1所示,得到第f个方面词对应的词向量af=(af,1,af,2,…,af,d,…,af,n),af,d表示第f个方面词所对应的第d个维度值;Step 8. Select F aspect words from the corpus, input the f aspect word into the pre-training XLNET model, as shown in Figure 1, obtain the word vector a f =(a f,1 , a f,2 ,…,a f,d ,…,a f,n ), a f,d represents the d-th dimension value corresponding to the f-th aspect word;
步骤9、分别对词性表征向量集合p″′和索引向量集合s″′中的元素进行逆序排列,并根据词总数max以“0”补齐;得到补齐后的逆序词性表征向量集合记为p″″和补齐后的逆序索引向量集合记为s″″;Step 9. Arrange the elements in the part-of-speech representation vector set p"' and the index vector set s"' respectively in reverse order, and fill them with "0" according to the total number of words max; the completed reversed-order part-of-speech representation vector set is recorded as p"" and the complemented reverse index vector set is denoted as s"";
步骤10、利用预训练XLNET模型对补齐后的逆序词性表征向量集合p″″中第j个词性进行n维词向量的转化处理,得到第j个逆序词性向量,记为p′j=(p′j,1,p′j,2,…,p′j,d,…,p′j,n),p′j,d表示第j个逆序词性向量中第d个维度值,d∈[1,n];Step 10, use the pre-training XLNET model to perform the transformation processing of the n-dimensional word vector on the jth part of speech in the complemented reverse order part of speech representation vector set p"", and obtain the jth reverse order part of speech vector, denoted as p' j = ( p′ j,1 ,p′ j,2 ,…,p′ j,d ,…,p′ j,n ), p′ j,d represents the d-th dimension value in the j-th reverse part-of-speech vector, d∈ [1,n];
步骤11、利用预训练XLNET模型对补齐后的逆序索引向量集合s″″中第j个词进行n维词向量的转化处理,得到第j个逆序词向量,记为s′j=(s′j,1,s′j,2,…,s′j,d,…,s′j,n),s′j,d表示第j个逆序词向量中第d个维度值;Step 11. Use the pre-trained XLNET model to perform the transformation of the n-dimensional word vector on the jth word in the complemented reverse order index vector set s"" to obtain the jth reverse order word vector, denoted as s' j = (s ′ j,1 ,s′ j,2 ,…,s′ j,d ,…,s′ j,n ), s′ j,d represents the d-th dimension value in the j-th reversed word vector;
步骤12、形成Bilstm模型的正向输入特征:Step 12. Form the forward input features of the Bilstm model:
将第j个词向量sj、第j个词性向量pj和F个方面词对应的词向量进行顺次拼接,得到特征向量fw_cellj并作为Bilstm模型的正向输入,特征向量fw_cellj的维度为2×n+n×F;相比起只使用词向量或者只是用词向量、词性向量、方面向量的两两拼接,通过将词向量、词性向量、方面向量三者相拼接,使原短文本保留了更多的语义信息。The jth word vector s j , the jth part of speech vector p j and the word vectors corresponding to the F aspect words are sequentially spliced to obtain the feature vector fw_cell j and used as the forward input of the Bilstm model, the dimension of the feature vector fw_cell j is 2×n+n×F; compared to using only word vectors or just splicing word vectors, part-of-speech vectors, and aspect vectors in pairs, by splicing word vectors, part-of-speech vectors, and aspect vectors, the original short text Ben retains more semantic information.
步骤13、形成Bilstm模型的逆向输入特征:Step 13. Form the reverse input feature of the Bilstm model:
将第j个逆序词向量s′j、第j个逆序词性向量p′j和F个方面词对应的词向量进行顺次拼接,得到逆序特征向量bw_cellj,并作为Bilstm模型的逆向输入(Bilstm模型自动通过顺序输入转化为逆序输入),逆序的输入有助于识别下文信息,使得在短文本的输入过程中,可以考虑到上下文;The jth reversed word vector s' j , the jth reversed part-of-speech vector p'j and the word vectors corresponding to the F aspect words are sequentially spliced to obtain the reversed feature vector bw_cell j , which is used as the reverse input of the Bilstm model (Bilstm The model automatically converts sequential input into reverse-order input), and the reverse-order input helps to identify the following information, so that the context can be considered during the input process of short text;
步骤14、建立F个矫正矩阵并识别方面信息:Step 14. Establish F correction matrices and identify aspect information:
令任意第f个矫正矩阵为(2+F)行乘以3列的矩阵,其中,第一列第一行的元素为“1”,第二列第二行的元素为“1”,第三列第f+2行的元素为“1”,其余元素均设置为“0”;Let any f-th correction matrix be a matrix of (2+F) rows multiplied by 3 columns, where the element of the first column and the first row is "1", the element of the second column and the second row is "1", and the element of the first column is "1". The element in row f+2 of the third column is "1", and the rest of the elements are set to "0";
将词向量集合t=(t1,t2,…,ti,…,tk)输入预训练XLNET模型中,得到词向量集合t所包含的方面信息;Input the word vector set t=(t 1 ,t 2 ,...,t i ,...,t k ) into the pre-training XLNET model to obtain the aspect information contained in the word vector set t;
通过词向量集合t所包含的方面信息获取相对应的方面词,从而根据方面词得到相对应的矫正矩阵;The corresponding aspect words are obtained through the aspect information contained in the word vector set t, so as to obtain the corresponding correction matrix according to the aspect words;
将特征向量fw_cellj与词向量集合t所对应的矫正矩阵相乘,得到输入向量Ij;Multiply the feature vector fw_cell j and the correction matrix corresponding to the word vector set t to obtain the input vector I j ;
将逆序特征向量bw_cellj与词向量集合t所对应的矫正矩阵相乘,得到逆序输入向量I′j;Multiply the inverse order feature vector bw_cell j and the correction matrix corresponding to the word vector set t to obtain the inverse order input vector I′ j ;
步骤15、利用F个方面词分别训练F个Bilstm模型,得到训练后的F个Bilstm模型;Step 15, using F aspect words to train F Bilstm models respectively, to obtain F Bilstm models after training;
将输入向量Ij分别输入相对应方面词的训练后的Bilstm模型中,从而得到词向量集合t所包含的方面信息所对应的输出向量hfj;The input vector I j is respectively input into the Bilstm model after the training of the corresponding aspect word, thereby obtaining the output vector hf j corresponding to the aspect information contained in the word vector set t;
将逆序输入向量I′j分别输入相对应方面词的训练后的Bilstm模型中,从而得到词向量集合t所包含的方面信息所对应的逆序输出向量hbj;Input the reverse-order input vectors I′ j into the trained Bilstm models of the corresponding aspect words respectively, so as to obtain the reverse-order output vector hb j corresponding to the aspect information contained in the word vector set t;
将输出向量hfj和逆序输出向量hbj进行拼接形成隐含向量hj;Splicing the output vector hf j and the reverse-order output vector hb j to form an implicit vector h j ;
步骤16、将隐含向量hj、第j个词性向量pj以及和F个方面词对应的词向量进行顺次拼接,得到Attention机制的隐含向量h′j:Step 16: Splicing the implicit vector h j , the j-th part-of-speech vector p j and the word vectors corresponding to the F aspect words in sequence to obtain the implicit vector h′ j of the Attention mechanism:
步骤17、利用F个方面对应的词向量训练Attention机制网络,得到训练后Attention机制网络(使用Attention机制可以让机器决定需要关注输入的哪部分,并分配有限的信息处理资源给重要的部分);Step 17. Use the word vectors corresponding to the F aspects to train the Attention mechanism network, and obtain the Attention mechanism network after training (using the Attention mechanism allows the machine to decide which part of the input needs to be paid attention to, and allocate limited information processing resources to important parts);
将Attention机制的隐含向量h′j输入训练后的Attention机制网络,得到第j个词向量sj对应的权重;Input the latent vector h′ j of the Attention mechanism into the trained Attention mechanism network to obtain the weight corresponding to the jth word vector s j ;
步骤18、预测分类结果:Step 18. Predict the classification result:
分别将各个隐含向量hj与其对应的权重相乘后求和,得到h*输入全连接层中,得到正向情感和负向情感所对应的分数;再将正向情感和负向情感所对应的分数输入softmax层中,得到正向情感和负向情感所对应的概率,并将概率较大的情感作为预测分类结果。Multiply each hidden vector h j and its corresponding weight and sum up, get h * input into the fully connected layer, and get the scores corresponding to positive emotion and negative emotion; The corresponding scores are input into the softmax layer, the probability corresponding to the positive emotion and the negative emotion is obtained, and the emotion with a larger probability is used as the predicted classification result.
Claims (1)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011277713.4A CN112347258B (en) | 2020-11-16 | 2020-11-16 | Short text aspect level emotion classification method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011277713.4A CN112347258B (en) | 2020-11-16 | 2020-11-16 | Short text aspect level emotion classification method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112347258A CN112347258A (en) | 2021-02-09 |
CN112347258B true CN112347258B (en) | 2022-09-13 |
Family
ID=74362772
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011277713.4A Active CN112347258B (en) | 2020-11-16 | 2020-11-16 | Short text aspect level emotion classification method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112347258B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113761910A (en) * | 2021-03-17 | 2021-12-07 | 中科天玑数据科技股份有限公司 | Comment text fine-grained emotion analysis method integrating emotional characteristics |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019102884A1 (en) * | 2017-11-21 | 2019-05-31 | 日本電信電話株式会社 | Label generation device, model learning device, emotion recognition device, and method, program, and storage medium for said devices |
CN111666761A (en) * | 2020-05-13 | 2020-09-15 | 北京大学 | Fine-grained emotion analysis model training method and device |
CN111914085A (en) * | 2020-06-18 | 2020-11-10 | 华南理工大学 | Text fine-grained sentiment classification method, system, device and storage medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110083705B (en) * | 2019-05-06 | 2021-11-02 | 电子科技大学 | A multi-hop attention depth model, method, storage medium and terminal for target emotion classification |
-
2020
- 2020-11-16 CN CN202011277713.4A patent/CN112347258B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019102884A1 (en) * | 2017-11-21 | 2019-05-31 | 日本電信電話株式会社 | Label generation device, model learning device, emotion recognition device, and method, program, and storage medium for said devices |
CN111666761A (en) * | 2020-05-13 | 2020-09-15 | 北京大学 | Fine-grained emotion analysis model training method and device |
CN111914085A (en) * | 2020-06-18 | 2020-11-10 | 华南理工大学 | Text fine-grained sentiment classification method, system, device and storage medium |
Non-Patent Citations (2)
Title |
---|
"Sentiment Classification for Chinese Text Based on Interactive Multitask Learning";Han Zhang等;《IEEE Access ( Volume: 8)》;20200708;第1-10页 * |
"基于BiLSTM-Attention的电商评论情感分析";史振杰等;《河北省科学院学报》;20200630;第12-19页 * |
Also Published As
Publication number | Publication date |
---|---|
CN112347258A (en) | 2021-02-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111881260B (en) | Emotion analysis method and device based on aspect attention and convolutional memory neural network | |
CN110502753A (en) | A Deep Learning Sentiment Analysis Model Based on Semantic Enhancement and Its Analysis Method | |
CN112131469A (en) | A deep learning recommendation method based on review text | |
CN114492327A (en) | Intelligent writing method for official documents | |
CN113254610A (en) | Multi-round conversation generation method for patent consultation | |
CN113239690A (en) | Chinese text intention identification method based on integration of Bert and fully-connected neural network | |
CN113326374A (en) | Short text emotion classification method and system based on feature enhancement | |
CN110472245B (en) | Multi-label emotion intensity prediction method based on hierarchical convolutional neural network | |
CN109308355B (en) | Legal judgment result prediction method and device | |
CN111985243B (en) | Emotion model training method, emotion analysis method, device and storage medium | |
CN112287106A (en) | An online review sentiment classification method based on two-channel hybrid neural network | |
CN114416969B (en) | LSTM-CNN online comment emotion classification method and system based on background enhancement | |
CN113255360A (en) | Document rating method and device based on hierarchical self-attention network | |
CN113435192A (en) | Chinese text emotion analysis method based on changing neural network channel cardinality | |
TWI734085B (en) | Dialogue system using intention detection ensemble learning and method thereof | |
CN114742047A (en) | Text emotion recognition method based on maximum probability filling and multi-head attention mechanism | |
CN118551004A (en) | Knowledge retrieval graph-based Chinese dialogue knowledge retrieval method and system | |
CN114417851A (en) | Emotion analysis method based on keyword weighted information | |
CN111274396B (en) | Visual angle level text emotion classification method and system based on external knowledge | |
CN115240713B (en) | Voice emotion recognition method and device based on multi-modal characteristics and contrast learning | |
CN112347258B (en) | Short text aspect level emotion classification method | |
CN114254645A (en) | Artificial intelligence auxiliary writing system | |
CN115510230A (en) | Mongolian emotion analysis method based on multi-dimensional feature fusion and comparative reinforcement learning mechanism | |
CN115712731A (en) | Multi-modal emotion analysis method based on ERNIE and multi-feature fusion | |
CN114385813A (en) | Water environment text aspect-level viewpoint mining method based on multi-feature fusion |
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 | ||
GR01 | Patent grant |