Method, device, and electronic device for joint recognition of comment area and sentiment polarity
By determining the comment object and dimension information, combined with the BERT and CRF models, efficient identification of comment areas and emotional polarity in user original data is achieved, solving the problem of low accuracy in the existing technology, and improving the recognition accuracy and efficiency.
Patent Information
- Application Number
- CN201911097178.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-11
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2039-11-11
AI Technical Summary
The prior art has low accuracy in entity and opinion mining methods in user original data, especially for data without emotional color, and the lack of full-text mining methods leads to a decrease in accuracy.
By determining the comment object and comment dimension information of the target text, the input data is constructed and the joint recognition model of the comment area and the emotional polarity is used, and the BERT and CRF models are combined for feature extraction and prediction, and the comment area and emotional polarity are identified.
The accuracy and efficiency of comment area and emotional polarity recognition in user original data has been improved, specifically manifested in the accuracy of comment area identification reaching 84% and emotional polarity recognition accuracy reaches 96%.
Smart Images

Figure CN110955750B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a method, device, electronic device, and computer-readable storage medium for jointly identifying comment areas and sentiment polarity. Background Art
[0002] User-generated data (such as user reviews) usually include users' different opinions on merchants or products. For example, in Internet shopping application scenarios, users' comments on online orders usually include users' different opinions on merchants or products they have purchased. Making full use of user-generated data and mining entity and opinion information in user-generated data is of great significance for merchants to improve product quality, enhance service quality, and recommend merchants and products. In the prior art, the method for entity and opinion mining is usually to identify the entire review data, identify the entities and / or opinions therein, and it is necessary to pre-identify the opinion keywords in the training samples. The entity and opinion mining methods in the prior art have a low accuracy rate for mining user-generated data that does not carry emotional color, and the lack of mining based on the full text of the review data will also lead to a decrease in mining accuracy. Summary of the Invention
[0003] The embodiment of the present application discloses a joint recognition method of comment area and sentiment polarity, which can improve the efficiency of mining specified information from user original data.
[0004] To solve the above problems, in a first aspect, embodiments of the present application disclose a method for jointly identifying comment regions and sentiment polarity, comprising:
[0005] Determining the name of the review object targeted by the target text and the review dimension information matching the target text, the review dimension information including: the name of the review dimension and keywords associated with the review dimension;
[0006] constructing input data according to the target text, the name of the review object, the name of the review dimension, and the keyword, and inputting the input data into a review area and sentiment polarity joint recognition model;
[0007] The comment area and sentiment polarity joint recognition model is used to estimate the sentiment polarity of the comment area in the target text and the target text matching based on the contextual information between the characters carried by the target text and the name of the comment object, the name of the comment dimension and the area information carried by the keyword.
[0008] In a second aspect, an embodiment of the present application discloses a device for jointly identifying comment areas and sentiment polarity, comprising:
[0009] A review object and review dimension determination module, configured to determine the name of the review object targeted by the target text and review dimension information matching the target text, wherein the review dimension information includes: the name of the review dimension and keywords associated with the review dimension;
[0010] An input data construction module, configured to construct input data according to the target text, the name of the review object, the name of the review dimension, and the keyword, and input the input data into the review area and sentiment polarity joint recognition model;
[0011] The comment area and sentiment polarity recognition module is used to estimate the sentiment polarity of the comment area in the target text and the target text matching based on the contextual information between the characters carried by the target text and the name of the comment object, the name of the comment dimension and the area information carried by the keywords through the comment area and sentiment polarity joint recognition model.
[0012] In a third aspect, an embodiment of the present application further discloses an electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the method for jointly identifying comment areas and sentiment polarity described in the embodiment of the present application is implemented.
[0013] In a fourth aspect, an embodiment of the present application discloses a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the steps of the method for jointly identifying comment areas and sentiment polarity disclosed in an embodiment of the present application.
[0014] The embodiment of the present application discloses a method for jointly identifying comment areas and sentiment polarity, which determines the name of the comment object targeted by the target text and the comment dimension information matching the target text, wherein the comment dimension information includes: the name of the comment dimension and the keywords associated with the comment dimension; constructs input data according to the target text, the name of the comment object, the name of the comment dimension and the keywords, and inputs the input data into a joint recognition model for comment areas and sentiment polarity; uses the joint recognition model for comment areas and sentiment polarity to estimate the sentiment polarity matching the comment area in the target text and the name of the comment object, the name of the comment dimension and the keywords based on the contextual information between the characters carried by the target text and the area information carried by the name of the comment object, the name of the comment dimension and the keywords, thereby simultaneously identifying the comment area in the target text and the sentiment polarity of the target text, and improving the efficiency of mining specified information from user-generated data. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0016] Figure 1 This is a flow chart of the joint recognition method of comment area and sentiment polarity in Example 1 of the present application;
[0017] Figure 2 Schematic diagram of the recognition model structure used in Example 1 of the present application;
[0018] Figure 3 This is one of the structural diagrams of the device for jointly identifying comment areas and sentiment polarity in Example 2 of the present application;
[0019] Figure 4 This is the second structural diagram of the device for jointly identifying comment areas and sentiment polarity in Example 2 of the present application. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0021] The joint recognition method of comment area and sentiment polarity disclosed in the embodiment of the present application can be used to identify comment areas in comment texts of objects under different categories. After identifying the comment area and sentiment polarity in the user's original text by the method of the present application, further opinion mining of the text model in the corresponding comment area can improve the accuracy of opinion mining. When the joint recognition method of comment area and sentiment polarity disclosed in the embodiment of the present application is applied to the user's original data in the field of takeout to identify the comment area, the fuzzy matching of the recognition of the comment area reaches 84%, the exact matching reaches 72%, and the accuracy rate of sentiment polarity recognition reaches 96%. The technical solution of the present application is elaborated in detail below in conjunction with specific embodiments.
[0022] Example 1
[0023] The embodiment of the present application discloses a joint recognition method of comment area and sentiment polarity, such as Figure 1 As shown, the method includes: steps 110 to 130.
[0024] Step 110 , determining the name of the review object targeted by the target text and the review dimension information that matches the target text.
[0025] The comment dimension information includes: the name of the comment dimension and keywords associated with the comment dimension, and the name of the comment dimension and the keywords associated with the comment dimension are determined according to words with descriptive functions in the target text.
[0026] During the specific implementation of this application, the comment area in the target text and the emotional polarity of the target text are predicted through a pre-trained joint recognition model of comment area and sentiment polarity. The input of the joint recognition model of comment area and sentiment polarity includes two parts of information. The first part of the information is the target text, and the second part of the information includes: the name of the comment object targeted by the target text, and the comment dimension information matched by the target text. Among them, the comment dimension information matched by the target text further includes: the name of the comment dimension, the keywords associated with the comment dimension, and the name of the comment dimension and the keywords associated with the comment dimension are stored in a preset corpus. For example, for the target text "Hot and sour noodles are so delicious, haha", it can be determined that the comment object it targets is "hot and sour noodles", and the comment dimension it matches can be any comment dimension stored in the preset corpus, and the keywords associated with the comment dimension are further determined based on the association relationship between the keywords and comment dimensions stored in the corpus. For example, it can be determined that the comment dimension matched by the target text is "taste and mouthfeel" or "delivery", etc.
[0027] In some embodiments of the present application, determining the name of the comment object targeted by the target text and the comment dimension information matching the target text includes: determining the name of the comment object targeted by the target text; and determining the keywords associated with the selected comment dimension and the name of the comment dimension based on the association relationship between the keywords stored in a preset corpus and the selected comment dimension.
[0028] In some embodiments of the present application, the name of the comment object targeted by the target text can be determined by a preset named entity recognition model. For example, the comment content of each user comment is used as the input of the model, and the comment object in the user comment is used as the prediction target of the model to train the named entity recognition model. Then, for the original user data to be processed, the comment object in the original user data to be processed can be identified by the named entity recognition model. For example, for the user comment text: "Boiled fish is delicious, fresh and tender, the delivery is great, and the packaging is atmospheric", it can be identified by the named entity recognition model, and it can be determined that the comment object therein is "boiled fish". For the training scheme of the named entity recognition model, please refer to the prior art and will not be repeated in the embodiments of the present application.
[0029] In other embodiments of the present application, the name of the review object targeted by the target text can also be determined by word matching. In other embodiments of the present application, the name of the review object targeted by the target text can also be determined by other methods. The present application does not limit the specific method for determining the name of the review object targeted by the target text.
[0030] In some embodiments of the present application, multiple comment dimensions are pre-set. For example, based on the analysis results of the user comment data, it can be determined that the user comment data involves more comment dimensions. When identifying the comment area and sentiment polarity of the target text, the combination of the comment object in the target text and the information of each preset comment dimension is used as input to determine the comment area and sentiment polarity prediction results corresponding to different comment dimensions. In some embodiments of the present application, it is also necessary to pre-determine the name of each comment dimension and the keywords associated with each comment dimension.
[0031] In some embodiments of the present application, the keywords associated with the selected comment dimension and the name of the comment dimension are determined based on the association relationship between the keywords and comment dimensions stored in a preset corpus. First, a corpus needs to be determined, in which the association relationship between the keywords and comment dimensions is stored.
[0032] In some embodiments of the present application, the association between keywords and comment dimensions is represented by the correspondence between the name of the comment dimension and the keyword. Typically, the name of a comment dimension corresponds to multiple keywords. For example, the association between keywords and comment dimensions can be expressed as {class, {keyword}}, where class represents the name of the comment dimension and {keyword} represents the set of keywords describing the comment dimension. After the comment dimension is determined, the keyword can be determined based on the association between the keyword and the comment dimension.
[0033] In some embodiments of the present application, the association relationship between the keywords and comment dimensions is determined in the following manner: determining a number of keywords based on a number of original user data obtained; clustering the keywords to determine multiple keyword categories; respectively determining a keyword set consisting of the keywords that meet preset conditions in each keyword category; abstracting the comment content of the keywords included in each keyword set, determining the comment dimension associated with each keyword set and the name of the comment dimension, and the comment dimension associated with the keyword is the comment dimension associated with the keyword set in which the keyword is located.
[0034] When constructing a corpus, first, the acquired user original data (such as user comment data) needs to be preprocessed. In some embodiments of the present application, the step of preprocessing the user original data includes: cleaning the target data with punctuation marks. For example, the comment text is punctuated, all punctuation marks are replaced with commas, and only one comma is retained for multiple consecutive commas. Take the user comment text: "The taste is good, the delivery is fast..." as an example. After preprocessing, the target data will become: "The taste is good, the delivery is fast."
[0035] Then, the pre-processed user-generated data is segmented to obtain a number of keywords. For example, a word segmentation tool can be used to segment the comment data using a preset vocabulary to obtain a number of words as keywords. Alternatively, a word segmentation tool such as Jieba or SnowNLP can be used to segment the pre-processed user-generated data to obtain a number of words.
[0036] Afterwards, the keywords are clustered to determine multiple keyword categories.
[0037] In some embodiments of the present application, a topic model may be used to perform unsupervised clustering on the keywords to determine multiple keyword categories, each of which includes multiple keywords. For example, a topic model (LDA) may be used to extract keywords from the words obtained by word segmentation to obtain multiple keywords, and unsupervised clustering may be performed on the extracted keywords to determine multiple keyword categories.
[0038] Next, a keyword set consisting of the keywords that meet preset conditions in each keyword category is determined respectively.
[0039] In some embodiments of the present application, the preset condition may be the K (K is a positive integer) keywords with the highest frequency of occurrence. For example, the top K keywords under each keyword category may be selected to represent the word description information of this keyword category. For example, for a set of user review data, the sentences it contains are<d1,d2,d3> , where d1 = "Good taste, fast delivery", d2 = "Excellent taste, hygienic", and d3 = "The chocolate is delicious, and the packaging is great." Jieba segmentation is used to obtain the segmentation results for each comment. The segmentation results are then subjected to the LDA topic model to extract the keywords from each comment. These keywords are then clustered to obtain multiple keyword categories. Next, TOPK keywords from each keyword category are selected to form the keyword set corresponding to that keyword category. For example, the resulting keyword sets include: Set 1 = <taste, flavor, very good>; Set 2 = <delivery, fast>; and Set 3 = <packaging, great>.
[0040] Finally, by abstracting the comment content of the keywords included in each keyword set, the comment dimension associated with each keyword set and the name of the comment dimension are determined.
[0041] As can be seen from the above steps, each keyword set includes K keywords, and the K keywords included in each keyword set can serve as a description of the keyword set. Therefore, by abstracting the comment content of the keywords included in the keyword set, the comment dimension associated with each keyword set is determined, and then the name of the comment dimension associated with each keyword set is determined. Then, the comment dimension associated with each keyword in the keyword set is the comment dimension associated with the keyword set in which the keyword is located.
[0042] For example, the review dimension matching set 1 can be set to "taste and texture," the review dimension matching set 2 can be set to "delivery," and the review dimension matching set 3 can be set to "appearance." Thus, the previously determined keyword sets and review dimension names can be expressed as: {taste and texture, {"taste", "flavor", "very good", ...}}, {delivery, {"delivery", "quick", "delivered", ...}}, {appearance, {"chocolate", "good-looking", "good", ...}}.
[0043] Finally, the determined keyword sets and the names of the comment dimensions corresponding to each keyword set are stored in the corpus in the form of a corresponding relationship.
[0044] Step 120 , constructing input data based on the target text, the name of the review object, the name of the review dimension, and keywords, and inputting the input data into the review area and sentiment polarity joint recognition model.
[0045] During the specific implementation of the present application, before the comment area and sentiment polarity are recognized on the target text by the comment area and sentiment polarity joint recognition model, it is first necessary to train the comment area and sentiment polarity joint recognition model.
[0046] In some embodiments of the present application, before determining the name of the comment object targeted by the target text and the comment dimension information matched by the target text, it also includes: the step of training the comment area and sentiment polarity joint recognition model. The step of training the comment area and sentiment polarity joint recognition model further includes: constructing a number of training samples based on user original data; each of the training samples includes two parts of data: model input data and output target data, the model input data includes: comment text, the name of the comment object targeted by the comment text, the name of the comment dimension matched by the comment text, and keywords associated with the comment dimension; the output target data includes: the true value of the position attribute identifier of each character in the comment text and the true value of the sentiment polarity identifier matched by the comment text. Afterwards, the comment area and sentiment polarity joint recognition model is trained with the goal of minimizing the weighted sum of the position attribute identifier loss value and the sentiment polarity identifier loss value of the training samples. Among them, the position attribute identifier is used to indicate whether the corresponding character is in the comment area; the position attribute identifier loss value of each training sample is calculated based on the difference between the predicted value of the position attribute identifier target of each character in the comment text and the true value; the sentiment polarity identifier loss value of each training sample is calculated based on the difference between the predicted value of the sentiment polarity identifier matched by the comment text and the true value.
[0047] In some embodiments of the present application, training samples are constructed by the following method.
[0048] First, obtain several pieces of user-generated data. Then, for each piece of user-generated data, determine the comment text included in the piece of user-generated data, the name of the comment object targeted by the user-generated data, the name of the comment dimension matched by the user-generated data, and the keywords associated with the name of each comment dimension. The specific method for determining the comment text included in the piece of user-generated data, the name of the comment object targeted by the user-generated data, the name of the comment dimension matched by the user-generated data, and the keywords associated with the name of each comment dimension from a piece of user-generated data can be found in the description of extracting the above information from the target text, which will not be repeated here.
[0049] Afterwards, based on the above information, training samples are constructed in a preset format. First, the model input data is constructed based on the comment text included in each piece of user-generated data, the name of the comment object targeted by the user-generated data, the name of the comment dimension matched by the user-generated data, and the keywords associated with the name of each comment dimension.
[0050] In an embodiment of the present application, the comment area and sentiment polarity joint recognition model requires that the characters in the above information be input into the model in sequence, and different data are input in segments. In some embodiments of the present application, the model input data of the comment area and sentiment polarity joint recognition model includes two parts: the first part of the input is the comment text, and the second part of the input includes the comment object and text description information. The text description information further includes: the keywords included in the comment text, and the comment dimension name corresponding to the keywords. Each part starts with [CLS] and ends with [SEP]. In order to facilitate model training, in an embodiment of the present application, the character length of the first part of the input is limited to M characters, and the character length of the second part of the input is limited to T characters, where M and T are positive integers. The values of M and T can be determined according to the normal length of the user's original data.
[0051] In some embodiments of the present application, the length of the first input is limited to M characters, and the comment text is placed in order. If the comment text is longer than M, the first M characters of the comment text are truncated as the first input. If the comment text is less than M, the [PAD] character is added after the comment text. Afterwards, two separators, [CLS] and [SEP], are added after the first input.
[0052] In some embodiments of the present application, the length of the second input is limited to T characters, and the comment object and text description information in the comment text are sequentially inserted. If the total character length of the comment object and text description information is greater than T, the first T characters are truncated and used as the second input. If the total character length of the comment object and text description information is less than T, the [PAD] character is added after the text description information. Subsequently, the [SEP] separator character is added after the second input.
[0053] Afterwards, for each piece of user-generated data, the output target data corresponding to the piece of data is determined.
[0054] The output target data of this model includes two parts of information, wherein the first part of the information is the position attribute identifier of each character in the comment area; the second part of the information is the emotional polarity identifier matched by the comment text in the model input data. In some embodiments of the application, the comment text corresponding to the user comment data can be annotated with BIO, that is, each character in the comment text is annotated with a label in the label set [B, I, O, Seq], wherein B represents the starting position of the comment area, I represents the middle position of the comment area, O represents not being in the comment area, and Seq represents the end position of the sentence. Then, the annotation result of the comment text is used as the first part of the model output target data corresponding to the original data of the user. For the second part of the model output target data, it can be annotated with a category identifier that identifies different emotional polarities, such as 0 or 1, according to the content of the comment text.
[0055] Take the comment data "Rice noodles are so delicious" as an example, where the comment text is "Rice noodles are so delicious," and the comment object in the comment is "spicy and sour rice noodles." If the comment dimension named "taste and texture" is selected, the keyword determined by the preset prediction library can be "delicious," and the sentiment polarity category of this comment data is "1" (assuming "1" indicates positive sentiment). Then, the model input data corresponding to the comment data "Rice noodles are so delicious" can include the following two parts: the first part: "Rice noodles are so delicious," and the second part: "spicy and sour rice noodles," "taste and texture," and "delicious." The input data for training the joint recognition model of comment area and sentiment polarity is expressed as: "[CLS]Rice noodles are so delicious, [SEP]Spicy and sour rice noodles taste and texture delicious [SEP]." The corresponding model output target data for the comment data "Rice noodles are so delicious" is expressed as: "BIIIII[SEP]OOOOO1." The length of the model output target data is M+1 characters, where the last character indicates the sentiment polarity category.
[0056] According to the above method, a training sample can be constructed based on each piece of user-generated data.
[0057] Next, the comment area and sentiment polarity joint recognition model is trained based on the training samples constructed using the above method.
[0058] In an embodiment of the present application, the comment area and sentiment polarity joint recognition model is built based on the BERT model, and the comment area and sentiment polarity joint recognition model includes: a comment area recognition task and a sentiment polarity recognition task, and the comment area recognition task and the sentiment polarity recognition task share the output of the BERT model.
[0059] In some embodiments of the present application, Figure 2As shown, the joint comment region and sentiment polarity recognition model uses the BERT (Bidirectional Encoder Representations from Transformers) model + CRF (conditional random field algorithm) model network structure, with the CRF model taking the BERT model input as input. The full name of the BERT model is: Bidirectional Encoder Representations from Transformer. The goal of the BERT model is to use large-scale unlabeled corpus training to obtain an expression of text that contains rich semantic information, namely: the semantic representation of text.
[0060] The joint comment region and sentiment polarity recognition model consists of two tasks: sentiment polarity recognition and comment region identification. After the input data passes through the BERT model, it outputs a hidden vector that expresses the correlation between the input text. The CRF model's sentiment polarity recognition and comment region recognition tasks map corresponding parts of the BERT model's hidden vector output, outputting comment region and sentiment polarity prediction results, respectively.
[0061] Taking the input data of the joint recognition model of comment area and sentiment polarity as an example, which includes M+2+T+1 characters, the input data will be converted into M+T+3 hidden vectors after passing through the BERT model. Among them, the first M+2 hidden vectors are used as the input of the comment area recognition task, and the dimension of each vector in the M+2 hidden vectors is d hidden ,The output matrix of the BERT model corresponding to the comment area recognition task is identified as H[M+2, d hidden ]; The T+1 hidden vectors are used as the input of the sentiment polarity recognition task, and the dimension of each vector in the T+1 hidden vectors is d hidden .
[0062] Furthermore, the emotion recognition task performs a linear transformation on the above M+2 hidden layer vectors to output the emotion polarity category label. In some embodiments of the present application, the linear transformation formula is: Y = WH + B, where label_size represents the dimension of the emotion polarity category, for example, label_size = 2; W is the transformation weight matrix, and the dimension of W is [label_size, (M+2)*d hidden ]; B is the bias matrix, the dimension of B is [label_size]; H is the first M+2 hidden layer vectors output by the BERT model, the dimension of H is [(M+2)*d hidden ,1],Y represents the prediction result of sentiment polarity category, and the dimension of Y is [label_size].
[0063] The comment area recognition task operates on the above M+2 hidden layer vectors and outputs the predicted position attribute identifier of each hidden layer vector.
[0064] The training objective of the joint comment region and sentiment polarity recognition model is to minimize the weighted sum of the loss value of the position attribute prediction result and the loss value of the sentiment polarity prediction result of the input comment text, that is, to minimize the weighted sum of the position attribute identification loss value and the sentiment polarity identification loss value of the training sample. The position attribute identification loss value of each training sample is calculated based on the difference between the predicted value and the true value of the position attribute identification target of each character in the comment text; the sentiment polarity identification loss value of each training sample is calculated based on the difference between the predicted value and the true value of the sentiment polarity identification matched to the comment text.
[0065] In some embodiments of the present application, the difference between the true value of the location attribute identifier and the predicted value of the location attribute identifier of each training sample is used as the location attribute identifier loss value of the training sample; the difference between the true value of the sentiment polarity identifier and the predicted value of the sentiment polarity identifier of the training sample is used as the sentiment polarity identifier loss value of the training sample. The predicted value is obtained after the recognition model calculates the model input data in the training sample. Afterwards, the location attribute identifier loss value and the sentiment polarity identifier loss value of each training sample are accumulated and averaged to obtain the loss value of the joint recognition model of the comment area and sentiment polarity.
[0066] In some other embodiments of the present application, the loss function of the comment area and sentiment polarity joint recognition model is configured as follows:
[0067] , where N represents the total number of training samples; M+2 represents the character length of the position attribute identifier; w is the weight of the sentiment polarity loss value; Represents the predicted value of the position attribute identifier of the jth character in the comment text in the i-th training sample; Indicates the true value of the position attribute corresponding to the jth character of the comment text in the i-th training sample, and The value range of is the preset value, such as {B, I, O, Seq}; S i represents the predicted value of the sentiment polarity of the i-th training sample; P i represents the true value of the sentiment polarity label of the i-th training sample; φ(θ) is the regularization term, and M and N are positive integers.
[0068] In some embodiments of the present application, the training sample can be represented as The training sample includes three parts of information. The first part is information x iis the input of the joint recognition model of comment area and sentiment polarity, denoted as x i =[u i :q i ], where u i Represents the comment text in the comment data corresponding to the i-th training sample, expressed as represents the nth character of the i-th training sample; q i Indicates the review object, description dimension and keywords corresponding to the description dimension included in the review text corresponding to the i-th training sample. The second part of information is the position attribute identifier of each character in the comment data corresponding to the i-th training sample, 1≤j≤M+2. The third part of information p i Indicates the sentiment polarity of the comment data corresponding to the i-th training sample, p i ∈{0,1}.
[0069] The input of the comment area and sentiment polarity joint recognition model is x i The comment area and sentiment polarity joint recognition model is used to identify the input x i The recognition result is expressed as in, It represents the prediction result of the model for the position attribute identification of each character in the comment text corresponding to the i-th training sample, s i S represents the model’s prediction result of the sentiment polarity of the comment text corresponding to the i-th training sample, i ∈{0,1}.
[0070] After training, the optimal parameters of the CRF model will be obtained. The sentiment polarity recognition task and comment area recognition task will perform character position attribute identification and sentiment polarity identification prediction based on the above optimal parameters.
[0071] In other embodiments of the present application, a fully connected network or an SVM model can be combined with a BERT model to construct a joint recognition model for comment areas and sentiment polarity. For the sample construction and model training process of the joint recognition model, please refer to the description in this embodiment.
[0072] Step 130 , using a joint recognition model of comment area and sentiment polarity to estimate the sentiment polarity of the comment area in the target text and the target text matching based on the contextual information between the characters carried by the target text and the name of the comment object, the name of the comment dimension, and the area information carried by the keywords.
[0073] In some embodiments of the present application, the step of using the comment area and sentiment polarity joint recognition model to estimate the sentiment polarity of the comment area in the target text and the target text matching according to the context information between the characters carried by the target text and the name of the comment object, the name of the comment dimension and the region information carried by the keyword includes: using the BERT model to perform feature extraction based on the context information between the characters carried by the target text and the name of the comment object, the name of the comment dimension and the region information carried by the keyword to obtain a latent vector corresponding to each character in the target text; performing feature mapping and transformation processing on the latent vector corresponding to each character through the comment area recognition task to estimate the position attribute identifier of each character in the target text; and, performing linear transformation processing on the latent vector corresponding to each character through the sentiment polarity recognition task to estimate the sentiment polarity identifier of the target text; determining the comment area in the target text according to the position attribute identifier of each character in the target text; and determining the sentiment polarity matching the target text according to the sentiment polarity identifier.
[0074] In the process of predicting the comment area and sentiment polarity of the target text, the BERT model first extracts features from the name of the comment object, the name of the comment dimension, and the region information carried by the keyword in the target text to obtain a latent vector of preset dimensions. Taking the model structure described in the previous step as an example, the BERT model outputs a size of (M+2)*d hidden +(T+1)*d hidden The hidden vector of . Among them, the (M+2)*d corresponding to the input comment text hidden The latent vector of the dimension reflects the context information between the characters of the target text and the name of the review object in the target text, the name of the review dimension, and the regional information carried by the keyword.
[0075] Afterwards, the comment area recognition task is performed on the aforementioned (M+2)*d hidden The latent vector of the dimension is subjected to feature mapping and transformation to obtain the position attribute identifier of each character in the target text. Taking the position attribute identifier as an example, the position attribute identifier is represented by a label in the aforementioned label set [B, I, O, Seq]. Furthermore, the comment area in the target text can be determined by the distribution of B and I in the output of the comment area identification task.
[0076] On the other hand, the sentiment polarity recognition task is for the aforementioned (M+2)*d hiddenBy performing a linear transformation on the latent vector of the target text dimension, a sentiment polarity flag of the target text can be obtained. Further, based on the sentiment polarity flag, the sentiment polarity of the target text can be determined. For example, if the sentiment polarity flag is 1, the sentiment polarity of the target text can be determined to be positive.
[0077] The method for jointly identifying comment areas and sentiment polarity disclosed in an embodiment of the present application determines the name of the comment object targeted by the target text and the comment dimension information matching the target text, the comment dimension information including: the name of the comment dimension and the keywords associated with the comment dimension; constructs input data according to the target text, the name of the comment object, the name of the comment dimension and the keywords, and inputs the input data into a joint recognition model for comment areas and sentiment polarity; estimates the sentiment polarity matching the comment area in the target text and the target text through the joint recognition model for comment areas and sentiment polarity based on the contextual information between the characters carried by the target text and the name of the comment object, the name of the comment dimension and the region information carried by the keywords, thereby simultaneously identifying the comment area in the target text and the sentiment polarity of the target text, and improving the efficiency of mining specified information from user-generated data.
[0078] On the other hand, the comment text combined with the comment object and comment dimension is used as the model input data. The comment object and comment dimension enable the model to learn the location information of the effective text in the comment text, which can improve the accuracy of comment area recognition.
[0079] Example 2
[0080] The embodiment of the present application discloses a joint recognition device for comment area and sentiment polarity, such as Figure 3 As shown, the device includes:
[0081] A review object and review dimension determination module 310 is configured to determine the name of the review object targeted by the target text and review dimension information matching the target text, wherein the review dimension information includes: the name of the review dimension and keywords associated with the review dimension;
[0082] An input data construction module 320 is configured to construct input data based on the target text, the name of the review object, the name of the review dimension, and the keyword, and input the input data into the review area and sentiment polarity joint recognition model;
[0083] The comment area and sentiment polarity recognition module 330 is used to estimate the sentiment polarity of the comment area in the target text and the target text matching based on the contextual information between the characters carried by the target text and the name of the comment object, the name of the comment dimension and the area information carried by the keyword through the comment area and sentiment polarity joint recognition model.
[0084] In some embodiments of the present application, the comment area and sentiment polarity joint recognition model is built based on the BERT model, including: comment area recognition tasks and sentiment polarity recognition tasks. The comment area and sentiment polarity recognition module 330 is further used to:
[0085] Using the BERT model, feature extraction is performed based on the contextual information between characters in the target text, the name of the review object, the name of the review dimension, and the regional information carried by the keyword to obtain a latent vector corresponding to each character in the target text;
[0086] Performing feature mapping and transformation processing on the latent vector corresponding to each character through the comment area recognition task to estimate the position attribute identifier of each character in the target text; and performing linear transformation processing on the latent vector corresponding to each character through the sentiment polarity recognition task to estimate the sentiment polarity identifier of the target text;
[0087] The comment area in the target text is determined according to the position attribute identifier of each character in the target text; and the sentiment polarity matched by the target text is determined according to the sentiment polarity identifier.
[0088] In some embodiments of the present application, Figure 4 As shown, it also includes:
[0089] The training sample construction module 340 is used to construct a number of training samples based on user-generated data; each training sample includes two parts of data: model input data and output target data. The model input data includes: the comment text, the name of the comment object targeted by the comment text, the name of the comment dimension matched by the comment text, and keywords associated with the comment dimension; the output target data includes: the true value of the position attribute identifier of each character in the comment text and the true value of the sentiment polarity identifier matched by the comment text;
[0090] The model training module 350 is used to train the comment area and sentiment polarity joint recognition model with the goal of minimizing the weighted sum of the location attribute identification loss value and the sentiment polarity identification loss value of the training samples.
[0091] Among them, the position attribute identification loss value of each training sample is calculated based on the difference between the predicted value of the position attribute identification target of each character in the comment text and the true value; the sentiment polarity identification loss value of each training sample is calculated based on the difference between the predicted value of the sentiment polarity identification matched by the comment text and the true value.
[0092] In some embodiments of the present application, the loss function of the comment area and sentiment polarity joint recognition model is configured as follows:
[0093] , where N represents the total number of training samples; M+2 represents the character length of the position attribute identifier; w is the weight of the sentiment polarity loss value; Represents the predicted value of the position attribute identifier of the jth character in the comment text in the i-th training sample; Indicates the true value of the position attribute corresponding to the jth character of the comment text in the i-th training sample, and The value range of S is selected from the preset value; i represents the predicted value of the sentiment polarity of the i-th training sample; P i represents the true value of the sentiment polarity label of the i-th training sample; φ(θ) is the regularization term, and M and N are positive integers.
[0094] In some embodiments of the present application, the review object and review dimension determination module 310 is further configured to:
[0095] Determine the name of the person the target text is commenting on;
[0096] According to the association relationship between the keywords stored in the preset corpus and the selected comment dimension, the keywords associated with the selected comment dimension and the name of the comment dimension are determined; wherein the association relationship between the keywords and the comment dimension is determined in the following manner:
[0097] Determine several keywords based on several pieces of user-generated data obtained;
[0098] Clustering the keywords to determine multiple keyword categories;
[0099] respectively determining a keyword set consisting of the keywords in each keyword category that meet preset conditions;
[0100] By abstracting the comment content of the keywords included in each keyword set, the comment dimension associated with each keyword set and the name of the comment dimension are determined, and the comment dimension associated with the keyword is the comment dimension associated with the keyword set where the keyword is located.
[0101] The device for jointly identifying comment areas and sentiment polarity disclosed in the embodiment of the present application is used to implement the various steps of the method for jointly identifying comment areas and sentiment polarity described in the first embodiment of the present application. The specific implementation methods of each module of the device can be found in the corresponding steps and will not be repeated here.
[0102] The embodiment of the present application discloses a device for jointly identifying comment areas and sentiment polarity, which determines the name of the comment object targeted by the target text and the comment dimension information matching the target text, wherein the comment dimension information includes: the name of the comment dimension and the keywords associated with the comment dimension; constructs input data according to the target text, the name of the comment object, the name of the comment dimension and the keywords, and inputs the input data into a joint recognition model for comment areas and sentiment polarity; uses the joint recognition model for comment areas and sentiment polarity to estimate the sentiment polarity matching the comment area in the target text and the name of the comment object, the name of the comment dimension and the keywords based on the contextual information between the characters carried by the target text and the area information carried by the name of the comment object, the name of the comment dimension and the keywords, thereby simultaneously identifying the comment area in the target text and the sentiment polarity of the target text, and improving the efficiency of mining specified information from user-generated data.
[0103] On the other hand, the comment text combined with the comment object and comment dimension is used as the model input data. The comment object and comment dimension enable the model to learn the location information of the effective text in the comment text, which can improve the accuracy of comment area recognition.
[0104] Accordingly, this application also discloses an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method for jointly identifying comment regions and sentiment polarity as described in Example 1 of this application. The electronic device may be a PC, a mobile terminal, a personal digital assistant, a tablet computer, or the like.
[0105] The present application also discloses a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the program implements the steps of the method for jointly identifying comment areas and sentiment polarity as described in the first embodiment of the present application.
[0106] Each embodiment in this specification is described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between the various embodiments can be referred to in conjunction with each other. For the device embodiments, since they are generally similar to the method embodiments, their description is relatively simple, and for relevant parts, reference can be made to the description of the method embodiments.
[0107] The above is a detailed introduction to a method and device for jointly identifying comment areas and sentiment polarity disclosed in this application. This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method of this application and its core idea; at the same time, for general technical personnel in this field, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on this application.
[0108] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.
Claims
1. A joint recognition method of comment area and sentiment polarity, characterized by: include: Determining the name of the review object targeted by the target text and the review dimension information matching the target text, the review dimension information including: the name of the review dimension and keywords associated with the review dimension; constructing input data according to the target text, the name of the review object, the name of the review dimension, and the keyword, and inputting the input data into a review area and sentiment polarity joint recognition model; The comment area and sentiment polarity joint recognition model is used to estimate the sentiment polarity of the comment area in the target text and the target text according to the context information between the characters carried by the target text and the name of the comment object, the name of the comment dimension, and the region information carried by the keyword; The comment area and sentiment polarity joint recognition model is built based on the BERT model and includes: a comment area recognition task and a sentiment polarity recognition task. The step of using the comment area and sentiment polarity joint recognition model to estimate the sentiment polarity of the comment area in the target text and the target text matching based on the contextual information between the characters carried by the target text, the name of the comment object, the name of the comment dimension, and the area information carried by the keyword includes: Using the BERT model, feature extraction is performed based on the contextual information between characters in the target text, the name of the review object, the name of the review dimension, and the regional information carried by the keyword to obtain a latent vector corresponding to each character in the target text; Performing feature mapping and transformation processing on the latent vector corresponding to each character through the comment area recognition task to estimate the position attribute identifier of each character in the target text; and performing linear transformation processing on the latent vector corresponding to each character through the sentiment polarity recognition task to estimate the sentiment polarity identifier of the target text; The comment area in the target text is determined according to the position attribute identifier of each character in the target text; and the sentiment polarity matched by the target text is determined according to the sentiment polarity identifier.
2. The method according to claim 1, characterized in that Before the step of determining the name of the comment object targeted by the target text and the comment dimension information matching the target text, the step of training a joint recognition model of comment area and sentiment polarity is also included. The step of training the joint recognition model of comment area and sentiment polarity further includes: Construct a number of training samples based on user-generated data; each training sample includes model input data and output target data, wherein the model input data includes: comment text, the name of the comment object targeted by the comment text, the name of the comment dimension matched by the comment text, and keywords associated with the comment dimension; the output target data includes: the true value of the position attribute identifier of each character in the comment text and the true value of the sentiment polarity identifier matched by the comment text; Training the comment area and sentiment polarity joint recognition model with the goal of minimizing the weighted sum of the location attribute identification loss value and the sentiment polarity identification loss value of the training samples; Among them, the position attribute identification loss value of each training sample is calculated based on the difference between the predicted value of the position attribute identification target of each character in the comment text and the true value; the sentiment polarity identification loss value of each training sample is calculated based on the difference between the predicted value of the sentiment polarity identification matched by the comment text and the true value.
3. The method according to claim 2, characterized in that The loss function of the comment area and sentiment polarity joint recognition model is configured as: Where N represents the total number of training samples; M+2 represents the character length of the position attribute identifier; w is the weight of the sentiment polarity loss value; Represents the predicted value of the position attribute identifier of the jth character in the comment text in the i-th training sample; Indicates the true value of the position attribute corresponding to the jth character of the comment text in the i-th training sample, and The value range of is selected from the preset value; Si represents the predicted value of the sentiment polarity mark of the i-th training sample; Pi represents the true value of the sentiment polarity mark of the i-th training sample; ϕ ( θ ) is a regularization term, M and N are positive integers.
4. The method according to any one of claims 1 to 3, characterized in that The step of determining the name of the review object targeted by the target text and the review dimension information matching the target text includes: Determine the name of the person the target text is commenting on; Determining the keywords associated with the selected comment dimension and the name of the comment dimension based on the association relationship between the keywords stored in the preset corpus and the selected comment dimension; The correlation between the keywords and the comment dimensions is determined in the following way: Determine several keywords based on several pieces of user-generated data obtained; Clustering the keywords to determine multiple keyword categories; respectively determining a keyword set consisting of the keywords in each keyword category that meet preset conditions; By abstracting the comment content of the keywords included in each keyword set, the comment dimension associated with each keyword set and the name of the comment dimension are determined, and the comment dimension associated with the keyword is the comment dimension associated with the keyword set where the keyword is located.
5. A joint recognition device for comment area and sentiment polarity, characterized in that: include: A review object and review dimension determination module, configured to determine the name of the review object targeted by the target text and review dimension information matching the target text, wherein the review dimension information includes: the name of the review dimension and keywords associated with the review dimension; An input data construction module, configured to construct input data according to the target text, the name of the review object, the name of the review dimension, and the keyword, and input the input data into the review area and sentiment polarity joint recognition model; A comment area and sentiment polarity recognition module is configured to estimate the sentiment polarity of the comment area in the target text and the target text according to the contextual information between the characters in the target text and the name of the comment object, the name of the comment dimension, and the area information carried by the keyword through the comment area and sentiment polarity joint recognition model; The comment area and sentiment polarity joint recognition model is built based on the BERT model. The comment area and sentiment polarity joint recognition model includes: a comment area recognition task and a sentiment polarity recognition task. The comment area and sentiment polarity recognition module is further used to: Using the BERT model, feature extraction is performed based on the contextual information between characters in the target text, the name of the review object, the name of the review dimension, and the regional information carried by the keyword to obtain a latent vector corresponding to each character in the target text; Performing feature mapping and transformation processing on the latent vector corresponding to each character through the comment area recognition task to estimate the position attribute identifier of each character in the target text; and performing linear transformation processing on the latent vector corresponding to each character through the sentiment polarity recognition task to estimate the sentiment polarity identifier of the target text; The comment area in the target text is determined according to the position attribute identifier of each character in the target text; and the sentiment polarity matched by the target text is determined according to the sentiment polarity identifier.
6. The device according to claim 5, characterized in that Also includes: A training sample construction module is used to construct a number of training samples based on user-generated data; wherein each training sample includes two parts of data: model input data and output target data. The model input data includes: the comment text, the name of the comment object targeted by the comment text, the name of the comment dimension matched by the comment text, and keywords associated with the comment dimension; the output target data includes: the true value of the position attribute identifier of each character in the comment text and the true value of the sentiment polarity identifier matched by the comment text; A model training module, configured to train the comment area and sentiment polarity joint recognition model with the goal of minimizing the weighted sum of the location attribute identification loss value and the sentiment polarity identification loss value of the training samples; Among them, the position attribute identification loss value of each training sample is calculated based on the difference between the predicted value of the position attribute identification target of each character in the comment text and the true value; the sentiment polarity identification loss value of each training sample is calculated based on the difference between the predicted value of the sentiment polarity identification matched by the comment text and the true value.
7. The device according to claim 6, characterized in that The loss function of the comment area and sentiment polarity joint recognition model is configured as: Where N represents the total number of training samples; M+2 represents the character length of the position attribute identifier; w is the weight of the sentiment polarity loss value; Represents the predicted value of the position attribute identifier of the jth character in the comment text in the i-th training sample; Indicates the true value of the position attribute corresponding to the jth character of the comment text in the i-th training sample, and The value range of is selected from the preset value; Si represents the predicted value of the sentiment polarity mark of the i-th training sample; Pi represents the true value of the sentiment polarity mark of the i-th training sample; ϕ ( θ ) is a regularization term, M and N are positive integers.
8. The device according to any one of claims 5 to 7, characterized in that The review object and review dimension determination module is further used to: Determine the name of the person the target text is commenting on; According to the association relationship between the keywords stored in the preset corpus and the selected comment dimension, the keywords associated with the selected comment dimension and the name of the comment dimension are determined; wherein the association relationship between the keywords and the comment dimension is determined in the following manner: Determine several keywords based on several pieces of user-generated data obtained; Clustering the keywords to determine multiple keyword categories; respectively determining a keyword set consisting of the keywords in each keyword category that meet preset conditions; By abstracting the comment content of the keywords included in each keyword set, the comment dimension associated with each keyword set and the name of the comment dimension are determined, and the comment dimension associated with the keyword is the comment dimension associated with the keyword set where the keyword is located.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the method for jointly identifying comment areas and sentiment polarity as described in any one of claims 1 to 4 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method for jointly identifying comment areas and sentiment polarity described in any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Comment entity-based aspect-level emotion classification method and device and model training thereof
CN109597997A
Restaurant user comment analysis system and method based on sentiment analysis
CN110134765A