Method, device, computer equipment and medium for extracting emotional information from comment text
Through the sequence-to-sequence model, the comment text is converted into a translated text containing quadruples of emotional elements, and the extraction model is used to output emotional elements, which solves the problem of inaccurate extraction of multi-tuples of emotional elements in the existing technology, and realizes quadruples of emotional elements Accurate extraction of groups and efficient analysis of emotional information.
Patent Information
- Application Number
- CN202111160199.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2041-09-30
AI Technical Summary
The existing aspect-based emotion analysis method cannot accurately extract emotional element quadruples at one time, and the accuracy of the single-emotional element extraction process is not high, resulting in inaccurate extraction results of emotional element multi-emotional element extraction results.
Use the sequence-to-sequence model to convert the comment text into a translated text containing a quadruple of emotional elements in a preset sentence structure, and directly output the emotional elements in the comment text by extracting the model. Use the sequence-to-sequence model to convert the text in the text predicts semantic information of subsequent characters, and predicts different emotional elements in association.
The accuracy of emotional element quadruples is improved, so that emotional element multitudes can be accurately extracted at one time, improving the overall performance of emotional information extraction.
Smart Images

Figure CN114201578B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence, and in particular, to a method, device, computer equipment and medium for extracting sentiment information from comment texts. Background Art
[0002] For a review text of a specific product, determining the sentiment tendency based on different aspects can help merchants find out what customers like or dislike, and can also help new customers quickly understand the characteristics of the product in various aspects. Aspect-based sentiment analysis (ABSA) has been widely used to analyze the review text of e-commerce products. It aims to extract sentiment information to determine the sentiment tendency based on aspects. The sentiment information usually involves four sentiment elements, namely aspect type, aspect words, opinion words and sentiment tendency.
[0003] Existing aspect-based sentiment analysis only considers the extraction of single sentiment elements, sentiment element pairs, and sentiment element triples. These methods have the following problems: first, it is impossible to extract all sentiment element quadruples at once, and the combination of four sentiment elements can comprehensively and systematically represent sentiment information; second, the extraction process of sentiment element multitudes is decoupled into multiple single sentiment element extraction processes according to the sentiment elements, among which the single sentiment element extraction process is usually performed using a classification network, which has low accuracy, and the overall performance of multi-sensory element extraction depends on the accuracy of each single sentiment element extraction. Therefore, the final extraction result of the sentiment element multitude will be inaccurate due to error accumulation. Summary of the invention
[0004] In view of this, the present disclosure aims to improve the analysis method of comment text so that the multi-tuple of sentiment elements can be accurately extracted at one time.
[0005] According to a first aspect of the present disclosure, a method for extracting sentiment information from a comment text is provided, comprising:
[0006] Obtain the comment text from which the sentiment information is to be extracted;
[0007] Inputting the review text into a sequence-to-sequence model, and obtaining a translated text of the review text character by character by the sequence-to-sequence model including a sentiment element quadruple in a preset sentence structure;
[0008] The translated text is input into an extraction model, and the extraction model outputs each group of sentiment elements in the comment text.
[0009] Optionally, the sequence-to-sequence model includes an encoding module and a decoding module;
[0010] The encoding module is used to encode the comment sentence into a context content vector;
[0011] The decoding module includes a decoding unit and a conversion unit, wherein the decoding unit performs current decoding based on the word vectors output by previous decodings and the context content vector and outputs the word vector generated by the current decoding, and the word vectors output by each decoding are also sequentially input into the conversion unit in a decoding order, so that the conversion unit converts multiple word vectors into the translated text in a decoding order.
[0012] Optionally, the sequence-to-sequence model is pre-trained in the following way:
[0013] Constructing a sample set consisting of comment samples, wherein the comment samples have element labels respectively predicted for the four elements of emotion and are associated with sentence labels formed by filling the element labels in the preset sentence structure;
[0014] Input each comment sample in the comment sample set into the sequence-to-sequence model, and obtain a predicted sentence for each comment sample from the sequence-to-sequence model;
[0015] The sentence label of each comment sample in the comment sample set is compared with the predicted sentence, and if the consistent ratio does not exceed the predetermined ratio, the weight of the sequence-to-sequence model is adjusted until the consistent ratio exceeds the predetermined ratio.
[0016] Optionally, the element tags include aspect type tags, aspect word tags, opinion word tags and sentiment tendency tags;
[0017] The preset sentence structure is: A is B because C is D, A, B, C and D represent four vacant positions;
[0018] In the sentence tag: the vacant position A is filled with the aspect type tag, the vacant position B is filled with the sentiment tendency tag, the vacant position C is filled with the aspect word tag, and the vacant position D is filled with the opinion word tag.
[0019] Optionally, in the case where the review sample includes aspect words, the aspect word label is set to the corresponding aspect word included in the review sample;
[0020] In the case that the review sample does not include aspect words, the aspect word label is set as a pronoun.
[0021] Optionally, in the case where the comment sample includes aspect words, the aspect word label is set to the corresponding aspect word included in the comment sample, the aspect type label is set to a pronoun, and the set of sentiment elements in the comment text output by the extraction model does not include the sentiment element of aspect type;
[0022] Alternatively, the aspect type tag is selected from a preset aspect type vocabulary, and one aspect type corresponds to only one word in the aspect type vocabulary.
[0023] Optionally, the sentiment tendency label is selected from a preset sentiment tendency vocabulary, and one sentiment tendency corresponds to only one word in the sentiment tendency vocabulary.
[0024] Optionally, the opinion word label is set as the sentiment tendency label, and the group of sentiment elements in the comment text output by the extraction model does not include the sentiment element of opinion word;
[0025] Alternatively, the opinion word label is set to the corresponding opinion word included in the comment sample.
[0026] Optionally, the comment sample includes a plurality of comment sentences, and one comment sentence is an evaluation made on one aspect;
[0027] The sentence tag includes a plurality of clause tags and separators arranged between adjacent clause tags;
[0028] Furthermore, the extraction model outputs each group of sentiment elements in the comment text by decomposing the translated text into a plurality of translated sentences according to the separator and outputting a plurality of sentiment elements of each of the translated sentences.
[0029] According to a second aspect of the present disclosure, a device for extracting sentiment information from a comment text is provided, comprising:
[0030] A sequence-to-sequence model, based on the comment text to be used for extracting sentiment information, obtains a translated text of the comment text character by character, including a quadruple of sentiment elements in a preset sentence structure;
[0031] The extraction model outputs each group of sentiment elements in the review text based on the translated text.
[0032] Optionally, the sequence-to-sequence model includes an encoding module and a decoding module;
[0033] The encoding module is used to encode the comment sentence into a context content vector;
[0034] The decoding module includes a decoding unit and a conversion unit, wherein the decoding unit performs current decoding based on the word vectors output by previous decodings and the context content vector and outputs the word vector generated by the current decoding, and the word vectors output by each decoding are also sequentially input into the conversion unit in a decoding order, so that the conversion unit converts multiple word vectors into the translated text in a decoding order.
[0035] According to a third aspect of the present disclosure, a computer device is provided, comprising:
[0036] A memory for storing computer executable code;
[0037] A processor is used to execute the computer executable code to implement any one of the methods described in the first aspect.
[0038] According to a fourth aspect of the present disclosure, a computer-readable medium is provided, comprising a computer executable code, wherein when the computer executable code is executed by a processor, any one of the methods described in the first aspect is implemented.
[0039] In the disclosed embodiment, the comment text to be extracted from the emotional information is input into the sequence-to-sequence model, the sequence-to-sequence model obtains the translated text of the comment text, and the translated text is input into the extraction model so that the extraction model outputs each group of emotional elements in the comment text, wherein the translated text is a text obtained character by character by the sequence-to-sequence model that includes the emotional element quadruple in a preset sentence structure, so the extraction model can directly extract each group of emotional tuples based on the preset sentence structure. In this process, the task of extracting emotional information is no longer performed by the classification network used in the traditional method, but is converted into a text conversion task performed by the sequence-to-sequence model, and the text conversion task is intended to generate a translated text of the comment text that represents the interpretation in a preset sentence structure and the emotional quadruple is included in the generated translated text. Since the sequence-to-sequence model predicts subsequent characters according to the semantics of the converted characters during the text conversion process, it can make good use of the semantic information of the label in the neural network and associate different emotional elements for prediction, thereby effectively improving the accuracy of the emotional element quadruple contained in the translated text, so that the emotional element tuple can be accurately extracted at one time. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The above and other objects, features and advantages of the present disclosure will become more apparent through the description of the embodiments of the present disclosure with reference to the following drawings, in which:
[0041] Figure 1A-1B An interface state diagram is shown when the emotion information extraction method of the embodiment of the present disclosure is applied;
[0042] Figure 2A-2B Another interface state diagram when the emotion information extraction method according to the embodiment of the present disclosure is applied is shown;
[0043] Figure 3 A flowchart of a method for extracting emotional information according to an embodiment of the present disclosure is shown;
[0044] Figure 4A sequence-to-sequence model diagram according to one embodiment of the present disclosure is shown;
[0045] Figure 5 The accuracy of various emotion information extraction methods applied to two test sample sets is shown;
[0046] Figure 6 A schematic diagram of the structure of an emotion information extraction device according to an embodiment of the present disclosure is shown;
[0047] Figure 7 A structural diagram of a computer device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0048] The present disclosure is described below based on embodiments, but the present disclosure is not limited to these embodiments. In the detailed description of the present disclosure below, some specific details are described in detail. It is possible for a person skilled in the art to fully understand the present disclosure without the description of these details. In order to avoid confusing the essence of the present disclosure, well-known methods, processes, and procedures are not described in detail. In addition, the drawings are not necessarily drawn to scale.
[0049] Aspect-based sentiment analysis can be used in a variety of scenarios. For example, it can be used to perform fine-grained analysis on customer reviews on e-commerce websites to help merchants find out what customers like or dislike or to help customers quickly understand the characteristics of various aspects of products, etc. In the scenario of analyzing customer reviews on e-commerce websites, Figure 1A As shown in FIG. 1 , a page prompting for entering the comment text to be extracted for sentiment information is displayed on the display interface. The backend maintenance personnel of the e-commerce website copy the customer comments to be analyzed to the page, such as Figure 1A "Yesterday's pasta was delicious!" in Figure 1B In the example, users (including customers and merchants) are presented with a tuple of sentiment elements extracted from the review text. In some cases, customer reviews may include more than one aspect, such as Figure 2A "Yesterday's wine list was great, but the space is too small for me!", in this case Figure 2B As shown, multiple sentiment element tuples are extracted from the comment text.
[0050] A sentiment element tuple is a data set that includes multiple sentiment elements in a comment. There are usually four types of sentiment elements, namely, aspect type, aspect word, opinion word and sentiment tendency. Aspect type indicates the category of the aspect described in a comment, aspect word refers to the word that indicates a specific aspect explicitly or implicitly mentioned in the comment text, opinion word refers to the opinion on the aspect mentioned in the comment text, and sentiment tendency indicates the category of opinion. Figure 1BIn the tuple of sentiment elements shown, "food quality" is an aspect type, "pasta" is an aspect word, "delicious" is an opinion word, and "affirmative" is an opinion tendency; Figure 2B In the sentiment element tuple 1 shown, "drink style" is an aspect type, "wine list" is an aspect word, "excellent" is an opinion word, and "affirmative" is an opinion tendency; and Figure 2B In the shown sentiment element tuple 2, "atmosphere" is an aspect type, "space" is an aspect word, "too small" is an opinion word, and "negative" is an opinion tendency.
[0051] The sentiment element tuple may be a sentiment element binary including two sentiment elements, a sentiment element triple including three sentiment elements, or a sentiment element quadruple including four sentiment elements. After the sentiment element tuple is extracted from the review text, it can be further used by subsequent decision models to generate various decisions, such as pushing a product with a "positive" sentiment tendency in a certain aspect to customers who value this aspect of the product.
[0052] It should be understood that the sentiment element tuple is not limited to Figure 1B and Figure 2B For example, the sentiment element tuple can also be displayed on the display interface as multiple elements in a fixed order in brackets, i.e. (c, a, o, p), where c represents the aspect type, a represents the aspect word, o represents the opinion word, and p represents the opinion tendency. This method is also used to represent the sentiment element quaternary group below. Figure 1A and Figure 2A The display interface shown allows the backend maintenance personnel to drag the scroll bar downward on the display interface to browse the subsequent part of the comment text; Figure 1B and Figure 2B The display interface shown allows the user to drag the scroll bar downward on the display interface to view one or more subsequent emotion element tuples extracted from the comment text.
[0053] In the prior art, the extraction task of multiple emotional elements is decoupled into multiple single emotional element extraction tasks by element, and then each single emotional element extraction task is processed in sequence in a pipeline manner, wherein the single emotional element extraction task is completed using a classification network. In this way, the label of the classification network is only represented by a digital sequence number for training the classification network. During the training process, the semantic information of different emotional element labels cannot be used, let alone mutually utilized to promote network learning, which affects the accuracy of prediction of each emotional element. For example, a comment is "The steamed bun is too cold", and the emotional element quadruple of the comment is (service, steamed bun, too cold, negative), wherein the aspect type is set to "service" because the steamed bun is too cold due to the merchant not keeping the steamed bun warm. However, it is difficult to predict the aspect type of this emotional element as "service" in the extraction of a single emotional element, because there is a large semantic difference between "steamed bun" and "service", and only the joint extraction of four emotional elements can accurately predict the aspect type as "service". In addition, the overall performance of multi-emotional element extraction depends on the accuracy of each single emotional element extraction. When the extraction accuracy of each single emotional element is not high, the final extraction result of the emotional element multi-group will be more inaccurate due to error accumulation.
[0054] In view of this, an embodiment of the present disclosure provides a method for extracting sentiment information from a comment text, the main idea of which is: by using a sequence-to-sequence model, the task of extracting sentiment element tuples is converted into a text conversion task, and the text conversion task is specifically equivalent to a paraphrase generation task. During the processing of the task, the original meaning of the comment text will not change, but the expression method will be changed, that is, the sentiment element quaternary group is included in the preset sentence structure, so that the subsequent extraction model can directly extract each group of sentiment elements from the translated text obtained from the sequence-to-sequence model based on the preset sentence structure. In this process, since the sequence-to-sequence model predicts subsequent characters according to the semantics of the converted characters (that is, the semantics of the element label after the sentiment element is predicted as a certain element label) during the text conversion process, it can make good use of the semantic information of the label and correlate different sentiment elements, thereby effectively improving the accuracy of the sentiment element quaternary group contained in the translated text, so that the sentiment element dyad, sentiment element triple and even sentiment element quaternary group can each be accurately extracted at one time.
[0055] When the extracted emotional element tuple is used by the e-commerce website to find out what the customer likes or dislikes, the emotional information extraction method is executed by the e-commerce website server. When the extracted emotional element tuple is used by the customer to understand the characteristics of various aspects of the product, the emotional information extraction method is executed by the customer's terminal. The e-commerce website server and the customer's terminal can execute the emotional information extraction method by installing an application that executes the emotional information extraction method.
[0056] Figure 3 FIG. 1 is a flowchart of a method for extracting emotional information according to an embodiment of the present disclosure. Figure 3 , emotional information extraction methods, including:
[0057] Step S110, obtaining the comment text of the emotional information to be extracted;
[0058] Step S120, inputting the comment text into a sequence-to-sequence model, and obtaining a translated text of the comment text character by character by the sequence-to-sequence model, which includes the sentiment element quadruple in a preset sentence structure, wherein one sentence of the translated text includes the sentiment element quadruple in a preset sentence structure;
[0059] Step S130, inputting the translated text into the extraction model, and the extraction model outputs each group of sentiment elements in the comment text.
[0060] The above steps are described in detail below.
[0061] In step S110, the comment text to be extracted with emotional information can be obtained as follows: Figure 1A or Figure 2A As shown, the interface for inputting the comment text to be extracted with emotional information is displayed to the backend maintenance personnel of the e-commerce website, and the input of the maintenance personnel is received to achieve this. It can also be achieved by scanning the paper comment text and then converting it into an electronic document through OCR (optical character recognition), etc. The comment text to be extracted with emotional information is determined by the maintenance personnel, and the emotional element tuple is obtained from the comment text with the help of a machine.
[0062] Step S120 involves a sequence-to-sequence model. Before describing step S120, the sequence-to-sequence model is first introduced.
[0063] Sequence to sequence, that is, Sequence-to-Sequence, abbreviated as seq2seq. The sequence to sequence model directly converts a character sequence into another character sequence through the encoding-decoding process, specifically realizing the translation of text. There is no interpretation conflict between the text before translation and the text after translation, but the length may be different. For example, the text before translation is a news article, and the text after translation is a generated news summary; the text before translation is in English, and the text after translation is translated into Chinese. In the disclosed embodiment, the text before translation is the comment text whose emotional information is to be extracted, and the text after translation is called the translated text.
[0064] In the sequence-to-sequence model, the encoding process is to input each character of the pre-translation text into the network in sequence according to the sequence relationship of the context and output a result each time accordingly, and the result of each output only retains the last hidden state, which is equivalent to condensing the entire pre-translation text together to form a context content vector for use in the subsequent decoding process. Each word in the text sequence input by the encoding process is known, and the decoding process is different from the encoding process in that the decoding process is equivalent to knowing nothing, and the subsequent results need to be obtained based on the previous results. In the embodiment of the present disclosure, the previous results include the decoded character word vectors contained in the preset sentence structure and the decoded emotional element word vectors, and the subsequent results include the undecoded emotional element word vectors. Since the emotional element is determined as an element label in the sequence-to-sequence model, the undecoded emotional element word vector will be obtained according to the word vector of the element label corresponding to the decoded emotional element. In the whole process, the semantics of the element label is fully utilized and the association prediction between multiple emotional elements is made, so the accuracy of the emotional element quadruple prediction is improved.
[0065] It should be noted that the output of the sequence-to-sequence model during the decoding process is not a general code, but a vector representing the semantics of the character, that is, the word vector mentioned above. Characters with different semantics have different word vectors. The closer the semantics of the characters, the smaller the distance between the word vectors; the farther the semantics of the characters, the larger the distance between the word vectors.
[0066] Figure 4 FIG. 4 shows an exemplary sequence-to-sequence model used in the embodiment of the present disclosure. Figure 4 , the sequence-to-sequence model 100 includes an encoding module 110 and a decoding module 120. The encoding module 110 receives the comment text X and outputs a context content vector e. The decoding module 120 includes a decoding unit 121 and a conversion unit 122. The decoding unit 121 performs the current decoding (i.e., the i-th decoding) based on the word vectors and the context content vector e output by the previous decodings and converts the word vector v generated by the current decoding into i (i ranges from 1 to n, n is the total number of characters in the translated text Y) Output. Since no decoding is performed before the first decoding, only the context vector e is used to generate the word vector v2 passed to the second decoding; since no decoding is required after the last decoding, there is no need to pass the decoded word vector v n The word vectors outputted from each decoding are also sequentially input into the conversion unit 122 in the decoding order, so that the conversion unit 122 converts the multiple word vectors into the translated text Y in the decoding order.
[0067] It should be noted that the decoding unit 121 has a storage function, that is, it will store the input word vector obtained by decoding before. Figure 4Although only the decoding unit 121 generates the word vector v after the i-th decoding, i Returning to itself, the decoding unit 121 performs the (i+1)th decoding based on the context content vector e and the word vectors v1, v2, ..., v i To generate word vector v i+1 of.
[0068] In this sequence-to-sequence model, since each decoding generates a word vector based on the word vectors output by the previous decodings and the context content vector e, the sentiment element decoded first will definitely be used by the sentiment element decoded subsequently to decode the word vector. This ensures the use of element label semantics and the joint prediction of multiple sentiment elements, which is beneficial to improving the prediction performance of sentiment element multi-tuples.
[0069] In one embodiment, the sequence-to-sequence model 100 is pre-trained in the following manner: constructing a sample set consisting of comment samples, the comment samples having element labels (i.e., aspect type, aspect word, opinion word, and sentiment tendency) that are pre-judged for the four elements of emotion (i.e., aspect type, aspect word, opinion word, and sentiment tendency) respectively and associated with sentence labels formed by filling in the element labels in a preset sentence structure; inputting each comment sample in the comment sample set into the sequence-to-sequence model, and obtaining a predicted sentence for each comment sample from the sequence-to-sequence model; comparing the sentence label and the predicted sentence of each comment sample in the comment sample set, and adjusting the weight of the sequence-to-sequence model if the consistent ratio does not exceed the predetermined ratio until the consistent ratio exceeds the predetermined ratio.
[0070] Taking the comment sample "Yesterday's pasta was delicious" as an example, the predicted element labels include: aspect type label "food quality", aspect word label "pasta", opinion word label "delicious", and sentiment tendency label "affirmative". The preset sentence structure is: A is B because C is D, A, B, C and D represent four empty positions; and in the sentence label: the empty position A is filled with the aspect type label, the empty position B is filled with the sentiment tendency label, the empty position C is filled with the aspect word label, and the empty position D is filled with the opinion word label. Therefore, the sentence label y1 is "the food quality is affirmative because the pasta is delicious".
[0071] In the above example, the comment sample only includes one comment sentence (in the present disclosure, one comment sentence is an evaluation made for one aspect, and the same applies below). For the case where the comment sample includes multiple comment sentences, the sentence label may include multiple clause labels and separators set between adjacent clause labels. Since the sequence-to-sequence model can encode and decode what type of text it becomes through training, if the comment text includes multiple sentences, the translated text generated by the sequence model to the sequence model in step S120 also includes multiple translated sentences and separators set between adjacent translated sentences. For a comment text including multiple sentences, the extraction model in the subsequent step S130 can decompose the translated text into multiple translated sentences according to the separator, thereby converting the multi-sentence comment text analysis process into a plurality of single-sentence comment text analysis processes.
[0072] For example, a sample comment is "Yesterday's wine list was great, but the space was too small for me". The predicted element labels include two label groups, one of which is: the aspect type label "beverage style", the aspect word label "wine list", the opinion word label "great", and the sentiment tendency label "affirmative"; the other is: the aspect type label "atmosphere", the aspect word label "space", the opinion word label "too small", and the sentiment tendency label "negative". The preset sentence structure is as described above: A is B because C is D. Therefore, the sentence label y2 is "The beverage style is positive because the wine list is great [SSEP] The atmosphere is negative because the space is too small", where "[SSEP]" is the separator set between the translated sentences as described above. It should be understood that the separator is not limited to "[SSEP]", as long as it is a symbol that is different from the semantic characters in the text, it can be used as a separator.
[0073] In the two examples given above, the preset sentence structures are the same, which are: A is B because C is D. This sentence structure can include the four elements of emotion in various situations in a way that conforms to language expression, and is universal; it has fewer characters, which reduces the difficulty of training sequence-to-sequence models and sequence conversion; the structure is regular and simple, which facilitates the subsequent extraction of emotional elements, which reduces the difficulty of extracting the model in the subsequent step S130.
[0074] It should be noted that in the training of sequence-to-sequence models, in theory, the goal is to find a sequence that makes P θ (v|e) takes the maximum weight θ, where P θ The expression of (v|e) is shown in formula (1).
[0075] P θ (v|e)=P θ (v1|e)·P θ (v2|e,v1)·P θ(v3|e,v1,v2)·…·P θ (v n |e,v <n ) (1)
[0076] In formula (1), v <w represents v1, v2, …, v w-1 (the value range of w is 2 to n, where n is the number of characters in the sentence label), v u represents the word vector of the uth character in the sentence label (the value of u ranges from 1 to n), P θ (v1|e) represents the probability of generating word vector v1 from context vector e, P θ (v w |e,v <w ) represents the context vector e and word vectors v1, v2, …, v w-1 Generate word vector v w probability.
[0077] In practice, it is impossible to exhaust all values of weight θ to train the sequence-to-sequence model to obtain P for a review sample. θ (v|e), so we set a sample set including a large number of review samples, and θ (v|e) is converted to the proportion of the sample set of comments that are consistent with the predicted sentence and sentence label. Next, since it is impossible to exhaust all the values of weight θ to determine P θ (v|e) takes the maximum value of weight θ, or in other words, it is impossible to exhaust all the values of weight θ in the sample set to determine the weight θ that makes the above ratio L take the maximum value, so a predetermined ratio (for example, 95%) is set, and then it is determined whether the proportion of comment samples in a sample set whose predicted sentences and sentence labels are consistent exceeds this predetermined ratio. If it does not exceed, the value of weight θ is adjusted, and if it exceeds, the training process is terminated.
[0078] Considering that what type of text the sequence-to-sequence model can encode and decode is achieved through training, the element labels in the above training process are equally important. The following introduces how to predict the element labels of the four emotional elements (i.e., aspect type labels, aspect word labels, opinion word labels, and sentiment tendency labels).
[0079] (1) About aspect word tags
[0080] Aspect words refer to words that are explicitly or implicitly mentioned in a review text and represent specific aspects. Therefore, a given review text may contain aspect words, or it may not contain aspect words but can be determined through inference.
[0081] For example, after a customer ordered a dish of Kung Pao Chicken with Rice from a restaurant, he commented, "It's so disappointing. I hope they can improve it next time." The aspect word in the comment text is "Kung Pao Chicken with Rice", but the entire comment text does not contain the characters "Kung Pao Chicken with Rice". It should be understood that this comment text is in line with people's expression habits.
[0082] In view of the above situation, when the comment sample includes aspect words, the aspect word label is set to the corresponding aspect word included in the comment sample, that is, a certain aspect word is determined as its own aspect word label; when the comment sample does not include aspect words, the aspect word label is set to a pronoun, as shown in formula (2).
[0083]
[0084] In formula (2), a represents the sentiment element of aspect word. Indicates aspect word label, Represents the aspect word label of a certain aspect word a. Pronouns can be set according to the aspects they refer to, such as "this" or "it".
[0085] Taking the above review text "What they did was so disappointing, I hope they will improve next time" as an example, the aspect type label is "food quality", the aspect word label is "this", the opinion word label is "so disappointing", the sentiment tendency label is "negative", and the final sentence label is "the food quality is negative because it is so disappointing".
[0086] Since the type of text generated by the sequence-to-sequence model is achieved through training, after the aspect word labels are set in the above manner, if a review text does not include aspect words, the aspect words are referred to by pronouns in its translated text, which is in line with people's expression habits.
[0087] (2) About aspect type labels
[0088] The aspect type indicates the category to which the aspect described in a review belongs, so the aspect type vocabulary (i.e., a set consisting of a large number of aspect type words) can be preset, so that the aspect type label of the review text only needs to be selected from the aspect type vocabulary. The aspect type vocabulary is an aspect type represented by only one of the words, so the category to which the same aspect belongs will only be represented by the same word. Since the sequence-to-sequence model generates what type of text through training, after the aspect type label is set in the above manner, if multiple review texts involve the same aspect type, the words describing the aspect type in the translated text are also the same. The unification of aspect type words is conducive to making decisions based on the analysis of aspect types after the extraction of multiple emotional elements, such as a bar analyzing the style of beverages to decide whether they need to be improved.
[0089] In some cases, it is not necessary to classify the comments into aspect types, so each group of sentiment elements extracted in step S130 does not need to include aspect types. For example, a group of sentiment elements is (Chinese food, delicious, affirmative), where "Chinese food" is an aspect word, "delicious" is an opinion word, and "affirmative" is a sentiment tendency, that is, the aspect type is defaulted. It should be understood that an effective sentiment analysis result of a comment cannot include neither aspect types nor aspect words. Therefore, in the sentiment analysis without extracting aspect types, the comment text should explicitly include aspect words. For this case, the training of the sequence-to-sequence model uses the comment text including aspect words as a sample, and the comment text using the sequence-to-sequence model for sentiment analysis also includes aspect words.
[0090] In order to reduce the learning difficulty of the sequence-to-sequence model or to save the sequence-to-sequence model from learning unnecessary knowledge, if there is no need to extract aspect types in sentiment analysis, the aspect type label can be set to pronouns in the training of the sequence-to-sequence model, that is, the aspect type labels of all comment texts in the sample set are the same pronoun. Also, since the sequence-to-sequence model generates what type of text through training, the aspect type included in each translated sentence in the translated text generated in step S120 is pronouns.
[0091] For example, the translated text of the sentiment element triple (Chinese food, delicious, affirmative) is extracted as "This is affirmative because Chinese food is delicious", where "this" indicates the aspect type.
[0092] (3) About sentiment labels
[0093] Sentimental tendency indicates the category of opinion, so the sentimental tendency vocabulary (i.e., a combination of a large number of sentimental tendency words) can be preset, so that the sentimental tendency label of the comment text only needs to be selected from the sentimental tendency vocabulary. The sentimental tendency vocabulary is a sentimental tendency represented by only one of the words, so the same sentimental tendency will only be represented by the same word. Since the sequence-to-sequence model generates what type of text through training, after the sentimental tendency label is set in the above manner, if multiple comment texts involve the same sentimental tendency, the words describing the sentimental tendency in the translated text are also the same. The unification of sentimental tendency words is conducive to making decisions based on sentimental tendency analysis after the extraction of multiple sentimental elements, such as a bar promoting a large-scale aspect that is positive about customers.
[0094] The setting of sentiment tendency vocabulary is based on universality as the main principle. For example, the sentiment tendency vocabulary is directly composed of the words "affirmative", "neutral" and "negative" that represent the three sentiment tendencies. Of course, the sentiment tendency vocabulary is not limited to "affirmative", "neutral" and "negative", but can also be the case shown in formula (3), that is, the affirmative sentiment tendency uses the sentiment tendency label "good", the neutral sentiment tendency uses the sentiment tendency label "okay", and the negative sentiment tendency uses the sentiment tendency label "bad".
[0095]
[0096] In formula (3), p represents the emotional element of emotional tendency. Indicates aspect word label, The sentiment label representing a sentiment tendency p.
[0097] For a specific field, sentiment can also use commonly used opinion words in this field, that is, a sentiment uses words commonly used in this sentiment in this field. For example, in the catering field, only different dishes are evaluated, and one dish is one aspect. Then "delicious" can be used as the sentiment label corresponding to the positive sentiment, "edible" can be used as the sentiment label corresponding to the neutral sentiment, and "not delicious" can be used as the sentiment label corresponding to the negative sentiment.
[0098] It should be understood that the emotional tendency is not limited to the above three types of affirmation, neutrality and negation. In practice, the types of emotional tendency can be divided more finely according to needs, that is, there are more than three emotional tendencies. Of course, the emotional tendency can also be two.
[0099] (4) About opinion word tags
[0100] Opinion words refer to the opinions of the parties mentioned in the comment text. A valid comment must include opinion words. Therefore, the opinion word label can be directly set to the corresponding opinion word included in the comment sample, that is, a certain opinion word in the comment text is determined as its own opinion word label, as shown in formula (4).
[0101]
[0102] In formula (4), o represents the sentiment element of opinion word, Indicates aspect word label, An opinion word label representing an opinion word o.
[0103] In some cases, there is no need to study the opinions in detail, only the emotional tendency is concerned, so each group of emotional elements extracted in step S130 does not need to include emotional words. For example, a group of emotional elements is (service, waiter, bad), where "service" is an aspect type, "waiter" is an aspect word, and "bad" is an emotional tendency, that is, the opinion word is omitted. For this case, in order to reduce the learning difficulty of the sequence-to-sequence model or to save the sequence-to-sequence model from learning unnecessary knowledge, the opinion word label can be set as the emotional tendency label in the training of the sequence-to-sequence model. Similarly, since the generation of what type of text by the sequence-to-sequence model is achieved through training, the opinion words and emotional tendencies included in each translated sentence in the translated text generated in step S120 are the same.
[0104] For example, the translated text of the above-mentioned sentiment element triple (service, waiter, bad) is extracted as "the service is bad because the waiter is bad", in which the first "bad" represents the sentiment tendency and the second "bad" represents the opinion word.
[0105] Step S130, inputting the translated text into the extraction model, and the extraction model outputs each group of sentiment elements in the comment text.
[0106] In combination with the above, the extraction model is a model that extracts various emotional elements based on a preset sentence structure. For example, if each translated sentence in the translated text adopts the preset sentence structure of "A is B because C is D", the extraction model only needs to recognize the first character "is" to extract the emotional element of aspect type; after recognizing the first two characters "is" and "because", the characters between the two characters can be determined as the emotional tuple of emotional tendency; similarly, after recognizing the two characters "because" and the second "is", the characters between the two characters can be determined as the emotional tuple of aspect words; finally, after recognizing the second "is" character at the end of the translated sentence, the characters after the second "is" in the translated sentence can be determined as the emotional element of opinion words. The above-mentioned character recognition can be implemented using existing technologies and will not be described in detail here.
[0107] As described above, the extraction model output may output a set of emotion elements, or may output multiple sets of emotion elements. In addition, each set of emotion elements output by the extraction model may be an emotion element binary, an emotion tuple triple, or an emotion element quadruple.
[0108] It should be noted that, from the above setting methods of aspect type labels and opinion word labels, it can be seen that the sentiment information extraction method of the comment text provided by the present disclosure is not only applicable to the extraction of sentiment element quadruplets, making it possible to accurately extract sentiment element quadruplets at one time; it is also applicable to the extraction of sentiment element triplets, improving the accuracy of sentiment element triplets extraction. Further, the combination of the above-mentioned default aspect type and default opinion word label prediction methods enables the sequence-to-sequence model to be combined with the prediction model to realize the extraction of sentiment element binary groups, that is, extracting sentiment element binary groups composed of two sentiment elements, namely, aspect words and sentiment tendency.
[0109] Since there have been many studies on the task of extracting bigrams of emotional elements and the accuracy is acceptable, the emotional information extraction method provided in the embodiments of the present invention has outstanding significance in extracting triplets of emotional elements and extracting quadruple of emotional elements. The above mainly introduces the method of setting element labels for extracting triplets of emotional elements and extracting quadruple of emotional elements, respectively.
[0110] It should be understood that if a comment does not include aspect words explicitly or implicitly, the comment is invalid. Therefore, the present embodiment of the disclosure does not describe in detail the method of predicting the labels of each element for the sequence-to-sequence model applicable to extracting the sentiment element triple of (aspect type, opinion word, sentiment tendency). In addition, the main purpose of sentiment analysis on a comment text is to mine the sentiment tendency therein, and the practical significance of extracting the sentiment element triple of (aspect type, aspect word, opinion word) is not great. Therefore, the present embodiment of the disclosure does not describe in detail the method of setting the labels of each element for the sequence-to-sequence model applicable to extracting the sentiment element triple of (aspect type, aspect word, opinion word).
[0111] Figure 5 Shown are the accuracies of various sentiment information extraction methods applied to the test sample sets Rest15 and Rest16. These methods are divided into three categories: one is the aforementioned pipeline method, including the two methods "HGCN-BERT+BERT-Linear" and "HGCN-BERT+BERT-TFM"; the other is the methods that are not currently classified into specific categories, including "TASO-BERT-Linear", "TASO-BERT-CRF" and "Direct-Gen"; and the third is the interpretation method "PARAPHRASE" proposed in the present disclosure. Figure 5The existing sentiment information extraction methods shown are built based on multiple mechanisms, among which BERT refers to the transformer bidirectional encoder representation model, HGCN-BERT refers to the hierarchical graph convolutional network enhanced by BERT, BERT-Linear refers to the linear transformer network enhanced by BERT, and BERT-TFM refers to the transformer network enhanced by BERT; TASO refers to the aspect type-aspect word-sentiment tendency joint prediction model extended to opinion words, CRF refers to the conditional random field model, and Direct-Gen refers to the method of directly generating sentiment elements.
[0112] Figure 5 In the formula, Pre stands for precision, which refers to the prediction results, that is, how many of the positive review samples predicted as positive in a test sample set are truly positive samples. The larger the value, the higher the accuracy. Rec stands for recall, which refers to the original sample, indicating how many positive examples in the test sample set are predicted correctly. The larger the value, the higher the accuracy. F1 stands for balanced F score, which is defined as the harmonic mean of precision and recall. Of course, the larger the value, the higher the accuracy. See Figure 5 , the two pipeline methods have very low accuracy; the three methods that are not classified into specific categories have improved in accuracy compared to the pipeline method, but are still not very high; the interpretation method "PARAPHRASE" provided by the present disclosure has considerable accuracy on both test sample sets, among which the balanced F score on the test sample set Rest15 is 46.93, and the balanced F score on the test sample set Rest16 is 57.93, both of which are higher than the three methods that are not classified into specific categories. It can be seen that the analysis method of the comment text provided by the present disclosure has a high accuracy.
[0113] The disclosed embodiment adopts a method of fully automatically analyzing the comment samples by relying on the model, and converts the comment text from which the emotional information is to be extracted into a translated text according to the sequence-to-sequence model. This process is equivalent to interpreting the comment text and highlighting the more important emotional elements therein. The emotional information extraction method of the comment text provided by the disclosed embodiment has a high extraction accuracy, provides technical support for the one-time extraction of the emotional element quadruple, and has a good market prospect in terms of emotional information extraction of comment text.
[0114] According to one embodiment of the present disclosure, Figure 6 As shown, a device for extracting emotional information from comment text is also provided, comprising:
[0115] The sequence-to-sequence model 100 obtains, based on the comment text X from which the sentiment information is to be extracted, a translated text Y of the comment text X character by character, which includes a quadruple of sentiment elements in a preset sentence structure;
[0116] The extraction model 200 outputs each group of sentiment elements Q in the comment text X based on the translated text Y.
[0117] Alternatively, see Figure 4 , the sequence-to-sequence model 100 includes an encoding module 110 and a decoding module 120, wherein the encoding module 110 is used to encode the comment sentence into a context content vector; the decoding module 120 includes a decoding unit 121 and a conversion unit 122, wherein the decoding unit 121 performs the current decoding (i.e., the i-th decoding) based on the word vectors and the context content vector e output by the previous decodings and converts the word vector v generated by the current decoding into the context content vector e. i Output, and the word vectors of each decoding output are also input into the conversion unit 122 in sequence according to the decoding order, so that the conversion unit 122 converts multiple word vectors into translated text Y in the decoding order.
[0118] Since the implementation details of the above device have been described in the detailed introduction of the method embodiment above, they will not be repeated here for the sake of saving space.
[0119] According to an embodiment of the present disclosure, a method for extracting sentiment information from a comment text may be performed by: Figure 7 The computer device 800 is implemented. Figure 7 800 according to an embodiment of the present disclosure is described below. Figure 7 The computer device 800 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0120] like Figure 7 As shown, the computer device 800 is in the form of a general computing device. The components of the computer device 800 may include but are not limited to: at least one processing unit 810, at least one storage unit 820, and a bus 830 connecting different system components (including the storage unit 820 and the processing unit 810).
[0121] The storage unit stores program codes, which can be executed by the processing unit 810, so that the processing unit 810 performs the steps of various exemplary embodiments of the present disclosure described in the description of the exemplary method described above in this specification. For example, the processing unit 810 can perform the steps shown in FIG. 2.
[0122] The storage unit 820 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 8201 and / or a cache memory unit 8202 , and may further include a read-only memory unit (ROM) 8203 .
[0123] The storage unit 820 may also include a program / utility 8204 having a set (at least one) of program modules 8205, such program modules 8205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0124] Bus 830 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0125] The computer device 800 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the computer device 800, and / or communicate with any device that enables the computer device 800 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 850. Furthermore, the computer device 800 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 860. As shown, the network adapter 860 communicates with other modules of the computer device 800 via a bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the computer device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0126] It should be understood that the above is only a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. For those skilled in the art, there are many variations of the embodiments of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
[0127] It should be understood that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0128] It should be understood that the above is a description of a specific embodiment of the present specification. Other embodiments are within the scope of the claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0129] It should be understood that an element described in singular form herein or shown in the drawings as only one does not limit the number of the element to one. In addition, modules or elements described or shown as separate herein may be combined into a single module or element, and modules or elements described or shown as single herein may be split into multiple modules or elements.
[0130] It should also be understood that the terms and expressions used herein are for description only, and one or more embodiments of this specification should not be limited to these terms and expressions. The use of these terms and expressions does not mean to exclude any equivalent features of the illustrations and descriptions (or parts thereof), and it should be recognized that various modifications that may exist should also be included in the scope of the claims. Other modifications, changes and substitutions may also exist. Accordingly, the claims should be deemed to cover all such equivalents.
Claims
1. A method for extracting sentiment information from a comment text, comprising: Obtain the comment text from which the sentiment information is to be extracted; Inputting the review text into a sequence-to-sequence model, and obtaining a translated text of the review text character by character by the sequence-to-sequence model including a sentiment element quadruple in a preset sentence structure; Inputting the translated text into an extraction model, and having the extraction model output each group of sentiment elements in the comment text; The sequence-to-sequence model is pre-trained in the following way: Constructing a sample set consisting of comment samples, wherein the comment samples have element labels respectively predicted for the four elements of emotion and are associated with sentence labels formed by filling the element labels in the preset sentence structure; Input each comment sample in the comment sample set into the sequence-to-sequence model, and obtain a predicted sentence for each comment sample from the sequence-to-sequence model; The sentence label of each comment sample in the comment sample set is compared with the predicted sentence, and if the consistent ratio does not exceed the predetermined ratio, the weight of the sequence-to-sequence model is adjusted until the consistent ratio exceeds the predetermined ratio.
2. The method for extracting emotional information according to claim 1, wherein: The sequence-to-sequence model includes an encoding module and a decoding module; The encoding module is used to encode the comment sentence into a context content vector; The decoding module includes a decoding unit and a conversion unit, wherein the decoding unit performs current decoding based on the word vectors output by previous decodings and the context content vector and outputs the word vector generated by the current decoding, and the word vectors output by each decoding are also sequentially input into the conversion unit in a decoding order, so that the conversion unit converts multiple word vectors into the translated text in a decoding order.
3. The method for extracting emotional information according to claim 1, wherein: The element labels include aspect type labels, aspect word labels, opinion word labels and sentiment tendency labels; The preset sentence structure is: A is B because C is D, A, B, C and D represent four vacant positions; In the sentence tag: the vacant position A is filled with the aspect type tag, the vacant position B is filled with the sentiment tendency tag, the vacant position C is filled with the aspect word tag, and the vacant position D is filled with the opinion word tag.
4. The method for extracting emotional information according to claim 3, wherein: In the case where the review sample includes aspect words, the aspect word label is set to the corresponding aspect word included in the review sample; In the case that the review sample does not include aspect words, the aspect word label is set as a pronoun.
5. The method for extracting emotional information according to claim 3, wherein: In the case where the comment sample includes aspect words, the aspect word label is set to the corresponding aspect word included in the comment sample, the aspect type label is set to a pronoun, and the set of sentiment elements in the comment text output by the extraction model does not include the sentiment element of aspect type; Alternatively, the aspect type tag is selected from a preset aspect type vocabulary, and one aspect type corresponds to only one word in the aspect type vocabulary.
6. The method for extracting emotional information according to claim 3, wherein: The sentiment tendency label is selected from a preset sentiment tendency vocabulary, and one sentiment tendency corresponds to only one word in the sentiment tendency vocabulary.
7. The method for extracting emotional information according to claim 3, wherein: The opinion word label is set as the sentiment tendency label, and the group of sentiment elements in the comment text output by the extraction model does not include the sentiment element of opinion word; Alternatively, the opinion word label is set to the corresponding opinion word included in the comment sample.
8. The method for extracting emotional information according to claim 1, wherein: The review sample includes a plurality of review sentences, and each review sentence is an evaluation made on one aspect; The sentence tag includes a plurality of clause tags and separators arranged between adjacent clause tags; Furthermore, the extraction model outputs each group of sentiment elements in the comment text by decomposing the translated text into a plurality of translated sentences according to the separator and outputting a plurality of sentiment elements of each of the translated sentences.
9. A device for extracting emotional information from a comment text, comprising: A sequence-to-sequence model, based on the comment text to be used for extracting sentiment information, obtains a translated text of the comment text character by character, including a quadruple of sentiment elements in a preset sentence structure; The sequence-to-sequence model is pre-trained in the following way: Constructing a sample set consisting of comment samples, wherein the comment samples have element labels respectively predicted for the four elements of emotion and are associated with sentence labels formed by filling the element labels in the preset sentence structure; Input each comment sample in the comment sample set into the sequence-to-sequence model, and obtain a predicted sentence for each comment sample from the sequence-to-sequence model; Compare the sentence label of each comment sample in the comment sample set with the predicted sentence, and if the consistent ratio does not exceed a predetermined ratio, adjust the weight of the sequence-to-sequence model until the consistent ratio exceeds the predetermined ratio; The extraction model outputs each group of sentiment elements in the review text based on the translated text.
10. A computer device comprising: A memory for storing computer executable code; A processor, configured to execute the computer executable code to implement the method according to any one of claims 1 to 8.
11. A computer-readable medium comprising a computer-executable code, wherein the computer-executable code implements the method according to any one of claims 1 to 8 when executed by a processor.
Citation Information
Patent Citations
Short-text emotion analysis method and device based on concept based on text emotion
CN108108468A
NLP-based sentiment analysis
US20120041937A1