Attribute-level sentiment classification method and device
By constructing attribute-level sentiment classification with multi-distance perception and semantic noise perception representation using deep learning methods, this solves the problem that document-level and sentence-level sentiment analysis cannot identify the sentiment tendency of attribute words. It achieves fine-grained sentiment polarity identification and noise word elimination, thereby improving the accuracy of sentiment classification.
Patent Information
- Application Number
- CN202411621516.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-11-13
AI Technical Summary
Existing document-level and sentence-level sentiment analysis methods cannot accurately identify the sentiment tendencies of specific attribute words in text, nor can they handle scenarios with multiple attribute words of different sentiment polarities.
We employ a deep learning-based attribute-level sentiment classification method. By acquiring the contextual representation, syntactic dependency distance, and semantic perception distance of attribute words in the text, we construct a multi-distance perception adjacency matrix. Combined with semantic noise perception representation and multi-information aggregation, we identify the sentiment polarity of attribute words.
It enables fine-grained analysis of the sentiment polarity of attribute words in text, improves the accuracy and precision of sentiment classification, can identify and eliminate the interference of noise words, and enhances the model's sentiment modeling capabilities.
Smart Images

Figure CN119578427B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of natural language processing, and particularly relates to an attribute-level sentiment classification method, an attribute-level sentiment classification device, a computer device, a computer readable storage medium and a computer program product. BACKGROUND
[0002] With the advent of the mobile Internet era, users are increasingly inclined to publicly express their opinions and comments on Internet social platforms and online shopping websites. It is important to study how to extract valuable information from these opinions and comments. In order to solve this problem, sentiment analysis methods are considered as an effective solution and have been successfully applied to the fields of public opinion supervision, public opinion survey, reputation analysis and market sentiment analysis.
[0003] Sentiment analysis methods can be divided into document-level sentiment analysis methods, sentence-level sentiment analysis methods and attribute-level sentiment analysis methods according to granularity. However, the document-level sentiment analysis method and the sentence-level sentiment analysis method only analyze the overall sentiment tendency of the text, and cannot obtain the sentiment tendency of a specific entity (attribute word) in the text. SUMMARY
[0004] The present disclosure provides an attribute-level sentiment classification method, which comprises: obtaining a text and a context representation of an attribute word in the text, a context distance between each word in the text and the attribute word and a context distance representation thereof, a syntactic dependency distance and a syntactic dependency distance representation thereof, and a semantic perception distance and a semantic perception distance representation thereof; obtaining a multi-distance perception adjacency matrix according to the context distance, the syntactic dependency distance and the semantic perception distance between each word in the text and the attribute word; obtaining a multi-distance perception representation according to the multi-distance perception adjacency matrix; obtaining a semantic noise perception representation according to the context representation of the text and the attribute word in the text, the context distance representation, the syntactic dependency distance representation and the semantic perception distance representation between each word in the text and the attribute word; obtaining a multi-information aggregation sentiment representation according to the multi-distance perception representation and the semantic noise perception representation; and obtaining a sentiment polarity of the attribute word according to the multi-information aggregation sentiment representation.
[0005] The embodiment of the present disclosure provides an attribute-level sentiment classification device, which comprises: a multi-semantics and distance embedding module, which is used to obtain a context representation of a text and an attribute word in the text, a context distance between each word in the text and the attribute word, a context distance representation thereof, a syntax dependency distance and a syntax dependency distance representation thereof, and a semantic perception distance and a semantic perception distance representation thereof; a multi-distance perception adjacency matrix module, which is used to obtain a multi-distance perception adjacency matrix according to the context distance, the syntax dependency distance and the semantic perception distance between each word in the text and the attribute word; a semantic and syntax perception module, which comprises a semantic noise perception attention sub-module and a multi-distance perception graph convolution network, wherein the semantic noise perception attention sub-module is used to obtain a semantic noise perception representation according to the context representation of the text and the attribute word in the text, the context distance representation, the syntax dependency distance representation and the semantic perception distance representation between each word in the text and the attribute word; the multi-distance perception graph convolution network is used to obtain a multi-distance perception representation according to the multi-distance perception adjacency matrix; an attribute perception aggregation module, which is used to obtain a multi-information aggregated sentiment representation according to the multi-distance perception representation and the semantic noise perception representation; and a sentiment prediction module, which is used to obtain a sentiment polarity of the attribute word according to the multi-information aggregated sentiment representation.
[0006] The embodiment of the present disclosure provides a computer device, which comprises a processor, a memory and an input and output interface; the processor is connected with the memory and the input and output interface respectively, wherein the input and output interface is used to receive and output data, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device comprising the processor executes the attribute-level sentiment classification method in any embodiment of the present disclosure.
[0007] The embodiment of the present disclosure provides a computer readable storage medium, which stores a computer program, and the computer program is suitable for being loaded and executed by a processor so that a computer device with the processor executes the attribute-level sentiment classification method in any embodiment of the present disclosure.
[0008] The embodiment of the present disclosure provides a computer program product or a computer program, which comprises computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions so that the computer device executes the method provided in any of the various optional manners of the embodiments of the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0009] Figure 1 It is a network interaction architecture diagram of an attribute-level sentiment classification method provided by the embodiment of the present disclosure.
[0010] Figure 2 is a flowchart of a property-level sentiment classification method provided by an embodiment of the present disclosure.
[0011] Figure 3 is a flowchart of another property-level sentiment classification method provided by an embodiment of the present disclosure.
[0012] Figure 4 is a schematic diagram of a property-level sentiment classification device provided by an embodiment of the present disclosure.
[0013] Figure 5 is a schematic diagram of another property-level sentiment classification device provided by an embodiment of the present disclosure.
[0014] Figure 6 is a schematic diagram of still another property-level sentiment classification device provided by an embodiment of the present disclosure.
[0015] Figure 7 is a structural schematic diagram of a computer device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0016] The technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present disclosure.
[0017] In the embodiments of the present disclosure, please refer to Figure 1 , Figure 1 is a network interaction architecture diagram of a property-level sentiment classification method provided by an embodiment of the present disclosure, and the embodiment of the present disclosure can be implemented by a terminal and / or a server. The terminal can obtain data from a computer device 101 and display the data, where the computer device 101 can interact with the terminal, the computer device 101 can be a server where an application program is located, or can belong to the terminal (i.e., be a background of the terminal), etc., which is not limited here.
[0018] The terminal can be a terminal 102a, a terminal 102b or a terminal 102c, and the embodiment of the present disclosure can be implemented by any one of the terminal 102a, the terminal 102b or the terminal 102c. Specifically, taking the terminal 102b as an example, the terminal 102b can be used for display. The data (e.g., sentiment polarity of attribute words) displayed by the terminal 102b can be obtained from the computer device 101, which can be a server corresponding to the target application, or a background of the terminal 102b, etc., which is not limited here.
[0019] The terminal can be a mobile phone (such as the terminal 102c) or a notebook computer (such as the terminal 102b), can also be a playing device in a vehicle (such as the terminal 102a), and the like, which is not limited herein. The terminal 102a can be considered as a playing device in the vehicle 103, and the terminal 102a can display a target application and the like. The terminal 102b can be considered as a notebook computer, and the terminal 102b can display a target application and the like. Figure 1 The terminal in the foregoing is only part of the devices exemplified, and the terminal in the present disclosure is not limited to the devices exemplified in the foregoing. Figure 1 The target application in the present disclosure can be any application program capable of displaying information / data.
[0020] It can be understood that the terminal mentioned in the embodiments of the present disclosure can be a computer device, and the computer device in the embodiments of the present disclosure includes but is not limited to a terminal or a server. In other words, the computer device can be a server or a terminal, or a system composed of a server and a terminal. The terminal mentioned above can be an electronic device, including but not limited to a mobile phone, a tablet computer, a desktop computer, a notebook computer, a palm computer, a vehicle-mounted device, an augmented reality / virtual reality (AR / VR) device, a head-mounted display, a smart television, a wearable device, a smart speaker, a digital camera, a camera, and other mobile internet devices (MID) with network access capability, or a terminal in a train, a ship, an airplane, and the like.
[0021] The server mentioned above can be a stand-alone physical server, can also be a server cluster or a distributed system composed of multiple physical servers, and can also be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, vehicle-road cooperation, content delivery networks (CDNs), and basic cloud computing services such as big data and artificial intelligence platforms.
[0022] Optionally, the data involved in the embodiments of the present disclosure can be stored in a computer device, or the data can be stored based on cloud storage technology, which is not limited herein.
[0023] To overcome the problem that the document-level sentiment analysis and the sentence-level sentiment analysis in the related art cannot obtain the sentiment polarity of the attribute word in the text, the present disclosure attempts to use an attribute-level sentiment classification method to solve this problem. The attribute-level sentiment classification is a fine-grained sentiment analysis task, and the goal is to identify the sentiment polarity of the attribute word in the text such as a sentence or a paragraph. The attribute-level sentiment analysis can provide fine-grained sentiment information and can better meet the needs of people. The goal of the attribute-level sentiment classification can be to extract the sentiment polarity of the attribute word given a sentence and the attribute word (also called a viewpoint object). The sentiment polarity can be positive, negative, or neutral.
[0024] The goal of the sentence-level and document-level sentiment analysis is to judge the sentiment polarity of the entire sentence or document, and it cannot handle the scenario that there are multiple attribute words with different sentiment polarities in a sentence or a document, while the attribute-level sentiment classification can better handle such fine-grained sentiment classification.
[0025] For example, a user's comment is "The location of this restaurant is good, but the service is not good." The sentiment polarity of the attribute word "location" in the comment is positive, and the sentiment polarity of the attribute word "service" is negative.
[0026] The attribute-level sentiment classification method includes three categories: rule-based method, machine learning-based method, and deep learning-based method. Among them, the rule-based method identifies the sentiment polarity of the attribute word through manually defined rules or uses a sentiment dictionary, and this method performs poorly in the scene where the sentiment resources are limited. The machine learning-based method uses statistical machine learning methods (for example, support vector machine, maximum entropy, naive Bayes, etc.) to extract the sentiment polarity. However, the performance of this method depends heavily on the quality of the designed features, and designing features is a very time-consuming and laborious work.
[0027] The deep learning-based method adopted by the embodiments of the present disclosure can automatically learn features suitable for specific tasks and has achieved good performance.
[0028] Figure 2 is a flowchart of an attribute-level sentiment classification method provided by the embodiments of the present disclosure. Figure 2 The method provided by the embodiments can be executed by any computer device, for example, the computer device 1000 described above. Figure 1 Any terminal and / or server in the embodiments is used as an example. As shown in Figure 2 The method provided by the embodiments of the present disclosure can include the following steps.
[0029] In S210, a text and a context representation of an attribute word in the text are obtained, and a context distance between each word in the text and the attribute word, a context distance representation thereof, a syntax dependency distance and a syntax dependency distance representation thereof, and a semantic perception distance and a semantic perception distance representation thereof.
[0030] In the embodiments of the present disclosure, the text refers to a text to be classified in terms of the sentiment polarity of an attribute word contained therein. The sentiment polarity, also known as sentiment duality or complexity, refers to the interaction of subjective experience and consciousness of a person with the objective environment. In the embodiments of the present disclosure, the sentiment polarity includes three categories: positive, negative, and neutral. The text can be a paragraph, a document, or a sentence. The text can contain multiple words, and the multiple words contain one or more attribute words. If the text contains multiple attribute words, for example, it contains q attribute words, q is a positive integer greater than 1, then the method provided by the embodiments of the present disclosure can be used to process the text and an attribute word in the text each time, and the sentiment polarity of an attribute word in the text is identified each time. If the sentiment polarity of q attribute words in the text needs to be identified, the method provided by the embodiments of the present disclosure can be called q times, and the sentiment polarity of a single attribute word is predicted each time.
[0031] In the embodiments of the present disclosure, after obtaining the text to be classified, an attribute word to be classified in the text is obtained. The attribute word to be classified can be any one of the attribute words contained in the text. The attribute word refers to a word in a sentence or a paragraph, which describes a certain attribute of a viewpoint object. The attribute word can be a word in a certain review text that evaluates various things such as goods, events, or characters. For example, in the restaurant review “the food in this restaurant is really delicious”, the attribute word is “food”. For another example, in the notebook computer review “the battery capacity of this notebook computer is large”, the attribute word is “battery capacity”.
[0032] In the embodiments of the present disclosure, the “representation” in the embodiments of the present disclosure can also be referred to as a vector or a matrix. The context representation of the text refers to the vectorization processing of each word in the text, and the word vector / vector representation of each word in the text is obtained. The context representation of the attribute word refers to the word vector / vector representation of each word in the attribute word. The word vector of each word is obtained according to the context environment in which the word is located, and is also referred to as a context representation.
[0033] In the embodiments of the present disclosure, the context distance is used to indicate the distance relationship between each word in the text and the position of the attribute word in the text, which reflects the closeness between each word in the text and the attribute word. It can be considered that the closer the context distance between each word in the text and the attribute word, the more relevant they are, and vice versa, the less relevant they are. The context distance representation refers to the vector representation of the context distance between each word in the text and the attribute word.
[0034] In the embodiments of the present disclosure, the syntax dependency distance is used to indicate the distance relationship between each word in the text and the attribute word in syntax or grammar obtained by syntax dependency analysis, which can be used to reflect the closeness between each word in the text and the attribute word in syntax or grammar. It can be considered that the smaller the syntax dependency distance between each word in the text and the attribute word, the more relevant they are in syntax or grammar, and vice versa, the less relevant they are. The syntax dependency distance representation refers to the vector representation of the syntax dependency distance between each word in the text and the attribute word.
[0035] In the embodiments of the present disclosure, the semantic perception distance is used to indicate the distance relationship between each word in the text and the attribute word in semantics obtained by analyzing the semantics of the attribute word and the semantics of each word in the text, which can be used to reflect the closeness between each word in the text and the attribute word in semantics. It can be considered that the smaller the semantic perception distance between each word in the text and the attribute word, the more relevant they are in semantics, and vice versa, the less relevant they are. The semantic perception distance representation refers to the vector representation of the semantic perception distance between each word in the text and the attribute word.
[0036] In the example embodiments, obtaining the context distance between each word in the text and the attribute word and its context distance representation, the syntax dependency distance and its syntax dependency distance representation, and the semantic perception distance and its semantic perception distance representation, comprises: concatenating a first character and a second character at both ends of the attribute word and the text respectively to obtain a concatenated sequence of the attribute word and a concatenated sequence of the text, the length of the concatenated sequence of the attribute word is m+2, m is the length of the attribute word; the length of the concatenated sequence of the text is n=m s +2, m s is the length of the text, m and m sare positive integers greater than or equal to 1, n is a positive integer greater than or equal to 3; calculating the context distance between each word in the concatenation sequence of the text and the attribute word; obtaining the context distance representation of each word in the concatenation sequence of the text according to the context distance between each word in the concatenation sequence of the text and the attribute word and the context distance embedding matrix; calculating the syntactic dependency distance between each word in the concatenation sequence of the text and the attribute word; obtaining the syntactic dependency distance representation of each word in the concatenation sequence of the text according to the syntactic dependency distance between each word in the concatenation sequence of the text and the attribute word and the syntactic dependency distance embedding matrix; calculating the semantic perception distance between each word in the concatenation sequence of the text and the attribute word; obtaining the semantic perception distance representation of each word in the concatenation sequence of the text according to the semantic perception distance between each word in the concatenation sequence of the text and the attribute word and the semantic perception distance embedding matrix.
[0037] In an example embodiment, obtaining the context representation of the text and the attribute word includes: obtaining the context representation of each word in the concatenation sequence of the text through a pre-trained language model; obtaining the context representation of each word in the concatenation sequence of the attribute word through a pre-trained language model; performing average pooling on the context representation of each word in the concatenation sequence of the attribute word to obtain the overall representation of the attribute word.
[0038] In the embodiments of the present disclosure, the pre-trained language model refers to a language model obtained through pre-training, which can be used to extract the context representation of the attribute word and the context representation of each word in the text. In the following embodiments, the pre-trained language model is exemplified as BERT (Bidirectional Encoder Representation from Transformers), but the present disclosure is not limited thereto. Other models or methods capable of vectorizing the attribute word and each word in the text can be used. Among them, BERT is a pre-trained language model. BERT aims to pre-train deep bidirectional representations by jointly conditioning on both left and right contexts in all layers.
[0039] In the embodiments of the present disclosure, the first character and the second character are spliced at both ends of the attribute word and at both ends of the text, in order to make the attribute word and the text conform to the input format or specification of the model used to extract the context representation thereof. For example, taking the BERT model as an example, the first character can be “CLS” and the second character can be “SEP”, but the present disclosure is not limited thereto.
[0040] In an example embodiment, the context distance con between the i th word in the text and the attribute word is obtained according to the following formulai :
[0041]
[0042] wherein, l asp_left represents the position of the leftmost word constituting the attribute word in the text; l asp_right represents the position of the rightmost word constituting the attribute word in the text; l i represents the position of the i-th word in the text, i is a positive integer greater than or equal to 1 and less than or equal to n. But the present disclosure is not limited thereto, and the context distance can also be obtained by other ways.
[0043] In an exemplary embodiment, the syntactic dependency distance dep between the i-th word in the text and the attribute word is obtained according to the following formula: i :
[0044]
[0045] wherein, represents the shortest syntactic distance between the i-th word in the text and the attribute word in the syntactic dependency tree, and if the attribute word includes multiple words, it is the shortest syntactic distance between the rightmost word constituting the attribute word; k is a hyperparameter of syntactic dependency distance, k is an integer greater than 0 and less than n. k can be used to limit the obtained syntactic dependency distance from being too large, so as to avoid that the too large syntactic dependency distance has a bad influence on the classification of the sentiment polarity of the attribute word. By calculating and analyzing the syntactic dependency distance, the computer can better understand the grammatical structure of the text, and then make more accurate analysis. But the present disclosure is not limited thereto, and the syntactic dependency distance can also be obtained by other ways.
[0046] In the embodiments of the present disclosure, the values of various hyperparameters can be set before the model (for example, the model shown in Figure 5 or Figure 6 starts training, and the sizes of these hyperparameters can be kept unchanged during the training process. If it is found that the training effect is not good and the expected result cannot be reached during the training process, the values of these hyperparameters can be adjusted, and then the model is retrained.
[0047] In an exemplary embodiment, the semantic perception distance dis between the i-th word in the text and the attribute word is obtained according to the following formula: i :
[0048]
[0049] wherein, C i =1 represents that there is a direct syntactic connection between the attribute word and the i-th word in the text; C i= 0 indicates that there is an indirect syntactic connection or no syntactic connection between the attribute word and the i-th word in the text; l i represents the position of the i-th word in the text, l asp_right represents the position of the rightmost word constituting the attribute word in the text. However, the disclosure is not limited thereto, and the semantic perception distance can also be obtained in other ways.
[0050] In S220, a multi-distance perception adjacency matrix is obtained according to the context distance, the syntactic dependency distance and the semantic perception distance between each word in the text and the attribute word, and a multi-distance perception representation is obtained according to the multi-distance perception adjacency matrix.
[0051] In an exemplary embodiment, the multi-distance perception adjacency matrix is obtained according to the following formula:
[0052]
[0053]
[0054] wherein con i and con j respectively represent the context distance between the i-th word and the j-th word in the concatenation sequence of the text and the attribute word, |con i -con j | represents the absolute value of the difference value between con i and con j , or in other words, the relative distance between the context distance between the i-th word and the j-th word in the concatenation sequence of the text and the attribute word; dep i and dep j respectively represent the syntactic dependency distance between the i-th word and the j-th word in the concatenation sequence of the text and the attribute word, |dep i -dep j | represents the absolute value of the difference value between dep i and dep j , or in other words, the relative distance between the syntactic dependency distance between the i-th word and the j-th word in the concatenation sequence of the text and the attribute word; dis i and dis j respectively represent the semantic perception distance between the i-th word and the j-th word in the concatenation sequence of the text and the attribute word, |dis i -dis j | represents the absolute value of the difference value between dis i and dis j , or in other words, the relative distance between the semantic perception distance between the i-th word and the j-th word in the concatenation sequence of the text and the attribute word; denotes the initial association weight of the i-th word and the j-th word in the concatenation sequence of the text; A i,j denotes the association weight of the i-th word and the j-th word in the concatenation sequence of the text in the multi-distance-aware adjacency matrix; i and j are both positive integers greater than or equal to 1 and less than or equal to n; k d is a hyperparameter of the multi-distance-aware adjacency matrix.
[0055] The multi-distance-aware adjacency matrix in the embodiments of the present disclosure can more accurately obtain the association relationship between each word in the text and the attribute word by simultaneously fusing the context distance, the syntactic dependency distance and the semantic-aware distance between each word in the text and the attribute word. Based on the extracted association relationship, a multi-distance-aware adjacency matrix can be generated, which quantitatively represents the association relationship between the words in the text and the attribute words in the form of a matrix.
[0056] In the embodiments of the present disclosure, the calculation method of the multi-distance-aware adjacency matrix is not limited to the above formula (4), as long as it simultaneously fuses the context distance, the syntactic dependency distance and the semantic-aware distance between each word in the text and the attribute word. For example, the following formula can also be used for calculation:
[0057] or
[0058]
[0059] In an exemplary embodiment, the multi-distance-aware representation is obtained by the following formula:
[0060]
[0061]
[0062] wherein tanh is the hyperbolic tangent function; W mda , b mda is a parameter of the multi-distance-aware graph convolutional network, which can be initialized first and then updated or adjusted during the model training process, and is a parameter that can be learned through model training; and denote the multi-distance aggregation representation of the i-th word in the concatenation sequence of the text output by the t-th layer and the t-1-th layer of the multi-distance-aware graph convolutional network, respectively, t is a positive integer greater than 1 and less than the total number of layers of the multi-distance graph convolutional network, which is pre-set and can be set according to actual needs, and the present disclosure does not limit this; denotes the multi-distance aggregation representation of the i-th word in the concatenation sequence of the text output by the last layer of the multi-distance-aware graph convolutional network; h mdaa multi-distance-aware representation output by the multi-distance-aware graph convolutional network.
[0063] In the embodiments of the present disclosure, a GCN (Graph Convolution Network) is used to process the multi-distance-aware adjacency matrix to obtain the multi-distance-aware representation, and therefore the GCN can also be referred to as a multi-distance GCN.
[0064] In the embodiments of the present disclosure, each word in the text can be a node of a graph. The multi-distance-aware adjacency matrix represents the association relationship between each word and each word in the text, that is, the association relationship between the nodes of the graph. It can be understood that the weight of the edge between the nodes in the graph is the association relationship between the nodes. The GCN aggregates the feature information of the neighbor nodes layer by layer through convolution operation on the graph, so as to capture the spatial information of the nodes in the graph and the association relationship between the nodes, thereby obtaining the multi-distance-aware representation, that is, the vector representation that simultaneously fuses the above-mentioned context distance, syntactic dependency distance, semantic-aware distance and other distance information. The spatial information refers to the information of the structure composed of the node and the surrounding connected nodes.
[0065] In S230, according to the text, the context representation of the attribute word in the text, the context distance representation between each word in the text and the attribute word, the syntactic dependency distance representation and the semantic-aware distance representation, a semantic noise-aware representation is obtained.
[0066] In an exemplary embodiment, the semantic noise-aware representation is obtained according to the following formula:
[0067]
[0068]
[0069]
[0070]
[0071] wherein, respectively represent the context representation, the context distance representation, the syntactic dependency distance representation and the semantic-aware distance representation of the i th word in the concatenated sequence of the text; h asp represents the overall representation of the attribute word; represents the context semantic representation of the i th word in the concatenated sequence of the text; W sn is a parameter of semantic noise-aware attention; and respectively represent the unnormalized semantic noise-aware attention weight of the i th word and the j th word in the concatenated sequence of the text; a normalized semantic-noise-aware attention weight of an i-th word in a concatenation sequence representing the text, h sna a semantic-noise-aware representation representing a semantic-noise-aware attention output; i and j are both positive integers greater than or equal to 1 and less than or equal to n.
[0072] In the embodiments of the present disclosure, BiLSTM (Bidirectional Long Short-Term Memory) is taken as an example to obtain the semantic-noise-aware representation, but the present disclosure is not limited thereto, for example, LSTM or GRU (Gated Recurrent Unit) can also be taken. BiLSTM is an improvement based on LSTM, including forward LSTM and reverse LSTM, which can consider bidirectional information at the same time, and can effectively process long-term dependencies in data.
[0073] In the embodiments of the present disclosure, first and h asp are concatenated, and then processed by BiLSTM and tanh in turn, so that the semantic-noise-aware attention weight of each word in the text to the attribute word can be obtained under the guidance of attribute word, context distance, syntactic dependency distance, semantic-aware distance, etc. The semantic-noise-aware attention weight is used to indicate the importance of each word in the text to the attribute word. The greater the semantic-noise-aware attention weight, the higher the importance of the word to the sentiment polarity judgment of the attribute word, and vice versa. If the sentiment polarity judgment of a certain word in the text to the attribute word is useless or has little effect, its corresponding semantic-noise-aware attention weight is 0 or close to 0, so that the noise word that is noise to the sentiment polarity judgment of the attribute word in the text can be identified. Therefore, the semantic-noise-aware representation refers to a vector representation for representing the attribute word by identifying and eliminating the noise in the text.
[0074] In S240, a multi-information-aggregated sentiment representation is obtained according to the multi-distance-aware representation and the semantic-noise-aware representation.
[0075] In the embodiments of the present disclosure, aggregation can include one or more operations such as addition, weighting, concatenation, etc. The sentiment representation refers to a vector or matrix containing emotional information for sentiment polarity judgment. The multi-information-aggregated sentiment representation refers to a sentiment representation that aggregates multiple types of information. Here, it refers to a sentiment representation that at least aggregates the multi-distance-aware representation and the semantic-noise-aware representation.
[0076] In the exemplary embodiments, the multi-information-aggregated sentiment representation is obtained according to the following formula:
[0077] p af = σ(Waf [h sna ;h mda ]) (14)
[0078] h af =p af h sna +(1-p af )h mda (15)
[0079] h fm =[h sna ;h af ;h mda ] (16)
[0080] wherein h sna represents the semantic noise perception representation; h mda represents the multi-distance perception representation; W af is a parameter of attribute perception aggregation attention, which can be initialized first and learned in the model training process; σ represents a sigmoid activation function; p af represents the weight of the attribute perception aggregation attention with respect to the semantic noise perception representation; h af represents the output representation of the attribute perception aggregation attention; h f m is the multi-information aggregation sentiment representation. That is, h sna and h mda are spliced first, then processed through a sigmoid activation function to obtain the weight of the semantic noise perception representation h sna , and the weight of h mda is (1-p af ); h sna and h mda are weighted and summed based on the above obtained weights to obtain h af ; h sna , h af and h mda are spliced to obtain the multi-information aggregation sentiment representation h fm .
[0081] In S250, the sentiment polarity of the attribute word is obtained according to the multi-information aggregation sentiment representation.
[0082] The attribute-level sentiment classification method provided by the embodiments of the present disclosure, on the one hand, obtains a multi-distance perception adjacency matrix according to the context distance, the syntactic dependency distance and the semantic perception distance between each word in the text and the attribute word, and obtains a multi-distance perception representation according to the multi-distance perception adjacency matrix, and obtains a multi-information aggregation sentiment representation according to the multi-distance perception representation and a semantic noise perception representation, so that the sentiment polarity judgment of the attribute word is more accurate by fusing multiple distances and multiple information; on the other hand, the semantic noise perception representation is obtained according to the context representation of the text and the attribute word in the text, the context distance representation, the syntactic dependency distance representation and the semantic perception distance representation between each word in the text and the attribute word, so that it can be identified which words in the text are more important for the sentiment polarity judgment of the attribute word, and which are not important or even noise words, thereby further improving the accuracy of the sentiment polarity classification of the attribute word.
[0083] In the related art, only useful information related to the attribute word is extracted from the sentence context to identify the sentiment polarity of the attribute word before performing sentiment prediction, and the redundant and interfering information in the context is ignored. Noise words can introduce redundant and interfering information, making the model confused and unable to accurately identify the sentiment polarity of the attribute word. Secondly, these methods use dependency tree aggregation node representations to judge the sentiment polarity of the attribute word, but the syntactic dependency tree only reveals whether there is an association relationship between the context and the attribute word, and ignores the different importance degrees of each word with respect to the attribute word, so it is difficult to determine which words are more valuable for the sentiment polarity judgment of the attribute word.
[0084] Based on the above problems, the method proposed by the embodiments of the present disclosure is an attribute-level sentiment classification method that fuses multi-syntactic and semantic distance perception and aggregation. By explicitly identifying and eliminating the redundant and interfering information of noise words, the noise information has not been effectively fused into the model. Removing noise information can provide more beneficial information to the model and improve the sentiment modeling capability of the model. By considering the importance degree of different words in the text, such as a sentence, with respect to the attribute word, the model can better capture the relevant sentiment expression of the attribute word. In addition, the graph convolution network can utilize multiple distances such as the context distance, the syntactic dependency distance and the semantic perception distance of the sentence to further improve the performance of attribute-level sentiment classification.
[0085] Figure 3 is a flowchart of another attribute-level sentiment classification method provided by the embodiments of the present disclosure. Figure 3 The embodiments are all exemplified by taking the text to be classified as a sentence, but the present disclosure is not limited thereto. Figure 3 The embodiments can be executed by any computer device. As shown in Figure 3 The method provided by the embodiments of the present disclosure can include the following steps.
[0086] In S310, the attribute word, sentence context (i.e., the sentence containing the attribute word), and their corresponding contextual distance, syntactic dependency distance, and semantic-aware distance with the attribute word are input into the multi-semantic and distance embedding module (see reference). Figure 4 to Figure 6 In any of the embodiments, the contextual representation of the attribute word and the contextual representation, contextual distance representation, syntactic dependency distance representation, and semantic perception distance representation of each word in the sentence are obtained.
[0087] refer to Figure 5 or Figure 6 In the example, based on the attribute words {a1,...,a...} m} and sentences Obtain context distance, syntactic dependency distance, and semantic perception distance. a1 represents the first word in the attribute words, a m This represents the m-th word in the attribute words. w1 represents the first word in the sentence. Indicates the m-th word in the sentence. s 1 word. Where m represents the length of the attribute word, m s Indicates the length of the sentence.
[0088] During model input, the special characters "CLS" (the first character) and "SEP" (the second character) are concatenated at both ends of the attribute word and the sentence context, respectively, to obtain the concatenation sequence I of the attribute word. asp ={a cls ,a1,...,a m ,a sep} and the concatenation sequence of sentence context
[0089] In this embodiment of the disclosure, the corresponding context distance sequence I is obtained by calculating the context distance between each word in the sentence and the attribute word. con ={con1,con2,...,con n-1 ,con n}, where n = m s +2, the formula for calculating the context distance can be found in formula (1) above. At this point, l asp_left Indicates the position of the leftmost word that makes up the attribute word in the sentence, l asp_right Indicates the position of the rightmost word that makes up the attribute word in the sentence, l i This indicates the position of the i-th word in the sentence. If the attribute word consists of a single word, then l asp_left =l asp_right .
[0090] In this embodiment of the disclosure, the corresponding syntactic dependency distance sequence I is obtained by calculating the syntactic dependency distance between each word in the sentence and the attribute word. depdep1, dep2,..., depn}. Wherein, the calculation formula of the syntax dependency distance can refer to the above formula (2). At this time, n-1 dep1, dep2,..., depn}. Wherein, the calculation formula of the syntax dependency distance can refer to the above formula (2). At this time, n dep1, dep2,..., depn}. Wherein, the calculation formula of the syntax dependency distance can refer to the above formula (2). At this time, represents the shortest syntax distance between the i-th word in the sentence and the attribute word in the syntax dependency tree, if the attribute word is composed of multiple words, it is the shortest syntax distance between the rightmost word of the attribute word and the attribute word.
[0091] In the embodiments of the present disclosure, by calculating the semantic perception distance between each word in the sentence and the attribute word, the corresponding semantic perception distance sequence I dis dis1, dis2,..., disn}. Wherein, the calculation formula of the semantic perception distance can refer to the above formula (3). At this time, C n-1 dis1, dis2,..., disn}. Wherein, the calculation formula of the semantic perception distance can refer to the above formula (3). At this time, C n dis1, dis2,..., disn}. Wherein, the calculation formula of the semantic perception distance can refer to the above formula (3). At this time, C i dis1, dis2,..., disn}. Wherein, the calculation formula of the semantic perception distance can refer to the above formula (3). At this time, C i dis1, dis2,..., disn}. Wherein, the calculation formula of the semantic perception distance can refer to the above formula (3). At this time, C i represents the position of the i-th word in the sentence, l asp_right represents the position of the rightmost word of the attribute word in the sentence. If the attribute word is composed of a single word, the position of the rightmost word of the attribute word is equivalent to the distance of the attribute word in the sentence.
[0092] In the embodiments of the present disclosure, through syntax dependency analysis, the dependency relationship between the words in the sentence can be obtained. If there is a dependency relationship between the words, it is considered that there is a direct syntax connection. If the words can be connected through the dependency relationship between other words, it is considered that there is an indirect syntax connection. If the words cannot be connected through the dependency relationship between other words, there is no syntax connection between the words.
[0093] Taking the sentence "The position of this restaurant is good, but the service is not good" and the attribute word "service" as an example. The words that have a direct syntax connection with the attribute word "service" are "not good", and the words that have an indirect syntax connection are, for example, "but".
[0094] The semantic perception distance in the embodiments of the present disclosure not only considers the syntax connection information between each word in the sentence and the attribute word, but also considers the relative distance between each word in the sentence and the attribute word, and the semantic information of the relative distance between the length of the attribute word and the length of the sentence. In this way, the perception distance between each word in the sentence and the attribute word, and the perception information of the length of the attribute word and the length of the sentence can be effectively injected into the model.
[0095] In the embodiments of the present disclosure, the spliced sequence of the attribute word and the spliced sequence of the sentence are input into the BERT embedding mapping unit 411 in the multi semantic and distance embedding module 410 to obtain the context representation of the attribute word and the context representation corresponding to each word in the sentence. That is, in the multi semantic and distance embedding module, the context representation of each word in the attribute word and the sentence is obtained using BERT, and the calculation process is as follows:
[0096]
[0097]
[0098] wherein BERT(·) represents all operations of BERT, thereby obtaining the context representation of each word / term in the spliced sequence of the sentence context
[0099] a q represents the qth word in the spliced sequence of the attribute word, represents the context representation of the qth word in the spliced sequence of the attribute word, q is a positive integer greater than or equal to 1 and less than or equal to m+2, and the context representation of each word in the spliced sequence of the attribute word is obtained The overall representation h of the attribute word is obtained by average pooling the context representation of each word of the attribute word asp After a spliced sequence of a specific attribute word passes through BERT, the context representation of each word in the attribute word is obtained, and after average pooling, the overall representation of the attribute word is obtained. This is because the attribute word may be composed of multiple words, so when modeling a specific attribute word, the context representation of each word that constitutes the attribute word is obtained. The context representations of these words are pooled to obtain the overall representation of the attribute word.
[0100] In the embodiments of the present disclosure, the context distance embedding matrix is used to obtain the context distance representation of each word in the spliced sequence of the sentence context The syntactic dependency distance embedding matrix is used to obtain the syntactic dependency distance representation of each word in the spliced sequence of the sentence context The semantic perception distance embedding matrix is used to obtain the semantic perception distance representation of each word in the spliced sequence of the sentence context
[0101] In the embodiments of the present disclosure, the representations of the context distance, the syntactic dependency distance and the semantic perception distance are obtained by mapping, that is, an embedding matrix is initialized, for example, randomly initialized, Gaussian or uniform distribution initialized, and then adjusted through a training process, which is learnable.
[0102] In the embodiments of the present disclosure, a context distance embedding matrix is obtained through initialization (for example, initialization through a Gaussian distribution, an average distribution, etc.), which is updated in the training process. The specific context distance is used to obtain the context distance representation corresponding to the context distance through the context distance embedding matrix. That is, the context distance representation of each word in the sentence, that is, the vector, is obtained for subsequent calculation and modeling. For example, if the context distance is 1, the first row of the context distance embedding matrix is taken as the corresponding context distance representation.
[0103] In the embodiments of the present disclosure, a syntax dependency distance embedding matrix is obtained through initialization (for example, initialization through a Gaussian distribution, an average distribution, etc.), which is updated in the training process. The specific syntax dependency distance is used to obtain the syntax dependency distance representation corresponding to the syntax dependency distance through the syntax dependency distance embedding matrix. That is, the syntax dependency distance representation of each word in the sentence, that is, the vector, is obtained for subsequent calculation and modeling.
[0104] In the embodiments of the present disclosure, a semantic perception distance embedding matrix is obtained through initialization (for example, initialization through a Gaussian distribution, an average distribution, etc.), which is updated in the training process. The specific semantic perception distance is used to obtain the semantic perception distance representation corresponding to the semantic perception distance through the semantic perception distance embedding matrix. That is, the semantic perception distance representation of each word in the sentence, that is, the vector, is obtained for subsequent calculation and modeling.
[0105] In S320, the context distance, the syntax dependency distance, and the semantic perception distance between each word in the sentence and the attribute word are input into the multi-distance perception adjacency matrix module to obtain a multi-distance perception adjacency matrix.
[0106] In the embodiments of the present disclosure, the distance perception adjacency matrix module receives the context distance, the syntax dependency distance, and the semantic perception distance as input, and can obtain the connection weight between the words in the sentence through calculation, so as to obtain the connection weight between all the words, that is, to construct the multi-distance perception adjacency matrix. The multi-distance perception adjacency matrix can effectively integrate and utilize the multi-distance information such as the context distance, the syntax dependency distance, and the semantic perception distance, so that the model can capture more semantic and grammatical information.
[0107] The multi-distance perception adjacency matrix is obtained through the multi-distance perception adjacency matrix module, and the calculation process can refer to the above formulas (4) and (5). At this time, A i,j represents the association weight of the i th word and the j th word in the multi-distance perception adjacency matrix, k d is a hyperparameter of the multi-distance perception adjacency matrix. k dThere is no specific range of values, a pre-set value. Can be adjusted according to the actual application effect size. The effect of the value is to play a filtering effect, when the distance value is too large, it may have a damaging effect on the performance of the model. Through this threshold, values greater than this value are changed to this threshold. For example, equal to 5.
[0108] In S330, the obtained context representation of the attribute word, the context representation of each word in the sentence, the context distance representation, the syntactic dependency distance representation, and the semantic perception distance representation are input into the semantic and syntactic perception module, the semantic noise perception representation containing more useful information is generated by using the semantic noise perception attention and the guidance information from the attribute word, and the multi-distance perception representation containing more useful information is generated by using the multi-distance perception GCN and the guidance information from the multi-distance perception adjacency matrix.
[0109] The semantic and syntactic perception module mainly includes a semantic noise perception attention unit and a multi-distance perception GCN. The semantic noise perception representation containing more useful information is generated by using the semantic noise perception attention and combining the guidance information from the attribute word. The multi-distance perception representation containing more useful information is generated by using the multi-distance perception GCN and combining the guidance information from the multi-distance perception adjacency matrix.
[0110] In the embodiment of the present disclosure, the semantic noise perception attention unit receives the context representation of each word in the sentence, the overall representation of the attribute word, the context distance representation of each word in the sentence, the syntactic dependency distance representation, and the semantic perception distance representation as input, obtains the attention weight of the word in the sentence (i.e. the normalized semantic noise perception attention weight) through intermediate representation calculation, then multiplies the attention weight of each word with the obtained context representation of the corresponding word, and adds all the words in the sentence to obtain the semantic noise perception representation. In the calculation of the attention weight, the present disclosure embodiment considers various distance information and semantic information, so that the calculated attention weight is more accurate.
[0111] In the calculation of the semantic noise perception attention, in the calculation process of the attention weight of each word in the sentence, the overall representation of the attribute word is spliced, and then the non-normalized attention weight is obtained through a nonlinear function, so there is guidance information from the attribute word. Through the calculation of the attention, the weight of some words unrelated to the attribute word to be classified will become relatively low, and the weight of the related words will be relatively high, so as to contain more useful information.
[0112] In the embodiments of the present disclosure, the noise word refers to a word irrelevant to the judgment of the attribute word to be subjected to sentiment polarity classification. For example, in the judgment of the sentiment polarity of "position" in the sentence "The position of this restaurant is very good, but the service is general", the attention weight of the two words "very good" in the generated weight is higher, and the attention weight of other words (for example, "general") is lower.
[0113] In the multi-distance-aware adjacency matrix in the embodiments of the present disclosure, the value at each position represents the connection weight or association weight between the ith word and the jth word in the sentence. The GCN obtains the multi-distance aggregation representation of each word in the sentence by performing convolution operation on the multi-distance-aware adjacency matrix. The construction method of this multi-distance-aware adjacency matrix is an intuitive construction method, which integrates multiple distances together to construct an adjacency matrix that fuses multiple distances.
[0114] The embodiments of the present disclosure can calculate the attention weight by utilizing the interaction between the multi-type distance representation and the attribute word, and the multi-type distance can provide more useful information than a single distance. After the calculation, the context word related to the attribute word is assigned a higher attention weight, and the irrelevant context word is assigned a lower attention weight. The calculation method of the semantic noise-aware attention can refer to the above formula (10) to formula (13). However, the present disclosure is not limited thereto. Although the single-head attention mechanism is exemplified in the embodiments of the present disclosure, in fact, the multi-head attention mechanism can also be used. In the above formula, BiLSTM(·) represents all operations of the BiLSTM, represents the context semantic representation of the semantic-aware modeling of the ith word in the concatenation sequence of the sentence (which can be understood as an intermediate vector in the semantic noise-aware attention calculation process). W sn is a parameter of the semantic noise-aware attention, which can be obtained by initialization (such as Gaussian distribution, average distribution, etc.) and updated by model training. The attention weight can be understood as reflecting the importance degree of the ith word to the attribute word.
[0115] In the embodiments of the present disclosure, the calculation method of the multi-distance-aware GCN can refer to the above formula (8) and formula (9). Through the GCN, the multi-distance-aware representation of each word in the sentence can be modeled by the specific structural information in the adjacency matrix. For example, at t=1, that is, the first layer, when calculating the multi-distance aggregation representation of the ith word in the sentence, the connection weight of each word in the ith row of the adjacency matrix is multiplied by the corresponding obtained multi-distance set representation of the previous layer, and the sum is accumulated to obtain the multi-distance-aware representation of this word at this layer. The value of t can be 2 or 3, which is a pre-set value. It can be adjusted according to the actual effect. The multi-distance aggregation representation of the last layer output of the multi-distance-aware GCN represents the i-th word in the sentence. At the 0th layer, the value of the multi-distance-aware representation of each word in the sentence (that is, the initial value of the multi-distance-aware representation of each word in the sentence) is the initial representation of each word in the sentence, that is,
[0116] The mean_pool(·) represents the average pooling operation. Because the obtained is the context representation of each word in the sentence context, not the overall representation of the sentence. After the average pooling operation, it can be regarded as obtaining a sentence representation related to multiple distances and attribute words, that is, a multi-distance-aware representation. When calculating the representation of each word, the GCN captures the different importance degrees of the word and other words in the sentence through the adjacency matrix, thereby obtaining the representation of each word in the sentence. At this time, the representation of each word contains useful information, and the average pooling integrates these useful information. The multi-distance-aware representation obtained by the average pooling is input to the subsequent module for calculating the sentiment polarity of the attribute word.
[0117] In S340, the semantic noise-aware representation and the multi-distance-aware representation are input to the attribute-aware aggregation module, and the attribute-aware aggregation attention mechanism is used to aggregate different sentiment representations, so that the multi-information aggregated sentiment representation modeled by the model can contain more information and more accurate sentiment knowledge.
[0118] In the embodiment of the disclosure, the attribute-aware aggregation module receives the semantic noise-aware representation and the multi-distance-aware representation as input, and obtains a gating value through a sigmoid function calculation. The gating value can be regarded as controlling how much information of the semantic noise-aware representation is input, and 1 minus the gating value represents how much information of the multi-distance-aware representation is input.
[0119] In the embodiment of the disclosure, the attribute-aware aggregation module mainly includes an attribute-aware aggregation attention unit 441. The attribute-aware aggregation attention mechanism aggregates different sentiment representations, so that the multi-information aggregated sentiment representation modeled by the model can contain more information and more accurate sentiment knowledge. The calculation method of the attribute-aware aggregation attention can refer to the above formula (14) and formula (15). The attribute-aware aggregation attention can automatically calculate how much information of the semantic noise-aware representation and the multi-distance-aware representation is needed for aggregation, which is used for subsequent calculation of sentiment polarity. The sigmoid function can be understood as a gating mechanism that controls how much information flows.
[0120] Subsequently, the semantic noise-aware representation and the multi-distance-aware representation are spliced to obtain a multi-information aggregated sentiment representation output by a splicing operation unit 442 of the attribute-aware aggregation module, and the calculation process is as follows:
[0121] h fm =[hsna h af h mda (19)
[0122] Here, the symbol ";" represents a concatenation operation, h fm This is a sentiment representation that aggregates more information and provides more accurate sentiment information, as output by the attribute-aware aggregation module.
[0123] In this embodiment, the semantic noise-aware attention can effectively utilize attribute words and multi-type distance guidance information to model semantic noise-aware representations. The multi-distance-aware GCN can effectively utilize the guidance information of the multi-distance-aware adjacency matrix to model multi-distance-aware representations. The above two representations are sentiment-related representations obtained through different modeling methods. The attribute-aware aggregation module can effectively aggregate the above two sentiment representations to obtain an aggregated representation, which is also a sentiment-related representation. By concatenating these three representations, the sentiment representation contains more information and more accurate sentiment information, making the prediction of sentiment polarity more accurate.
[0124] In S350, the obtained sentiment representation of multi-information aggregation is input into the sentiment prediction module, and the sentiment polarity of specific attribute words in the sentence is output.
[0125] The sentiment representation, aggregating multiple pieces of information, is input into the sentiment prediction module, which outputs the sentiment polarity of the sentence context with respect to the attribute words. In this embodiment, the calculation process of the sentiment prediction module is as follows:
[0126] h sc =W sc h fm +b sc (20)
[0127]
[0128] Among them, W sc and b sc h are the learnable parameters of the model. fm h represents the sentiment representation, which is a multi-information aggregation that contains more information and more accurate sentiment information, as output by the attribute-aware module. sc This represents the sentiment representation resulting from the aggregation of multiple information elements after passing through linear layer 451. This represents the sentiment polarity distribution of the attribute words output by the model after applying softmax 452. Softmax is a normalized exponential function.
[0129] The embodiment of the present disclosure provides a kind of overall framework, structure and model composition of attribute-level sentiment classification method of fusion multi-sentence and semantic distance perception and aggregation.The scheme provided by the embodiment of the present disclosure can explicitly identify and eliminate redundant information and interference information in sentence context, can fuse context distance, syntax dependency distance, semantic perception distance into attribute word related sentence representation coding and sentiment polarity prediction, overcome the problem that attribute-level sentiment classification method has not effectively identified and eliminated the redundancy and interference information of noise word, make model can learn more beneficial information, improve the modeling capability of model to sentiment information and the expression ability of model.Secondly, the different importance degree of each word in sentence with respect to specific attribute word in graph structure is explicitly considered, the different importance degree of each word in sentence with respect to specific attribute word can be effectively modeled and encoded, the problem that the different importance degree of each word in sentence with respect to specific attribute word has not been effectively modeled is overcome, so that the model can better capture the relevant sentiment expression of attribute word, further improve the expression ability of model.
[0130] In the embodiment of the present disclosure, context distance calculation can effectively inject the relative position distance between each word and attribute word into the model, syntax dependency distance can effectively inject the relative dependency syntax distance between each word and attribute word into the model, semantic perception distance calculation can effectively inject the perception distance between each word and attribute word and the perception information of attribute word length and sentence length into the model.Multiple distance perception adjacency matrix module can effectively integrate and utilize context distance, syntax dependency distance, semantic perception distance and other information to model multiple distance perception adjacency matrix.Semantic noise perception attention can effectively utilize attribute word and multiple type distance guide information to model semantic noise perception representation.Multiple distance perception GCN can effectively utilize the guide information of multiple distance perception adjacency matrix to model multiple distance perception representation.Attribute perception aggregation module can effectively aggregate different sentiment representations, so that the model can model more information amount and more accurate sentiment knowledge, further improve the sentiment understanding ability of model.
[0131] Figure 4 It is a schematic diagram of an attribute-level sentiment classification device provided by the embodiment of the present disclosure.As shown in Figure 4 The attribute-level sentiment classification device 400 provided by the embodiment of the present disclosure can include a multi-semantic and distance embedding module 410, a multiple distance perception adjacency matrix module 420, a semantic and syntax perception module 430, an attribute perception aggregation module 440 and a sentiment prediction module 450.
[0132] The multi-semantics and distance embedding module 410 is configured to obtain the context representation of the text and the attribute word in the text, the context distance between each word in the text and the attribute word, the context distance representation thereof, the syntactic dependency distance and the syntactic dependency distance representation thereof, and the semantic perception distance and the semantic perception distance representation thereof.
[0133] The multi-distance perception adjacency matrix module 420 is configured to obtain a multi-distance perception adjacency matrix according to the context distance, the syntactic dependency distance and the semantic perception distance between each word in the text and the attribute word.
[0134] The semantic and syntactic perception module 430 includes a semantic noise perception attention sub-module and a multi-distance perception graph convolution network. The semantic noise perception attention sub-module is configured to obtain a semantic noise perception representation according to the context representation of the text and the attribute word in the text, the context distance representation, the syntactic dependency distance representation and the semantic perception distance representation between each word in the text and the attribute word. The multi-distance perception graph convolution network is configured to obtain a multi-distance perception representation according to the multi-distance perception adjacency matrix.
[0135] The attribute perception aggregation module 440 is configured to obtain a multi-information aggregated sentiment representation according to the multi-distance perception representation and the semantic noise perception representation.
[0136] The sentiment prediction module 450 is configured to obtain a sentiment polarity of the attribute word according to the multi-information aggregated sentiment representation.
[0137] Figure 4 Other contents of the embodiments can be parameterized on the basis of the above other embodiments, which will not be described herein again.
[0138] Figure 5 FIG. 1 is a schematic diagram of another attribute-level sentiment classification device provided by an embodiment of the present disclosure. As shown in FIG. 1, the attribute-level sentiment classification device mainly includes a multi-semantics and distance embedding module 410, a multi-distance perception adjacency matrix module 420, a semantic and syntactic perception module 430, an attribute perception aggregation module 440 and a sentiment prediction module 450. Figure 5
[0139] The multi-semantics and distance embedding module 410 can further include a BERT embedding mapping unit 411, a context distance embedding mapping unit 412, a syntactic dependency distance embedding mapping unit 413 and a semantic perception embedding mapping unit 414. The BERT embedding mapping unit 411 is configured to obtain the context representation of the attribute word and the context representation of each word in the sentence. The context distance embedding mapping unit 412, the syntactic dependency distance embedding mapping unit 413 and the semantic perception embedding mapping unit 414 are respectively configured to obtain the syntactic dependency distance representation, the semantic perception distance representation and the context distance representation of each word in the sentence.
[0140] The multi-distance-aware adjacency matrix module 420 is configured to integrate the contextual distance, the syntactic dependency distance and the semantic-aware distance to generate a multi-distance-aware adjacency matrix.
[0141] The semantic and syntactic-aware module 430 mainly includes a semantic noise-aware attention unit 431 and a multi-distance-aware GCN 432, which are configured to eliminate noise information irrelevant to the attribute word and better model the association between different words with respect to the attribute word, to generate semantic noise-aware representations and multi-distance-aware representations containing more useful information.
[0142] The attribute-aware aggregation module 440 mainly includes an attribute-aware aggregation attention unit 441 and a concatenation operation unit 442, which are configured to generate attribute-aware aggregation representations, so as to obtain multi-information aggregated sentiment representations with more information.
[0143] The sentiment prediction module 450 can further include a linear layer 451 and a Softmax 452, which are configured to output the sentiment polarity of the specific attribute word in the sentence.
[0144] The attribute-level sentiment classification method provided by the embodiment of the present disclosure can effectively integrate the contextual distance, the syntactic dependency distance and the semantic-aware distance into the model, effectively alleviate the redundancy and noise information in the context of the sentence, and effectively learn and model the importance degree of each word in the sentence with respect to the attribute word in the graph structure. The multi-semantic and distance embedding module and the semantic noise-aware attention provided by the embodiment can effectively integrate the contextual distance, the syntactic dependency distance and the semantic-aware distance into the attribute word related sentence representation encoding and the sentiment polarity prediction, overcome the problem that the attribute-level sentiment classification method has not effectively identified and eliminated the redundant and interfering information of the noise word, enable the model to learn more useful information, and improve the modeling ability of the model for the sentiment information and the expression ability of the model. Further, the attribute-aware aggregation module is provided, which can effectively dynamically select the semantic noise-aware representation, the multi-distance-aware representation and the output representation of the attribute-aware aggregation attention to aggregate, so that the model can model the sentiment knowledge containing more information and more accurately, further improve the sentiment understanding ability of the model, and improve the performance of the attribute-level sentiment classification model, so that the sentiment polarity of the attribute word in the sentence can be more accurately determined.
[0145] Figure 6 FIG. 7 is a schematic diagram of another attribute-level sentiment classification device provided by the embodiment of the present disclosure. Figure 6 Embodiments and Figure 5The difference of the embodiment is that the input of the attribute-aware aggregation attention unit 441 includes not only the semantic noise-aware attention of the semantic noise-aware attention unit 431 input and the multi-distance-aware representation of the multi-distance-aware GCN 432 input, but also the representation of the attribute word of the BERT embedding mapping unit 411 input. For example, the above formula (14) can be modified as:
[0146] p af = σ (W af [h sna ; h mda ; h af ]) (22)
[0147] In the embodiments of the present disclosure, Figure 4 to Figure 6 The various modules in any embodiment are trained together. For example, the specific training process is that the sentence and attribute word in the training sample are input, and the prediction value of the model (i.e., the sentiment polarity of the attribute word in the training sample predicted by the model) is calculated through the above series of calculations. The prediction value and the true value (i.e., the true sentiment polarity of the attribute word in the training sample) are calculated through cross entropy to calculate the loss function, for example, the calculation formula of the loss function is as follows:
[0148]
[0149] In the above formula, D represents all training samples in the training data set, represents the sentiment polarity distribution of the specific attribute word in the sentence output by the model, and y represents the true sentiment polarity of the attribute word in the training sample.
[0150] The scheme proposed in the embodiments of the present disclosure can better identify the sentiment polarity of a specific attribute word in a sentence after the model is trained. The semantic noise-aware attention can effectively utilize the guiding information of the attribute word and the multi-type distance to model the semantic noise-aware representation; the proposed multi-distance-aware GCN can effectively utilize the guiding information of the multi-distance-aware adjacency matrix to model the multi-distance-aware representation; the proposed attribute-aware aggregation module can effectively aggregate different sentiment representations, so that the model can model sentiment knowledge containing more information and more accurate, and further improve the sentiment understanding ability of the model. The scheme proposed in the embodiments of the present disclosure can be widely applied in text classification. For example, it can be applied to service customer service scenarios, comment analysis scenarios, intelligent justice scenarios, intelligent education scenarios, etc.
[0151] Figure 4 to Figure 6 Any of the attribute-level sentiment classification devices shown can be a computer program (including program code, etc.) running in a computer device, for example, the attribute-level sentiment classification device can be an application software; the device can be used to execute the corresponding steps in the method provided by the embodiments of the present disclosure.Figure 4 to Figure 6 Any of the attribute-level sentiment classification apparatuses 400 shown can be used to Figure 4 the computer device in the corresponding embodiments.
[0152] Referring to Figure 7 , Figure 7 is a structural schematic diagram of a computer device provided by the embodiments of the present disclosure. As shown in the figure, Figure 7 the computer device in the embodiments of the present disclosure can include one or more processors 701, a memory 702, and an input / output interface 703. The processor 701, the memory 702, and the input / output interface 703 are connected through a bus 704. The memory 702 is configured to store a computer program, the computer program including program instructions, the input / output interface 703 is configured to receive and output data, such as for data interaction between a host computer and the computer device, or for data interaction between various virtual machines in the host computer; and the processor 701 is configured to execute the program instructions stored in the memory 702. The processor 701 can execute each step of the method shown in any of the above embodiments.
[0153] In some possible implementation manners, the processor 701 can be a central processing unit (CPU), and the processor can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0154] The memory 702 can include read-only memory and random access memory, and provide instructions and data for the processor 701 and the input / output interface 703. A portion of the memory 702 can also include non-volatile random access memory. For example, the memory 702 can also store device type information.
[0155] In specific implementations, the computer device can execute the implementation manners provided by each step of any of the above method embodiments through various functional modules and / or units built therein, and specific implementation manners can be referred to the implementation manners provided by each step of the figures shown in the above method embodiments, which will not be described herein again.
[0156] The embodiment of the present disclosure provides a computer device, which comprises a processor, an input and output interface, and a memory. The computer program in the memory is acquired by the processor, and each step of the method shown in any of the above embodiments is executed.
[0157] The embodiment of the present disclosure also provides a computer readable storage medium, which stores a computer program. The computer program is suitable for being loaded by the processor and performing the attribute-level sentiment classification method provided by each step of any of the above embodiments. For details, refer to the implementation manner provided by each step of any of the above embodiments, which will not be described here. In addition, the beneficial effects of using the same method will not be described here. For technical details not disclosed in the embodiment of the computer readable storage medium involved in the present disclosure, refer to the description of the method embodiment of the present disclosure. As an example, the computer program can be deployed to be executed on one computer device, or on multiple computer devices located in one place, or on multiple computer devices distributed in multiple places and interconnected through a communication network.
[0158] The computer readable storage medium can be the attribute-level sentiment classification apparatus provided by any of the above embodiments or the internal storage unit of the computer device, such as the hard disk or the memory of the computer device. The computer readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the computer readable storage medium can include both the internal storage unit and the external storage device of the computer device. The computer readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer readable storage medium can also be used to temporarily store data that has been output or will be output.
[0159] The embodiment of the present disclosure also provides a computer program product or a computer program, which comprises computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium. The processor executes the computer instructions, so that the computer device executes the method provided in any of the above embodiments.
[0160] The terms "first", "second", etc. in the specification and claims of the present disclosure and the drawings are used to distinguish different objects, rather than to describe a particular order. In addition, the term "comprising" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product or equipment including a series of steps or units is not limited to the steps or units listed, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, device, product or equipment.
[0161] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in general terms in the description. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present disclosure.
[0162] The method and related apparatus provided by the embodiments of the present disclosure are described with reference to the method flowchart and / or structural schematic diagram provided by the embodiments of the present disclosure. Each flow and / or block in the method flowchart and / or structural schematic diagram, and the combination of the flows and / or blocks in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor or other programmable application display devices to produce a machine, so that the instructions executed by the computer or other programmable application display devices produce a device that realizes the functions specified in the flow Figure 1 The functions specified in one flow or multiple flows and / or structural schematic Figure 1 The functions specified in one flow or multiple flows and / or structural schematic Figure 1 The functions specified in one flow or multiple flows and / or structural schematic Figure 1 The functions specified in one flow or multiple flows and / or structural schematic Figure 1 The functions specified in one flow or multiple flows and / or structural schematic
[0163] The above disclosure is merely the preferred embodiments of the present disclosure, and of course cannot be used to limit the scope of the present disclosure, so the equivalent changes made according to the claims of the present disclosure are still within the scope of the present disclosure.
Claims
1. An attribute level sentiment classification method characterized by, The method comprises the following steps: obtaining the context representation of the text and the attribute word in the text, the context distance between each word in the text and the attribute word, the context distance representation thereof, the syntactic dependency distance and the syntactic dependency distance representation thereof, and the semantic perception distance and the semantic perception distance representation thereof; obtaining a multi-distance perception adjacency matrix according to the context distance, the syntactic dependency distance and the semantic perception distance between each word in the text and the attribute word; obtaining a multi-distance perception representation according to the multi-distance perception adjacency matrix; obtaining a semantic noise perception representation according to the context representation of the text and the attribute word in the text, the context distance representation between each word in the text and the attribute word, the syntactic dependency distance representation and the semantic perception distance representation; obtaining a multi-information aggregation sentiment representation according to the multi-distance perception representation and the semantic noise perception representation; obtaining the sentiment polarity of the attribute word according to the multi-information aggregation sentiment representation.
2. The method of claim 1, wherein, The method comprises the following steps: Splicing a first character and a second character at two ends of the attribute word and the text respectively to obtain a splicing sequence of the attribute word and a splicing sequence of the text, the length of the splicing sequence of the attribute word is m+2, m is the length of the attribute word; the length of the splicing sequence of the text is n=m+2, m is the length of the text s +2, m s s are positive integers greater than or equal to 1; calculating the context distance between each word in the concatenated sequence of the text and the attribute word; and obtaining the context distance representation of each word in the concatenated sequence of the text according to the context distance between each word in the concatenated sequence of the text and the attribute word and a context distance embedding matrix; calculating the syntactic dependency distance between each word in the concatenated sequence of the text and the attribute word; and obtaining the syntactic dependency distance representation of each word in the concatenated sequence of the text according to the syntactic dependency distance between each word in the concatenated sequence of the text and the attribute word and a syntactic dependency distance embedding matrix; calculating the semantic perception distance between each word in the concatenated sequence of the text and the attribute word; and obtaining the semantic perception distance representation of each word in the concatenated sequence of the text according to the semantic perception distance between each word in the concatenated sequence of the text and the attribute word and a semantic perception distance embedding matrix.
3. The method of claim 2, wherein, The context distance con between the i-th word in the text and the attribute word is obtained according to the following formula i : wherein, l asp_left denotes the position of the leftmost word constituting the attribute word in the text; l asp_right denotes the position of the rightmost word constituting the attribute word in the text; l i denotes the position of the i-th word in the text, i being a positive integer greater than or equal to 1 and less than or equal to n.
4. The method of claim 2, wherein, The syntactic dependency distance dep between the i-th word in the text and the attribute word is obtained according to the following formula i : wherein, represents the shortest syntactic distance between the i-th word in the text and the attribute word in the syntactic dependency tree, if the attribute word comprises multiple words, the shortest syntactic distance between the rightmost word constituting the attribute word; k is a hyperparameter of syntactic dependency distance, k is an integer greater than 0 and less than n.
5. The method of claim 2, wherein, The semantic perception distance dis between the i-th word in the text and the attribute word is obtained according to the following formula i : wherein C i = 1 indicates that there is a direct syntactic connection between the attribute word and the i-th word in the text; C i = 0 indicates that there is an indirect syntactic connection or no syntactic connection between the attribute word and the i-th word in the text; l i denotes the position of the i-th word in the text, l asp_right denotes the position of the rightmost word constituting the attribute word in the text.
6. The method of claim 2, wherein, The multi-distance perception adjacency matrix is obtained according to the following formula: wherein, con i and con j respectively represent the contextual distance between the i-th word and the j-th word in the concatenation sequence of the text and the attribute word; dep i and dep j respectively represent the syntactic dependency distance between the i-th word and the j-th word in the concatenation sequence of the text and the attribute word; dis i and dis j respectively represent the semantic perception distance between the i-th word and the j-th word in the concatenation sequence of the text and the attribute word; represents the initial association weight of the i-th word and the j-th word in the concatenation sequence of the text; A i,j represents the association weight of the i-th word and the j-th word in the concatenation sequence of the text in the multi-distance perception adjacency matrix; i and j are both positive integers greater than or equal to 1 and less than or equal to n; k d is a hyperparameter of the multi-distance perception adjacency matrix.
7. The method of claim 6, wherein, The multi-distance perception representation is obtained by the following formula: wherein W mda , b mda are parameters of the multi-distance-aware graph convolutional network; and respectively represent the multi-distance aggregated representation of the i-th word in the concatenated sequence of the text output by the t-th layer and the t-1-th layer of the multi-distance-aware graph convolutional network, t is a positive integer greater than 1; represents the multi-distance aggregated representation of the i-th word in the concatenated sequence of the text output by the last layer of the multi-distance-aware graph convolutional network; h mda represents the multi-distance-aware representation output by the multi-distance-aware graph convolutional network.
8. The method of claim 2, wherein, The method comprises the following steps: obtaining the context representation of each word in the concatenated sequence of the text by using a pre-trained language model; obtaining the context representation of each word in the concatenated sequence of the attribute word by using a pre-trained language model; performing average pooling on the context representation of each word in the concatenated sequence of the attribute word to obtain the overall representation of the attribute word.
9. The method of claim 8, wherein, The semantic noise perception representation is obtained according to the following formula: wherein, respectively represent the context representation, the context distance representation, the syntax dependency distance representation, the semantic awareness distance representation of the i-th word in the concatenation sequence of the text; h asp represents the overall representation of the attribute word; represents the context semantic representation of the i-th word in the concatenation sequence of the text; W sn is a parameter of semantic noise-aware attention; and respectively represent the un-normalized semantic noise-aware attention weight of the i-th word and the j-th word in the concatenation sequence of the text; represents the normalized semantic noise-aware attention weight of the i-th word in the concatenation sequence of the text, h sna represents the semantic noise-aware representation of the semantic noise-aware attention output; i and j are both positive integers greater than or equal to 1 and less than or equal to n.
10. The method of claim 1, wherein, The multi-information aggregation sentiment representation is obtained according to the following formula: p af = σ(W af [ h sna ; h mda ]) h af = p af h sna + (1 - p af )h mda h fm = [h sna ; h af ; h mda ] wherein h sna represents the semantic noise-aware representation; h mda represents the multi-distance-aware representation; W af is a parameter of the attribute-aware aggregated attention; p af represents the weight of the attribute-aware aggregated attention with respect to the semantic noise-aware representation; h af represents the output representation of the attribute-aware aggregated attention; h fm is the sentiment representation of the multi-information aggregation.
11. An attribute level sentiment classification apparatus, characterized by, The method comprises the following steps: a multi-semantics and distance embedding module is configured to obtain the context representation of the text and the attribute word in the text, the context distance between each word in the text and the attribute word and the context distance representation thereof, the syntactic dependency distance and the syntactic dependency distance representation thereof, and the semantic perception distance and the semantic perception distance representation thereof; a multi-distance-aware adjacency matrix module, configured to obtain a multi-distance-aware adjacency matrix according to a context distance between each word in the text and the attribute word, a syntactic dependency distance, and a semantic-aware distance; a semantic and syntactic-aware module, including a semantic noise-aware attention sub-module and a multi-distance-aware graph convolution network, the semantic noise-aware attention sub-module being configured to obtain a semantic noise-aware representation according to a context representation of the text and the attribute word, a context distance representation between each word in the text and the attribute word, a syntactic dependency distance representation, and a semantic-aware distance representation, and the multi-distance-aware graph convolution network being configured to obtain a multi-distance-aware representation according to the multi-distance-aware adjacency matrix; an attribute-aware aggregation module, configured to obtain a multi-information-aggregated sentiment representation according to the multi-distance-aware representation and the semantic noise-aware representation; a sentiment prediction module, configured to obtain a sentiment polarity of the attribute word according to the multi-information-aggregated sentiment representation.
12. A computer device, comprising: a processor, a memory, and an input / output interface; the input / output interface is configured to receive and output data, the memory is configured to store a computer program, and the processor is configured to call the computer program to enable the computer device to perform the method in any one of claims 1-10.
13. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is adapted to be loaded and executed by the processor to enable the computer device having the processor to perform the method in any one of claims 1-10.
14. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the method in any one of claims 1-10.
Citation Information
Patent Citations
Text attribute word sentiment classification method based on deep learning network
CN112417157A
Text attribute word sentiment classification method and device, equipment and medium
CN116701638A