Text attribute word sentiment classification method, device, equipment and medium
By acquiring the context vector and attribute syntactic distance vector of text data, and using techniques such as embedding layers and syntactic adaptation layers, the problem of data dependence and insufficient perception ability in attribute-level sentiment classification in existing technologies is solved, and more accurate attribute word sentiment classification is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA TELECOM CORP LTD TECHNOLOGY INNOVATION CENTER
- Filing Date
- 2023-07-14
- Publication Date
- 2026-06-12
Smart Images

Figure CN116701638B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of natural language processing technology, and in particular to a method, apparatus, device, and medium for classifying the sentiment of text attribute words. Background Technology
[0002] Attribute-based sentiment classification aims to identify the sentiment polarity of attribute words in sentences. It is currently a hot research topic in the field of natural language processing and a key technology for achieving strong artificial intelligence and intelligent question answering. For example, product suppliers can use attribute-based sentiment classification methods to identify people's positive or negative evaluations of a product or its attributes from a large number of user text reviews, thereby making targeted improvements to the product and reducing the cost of manual research and analysis.
[0003] Traditional statistical machine learning methods utilize statistical machine models, such as support vector machines (SVM) and maximum entropy models, to mine the sentiment polarity of attribute words. However, such methods heavily rely on the quality of manually designed features, which is very time-consuming and labor-intensive.
[0004] Deep learning-based methods can automatically learn relevant features suitable for specific tasks, and can generate more abstract features as the number of layers increases. In attribute-level sentiment classification, neural networks such as Long Short-Term Memory (LSTM), Gated Learning Units (GRU), and Convolutional Neural Networks (CNN) have been widely used and achieved good performance.
[0005] In recent years, the large-scale attribute word sentiment classification model BERT has achieved great success in many natural language processing tasks, but such methods still have some shortcomings. For example, BERT cannot capture different contextual and sentiment information for different attribute words in a sentence; it cannot continuously update the semantic information of attribute-related sentences during the learning process; and its ability to model the syntactic information that attribute words depend on in a sentence is weak, as it does not explicitly model and learn syntactic knowledge related to attribute words.
[0006] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0007] This disclosure provides a method, apparatus, device, and medium for sentiment classification of text attribute words, which at least to some extent overcomes the problem in related technologies that rely on a large amount of manually labeled data and lack the ability to perceive machine-related information of attribute words in text data, thus failing to accurately determine the sentiment category of attribute words in text data.
[0008] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.
[0009] According to one aspect of this disclosure, a text attribute word sentiment classification method is provided, comprising: acquiring text data, wherein the text data includes multiple sentences, each sentence contains multiple words, and the multiple words include attribute words; determining the context vector, attribute word vector, and attribute syntactic distance vector of each word in a target sentence, wherein the target sentence is any sentence in the text data, and the attribute syntactic distance of the attribute word is the distance in syntactic structure between the word pair formed by the context words associated with the attribute word in the sentence and the attribute word; inputting the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into a pre-trained attribute word sentiment classification model, and outputting the sentiment classification result of the attribute words in the target sentence.
[0010] In some embodiments, determining the attribute syntactic distance of attribute words in a target sentence includes: determining attribute words in the target sentence; determining a first word and a second word corresponding to the attribute words in the target sentence, wherein the first word is a word appearing in the preceding context of the attribute word in the sentence, and the second word is a word appearing in the following context of the attribute word in the sentence; calculating a first attribute syntactic distance between the first word and the attribute word; calculating a second attribute syntactic distance between the second word and the attribute word; and determining the attribute syntactic distance of the attribute word based on the first attribute syntactic distance and the second attribute syntactic distance.
[0011] In some embodiments, the attribute syntactic distance of attribute words in the target sentence is obtained by the following formula:
[0012]
[0013] in, Let l represent the syntactic distance between the word pair consisting of the i-th and j-th words in a sentence and the attribute word. i Let l represent the number of jumps obtained by connecting the i-th word with the attribute word. j Let represent the number of hops obtained by connecting the j-th word with the attribute word, k represent the pre-set hop count threshold, [pad] represent the attribute distance vector when the i-th word and the j-th word have no relation to the attribute word in the syntactic structure, con(i,j) = 1 indicates that the i-th word and the j-th word have a relation to the attribute word in the syntactic structure, and con(i,j) = 0 indicates that the i-th word and the j-th word have no relation to the attribute word in the syntactic structure.
[0014] In some embodiments, the attribute word sentiment classification model includes: an embedding layer, an attribute word and syntax adaptation layer, a dynamic semantic adjustment layer, and an attribute word sentiment prediction layer. The embedding layer generates a context vector, an attribute word vector, and an attribute syntactic distance vector for each word in the target sentence based on the context information of each word, the attribute word, and the attribute syntactic distance vector between the attribute words. The attribute word and syntax adaptation layer generates an attribute syntactic perception vector for each word in the target sentence based on the context vector, attribute word vector, and attribute syntactic distance vector. The dynamic semantic adjustment layer generates a sentence vector corresponding to attribute-related sentences based on the attribute syntactic perception vector for each word in the target sentence. The attribute word sentiment prediction layer generates the sentiment classification result of the attribute words in the target sentence based on the sentence vector corresponding to the attribute-related sentences.
[0015] In some embodiments, the step of inputting the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into a pre-trained attribute word sentiment classification model and outputting the sentiment classification result of the attribute words in the target sentence includes: generating an attribute syntactic perception vector corresponding to each word in the target sentence based on the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence; generating a sentence vector corresponding to the attribute-related sentence based on the attribute syntactic perception vector corresponding to each word in the target sentence; and generating the sentiment classification result of the attribute words in the target sentence based on the sentence vector corresponding to the attribute-related sentence.
[0016] In some embodiments, the sentiment classification result of attribute words in the target sentence is obtained by the following formula:
[0017] p = Softmax(W p h m +b p )
[0018] h m =Relu(W m h b +b m )
[0019] in, This indicates the probability of the sentiment category corresponding to the output attribute word. This represents a distribution map of sentiment polarity, including the number of sentiment categories and their corresponding probabilities, where K represents the number of sentiment categories, and h represents the probability of each category. m h represents an intermediate quantity in the calculation. b The sentence vector represents the sentence corresponding to the attribute-related sentence. The Softmax and ReLU functions represent the activation functions. W m Wp b m and b p This represents the learning parameters of the sentiment prediction layer.
[0020] In some embodiments, the method further includes: based on an attention mechanism, inputting the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into a pre-trained attribute word sentiment classification model, and outputting the sentiment classification result of the attribute words in the target sentence.
[0021] According to another aspect of this disclosure, a text attribute word sentiment classification device is also provided, comprising: a text data acquisition module for acquiring text data, wherein the text data includes multiple sentences, each sentence contains multiple words, and the multiple words include attribute words; a data vector determination module for determining the context vector, attribute word vector, and attribute syntactic distance vector of each word in a target sentence, wherein the target sentence is any sentence in the text data, and the attribute syntactic distance of the attribute word is the distance in syntactic structure between the word pair formed by the context words associated with the attribute word in the sentence and the attribute word; and a sentiment classification result output module for inputting the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into a pre-trained attribute word sentiment classification model, and outputting the sentiment classification result of the attribute words in the target sentence.
[0022] According to another aspect of this disclosure, an electronic device is also provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the text attribute word sentiment classification method described above by executing the executable instructions.
[0023] According to another aspect of this disclosure, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the text attribute word sentiment classification method described in any of the preceding claims.
[0024] According to another aspect of this disclosure, a computer program product is also provided, including a computer program that, when executed by a processor, implements the text attribute word sentiment classification method of any of the above.
[0025] This disclosure provides a text attribute word sentiment classification method, apparatus, device, and medium. Based on acquired text data, it determines the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence. The obtained vector data is input into a pre-trained attribute word sentiment classification model, which outputs the sentiment classification result of the attribute words in the target sentence. This disclosure enhances the attribute word sentiment classification model's ability to perceive attribute words and their related information in text data, overcomes the model's weak ability to model attribute word-related information, improves the model's encoding ability for attribute word-related information, and thus more accurately determines the sentiment category of attribute words in text data.
[0026] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0027] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0028] Figure 1 This diagram illustrates a flowchart of a text attribute word sentiment classification method according to an embodiment of the present disclosure;
[0029] Figure 2 This diagram illustrates a sentiment classification model for attribute words in an embodiment of the present disclosure.
[0030] Figure 3 This diagram illustrates a flowchart of a text attribute word sentiment classification method according to an embodiment of the present disclosure;
[0031] Figure 4 This diagram illustrates a flowchart of a text attribute word sentiment classification method according to an embodiment of the present disclosure;
[0032] Figure 5 This diagram illustrates a text attribute word sentiment classification device according to an embodiment of the present disclosure.
[0033] Figure 6 A block diagram of an electronic device according to an embodiment of the present disclosure is shown;
[0034] Figure 7 A schematic diagram of a computer-readable storage medium according to an embodiment of the present disclosure is shown. Detailed Implementation
[0035] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0036] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0037] Figure 1 This diagram illustrates a flowchart of a text attribute word sentiment classification method according to an embodiment of the present disclosure, such as... Figure 1 As shown, the method includes the following steps:
[0038] S102, Obtain text data, wherein the text data includes multiple sentences, each sentence contains multiple words, and the multiple words contain attribute words.
[0039] In one embodiment of this disclosure, the text data to be analyzed may be text fragments directly input by researchers or obtained directly by the model from other means, such as articles, short sentences, comments, etc. The text data may contain multiple sentences, each sentence may contain multiple words, and the multiple words may contain attribute words, which may be an entity containing features.
[0040] S104, determine the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence. The target sentence is any sentence in the text data. The attribute syntactic distance of the attribute word is the distance between the word pair formed by the context words associated with the attribute word in the sentence and the attribute word in terms of syntactic structure.
[0041] In one embodiment of this disclosure, the target sentence can refer to any sentence determined from text data; the attribute syntactic distance vector of the attribute word is obtained by performing structural analysis on the target sentence through dependency parsing, based on the distance between the word pair formed by the context words associated with the attribute word in the sentence and the attribute word in terms of syntactic structure. Dependency parsing determines the syntactic structure of a sentence by analyzing the dependency relationships between words in the sentence.
[0042] S106: Input the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into the pre-trained attribute word sentiment classification model, and output the sentiment classification result of the attribute words in the target sentence.
[0043] In one embodiment of this disclosure, the sentiment classification result of an attribute word can refer to the multiple possible sentiment classification results corresponding to the attribute word and their corresponding probability values.
[0044] As described above, the method in this embodiment determines the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence based on the acquired text data. The obtained vector data is then input into a pre-trained attribute word sentiment classification model, outputting the sentiment classification result of the attribute words in the target sentence. This disclosure enhances the attribute word sentiment classification model's ability to perceive attribute words and their related information in text data, overcomes the model's weak ability to model attribute word-related information, improves the model's encoding ability for attribute word-related information, and thus more accurately determines the sentiment category of attribute words in text data.
[0045] In one embodiment of this disclosure, S104 includes: determining attribute words in a target sentence; determining a first word and a second word corresponding to the attribute words in the target sentence, wherein the first word is a word appearing in the preceding information of the attribute words in the sentence, and the second word is a word appearing in the following information of the attribute words in the sentence; calculating a first attribute syntactic distance between the first word and the attribute words; calculating a second attribute syntactic distance between the second word and the attribute words; and determining the attribute syntactic distance of the attribute words based on the first attribute syntactic distance and the second attribute syntactic distance.
[0046] It should be noted that the first and second words do not refer to ordinary English words, but rather to words composed of one or more morphemes in grammar, where a morpheme is the smallest grammatical unit. For example, "horse" is a word composed of one morpheme, and "water cup" is a word composed of two morphemes.
[0047] In one embodiment of this disclosure, the attribute syntactic distance vector of the attribute words in the target sentence can be obtained by the following formula in S104:
[0048]
[0049] in, Let l represent the syntactic distance between the word pair consisting of the i-th and j-th words in a sentence and the attribute word. i Let l represent the minimum number of hops required to connect the i-th word with the attribute word. jLet represent the minimum number of hops obtained by connecting the j-th word with the attribute word, k represent the pre-set hop threshold, [pad] represent the attribute distance vector when the i-th word and the j-th word have no relation to the attribute word in the syntactic structure, con(i,j) = 1 indicates that the i-th word and the j-th word have a relation to the attribute word in the syntactic structure, and con(i,j) = 0 indicates that the i-th word and the j-th word have no relation to the attribute word in the syntactic structure.
[0050] It should be noted that the preset hop count threshold can be set to 5 and can be adjusted according to training experience and actual conditions. This embodiment does not specifically limit the preset hop count threshold.
[0051] In one embodiment of this disclosure, dependency parsing methods can be used to obtain the connection relationships between each word and attribute words in a sentence, thereby determining the attribute syntactic distance between each word and attribute words; it can also be determined whether the two words in each word pair can be connected by attribute words, thereby determining the attribute syntactic distance between each word and attribute words. It should be noted that dependency parsing tools can be used out-of-the-box to perform dependency parsing to obtain a dependency syntactic structure graph, such as the Stanza Python toolkit for natural language processing; this disclosure does not specifically limit this approach.
[0052] In one embodiment of this disclosure, the attribute word sentiment classification model includes: an embedding layer, an attribute word and syntactic adaptation layer, a dynamic semantic adjustment layer, and an attribute word sentiment prediction layer. The embedding layer generates a context vector, an attribute word vector, and an attribute syntactic distance vector for each word in the target sentence based on the context information of each word in the target sentence, the attribute word, and the attribute syntactic distance vector between the attribute words. The attribute word and syntactic adaptation layer generates an attribute syntactic perception vector for each word in the target sentence based on the context vector, attribute word vector, and attribute syntactic distance vector. The dynamic semantic adjustment layer generates a sentence vector corresponding to attribute-related sentences based on the attribute syntactic perception vector for each word in the target sentence. The attribute word sentiment prediction layer generates the sentiment classification result of the attribute words in the target sentence based on the sentence vector corresponding to the attribute-related sentences.
[0053] In one embodiment of this disclosure, the given sentence context information can be S = {w1, w2, ..., w...} n}, where S represents the context of the current sentence, w n Let A represent the nth word in the sentence, and let the attribute word A = {a1, a2, ..., a...}. m}, where A represents the set of attribute words, a m This represents the m-th attribute word, and the attribute syntactic distance information of the attribute word. Where D represents the set of attribute syntactic distances, This represents the attribute syntactic distance between the nth word in a sentence and the attribute word, where n can be the same or different.
[0054] In one embodiment of this disclosure, mapping each word and attribute word in a sentence to an embedding matrix in the BERT attribute word sentiment classification model may include mapping via a normal distribution or random initialization to generate a context vector for each word in the sentence. Where Hc represents the set of context vectors for each word. This represents the context vector corresponding to the nth word and the word vector of the attribute word. Among them, H a The set of word vectors representing attribute words. Let h represent the word vector of the m-th attribute word. The word vectors of the attribute words are then subjected to average pooling to obtain the overall vector h of the attribute words. a .
[0055] In one embodiment of this disclosure, the attribute syntactic distance of attribute words can be mapped using a learnable syntactic distance embedding matrix to obtain the attribute syntactic distance vector of the attribute words. Among them, H r The set representing the attribute syntactic distance vectors. This represents the attribute syntactic distance vector between the nth word, the word pair formed by the nth word, and the attribute word in the sentence. The value of n can be the same or different.
[0056] It should be noted that the overall vector of attribute words can also be obtained using a Long Short-Term Memory (LSTM) network combined with an attention mechanism; this embodiment does not specifically limit this approach. Using average pooling is relatively simple and fast, without introducing additional complex calculations and operations; other methods may complicate the model structure and computation process.
[0057] In one embodiment of this disclosure, S106 includes: generating an attribute syntax-aware vector corresponding to each word in the target sentence based on the context vector, attribute word vector, and attribute syntax distance vector of each word in the target sentence; generating a sentence vector corresponding to the attribute-related sentence based on the attribute syntax-aware vector corresponding to each word in the target sentence; and generating a sentiment classification result of the attribute words in the target sentence based on the sentence vector corresponding to the attribute-related sentence.
[0058] In one embodiment of this disclosure, the attribute syntactic-aware vector corresponding to each word can be obtained by the following formula:
[0059]
[0060]
[0061]
[0062]
[0063] p ij =Softmax(e ij (6)
[0064]
[0065] in, It is the output of the self-attention mechanism. This represents the context vector corresponding to the i-th word. Let represent the context vector corresponding to the j-th word, and d represent the dimension of the context vector corresponding to the word. It is the output of the attribute word adapter attention mechanism. This represents the word vector of the i-th attribute word. It is the output of the syntactic structure adapter attention mechanism. e represents the syntactic distance between the word pair consisting of the i-th and j-th words and the attribute word. ij p represents the unnormalized attention weights. ij z represents the normalized attention weights. i W is the attribute syntax-aware vector of the i-th word, which is the final output of the attribute word and the syntax adapter layer. Q W K and W V These are the learning parameters for attribute words and the syntactic adapter layer.
[0066] In one embodiment of this disclosure, the attribute syntactic-aware vector of each word in the sentence is added to the context vector of each word and then subjected to layer regularization calculation to obtain the attribute syntactic-aware vector of each word after regularization output.
[0067] In one embodiment of this disclosure, the attribute syntactic-aware vector of each word after regularization can be obtained by the following formula:
[0068]
[0069] in, Let represent the attribute syntactic-aware vector of the i-th word after regularization. Let z represent the context vector corresponding to the i-th word. i Let LN(·) represent the attribute syntactic-aware vector of the i-th word, and LN(·) denote layer regularization. This indicates element-wise addition.
[0070] In one embodiment of this disclosure, the data can be received via a feedforward neural network (FNN). As input, we obtain the attribute syntactic-aware vector of each word output by the FNN.
[0071] In one embodiment of this disclosure, the sentence vector h, which is the output of the target sentence after attribute-aware attention computation, can be obtained through a semantic adjustment network. t The sentence vector output by attribute-aware attention computation on the target sentence can be obtained using the following formula:
[0072]
[0073]
[0074]
[0075] in, h represents the attention weight corresponding to the i-th word. a Represents the overall vector of attribute words. Let represent the attribute syntactic-aware vector of the i-th word after regularization. h represents the attribute syntactic-aware vector of the j-th word after regularization. t-1 h represents the sentence vector output after attribute-aware attention computation at step t-1. t Let represent the sentence vector output by attribute-aware attention at step t in the LSTM, where t∈[1,T] is the number of steps in the semantic adjustment network, and T is a hyperparameter.
[0076] In one embodiment of this disclosure, the output vector of the semantic adjustment network in the last step is added to the output vector of the FNN to serve as the output of the current word in the dynamic semantic adjustment layer, ultimately obtaining the output word vector matrix corresponding to the target sentence that integrates dynamic semantic and syntactic information. Among them, H B This represents the output word vector matrix that integrates dynamic semantic and syntactic information. This represents the output word vector corresponding to the nth word, which integrates dynamic semantic and syntactic information.
[0077] In one embodiment of this disclosure, the output word vector, which integrates dynamic semantic and syntactic information, corresponding to each word can be calculated using the following formula:
[0078]
[0079] in, h represents the output word vector corresponding to the i-th word, which integrates dynamic semantic and syntactic information. t This represents the sentence vector output by attribute-aware attention computation at step t in the LSTM. Let LN(·) represent the attribute syntactic awareness vector of the i-th word output by the FNN, and let LN(·) represent layer regularization. This indicates element-wise addition.
[0080] In one embodiment of this disclosure, max pooling can be performed on the output word vector matrix corresponding to the target sentence, which integrates dynamic semantic and syntactic information, to obtain the sentence vector corresponding to the attribute-related sentence. Max pooling can be calculated using the following formula:
[0081] h b =maxpooling(H B (13)
[0082] Among them, h b H represents the sentence vector corresponding to the attribute-related sentences. B This represents the output word vector matrix that incorporates dynamic semantic and syntactic information.
[0083] It should be noted that average pooling can also be used to calculate the sentence vectors corresponding to attribute-related sentences, and this disclosure does not impose any specific restrictions on this.
[0084] In one embodiment of this disclosure, the attribute word and syntactic adapter layer and the dynamic semantic adjustment layer can be combined into a single structure for multi-layer computation. This structure can be repeated K times, with the output of the dynamic semantic adjustment layer used as the input for the next attribute word and syntactic adapter layer, forming a K-layer network. The advantage of multi-layer computation is its ability to extract more abstract semantic information; however, a larger number of layers can also lead to model fitting issues. It should be noted that the value of K in this embodiment is a hyperparameter and can be adjusted based on actual performance. This embodiment does not impose a specific limitation on the value of K.
[0085] In one embodiment of this disclosure, the sentiment classification result of the attribute words in the target sentence can be obtained by the following formula in step S106:
[0086] p = Softmax(W p h m +b p (14)
[0087] h m =Relu(W m h b +bm (15)
[0088] in, This indicates the probability of the sentiment category corresponding to the output attribute word. This represents a distribution map of sentiment polarity, including the number of sentiment categories and their corresponding probabilities, where K represents the number of sentiment categories, and h represents the probability of each category. m h represents an intermediate quantity in the calculation. b The sentence vector represents the sentence corresponding to the attribute-related sentence. The Softmax and ReLU functions represent the activation functions. W m W p b m and b p This represents the learning parameters of the sentiment prediction layer.
[0089] In one embodiment of this disclosure, S106 includes: based on an attention mechanism, inputting the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into a pre-trained attribute word sentiment classification model, and outputting the sentiment classification result of the attribute words in the target sentence.
[0090] For example, when the emotion categories are divided into positive, negative, and neutral, K is 3. Assuming that the obtained emotion polarity distribution p is [0.7, 0.2, 0.1], then the probability of representing a positive emotion is 0.7, the probability of representing a negative emotion is 0.2, and the probability of representing a neutral emotion is 0.1.
[0091] Figure 2 This diagram illustrates a sentiment classification model for attribute words in an embodiment of the present disclosure, such as... Figure 2 As shown, the model 20 includes: an embedding layer 201, an attribute word and syntax adaptation layer 202, a dynamic semantic adjustment layer 203, and an attribute word sentiment prediction layer 204.
[0092] The embedding layer 201 generates context vectors, attribute word vectors, and attribute syntactic distance vectors for each word in the target sentence based on the context information, attribute words, and attribute syntactic distances of each attribute word. The attribute word and syntax adaptation layer 202 generates attribute syntactic perception vectors for each word in the target sentence based on the context vectors, attribute word vectors, and attribute syntactic distance vectors of each word. The dynamic semantic adjustment layer 203 generates sentence vectors for attribute-related sentences based on the attribute syntactic perception vectors for each word in the target sentence. The attribute word sentiment prediction layer 204 generates sentiment classification results for attribute words in the target sentence based on the sentence vectors for attribute-related sentences.
[0093] As described above, the model in this embodiment can be used to determine the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence based on the acquired text data. The obtained vector data is then input into a pre-trained attribute word sentiment classification model, which outputs the sentiment classification result of the attribute words in the target sentence. This disclosure enhances the attribute word sentiment classification model's ability to perceive attribute words and their related information in text data, overcomes the model's weak ability to model attribute word-related information, and improves the model's encoding ability for attribute word-related information, thereby more accurately determining the sentiment category of attribute words in text data.
[0094] Figure 3 This diagram illustrates a flowchart of a text attribute word sentiment classification method according to an embodiment of the present disclosure, such as... Figure 3 As shown, the method includes the following steps:
[0095] S302, input the context information of the sentence, attribute words, and attribute syntactic distance of attribute words into the embedding layer to obtain the context vector, attribute word vector, and attribute syntactic distance vector of each word in the sentence.
[0096] In one embodiment of this disclosure, the embedding layer may consist of an embedding matrix in BERT and a learnable syntactic distance embedding matrix.
[0097] S304. Input the context vector, attribute word vector, and attribute syntactic distance vector of each word in the sentence to the attribute word and syntactic adapter layer. Use the self-attention mechanism to model the overall semantic information of the sentence, use the attribute word adapter attention mechanism to model the context information related to the attribute words, and use the syntactic structure adapter attention mechanism to model the syntactic structure information related to the attribute words, to obtain the attribute syntactic perception vector corresponding to each word in the sentence.
[0098] In one embodiment of this disclosure, the attribute word and syntactic adapter layer may consist of a self-attention mechanism, an attribute word adapter attention mechanism, and a syntactic structure adapter attention mechanism.
[0099] In one embodiment of this disclosure, the attribute word adapter attention mechanism can effectively enable the attribute word sentiment classification model to capture and model the contextual information related to attribute words in a sentence, overcoming the problem that the attribute word sentiment classification model is weak in modeling the specific contextual information of attribute words, enabling the attribute word sentiment classification model to have the ability to perceive attribute word information, and improving the model's ability to encode the contextual information of attribute words.
[0100] In one embodiment of this disclosure, the syntactic structure adapter attention mechanism can effectively model the syntactic structure information dependent on attribute words, overcoming the problem that the attribute word sentiment classification model has weak modeling of syntactic information. It enables the attribute word sentiment classification model to learn attribute-related syntactic knowledge and improves the model's ability to encode attribute-related syntactic structure information.
[0101] In one embodiment of this disclosure, the fusion of multiple adapter attention mechanisms can further enhance the ability of the attribute word sentiment classification model to understand and represent attribute-related contextual information and attribute-related syntactic information.
[0102] S306 inputs the attribute syntax-aware vector corresponding to each word in the sentence into the dynamic semantic adjustment layer, dynamically learns the overall semantics of the sentence related to the attributes, and outputs the sentence vector corresponding to the attribute-related sentence.
[0103] In one embodiment of this disclosure, the dynamic semantic adjustment layer may consist of an FNN and a semantic adjustment network, wherein the semantic adjustment network may consist of an LSTM and an attribute-aware attention mechanism.
[0104] In one embodiment of this disclosure, the dynamic semantic adjustment layer can effectively encode sentence representations dynamically based on multiple attribute-related information, overcoming the problem that the attribute word sentiment classification model is weak in modeling the dynamic semantics of sentences about attribute words. It can continuously update the attribute-related sentence semantic information during the learning process, further enhancing the attribute word sentiment classification model's ability to encode and model attribute-related semantic information.
[0105] S308, after multiple stacked calculations, inputs the sentence vectors corresponding to the attribute-related sentences output by the last layer into the sentiment prediction layer, and outputs the sentiment classification results of the attribute words.
[0106] In one embodiment of this disclosure, the sentiment prediction layer may consist of a multilayer perceptron and an activation function Softmax.
[0107] Figure 4 This diagram illustrates a flowchart of a text attribute word sentiment classification method according to an embodiment of the present disclosure, such as... Figure 4 As shown, the method includes the following steps:
[0108] S401, Input the context information of the sentence.
[0109] S402, Input the attribute words in the sentence.
[0110] S403, Input attribute syntactic distance of attribute words.
[0111] In one embodiment of this disclosure, the attribute syntactic distance of an attribute word can be obtained by the above formula (1).
[0112] S404 uses BERT embedding to map the context information and attribute words of the sentence, outputting the context vector and attribute word vector of each word in the sentence.
[0113] S405: Based on the attribute syntactic distance of the attribute words, the syntactic distance is mapped using the syntactic distance embedding method, and the attribute syntactic distance vector of the attribute words is output.
[0114] S406 inputs the context vector, attribute word vector, and attribute syntactic distance vector of each word in the sentence into the self-attention mechanism to model the overall semantic information of the sentence.
[0115] In one embodiment of this disclosure, the overall semantic information of a sentence can be obtained through the above formula (2).
[0116] S407 inputs the context vector of each word in the sentence, the word vector of the attribute word, and the attribute syntactic distance vector of the attribute word into the attribute word adapter attention mechanism to model the context information related to the attribute word.
[0117] In one embodiment of this disclosure, the contextual information related to the attribute word can be obtained through the above formula (3).
[0118] S408 inputs the context vector of each word in the sentence, the word vector of the attribute word, and the attribute syntactic distance vector of the attribute word into the syntactic structure adapter attention mechanism to model the syntactic structure information related to the attribute word.
[0119] In one embodiment of this disclosure, the syntactic structure information related to attribute words can be obtained through the above formula (4).
[0120] S409, based on the attribute syntax-aware vector of each word output by the attention mechanism, combined with the context vector of each word in the sentence, after addition and layer regularization, outputs the attribute syntax-aware vector corresponding to each word.
[0121] In one embodiment of this disclosure, the attribute syntactic-aware vector of each word can be obtained by the above formulas (5) to (7).
[0122] In one embodiment of this disclosure, the attribute syntax-aware vector of each word after regularization can be obtained by formula (8) above.
[0123] S410, input the attribute syntax-aware vector corresponding to each word into the feedforward neural network to generate the attribute syntax-aware vector corresponding to each word output by the feedforward neural network.
[0124] S411, input the attribute syntax-aware vector corresponding to each word output by the feedforward neural network to the attribute-aware attention mechanism to generate the attribute syntax-aware vector corresponding to each word output by the attribute-aware attention calculation.
[0125] In one embodiment of this disclosure, the attribute syntactic awareness vector corresponding to each word in the attribute-aware attention calculation output can be obtained through the above formulas (9) to (10).
[0126] S412, input the attribute-aware syntax vector corresponding to each word output by the attribute-aware attention calculation into the LSTM to generate the attribute-aware syntax vector corresponding to each word output by the LSTM.
[0127] In one embodiment of this disclosure, the attribute syntax-aware vector corresponding to each word output by the LSTM can be obtained by the above formula (11).
[0128] S413: The attribute syntactic awareness vectors corresponding to each word output by the LSTM are combined with the attribute syntactic awareness vectors corresponding to each word output by the feedforward neural network. The results are then summed and layer regularized to generate an output word vector matrix that integrates dynamic semantic and syntactic information.
[0129] In one embodiment of this disclosure, the output word vector matrix corresponding to the sentence, which integrates dynamic semantic and syntactic information, can be obtained through the above formula (12).
[0130] S414 performs max pooling on the output word vector matrix that integrates dynamic semantic and syntactic information to obtain the sentence vectors corresponding to attribute-related sentences.
[0131] In one embodiment of this disclosure, the sentence vector corresponding to the attribute-related sentence can be obtained by the above formula (13).
[0132] S415, input the sentence vector corresponding to the attribute-related sentence into the Multilayer Perceptron (MLP) to generate the sentence vector corresponding to the attribute-related sentence after calculation by the ReLU activation function.
[0133] S416: Input the sentence vectors corresponding to the attribute-related sentences output by the ReLU function into the Softmax function for calculation, and generate the attribute word sentiment polarity distribution output by the Softmax activation function.
[0134] S417. Based on the sentiment polarity distribution of the attribute words calculated by the Softmax function, the sentiment classification results of the attribute words are obtained.
[0135] In one embodiment of this disclosure, the sentiment classification result of the attribute words can be obtained by the above formulas (14) to (15).
[0136] It should be noted that S401 to S403 can be executed simultaneously or in any order. This embodiment does not specify the execution order of the above steps.
[0137] It should be noted that S406 to S408 can be executed simultaneously or in any order. This embodiment does not specify the execution order of the above steps.
[0138] Based on the same inventive concept, this disclosure also provides a text attribute word sentiment classification device, as described in the following embodiments. Since the principle by which this device solves the problem is similar to that of the above-described method embodiments, the implementation of this device embodiment can refer to the implementation of the above-described method embodiments, and repeated details will not be elaborated further.
[0139] Figure 5 This diagram illustrates a text attribute word sentiment classification device according to an embodiment of the present disclosure, such as... Figure 5 As shown, the device 50 includes: a text data acquisition module 501, a data vector determination module 502, and a sentiment classification result output module 503.
[0140] The system includes a text data acquisition module 501, which acquires text data, including multiple sentences, each containing multiple words, and attribute words among the words. A data vector determination module 502 determines the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence. The target sentence is any sentence in the text data, and the attribute syntactic distance is the distance in syntactic structure between the word pair formed by the context words associated with the attribute word and the attribute word itself. A sentiment classification result output module 503 inputs the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into a pre-trained attribute word sentiment classification model and outputs the sentiment classification result of the attribute words in the target sentence.
[0141] As described above, in this embodiment, the device is used to determine the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence based on the acquired text data. The obtained vector data is then input into a pre-trained attribute word sentiment classification model, and the sentiment classification result of the attribute words in the target sentence is output. This disclosure enhances the attribute word sentiment classification model's ability to perceive attribute words and their related information in text data, overcomes the model's weak ability to model attribute word-related information, improves the model's encoding ability for attribute word-related information, and thus more accurately determines the sentiment category of attribute words in text data.
[0142] In one embodiment of this disclosure, the data vector determination module 502 can also be used to determine attribute words in the target sentence; determine the first word and the second word corresponding to the attribute word in the target sentence, wherein the first word is a word in the sentence that appears in the preceding information of the attribute word, and the second word is a word in the sentence that appears in the following information of the attribute word; calculate the first attribute syntactic distance between the first word and the attribute word; calculate the second attribute syntactic distance between the second word and the attribute word; and determine the attribute syntactic distance of the attribute word based on the first attribute syntactic distance and the second attribute syntactic distance.
[0143] In one embodiment of this disclosure, the data vector determination module 502 can also obtain the attribute syntactic distance of the attribute words in the target sentence through the above formula (1).
[0144] In one embodiment of this disclosure, the attribute word sentiment classification model includes: an embedding layer, an attribute word and syntactic adaptation layer, a dynamic semantic adjustment layer, and an attribute word sentiment prediction layer. The embedding layer generates a context vector, an attribute word vector, and an attribute syntactic distance vector for each word in the target sentence based on the context information of each word in the target sentence, the attribute word, and the attribute syntactic distance vector between the attribute words. The attribute word and syntactic adaptation layer generates an attribute syntactic perception vector for each word in the target sentence based on the context vector, attribute word vector, and attribute syntactic distance vector. The dynamic semantic adjustment layer generates a sentence vector corresponding to attribute-related sentences based on the attribute syntactic perception vector for each word in the target sentence. The attribute word sentiment prediction layer generates the sentiment classification result of the attribute words in the target sentence based on the sentence vector corresponding to the attribute-related sentences.
[0145] In one embodiment of this disclosure, the sentiment classification result output module 503 is further configured to generate an attribute syntax perception vector corresponding to each word in the target sentence based on the context vector, attribute word vector, and attribute syntax distance vector of each word in the target sentence; generate a sentence vector corresponding to the attribute-related sentence based on the attribute syntax perception vector corresponding to each word in the target sentence; and generate the sentiment classification result of the attribute words in the target sentence based on the sentence vector corresponding to the attribute-related sentence.
[0146] In one embodiment of this disclosure, the sentiment classification result output module 503 is also used to obtain the sentiment classification result of the attribute words in the target sentence through the above formulas (14) to (15).
[0147] In one embodiment of this disclosure, the sentiment classification result output module 503 is further configured to input the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into a pre-trained attribute word sentiment classification model based on an attention mechanism, and output the sentiment classification result of the attribute words in the target sentence.
[0148] Those skilled in the art will understand that various aspects of this disclosure can be implemented as a system, method, or program product. Therefore, various aspects of this disclosure can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "system."
[0149] Figure 6 A block diagram of an electronic device according to an embodiment of the present disclosure is shown. Referring below... Figure 6 To describe an electronic device 600 according to such an embodiment of the present disclosure. Figure 6 The electronic device 600 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.
[0150] like Figure 6 As shown, the electronic device 600 is manifested in the form of a general-purpose computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, and a bus 630 connecting different system components (including storage unit 620 and processing unit 610).
[0151] The storage unit stores program code that can be executed by the processing unit 610, causing the processing unit 610 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. For example, the processing unit 610 can perform the following steps of the above method embodiments: acquiring text data, wherein the text data includes multiple sentences, each sentence contains multiple words, and the multiple words include attribute words; determining the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence, wherein the target sentence is any sentence in the text data, and the attribute syntactic distance of the attribute word is the distance in syntactic structure between the word pair formed by the context words associated with the attribute word in the sentence and the attribute word; inputting the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into a pre-trained attribute word sentiment classification model, and outputting the sentiment classification result of the attribute words in the target sentence.
[0152] Storage unit 620 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 6201 and / or cache memory 6202, and may further include a read-only memory (ROM) 6203.
[0153] Storage unit 620 may also include a program / utility 6204 having a set (at least one) program module 6205, such program module 6205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0154] Bus 630 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0155] Electronic device 600 can also communicate with one or more external devices 640 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 600, and / or with any device that enables electronic device 600 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 650. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 660. As shown, network adapter 660 communicates with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0156] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0157] In particular, according to embodiments of this disclosure, the process described above with reference to the flowchart can be implemented as a computer program product, which includes a computer program that, when executed by a processor, implements the above-described text attribute word sentiment category method.
[0158] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, which may be a readable signal medium or a readable storage medium. Figure 7 This illustration shows a schematic diagram of a computer-readable storage medium according to an embodiment of the present disclosure, such as... Figure 7 As shown, the computer-readable storage medium stores a program product 700 capable of implementing the methods described above. In some possible embodiments, various aspects of this disclosure may also be implemented as a program product comprising program code that, when run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure.
[0159] More specific examples of computer-readable storage media in this disclosure may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0160] In this disclosure, a computer-readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting a program for use by or in connection with an instruction execution system, apparatus, or device.
[0161] Optionally, the program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0162] In practical implementation, program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0163] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0164] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.
[0165] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0166] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the appended claims.
Claims
1. A method for sentiment classification of text attribute words, characterized in that, include: Acquire text data, wherein the text data includes multiple sentences, each sentence contains multiple words, and the multiple words include attribute words; Determine the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence, wherein the target sentence is any sentence in the text data, and the attribute syntactic distance of the attribute word is the distance between the word pair formed by the context words associated with the attribute word in the sentence and the attribute word in terms of syntactic structure; The context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence are input into a pre-trained attribute word sentiment classification model, and the sentiment classification result of the attribute words in the target sentence is output. The attribute word sentiment classification model comprises: an attribute word and syntax adaptation layer, a dynamic semantic adjustment layer, and an attribute word sentiment prediction layer. The attribute word and syntax adaptation layer utilizes a self-attention mechanism to model the overall semantic information of the sentence, an attribute word adapter attention mechanism to model the contextual information related to attribute words, and a syntax structure adapter attention mechanism to model the syntactic structure information related to attribute words, thereby obtaining an attribute syntax-aware vector corresponding to each word in the target sentence. The dynamic semantic adjustment layer generates sentence vectors corresponding to attribute-related sentences based on the attribute syntax-aware vectors corresponding to each word in the target sentence. The attribute word sentiment prediction layer generates the sentiment classification result of the attribute words in the target sentence based on the sentence vectors corresponding to the attribute-related sentences.
2. The method of claim 1, wherein the sentiment classification of the text attribute word is performed by: The determination of the attribute syntactic distance of attribute words in the target sentence includes: Identify the attribute words in the target sentence; Determine the first word and the second word corresponding to the attribute word in the target sentence, wherein the first word is the word in the sentence that appears in the preceding information of the attribute word, and the second word is the word in the sentence that appears in the following information of the attribute word; Calculate the first attribute syntactic distance between the first word and the attribute word; Calculate the second attribute syntactic distance between the second word and the attribute word; The attribute syntactic distance of the attribute word is determined based on the first attribute syntactic distance and the second attribute syntactic distance.
3. The text attribute word sentiment classification method according to claim 2, characterized in that, The attribute syntactic distance of attribute words in the target sentence can be obtained using the following formula: in, Indicates the first character in the sentence. The word, the first The syntactic distance between word pairs consisting of individual words and attribute words. Indicates the first The number of jumps obtained by connecting each word with its attribute word Indicates the first The number of jumps obtained by connecting each word with its attribute word This indicates the preset hop count threshold. Indicates when the first The word and the first The attribute distance vector when a word and its attribute words have no relation in the syntactic structure. Indicates the first The word and the first The individual words and attribute words are related in syntactic structure. Indicates the first The word and the first The individual words and attribute words have no relation in the syntactic structure.
4. The text attribute word sentiment classification method according to claim 1, characterized in that, The attribute word sentiment classification model also includes: an embedding layer; The embedding layer is used to generate the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence based on the context information, attribute words, and attribute syntactic distance of each attribute word in the target sentence.
5. The text attribute word sentiment classification method according to claim 1, characterized in that, The process involves inputting the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into a pre-trained attribute word sentiment classification model, and outputting the sentiment classification result of the attribute words in the target sentence, including: Based on the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence, generate the attribute syntactic-aware vector corresponding to each word in the target sentence; Based on the attribute syntax-aware vector corresponding to each word in the target sentence, generate the sentence vector corresponding to the attribute-related sentence; Based on the sentence vectors corresponding to the attribute-related sentences, the sentiment classification results of the attribute words in the target sentence are generated.
6. The text attribute word sentiment classification method according to claim 5, characterized in that, The sentiment classification results of the attribute words in the target sentence are obtained using the following formula: in, This indicates the probability of the sentiment category corresponding to the output attribute word. This represents a distribution map of sentiment polarity, including the number of sentiment categories and their corresponding probabilities. Indicates the number of emotion categories, Indicates intermediate quantities in the calculation. This represents the sentence vector corresponding to the attribute-related sentences. functions and The function represents the activation function. , , and This represents the learning parameters of the sentiment prediction layer.
7. The text attribute word sentiment classification method according to claim 5, characterized in that, The method further includes: Based on the attention mechanism, the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence are input into a pre-trained attribute word sentiment classification model, and the sentiment classification result of the attribute words in the target sentence is output.
8. A text attribute word sentiment classification device, characterized in that, include: A text data acquisition module is used to acquire text data, wherein the text data includes multiple sentences, each sentence contains multiple words, and the multiple words include attribute words; The data vector determination module is used to determine the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence. The target sentence is any sentence in the text data, and the attribute syntactic distance of the attribute word is the distance between the word pair formed by the context words associated with the attribute word in the sentence and the attribute word in terms of syntactic structure. The sentiment classification result output module is used to input the context vector, attribute word vector, and attribute syntactic distance vector of each word in the target sentence into the pre-trained attribute word sentiment classification model, and output the sentiment classification result of the attribute words in the target sentence; The attribute word sentiment classification model comprises: an attribute word and syntax adaptation layer, a dynamic semantic adjustment layer, and an attribute word sentiment prediction layer. The attribute word and syntax adaptation layer utilizes a self-attention mechanism to model the overall semantic information of the sentence, an attribute word adapter attention mechanism to model the contextual information related to attribute words, and a syntax structure adapter attention mechanism to model the syntactic structure information related to attribute words, thereby obtaining an attribute syntax-aware vector corresponding to each word in the target sentence. The dynamic semantic adjustment layer generates sentence vectors corresponding to attribute-related sentences based on the attribute syntax-aware vectors corresponding to each word in the target sentence. The attribute word sentiment prediction layer generates the sentiment classification result of the attribute words in the target sentence based on the sentence vectors corresponding to the attribute-related sentences.
9. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the text attribute word sentiment classification method according to any one of claims 1 to 7 by executing the executable instructions.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the text attribute word sentiment classification method according to any one of claims 1 to 7.