Text attribute-level sentiment classification methods, devices, electronic devices and storage media

By generating attribute syntactic distance vectors and related word vectors, and combining word vectors and syntactic distance, attention mechanisms are used for text sentiment classification. This solves the problem of existing methods' dependence on manually labeled data and enables efficient sentiment analysis in scenarios where labeled data is insufficient or missing.

CN116860976BActive Publication Date: 2025-10-28CHINA TELECOM CORP LTD TECHNOLOGY INNOVATION CENTER +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310869693.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-14
Publication Date
2025-10-28
Estimated Expiration
2043-07-14

AI Technical Summary

Technical Problem

Existing attribute-level sentiment classification methods rely on a large amount of manually labeled data, which is time-consuming and labor-intensive, and it is difficult to effectively utilize unlabeled data and syntactic distance information, especially in scenarios where labeled data is insufficient or missing.

Method used

By generating attribute syntactic distance vectors and attribute-related word vectors, and combining word vectors and syntactic distance, sentence vectors are generated using an attention mechanism to calculate sentiment classification results. This effectively utilizes unlabeled data and improves the model's scalability and generalization ability.

Benefits of technology

It reduces the need for manual annotation, improves computational efficiency, and enables effective text sentiment analysis in scenarios with insufficient or missing labeled data, thereby enhancing the model's scalability and generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116860976B_ABST
    Figure CN116860976B_ABST
Patent Text Reader

Abstract

This disclosure provides a method, apparatus, device, and medium for text attribute-level sentiment classification. The method includes acquiring text data to be analyzed, the text data comprising multiple sentences; generating an attribute syntactic distance vector corresponding to each word in the text data based on the attribute syntactic distance between each word and predefined attribute words; generating word vectors corresponding to attribute-related words contained in the text data based on attribute-related words; determining sentence vectors of one or more attribute-related sentences in the text data based on the word vectors of each word, the attribute syntactic distance vectors corresponding to each word, the word vectors of attribute-related words, and the word vectors of attribute words; and determining the attribute-level sentiment classification result of the text data based on the sentence vectors of one or more attribute-related sentences in the text data. This disclosure can effectively utilize unannotated information to improve the scalability and generalization ability of the attribute-level sentiment classification model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of sentiment analysis technology, and in particular to a text attribute-level sentiment classification method, apparatus, electronic device, and storage medium. Background Technology

[0002] Attribute-level sentiment classification of text data is a fine-grained sentiment classification task that aims to identify people's emotional tendencies towards specific aspects of the same entity in text. A key subtask of attribute-level sentiment analysis is attribute category extraction, which aims to identify the attribute category corresponding to the sentiment expression object in a sentence.

[0003] Traditional statistical machine learning methods have moved beyond early approaches that relied on rules and relevant dictionaries to identify attribute categories in sentences. They now employ models such as Support Vector Machines (SVMs) and Latent Dirichlet Allocation (LDA), which perform well on small datasets. However, traditional statistical machine learning methods heavily depend on the quality of manually designed features, which is time-consuming and labor-intensive, and also requires the labelers to possess a certain level of domain knowledge.

[0004] With the development of deep learning, deep neural networks have achieved good performance in attribute-level sentiment analysis, such as Recurrent Neural Networks (RNNs), Long Short-Term Memory Networks (LSTMs), and Gated Recurrent Units (GRUs). Their main advantage is that they can automatically learn task-related abstract vectors without the need for manual feature design. However, they still have some shortcomings in utilizing large amounts of unlabeled data and modeling the sentiment semantics related to attribute words. For example, most existing attribute-level sentiment classification methods are supervised learning methods, and a large amount of unlabeled data (i.e., data that has not been manually labeled) has not been effectively utilized in attribute-level sentiment classification, making it difficult to apply to scenarios with insufficient or missing labeled data. On the other hand, existing unsupervised attribute-level sentiment classification methods have not effectively utilized and modeled the syntactic distance information related to attribute words, and their ability to model and capture the sentiment semantic information related to attribute words is insufficient.

[0005] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0006] This disclosure provides a text attribute-level sentiment classification method, apparatus, electronic device, and storage medium, which at least to some extent overcomes the problem that related machine learning-based attribute classification methods rely on a large amount of manually labeled data, resulting in time-consuming and labor-intensive processes.

[0007] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.

[0008] According to one aspect of this disclosure, a text attribute-level sentiment classification method is provided, comprising: acquiring text data to be analyzed, the text data including multiple sentences, wherein each sentence includes multiple words; generating an attribute syntactic distance vector corresponding to each word in the text data based on the attribute syntactic distance between each word in the text data and predefined attribute words; generating word vectors corresponding to attribute-related words contained in the text data, wherein the attribute-related words are one or more words in the text data that satisfy a preset similarity condition with predefined attribute words; determining sentence vectors of one or more attribute-related sentences in the text data based on the word vectors of each word in the text data, the attribute syntactic distance vectors corresponding to each word, the word vectors of attribute-related words, and the word vectors of predefined attribute words, wherein the attribute-related sentences are sentences in the text data that contain one or more words that have a semantic relationship with the attribute words; and determining the attribute-level sentiment classification result of the text data based on the sentence vectors of one or more attribute-related sentences in the text data.

[0009] In some embodiments, the method of determining the attribute syntactic distance between each word in the text data and each predefined attribute word includes: obtaining the connection relationship between each word in the text data and each predefined attribute word through a dependency parsing method; and determining the attribute syntactic distance between each word in the text data and each predefined attribute word based on the connection relationship between each word in the text data and each predefined attribute word.

[0010] In some embodiments, the attribute syntactic distance between each word in the text data and predefined attribute words is calculated using the following formula:

[0011]

[0012] Where, d i Represents the attribute syntactic distance, A i In the dependency parsing graph of a sentence, A indicates whether there is a direct connection between the i-th word and the attribute word. i =1 indicates that there is a direct edge connecting the i-th word and the attribute word, A i =0 indicates that there is no direct edge connecting the i-th word and the attribute word, l i Max(l) represents the minimum number of hops that the i-th word can connect to all attribute words. i ,0) means taking l i The maximum value between 0 and 0.

[0013] In some embodiments, before generating word vectors corresponding to attribute-related words based on attribute-related words contained in text data, the method further includes: defining attribute categories corresponding to predefined attribute words; calculating the cosine similarity between each word in the text data and the attribute category; sorting the cosine similarity between each word in the text data and the attribute category in descending order; and obtaining words with cosine similarity ranking higher than a preset rank as attribute-related words contained in the text data.

[0014] In some embodiments, calculating the cosine similarity between words in the text data and the attribute category includes: filtering words from the text data that meet a preset frequency of occurrence; and calculating the cosine similarity between the words that meet the preset frequency of occurrence and the attribute category.

[0015] In some embodiments, determining the sentence vector of one or more attribute-word-related sentences in the text data based on the word vector of each word in the text data, the attribute syntactic distance vector corresponding to each word, the word vector of attribute-related words, and the word vector of predefined attribute words includes: generating the sentence vector of one or more attribute-word-related sentences in the text data based on an attention mechanism, according to the word vector of each word in the text data, the attribute syntactic distance vector corresponding to each word, the word vector of attribute-related words, and the word vector of predefined attribute words.

[0016] In some embodiments, determining the attribute-level sentiment classification result of the text data based on the sentence vectors of one or more attribute-word related sentences in the text data includes: obtaining predefined sentiment category labels; generating sentiment category vectors corresponding to the sentiment category labels based on the sentiment category labels; calculating the cosine similarity between the sentence vectors of one or more attribute-word related sentences in the text data and the sentiment category vectors; and determining the attribute-level sentiment classification result of the text data based on the cosine similarity between the sentence vectors of one or more attribute-word related sentences in the text data and the sentiment category vectors.

[0017] According to another aspect of this disclosure, a text attribute-level sentiment classification device is also provided, comprising: a text data acquisition module for acquiring text data to be analyzed, the text data including multiple sentences, wherein each sentence includes multiple words; an attribute syntactic distance vector generation module for generating an attribute syntactic distance vector corresponding to each word in the text data based on the attribute syntactic distance between each word in the text data and predefined attribute words; and an attribute-related word vector generation module for generating word vectors corresponding to the attribute-related words based on the attribute-related words contained in the text data, wherein the attribute-related words are words in the text data that are related to the predefined attribute words. The system includes: a semantic attribute word and a related sentence vector generation module, which determines the sentence vector of one or more attribute word related sentences in the text data based on the word vector of each word in the text data, the attribute syntactic distance vector corresponding to each word, the word vector of attribute related words, and the word vector of predefined attribute words; and a sentiment classification result determination module, which determines the attribute-level sentiment classification result of the text data based on the sentence vector of one or more attribute word related sentences in the text data.

[0018] According to another aspect of this disclosure, an electronic device is also provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the text attribute-level sentiment classification method described in any of the preceding claims by executing the executable instructions.

[0019] According to another aspect of this disclosure, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the text attribute-level sentiment classification method described in any of the preceding claims.

[0020] According to another aspect of this disclosure, a computer program product is also provided, including a computer program that, when executed by a processor, implements the text attribute-level sentiment classification method of any of the above.

[0021] The text attribute-level sentiment classification method, apparatus, electronic device, and storage medium provided in the embodiments of this disclosure combine words in the text data with predefined attribute words to generate attribute syntactic distance vectors, generate word vectors corresponding to attribute-related words, determine sentence vectors of attribute-related sentences based on the word vectors of each word in the text data and the word vectors of attribute words, and determine the attribute-level sentiment classification result of the text data based on the sentence vectors of attribute-related sentences. This disclosure effectively utilizes unannotated information to analyze text sentiment, extracting the sentiment information hidden in attribute words to improve the scalability and generalization ability of the model, enabling it to be used in scenarios with insufficient or missing labeled data, while reducing manpower consumption and improving computational efficiency.

[0022] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0023] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0024] Figure 1 This diagram illustrates a text attribute-level sentiment classification method according to an embodiment of the present disclosure.

[0025] Figure 2 This diagram illustrates a flowchart of an attribute-related word extraction strategy method according to an embodiment of the present disclosure;

[0026] Figure 3 This diagram illustrates a text attribute sentiment classification algorithm according to an embodiment of the present disclosure.

[0027] Figure 4 This diagram illustrates a text attribute sentiment classification method according to an embodiment of the present disclosure.

[0028] Figure 5 This diagram illustrates a text attribute-level sentiment classification device according to an embodiment of the present disclosure.

[0029] Figure 6 A block diagram of an electronic device according to an embodiment of the present disclosure is shown;

[0030] Figure 7 A schematic diagram of a computer-readable storage medium according to an embodiment of the present disclosure is shown. Detailed Implementation

[0031] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0032] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0033] The specific implementation methods of the embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.

[0034] Figure 1 This diagram illustrates a flowchart of a text attribute-level sentiment classification method according to an embodiment of the present disclosure, such as... Figure 1 As shown, the method includes the following steps:

[0035] S102, Obtain the text data to be analyzed. The text data includes multiple sentences, where each sentence includes multiple words.

[0036] In one embodiment of this disclosure, the text data to be analyzed may be text fragments directly input by researchers or obtained directly by the model from other means, such as articles, short sentences, etc. The text data may contain multiple sentences, and each sentence may contain multiple words.

[0037] S104. Generate the attribute syntactic distance vector corresponding to each word in the text data based on the attribute syntactic distance between each word in the text data and each predefined attribute word.

[0038] In one embodiment of this disclosure, attribute words can be predefined words, which are entities containing features. The attribute syntactic distance for each word refers to the relative distance between each word and the attribute word after obtaining the dependency syntactic graph of the sentence according to dependency parsing. Dependency parsing determines the syntactic structure of a sentence by analyzing the dependency relationships between words in the sentence.

[0039] S106. Generate word vectors corresponding to attribute-related words based on the attribute-related words contained in the text data. The attribute-related words are one or more words in the text data that meet the preset similarity conditions with the predefined attribute words.

[0040] In one embodiment of this disclosure, attribute-related words may refer to words in text data that are related to attribute words, and can be extracted from text data through an attribute-related word extraction strategy.

[0041] S108. Based on the word vector of each word in the text data, the attribute syntactic distance vector corresponding to each word, the word vector of attribute-related words, and the word vector of predefined attribute words, determine the sentence vector of one or more attribute-related sentences in the text data. The attribute-related sentences are sentences in the text data that contain one or more words that have a semantic relationship with the attribute words.

[0042] In one embodiment of this disclosure, an attribute-related sentence can refer to a sentence in text data that contains words that have a semantic relationship with the attribute words. The predefined word vector of the attribute words is obtained by average pooling the word vectors of all attribute words, and the result is used as the final word vector of the attribute words to be calculated.

[0043] S110, Determine the attribute-level sentiment classification result of the text data based on the sentence vectors of sentences related to one or more attribute words in the text data.

[0044] As described above, the method in this embodiment combines words in the text data with predefined attribute words to generate attribute syntactic distance vectors, generates word vectors corresponding to attribute-related words, and uses the word vectors of each word in the text data and the word vectors of attribute words to determine the sentence vectors of sentences related to attribute words. Based on the sentence vectors of sentences related to attribute words, the attribute-level sentiment classification result of the text data is determined. This disclosure effectively utilizes unannotated information to analyze text sentiment, extracting the sentiment information hidden by attribute words to improve the scalability and generalization ability of the model, enabling it to be used in scenarios with insufficient or missing labeled data. Simultaneously, it reduces manpower consumption and improves computational efficiency.

[0045] In one embodiment of this disclosure, the given sentence context may be S = {w1, w2, ..., w...} n}, where S represents the context of the current sentence, w n This represents the nth word in the current sentence. The given attribute word can be Asp = {asp1, asp2, ..., asp}. m}, where Asp represents a set of attribute words, asp m Let m be the m-th attribute word. We then use Global Vectors for Word Representation (GloVe) embedding to map this word, obtaining the word vector for each word in the sentence. Among them, H s This represents the set of word vectors in a sentence. This represents the word vector of the nth word in the current sentence, and the word vector of each word in the attribute words. Among them, H a This represents the set of word vectors in attribute words. Let represent the word vector of the m-th word in the attribute words. Average pooling is then performed on all word vectors of the attribute words to obtain the overall word vector h of the attribute words. a .

[0046] It should be noted that other word embedding methods can also be used for mapping. For example, word embeddings (Word2Vec) can be used here, and this embodiment does not specifically limit the method. The advantage of using the GloVe word embedding method is that the word vectors are open source and can be downloaded at any time without retraining. At the same time, most works also use the GloVe word embedding method.

[0047] It should be noted that the overall vector of attribute words can also be obtained using a Long Short-Term Memory (LSTM) network combined with an attention mechanism; this embodiment does not specifically limit this approach. Using average pooling is relatively simple and fast, without introducing additional complex calculations and operations; other methods may complicate the model structure and computation process.

[0048] In one embodiment of this disclosure, dependency parsing is used to obtain the connection relationships between each word in the text data and predefined attribute words. Based on the connection relationships between each word in the text data and predefined attribute words, the attribute syntactic distance between each word in the text data and predefined attribute words is determined. This allows the model to focus on words that are more relevant to the sentiment information of attribute words in terms of syntactic structure, thereby improving the model's ability to encode the sentiment information of different attribute words in a sentence.

[0049] It should be noted that dependency parsing tools can be used out of the box to perform dependency parsing to obtain dependency parsing structure graphs, such as the Stanza Python toolkit for natural language processing. This disclosure does not specifically limit this approach.

[0050] In one embodiment of this disclosure, the attribute syntactic distance between each word in the text data and predefined attribute words is calculated using the following formula:

[0051]

[0052] Where, d i Represents the attribute syntactic distance, A iIn the dependency parsing graph of a sentence, A indicates whether there is a direct connection between the i-th word and the attribute word. i =1 indicates that there is a direct edge connecting the i-th word and the attribute word, A i =0 indicates that there is no direct edge connecting the i-th word and the attribute word, l i Max(l) represents the minimum number of hops that the i-th word can connect to. i ,0) means taking l i The maximum value between 0 and 0.

[0053] For example, if the i-th word can be connected to the attribute word through another word, the jump count is 2. If the word can also be connected to the current attribute word through another different word, the jump count is 3. If the word can be connected to another attribute word through two other different words, the jump count is 4. Therefore, the jump count between the word and the attribute word should be 2, i.e., l. i =2. If the i-th word has no related connection with the attribute word, then l i =-1.

[0054] In one embodiment of this disclosure, matrix sentence embedding method E can be used. syn Mapping is performed, where syn stands for syntax, and E... syn It can be initialized using a Gaussian distribution with a mean of 0 and a variance of 1. This generates the attribute syntactic distance vector for each word in the sentence. in, This represents the attribute syntactic distance vector corresponding to the nth word in the sentence.

[0055] In one embodiment of this disclosure, an attribute category corresponding to a predefined attribute word is defined; the cosine similarity between each word in the text data and the attribute category is calculated; the cosine similarity between each word in the text data and the attribute category is sorted in descending order; and words with cosine similarity ranking higher than a preset ranking are obtained as attribute-related words contained in the text data.

[0056] It should be noted that the preset ranking is a parameter set before model training and can be adjusted according to the actual effect. This embodiment does not impose any specific limitations on it.

[0057] In one embodiment of this disclosure, words that meet a preset frequency of occurrence are selected from text data; the cosine similarity between the words that meet the preset frequency of occurrence and the attribute category is calculated.

[0058] It should be noted that the preset occurrence count is a parameter set before model training. In this embodiment, the preset occurrence count can be set to 2, but this embodiment does not impose a specific limitation on it. When the preset occurrence count is 1, some irrelevant words will be introduced as noise to have an impact; while the larger the value of the preset occurrence count, the fewer words will be selected. When the preset occurrence count is set to 2, as many words as possible can be included and some irrelevant words can be removed.

[0059] In one embodiment of this disclosure, based on an attention mechanism, sentence vectors for one or more attribute-related sentences in the text data are generated according to the word vector of each word in the text data, the attribute syntactic distance vector corresponding to each word, the word vectors of attribute-related words, and the word vectors of predefined attribute words. This further improves attribute generalization ability, enabling the generation of more accurate attribute-related sentence representations, enhancing the model's representational power, and thus further improving the model's performance.

[0060] In one embodiment of this disclosure, the sentence vector of attribute-related sentences can be calculated using the following formula:

[0061]

[0062]

[0063]

[0064]

[0065] in, This represents the word vector corresponding to the nth word, which contains semantic and syntactic distance information. This represents the word vector of the nth word in the current sentence. Let r represent the attribute syntactic distance vector corresponding to the nth word in the sentence. n h represents the unnormalized weight of the nth word in the sentence. a B represents the overall word vector obtained after average pooling of all attribute words. a a represents a set of representative attribute-related terms for the attribute category corresponding to the current attribute term. n Let r represent the attention weight of the nth word in the sentence. j denoted by , z represents the unnormalized weight of the j-th word in the sentence, z represents the sentence representation related to the attribute words output by the attribute generalization attention mechanism, and m represents the total number of words in the sentence.

[0066] In one embodiment of this disclosure, a predefined sentiment category label is obtained; a sentiment category vector corresponding to the sentiment category label is generated based on the sentiment category label; the cosine similarity between the sentence vector of one or more attribute word-related sentences in the text data and the sentiment category vector is calculated; and the attribute-level sentiment classification result of the text data is determined based on the cosine similarity between the sentence vector of one or more attribute word-related sentences in the text data and the sentiment category vector.

[0067] In one embodiment of this disclosure, the sentiment category label may include three sentiment categories: positive, negative, and neutral. The sentiment category vector can be generated by GloVe word embedding. It should be noted that this embodiment of the disclosure does not specifically limit the method of generating the vector.

[0068] In one embodiment of this disclosure, the attribute-level sentiment classification result of text data can be determined by the following formula:

[0069]

[0070]

[0071] Where, p i Let C represent the cosine similarity between the sentence representation related to the attribute words and the sentiment category embedding of the i-th sentiment category label, where C represents the set of sentiment categories. y represents the sentiment category embedding of the i-th sentiment category label, and y represents the sentiment category of the output attribute word.

[0072] Figure 2 This diagram illustrates a flowchart of an attribute-related word extraction strategy method according to an embodiment of the present disclosure, such as... Figure 2 As shown, the method includes the following steps:

[0073] S202, Define the attribute category based on the predefined attribute words.

[0074] S204: Filter out words from the text data that meet the preset frequency of occurrence.

[0075] S206, Calculate the cosine similarity between words selected from the text data and attribute categories.

[0076] S208, sort the cosine similarity between each word selected from the text data and the current attribute category in descending order.

[0077] S210: Select words with cosine similarity ranking higher than the preset ranking in sequence as attribute-related words for the current attribute category.

[0078] In one embodiment of this disclosure, S202 and S204 can be executed simultaneously or in any order. This embodiment of the disclosure does not impose a specific limitation on the execution order of the above steps.

[0079] In one embodiment of this disclosure, the attribute categories may be determined based on the different domains involved in the text. For example, in a laptop review, the attribute categories may be appearance, price, battery, etc., while in a restaurant review, the attribute categories may be food, environment, service, etc.

[0080] In one embodiment of this disclosure, when the preset occurrence count is 2 and the preset ranking is 5, all words that occur more than or equal to 2 times are obtained from the text data. Attribute categories are defined according to the preset attribute words. The cosine similarity between the words selected based on the preset occurrence count and the attribute categories is calculated. The words are sorted in descending order, and the top 5 words are taken as attribute-related words of the attribute categories, thus obtaining 5 attribute-related words.

[0081] For example, when the attribute category is "food", the words obtained based on the preset frequency of occurrence are a, b, and c. The cosine similarity between word 'a' and the attribute category "food" can be calculated using the following formula:

[0082] p = cos(h) a ,h food (8)

[0083] Among them, h a h represents the word vector of word a. food Let represent the word vector of the attribute category "food", and p represent the cosine similarity between word a and the attribute category "food".

[0084] Similarly, we can obtain the cosine similarity between words b and c and the attribute category "food", as well as the cosine similarity between words a, b, and c and other attribute categories.

[0085] It should be noted that word vectors and attribute category word vectors can be generated through GloVe word embedding. It should also be noted that the embodiments disclosed herein do not specifically limit the method of generating vectors.

[0086] Figure 3 This diagram illustrates a text attribute sentiment classification algorithm according to an embodiment of the present disclosure, such as... Figure 3 As shown, the algorithm includes the following steps:

[0087] S302 takes the sentence, attribute syntactic distance, and attribute words as input to the embedding layer and generates word vectors for each word in the sentence, attribute syntactic distance vectors for each word, and word vectors for attribute words.

[0088] In one embodiment of this disclosure, the embodiment may be a pre-trained text attribute-level sentiment classification model, which may include: an embedding layer, an attribute sentiment semantic modeling layer, and an attribute sentiment semantic calculation layer.

[0089] In one embodiment of this disclosure, the embedding layer can be used to convert each word in the sentence and each word in the attribute words into a fixed word embedding, and to convert the attribute syntactic distance of each word into a syntactic distance embedding, thereby generating the word vector of each word in the sentence, the word vector of the attribute words, and the attribute syntactic distance vector of each word.

[0090] In one embodiment of this disclosure, the attribute syntactic distance can be obtained by the above formula (1).

[0091] In one embodiment of this disclosure, word vectors for each word in a sentence and word vectors for attribute words can be generated using GloVe word embedding, and attribute syntactic distance vectors for each word can be generated using matrix sentence embedding.

[0092] S304, define attribute categories, obtain representative attribute-related words for each attribute category, and generate word vectors for attribute-related words.

[0093] In one embodiment of this disclosure, attribute-related words can be obtained by the above formula (8).

[0094] In one embodiment of this disclosure, word vectors for attribute-related words can be generated using GloVe word embedding.

[0095] S306. The obtained word vectors, attribute syntactic distance vectors, attribute word vectors, and attribute-related word vectors are input into the attribute sentiment semantic modeling layer to model the sentiment semantic association between attribute words and different words in the sentence, and generate more accurate attribute-related sentence vectors.

[0096] In one embodiment of this disclosure, the attribute sentiment semantic modeling layer can be used to model and capture the degree of sentiment semantic association between the current attribute word and different words in the sentence, generating more accurate attribute-related sentence vectors that contain more effective information.

[0097] In one embodiment of this disclosure, the attribute-related sentence vector can be obtained by the above formulas (2) to (5).

[0098] S308: Input the obtained attribute-related sentence vectors into the attribute sentiment semantic calculation layer, calculate the semantic similarity between the attribute-related sentence vectors and the sentiment category vectors, and output the sentiment category of the current attribute word.

[0099] In one embodiment of this disclosure, the attribute sentiment semantic computing layer can be used to calculate the relationship between the sentence vector of attribute-related sentences and the sentiment category vector, and output the sentiment category of attribute words.

[0100] In one embodiment of this disclosure, the emotion category can be obtained by the above formulas (6) to (7).

[0101] Figure 4 This diagram illustrates a flowchart of a text attribute sentiment classification method according to an embodiment of the present disclosure, such as... Figure 4 As shown, the model includes the following steps:

[0102] S401, Input the given sentence context information.

[0103] S402, Input the given attribute word.

[0104] S403, Calculate the attribute syntactic distance between each word and the attribute word based on the given sentence context information and attribute words.

[0105] In one embodiment of this disclosure, the attribute syntactic distance can be obtained by the above formula (1).

[0106] S404 maps the given sentence context information to the attribute words input embedding layer, generating word vectors for each word in the sentence and attribute syntactic distance vectors between each word and each attribute word.

[0107] S405, sum the word vector of each word in the generated sentence with the attribute syntactic distance vector between each word and each attribute word to obtain the word vector corresponding to each word, which contains semantic and syntactic distance information.

[0108] In one embodiment of this disclosure, the attribute syntactic distance can be obtained by the above formula (2).

[0109] S406: Input the given attribute words into the embedding layer for mapping to generate word vectors for the attribute words.

[0110] S407. Based on the attribute word related strategy, extract words that meet the conditions from the given sentence context information and use them as representative attribute related words for each attribute category.

[0111] In one embodiment of this disclosure, the attribute syntactic distance can be obtained by the above formula (8).

[0112] S408 maps attribute-related words to generate word vectors for attribute-related words.

[0113] S409, the word vectors containing semantic and syntactic distance information, the word vectors of attribute-related words, and the word vectors of attribute-related words corresponding to each generated word are input into the attribute generalization attention mechanism.

[0114] S410 outputs sentence vectors related to attribute words.

[0115] In one embodiment of this disclosure, the sentence vector related to the attribute word can be obtained by the above formulas (3) to (5).

[0116] S411: Map the given sentiment category labels to generate sentiment category vectors.

[0117] S412 calculates the cosine similarity between the sentence vectors related to attribute words and the sentiment category vectors.

[0118] In one embodiment of this disclosure, the cosine similarity between the sentence vectors related to attribute words and the sentiment category vectors can be obtained by the above formula (6).

[0119] S413: Select the sentiment category vector with the highest cosine similarity to the sentence vector related to the attribute word as the sentiment category output for that attribute word.

[0120] In one embodiment of this disclosure, the sentiment category of the attribute word can be obtained by the above formula (7).

[0121] It should be noted that S401 and S402 can be executed simultaneously or in any order. This embodiment does not specify the execution order of the above steps.

[0122] It should be noted that S406 can be executed at any time after S402 and before S409. This embodiment of the disclosure does not impose specific restrictions on the execution order of the above steps.

[0123] It should be noted that S407 and S408 only need to be executed before S409. This embodiment of the disclosure does not impose specific limitations on the execution order of the above steps.

[0124] It should be noted that S411 only needs to be executed before S412, and the execution order of the above steps is not specifically limited in this embodiment.

[0125] Based on the same inventive concept, this disclosure also provides a text attribute-level sentiment classification device, as described in the following embodiments. Since the principle by which this device solves the problem is similar to that of the above-described method embodiments, the implementation of this device embodiment can refer to the implementation of the above-described method embodiments, and repeated details will not be elaborated further.

[0126] Figure 5This diagram illustrates a text attribute-level sentiment classification device according to an embodiment of the present disclosure, such as... Figure 5 As shown, the device 50 includes: a text data acquisition module 501, an attribute syntactic distance vector generation module 502, an attribute-related word vector generation module 503, an attribute word-related sentence vector generation module 504, and a sentiment classification result determination module 505.

[0127] The system includes the following modules: a text data acquisition module 501, which acquires text data to be analyzed, comprising multiple sentences, each sentence containing multiple words; an attribute syntactic distance vector generation module 502, which generates an attribute syntactic distance vector for each word in the text data based on the attribute syntactic distance between each word and predefined attribute words; an attribute-related word vector generation module 503, which generates word vectors for attribute-related words in the text data, wherein attribute-related words are one or more words in the text data that satisfy a preset similarity condition with predefined attribute words; an attribute-related sentence vector generation module 504, which determines the sentence vectors of one or more attribute-related sentences in the text data based on the word vectors of each word in the text data, the attribute syntactic distance vectors corresponding to each word, the word vectors of attribute-related words, and the word vectors of predefined attribute words, wherein attribute-related sentences are sentences in the text data that contain one or more words that have a semantic relationship with the attribute words; and a sentiment classification result determination module 505, which determines the attribute-level sentiment classification result of the text data based on the sentence vectors of one or more attribute-related sentences in the text data.

[0128] As described above, the apparatus in this embodiment is used to generate attribute syntactic distance vectors by combining words in text data with predefined attribute words, generate word vectors corresponding to attribute-related words, determine sentence vectors for attribute-related sentences based on the word vectors of each word in the text data and the word vectors of attribute words, and determine the attribute-level sentiment classification result of the text data based on the sentence vectors of attribute-related sentences. This disclosure effectively utilizes unannotated information to analyze text sentiment, extracting the sentiment information hidden by attribute words to improve the scalability and generalization ability of the model, enabling it to be used in scenarios with insufficient or missing labeled data, while reducing manpower consumption and improving computational efficiency.

[0129] In one embodiment of this disclosure, the attribute syntactic distance vector generation module 502 is further configured to obtain the connection relationship between each word in the text data and each predefined attribute word through a dependency parsing method; and determine the attribute syntactic distance between each word in the text data and each predefined attribute word based on the connection relationship between each word in the text data and each predefined attribute word.

[0130] In one embodiment of this disclosure, the attribute syntactic distance vector generation module 502 is further configured to calculate the attribute syntactic distance between each word in the text data and each predefined attribute word using the formula (1) above.

[0131] In one embodiment of this disclosure, the attribute-related word vector generation module 503 is further configured to define the attribute category corresponding to the predefined attribute words based on the predefined attribute words; calculate the cosine similarity between each word in the text data and the attribute category; sort the cosine similarity between each word in the text data and the attribute category in descending order; and obtain the words with the highest cosine similarity ranking as the attribute-related words contained in the text data.

[0132] In one embodiment of this disclosure, the attribute-related word vector generation module 503 is further configured to filter out words that meet a preset frequency of occurrence from text data; and calculate the cosine similarity between the words that meet the preset frequency of occurrence and the attribute category.

[0133] In one embodiment of this disclosure, the attribute word related sentence vector generation module 504 is further configured to generate sentence vectors of one or more attribute word related sentences in the text data based on an attention mechanism, according to the word vector of each word in the text data, the attribute syntactic distance vector corresponding to each word, the word vector of attribute related words, and the word vector of predefined attribute words.

[0134] In one embodiment of this disclosure, the sentiment classification result determination module 505 is further configured to retrieve predefined sentiment category labels; generate sentiment category vectors corresponding to the sentiment category labels based on the sentiment category labels; calculate the cosine similarity between the sentence vectors of one or more attribute word-related sentences in the text data and the sentiment category vectors; and determine the attribute-level sentiment classification result of the text data based on the cosine similarity between the sentence vectors of one or more attribute word-related sentences in the text data and the sentiment category vectors.

[0135] Those skilled in the art will understand that various aspects of this disclosure can be implemented as a system, method, or program product. Therefore, various aspects of this disclosure can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "system."

[0136] The following reference Figure 6 To describe an electronic device 600 according to such an embodiment of the present disclosure. Figure 6 The electronic device 600 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0137] Figure 6A block diagram of an electronic device according to an embodiment of the present disclosure is shown. Referring below... Figure 6 To describe an electronic device 600 according to such an embodiment of the present disclosure. Figure 6 The electronic device 600 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0138] like Figure 6 As shown, the electronic device 600 is manifested in the form of a general-purpose computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, and a bus 630 connecting different system components (including storage unit 620 and processing unit 610).

[0139] The storage unit stores program code that can be executed by the processing unit 610, causing the processing unit 610 to perform the steps described in the "Exemplary Methods" section above according to various exemplary embodiments of this disclosure. For example, the processing unit 610 can execute the following steps of the above method embodiment: acquiring text data to be analyzed, the text data including multiple sentences, wherein each sentence includes multiple words; generating an attribute syntactic distance vector corresponding to each word in the text data based on the attribute syntactic distance between each word in the text data and each predefined attribute word; generating word vectors corresponding to attribute-related words based on attribute-related words contained in the text data, wherein attribute-related words are one or more words in the text data that satisfy a preset similarity condition with the predefined attribute words; determining sentence vectors of one or more attribute-related sentences in the text data based on the word vectors of each word in the text data, the attribute syntactic distance vectors corresponding to each word, the word vectors of attribute-related words, and the word vectors of predefined attribute words, wherein attribute-related sentences are sentences in the text data that contain one or more words that have a semantic relationship with the attribute words; and determining the attribute-level sentiment classification result of the text data based on the sentence vectors of one or more attribute-related sentences in the text data.

[0140] Storage unit 620 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 6201 and / or cache memory 6202, and may further include a read-only memory (ROM) 6203.

[0141] Storage unit 620 may also include a program / utility 6204 having a set (at least one) program module 6205, such program module 6205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0142] Bus 630 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0143] Electronic device 600 can also communicate with one or more external devices 640 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 600, and / or with any device that enables electronic device 600 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 650. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 660. As shown, network adapter 660 communicates with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0144] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0145] In particular, according to embodiments of this disclosure, the process described above with reference to the flowchart can be implemented as a computer program product, which includes a computer program that, when executed by a processor, implements the above-described text attribute-level sentiment classification method.

[0146] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, which may be a readable signal medium or a readable storage medium. Figure 7 This illustration shows a schematic diagram of a computer-readable storage medium according to an embodiment of the present disclosure, such as... Figure 7As shown, the computer-readable storage medium stores a program product 700 capable of implementing the methods described above. In some possible embodiments, various aspects of this disclosure may also be implemented as a program product comprising program code that, when run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure.

[0147] More specific examples of computer-readable storage media in this disclosure may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0148] In this disclosure, a computer-readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting a program for use by or in connection with an instruction execution system, apparatus, or device.

[0149] Optionally, the program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0150] In practical implementation, program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0151] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0152] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.

[0153] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0154] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the appended claims.

Claims

1. A text attribute-level sentiment classification method, characterized in that, include: Obtain the text data to be analyzed, which includes multiple sentences, each sentence including multiple words; Based on the attribute syntactic distance between each word in the text data and each predefined attribute word, generate the attribute syntactic distance vector corresponding to each word in the text data; Based on the attribute-related words contained in the text data, generate word vectors corresponding to the attribute-related words, wherein the attribute-related words are one or more words in the text data that satisfy a preset similarity condition with predefined attribute words; Based on the word vector of each word in the text data, the attribute syntactic distance vector corresponding to each word, the word vector of attribute-related words, and the word vector of predefined attribute words, determine the sentence vector of one or more attribute-related sentences in the text data, wherein the attribute-related sentences are sentences in the text data that contain one or more words that have a semantic relationship with the attribute words; Based on the sentence vectors of sentences related to one or more attribute words in the text data, determine the attribute-level sentiment classification result of the text data.

2. The text attribute-level sentiment classification method according to claim 1, characterized in that, Based on the attribute syntactic distance between each word in the text data and predefined attribute words, including: The dependency parsing method is used to obtain the connection relationship between each word in the text data and each predefined attribute word; Based on the connection relationship between each word in the text data and each predefined attribute word, determine the attribute syntactic distance between each word in the text data and each predefined attribute word.

3. The text attribute-level sentiment classification method according to claim 2, characterized in that, The attribute syntactic distance between each word in the text data and each predefined attribute word is calculated using the following formula: Where, d i Represents the attribute syntactic distance, A i In the dependency parsing graph of a sentence, A indicates whether there is a direct connection between the i-th word and the attribute word. i =1 indicates that there is a direct edge connecting the i-th word and the attribute word, A i =0 indicates that there is no direct edge connecting the i-th word and the attribute word, l i Max(l) represents the minimum number of hops that the i-th word can connect to all attribute words. i ,0) means taking l i The maximum value between 0 and 0.

4. The text attribute-level sentiment classification method according to claim 1, characterized in that, Before generating word vectors corresponding to the attribute-related words contained in the text data, the method further includes: Define the attribute category corresponding to the predefined attribute words; Calculate the cosine similarity between words in the text data and the attribute category; The cosine similarity between each word in the text data and the attribute category is sorted in descending order. Words with cosine similarity rankings above a preset level are selected as attribute-related words in the text data.

5. The text attribute-level sentiment classification method according to claim 4, characterized in that, The calculation of the cosine similarity between words in the text data and the attribute category includes: Filter words that meet the preset frequency of occurrence from the text data; Calculate the cosine similarity between the words that meet the preset occurrence frequency and the attribute category.

6. The text attribute-level sentiment classification method according to claim 1, characterized in that, Based on the word vector of each word in the text data, the attribute syntactic distance vector corresponding to each word, the word vectors of attribute-related words, and the word vectors of predefined attribute words, determine the sentence vectors of one or more attribute-related sentences in the text data, including: Based on the attention mechanism, sentence vectors of one or more attribute-related sentences in the text data are generated according to the word vector of each word in the text data, the attribute syntactic distance vector corresponding to each word, the word vector of attribute-related words, and the word vector of predefined attribute words.

7. The text attribute-level sentiment classification method according to claim 1, characterized in that, Based on the sentence vectors of sentences related to one or more attribute words in the text data, determine the attribute-level sentiment classification result of the text data, including: Retrieve predefined sentiment category labels; Based on the emotion category label, generate an emotion category vector corresponding to the emotion category label; Calculate the cosine similarity between the sentence vector of one or more attribute words related to the text data and the sentiment category vector; The attribute-level sentiment classification result of the text data is determined based on the cosine similarity between the sentence vectors of one or more attribute words related to the text data and the sentiment category vector.

8. A text attribute-level sentiment classification device, characterized in that, include: The text data acquisition module is used to acquire text data to be analyzed, wherein the text data includes multiple sentences, and each sentence includes multiple words; The attribute syntactic distance vector generation module is used to generate an attribute syntactic distance vector corresponding to each word in the text data based on the attribute syntactic distance between each word in the text data and each predefined attribute word; The attribute-related word vector generation module is used to generate word vectors corresponding to attribute-related words contained in text data, wherein the attribute-related words are one or more words in the text data that satisfy a preset similarity condition with predefined attribute words; The attribute word related sentence vector generation module is used to determine the sentence vector of one or more attribute word related sentences in the text data based on the word vector of each word in the text data, the attribute syntactic distance vector corresponding to each word, the word vector of attribute related words, and the word vector of predefined attribute words. The attribute word related sentences are sentences in the text data that contain one or more words that have a semantic relationship with the attribute words. The sentiment classification result determination module is used to determine the attribute-level sentiment classification result of the text data based on the sentence vectors of sentences related to one or more attribute words in the text data.

9. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the text attribute-level sentiment classification method according to any one of claims 1 to 7 by executing the executable instructions.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the text attribute-level sentiment classification method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Dependency tree and attention mechanism-based attribute sentiment classification method

    CN108399158A

  • Emotion analysis method and device, equipment and storage medium

    CN113255367A