A double-flow sentiment cause-effect relationship extraction method and system based on conjunction word enhancement
By employing a two-stream sentiment causality extraction method based on connector enhancement and utilizing a masked language model to process sentence pair sets, sentiment-cause and cause-sentiment sentence pairs are constructed. This solves the problems of errors and incompleteness in sentiment causality extraction in existing technologies and improves the extraction accuracy.
Patent Information
- Application Number
- CN202311220009.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-20
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2043-09-20
AI Technical Summary
In sentiment-cause analysis, existing technologies are prone to producing erroneous or incomplete results when studying sentiment-cause sentence pairs or cause-sentiment sentence pairs in isolation, leading to a low accuracy rate in extracting sentiment causal relationships.
We employ a two-stream sentiment causal relationship extraction method based on connector enhancement. By predicting connectors, we reveal the causal relationship between sentiment and its cause. We extract the sentiment causal representations of sentiment and cause in a bidirectional manner and use a masked language model to process the sentence pair set to construct sentiment-cause and cause-sentiment sentence pairs.
It improves the accuracy of extracting sentiment causal relationships, avoids errors and incomplete results from studying sentiment-cause sentence pairs or cause-sentiment sentence pairs in isolation, and enhances the understanding of the connection between sentiment and cause.
Smart Images

Figure CN117634466B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of information extraction, and in particular relates to a method and system for extracting causal relationships of two-stream sentiment based on conjunction enhancement. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] Emotion-Cause Analysis (ECA) aims to extract emotional expressions and identify the underlying causes of those emotions, which can be helpful in applications such as human-computer interaction, companionship, and depression treatment. Gui et al. (2016) first proposed extracting some causes of emotions and constructing a corresponding corpus. Xia et al. (2019) subsequently proposed the task of Emotion-Cause Pair Extraction (ECPE), which aims to extract all possible emotion-cause sentence pairs consisting of emotions and their corresponding causes. This is a task that is highly context-dependent, as the model needs to find the deep relationship between emotions and their causes. Previous methods for ECPE can be divided into two categories: clause pairing matrix methods and sequence labeling methods. Ding et al. (2020) and Wei et al. (2020) used the clause pairing matrix method to attempt to identify emotion-cause sentence pairs from a matrix containing all clause combinations. However, the matrix constructed by this method is very sparse, resulting in extremely high computational costs. Chen et al. (2020) and Yuan et al. (2020) used sequence labeling methods to explore some novel labeling schemes to identify emotions and causes, but this method cannot well simulate the relationship between emotions and their corresponding causes.
[0004] In summary, current sentiment-causal analysis techniques involve first extracting the sentiment and then its corresponding cause; or first extracting the cause of the sentiment and then the sentiment. This process can lead to errors or incomplete results when studying sentiment-causal sentence pairs or cause-sentiment sentence pairs separately, thus reducing the accuracy of sentiment causal relationship extraction. Summary of the Invention
[0005] To address the technical problems existing in the background art, the present invention provides a two-stream sentiment causal relationship extraction method and system based on conjunction enhancement. By predicting conjunctions to reveal the causal relationship between sentiment and its cause, and extracting the sentiment causal representations of sentiment and cause separately, the bidirectional extraction of causal relationships can avoid the erroneous and incomplete results produced by studying sentiment-cause sentence pairs or cause-sentiment sentence pairs separately, thereby improving the accuracy of sentiment causal relationship extraction.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] The first aspect of the present invention provides a method for extracting causal relationships of two stream sentiment based on conjunction enhancement.
[0008] A method for extracting causal relationships of sentiment from two streams based on conjunction enhancement, comprising:
[0009] Encode the text to obtain the hidden state representation of each clause in the text;
[0010] Based on the known mapping relationship between the hidden state representation of clauses and sentiment and cause, the probability of each clause in the text being a sentiment sentence and the probability of being a cause sentence are obtained, and all sentiment sentences and cause sentences are extracted.
[0011] Based on the probability that each clause is an emotion clause or a cause clause, construct a first set of sentence pairs and a second set of sentence pairs; wherein, the elements of the first set of sentence pairs are emotion clauses and all candidate cause clauses; the elements of the second set of sentence pairs are cause clauses and all candidate emotion clauses.
[0012] By using a masked language model to process each clause pair in the first set of sentence pairs and the second set of sentence pairs respectively, we can obtain each connector and its hidden state representation for each set.
[0013] The hidden state representations of each clause in the first sentence pair set are connected with the hidden state representations of the conjunctions to obtain the first hidden state representation of the sentence pair; the hidden state representations of each clause in the second clause pair set are connected with the hidden state representations of the conjunctions to obtain the second hidden state representation of the sentence pair; based on the mapping relationship between the first and second hidden state representations of the sentence pair and the sentence pair, the sentiment-cause sentence pairs and cause-sentiment sentence pairs are extracted to determine the causal relationship of the two-stream sentiment.
[0014] A second aspect of the present invention provides a two-stream sentiment causality extraction system based on conjunction enhancement.
[0015] A two-stream sentiment causal relationship extraction system based on conjunction enhancement, comprising:
[0016] The hidden state representation module is used to encode the text to obtain the hidden state representation of each clause in the text.
[0017] The sentiment and cause sentence extraction module is used to extract all sentiment sentences and cause sentences by obtaining the probability that each clause in the text is a sentiment sentence and the probability that it is a cause sentence based on the known mapping relationship between the hidden state representation of the clause and the sentiment and cause, respectively.
[0018] The clause pairing module is used to construct a first set of clause pairs and a second set of clause pairs based on the probability that each clause is a sentiment clause or a cause clause; wherein, the elements of the first set of clause pairs are sentiment clause pairs with all candidate cause clause pairs; the elements of the second set of clause pairs are cause clause pairs with all candidate sentiment clause pairs.
[0019] The connector extraction module is used to process each clause pair in the first sentence pair set and the second sentence pair set using the masked language model, to obtain each connector and its hidden state representation for each set.
[0020] The causal relationship determination module is used to connect the latent state representations of each clause in the first sentence pair set with the latent state representations of conjunctions to obtain the first latent state representation of the sentence pair; connect the latent state representations of each clause in the second clause pair set with the latent state representations of conjunctions to obtain the second latent state representation of the sentence pair; based on the mapping relationship between the first and second latent state representations of the sentence pair and the sentence pair respectively, the corresponding sentiment-cause sentence pairs and cause-sentiment sentence pairs are extracted to determine the causal relationship of the two streams.
[0021] A third aspect of the present invention provides a computer-readable storage medium.
[0022] A computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the above-described method for extracting causal relationships of two stream sentiment based on conjunction enhancement.
[0023] A fourth aspect of the present invention provides a computer device.
[0024] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the steps of the dual-stream sentiment causality extraction method based on connector enhancement as described above.
[0025] Compared with the prior art, the beneficial effects of the present invention are:
[0026] (1) The dual-stream sentiment causal relationship extraction method and system based on connector enhancement provided by the present invention extracts connectors from sentiment and all candidate cause clause pairs and cause and all candidate sentiment clause pairs. The connectors complete the text structure and reveal the causal relationship between sentiment and its cause, highlighting the connection between sentiment and cause, thereby improving the effect of causal relationship extraction.
[0027] (2) This invention extracts emotion-cause sentence pairs and cause-emotion sentence pairs to achieve bidirectional extraction of causal relationships between emotion and cause, and finally integrates the key information of emotion-cause sentence pairs. At the same time, it explores "what is the cause of a given emotional effect" and "what is the emotional effect of a given cause", avoiding the erroneous and incomplete results produced by studying the relationship between emotion-cause sentence pairs or cause-emotion sentence pairs separately, thereby improving the effect of emotional causal relationship extraction.
[0028] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0029] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0030] Figure 1 This is a schematic diagram of the principle of two-stream sentiment causal relationship extraction based on connector enhancement in an embodiment of the present invention;
[0031] Figure 2 This is a schematic diagram of the process of extracting causal relationships of two streams of sentiment based on conjunction enhancement in an embodiment of the present invention;
[0032] Figure 3 This is a flowchart of the two-stream sentiment causal relationship extraction method based on connector enhancement according to an embodiment of the present invention. Detailed Implementation
[0033] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0034] It should be noted that the following detailed description is illustrative and intended to provide further explanation of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0035] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0036] Terminology Explanation:
[0037] Emotion-Cause Analysis (ECA) aims to extract emotional expressions and identify the underlying causes of emotions, which can be helpful in applications such as human-computer interaction, companionship, and depression treatment.
[0038] Emotion-Cause Pair (ECP): A clause pair extracted from the text, consisting of an emotion clause and its corresponding cause clause. The emotion clause comes first, followed by the cause clause.
[0039] Cause-Emotion Pair (CEP): A clause pair extracted from the text, consisting of an emotion clause and its corresponding cause clause. The cause clause comes first, followed by the emotion clause.
[0040] Emotion-Cause Pair Extraction (ECPE): This aims to extract all possible emotion-cause pair sentences, consisting of an emotion and its corresponding cause. Emotion-cause pair extraction can be formally described as follows: Given a set of n clauses C1, ..., C2... n Text, where C i This represents the i-th clause. Emotion-cause pair extraction aims to identify each emotion-cause sentence pair (Ci). emo C cau ), where the reason clause C cau It is the emotional clause C that leads to emo The corresponding reasons.
[0041] Attention: The attention mechanism is a method that mimics the human visual and cognitive system, allowing neural networks to focus on relevant parts of the input data. By introducing the attention mechanism, neural networks can automatically learn and selectively focus on important information in the input, improving the model's performance and generalization ability.
[0042] Graph Neural Networks (GNNs): Neural network structures used to process graph data.
[0043] Graph Attention Networks (GAT): GAT introduces attention mechanisms into spatial domain-based graph neural networks.
[0044] BERT (Bidirectional Encoder Representation from Transformers): BERT is a pre-trained language representation model. It is pre-trained using a novel Masked Language Model (MLM) to generate deep bidirectional language representations.
[0045] Token: For the model, a token is a digital representation. Each token is associated with a unique numeric ID, which the model uses to distinguish different tokens. During training, the model learns how to map text to these numeric IDs in order to encode and decode new text.
[0046] Binary Cross Entropy (BCE): Binary cross entropy is a commonly used loss function in binary classification problems.
[0047] Example 1
[0048] according to Figure 1 , Figure 2 and Figure 3 This embodiment provides a method for extracting causal relationships of two-stream sentiment based on conjunction enhancement, which specifically includes the following steps:
[0049] Step 1: Encode the text to obtain the hidden state representation of each clause in the text.
[0050] Table 1 Examples
[0051]
[0052] The process of representing the hidden state of each clause in the text is as follows:
[0053] Step 1.1: Use the BERT model to obtain the hidden state representation H of all tokens in text T. T :
[0054] T={t 11 , t 12 , ..., t i1 , t i2 , ..., t n1 , t n2 , ...}
[0055] H T =BERT(T)={ht 11 , ..., ht n1 , ...}
[0056] Where tij Ht represents the j-th token in the i-th clause. ij This represents the hidden state representation of the j-th token in the i-th clause.
[0057] Step 1.2: Based on the hidden state representations of all tokens in the text, use a clause-level attention layer to construct the intermediate hidden state representation of the clause;
[0058] Specifically, the process of constructing the intermediate implicit state representation of the clause is as follows:
[0059] Take the set of hidden state representations of each Token in the clause, and calculate the weighted sum of each element in the set to calculate the intermediate hidden state representation of the clause.
[0060] For example: clause C i The set of hidden states represented by each Token Calculate their weighted sum to compute the hidden state representation hc of clause i. i :
[0061]
[0062]
[0063] H C =Attn(H T )={hc1,hc2,...,hc n}
[0064] Where w i and b i These are learnable parameters.
[0065] Step 1.3: Based on the intermediate hidden state representation of the clauses, use a graph attention network to establish the interaction between clauses, and finally obtain the hidden state representation H of each clause.
[0066] H = GAT(H) C )={h1,h2,...,h n}
[0067] Where h i Clause C i The final hidden state is represented by the output.
[0068] The basic structure of the encoder that encodes the text in step 1 can be summarized as follows:
[0069] H=Encoder(T)=GAT(Attn(BERT(T))).
[0070] Step 2: Based on the known mapping relationship between the hidden state representation of the clause and the sentiment and cause, obtain the probability that each clause in the text is a sentiment sentence and the probability that it is a cause sentence, and extract all sentiment sentences and cause sentences.
[0071] In the specific implementation process, a linear layer L is used. emo The sigmoid function directly predicts sentiment clauses.
[0072] y emo =sigmoid(L emo (h i ))
[0073] Where y emo Let y represent the predicted probability that each clause is a sentiment clause. emo A threshold of 0.5 is used to predict whether a clause is a sentiment clause. It can be predicted that C4 is a sentiment clause.
[0074] Using linear layer L cau The sigmoid function directly predicts sentiment clauses.
[0075] y cau =sigmoid(L cau (h i ))
[0076] Where y cau Let y represent the predicted probability that each clause is a sentiment clause. cau A threshold of 0.5 is used to predict whether a clause is a sentiment clause. It can predict that C2 and C3 are causal clauses.
[0077] Step 3: Based on the probability that each clause is an emotion clause or a cause clause, construct a first sentence pair set and a second sentence pair set; wherein, the elements of the first sentence pair set are emotion clauses and all candidate cause clauses; the elements of the second sentence pair set are cause clauses and all candidate emotion clauses.
[0078] Many sentiment-cause sentence pairs do not contain any conjunctions. In order to implement a conjunction-based enhancement approach, it is necessary to predict the conjunctions here.
[0079] After obtaining the predicted sentiment clauses, for each of them, this sentiment clause is paired with every clause in the same text. These sentence pairs are formatted similarly to (C emo C cand ), where C emo Clauses expressing emotion, c cand Clauses indicating possible candidate reasons.
[0080] After obtaining the predicted sentiment clauses, for each of them, this cause clause is paired with every clause in the same text. These sentence pairs are formatted similarly to (C cau C cand ), where C cau Indicating a reason clause, C cand Indicates possible candidate sentiment clauses.
[0081] Step 4: Use the masked language model to process each clause pair in the first sentence pair set and the second sentence pair set respectively, to obtain each connector and its hidden state representation for each set.
[0082] However, for some sentence pairs, the conjunctions may already exist, such as (C4, C3). We only need to extract them without adding additional conjunctions. A rule-based approach is set up for this situation. The following are the rules followed when predicting conjunctions:
[0083] (1) First, search for several consecutive sequences of conjunctions from the beginning to the end of the candidate clauses. For example, "but because" is a consecutive sequence of conjunctions. Define the sequence at the beginning of the candidate clauses as the head sequence.
[0084] (2) If the clause itself forms a pair with itself, then delete the head sequence (if it exists). If a causal conjunction exists in other conjunction sequences, select it directly as the predicted conjunction. If there are multiple choices, select the first one that appears in sequence; otherwise, predict the conjunction using BERT in step 1 below.
[0085] (3) Otherwise, if the head sequence exists, it will be deleted. Then, the connector will be predicted using BERT in step 1 below.
[0086] In the specific implementation process, the process of obtaining each connector and its hidden state representation corresponding to each set includes:
[0087] First, insert a special sentence separator [SEP] and a mask [MASK] token;
[0088] Then, the probability of each connector is obtained using the probabilistic vocabulary of the masked language model:
[0089] The sentence pairs with added conjunctions are re-encoded, and the latent state representations of the conjunctions in the sentiment-cause sentence pairs are obtained based on the position index of the conjunctions. Implicit representation of conjunctions in cause-emotion sentence pairs
[0090]
[0091]
[0092] C ecp =(C emo [SEP][MASK]C cand [SEP])
[0093]
[0094]
[0095] C cep =(C cau [SEP][MASK]C cand [SEP])
[0096] Where c i Indicate each possible conjunction, P MLM These represent the probabilities of conjunctions in sentiment-cause clause pairs, the probabilities of conjunctions in cause-sentiment clause pairs, and the probability likelihood of the BERT masked language model, respectively. Finally, all c are selected. i The most frequent conjunction in the middle ecp and conn cep These serve as conjunctions for the predicted sentiment-cause clause pairs and cause-sentiment clause pairs, respectively.
[0097]
[0098]
[0099] Where index ecp and index cep These represent the position indices of the conjunctions in the sentiment-cause clause pairs and the cause-sentiment clause pairs, respectively. and These represent the implicit state representation of conjunctions in emotion-cause clause pairs and cause-emotion clause pairs, respectively.
[0100] Step 5: Connect the latent state representations of each clause in the first sentence pair set with the latent state representations of the conjunctions to obtain the first latent state representation of the sentence pair; connect the latent state representations of each clause in the second clause pair set with the latent state representations of the conjunctions to obtain the second latent state representation of the sentence pair; based on the mapping relationship between the first and second latent state representations of the sentence pair and the sentence pair, extract the sentiment-cause sentence pairs and cause-sentiment sentence pairs accordingly to determine the causal relationship of the two-stream sentiment.
[0101] By concatenating the three hidden state representations, we obtain the first sentence's hidden state representation:
[0102]
[0103] in This represents the implicit state representation of the sentiment clause in a sentiment-cause clause pair. This represents the implicit state of candidate causal clauses in the emotion-cause clause pair.
[0104] Treating the extraction of sentiment-cause sentences as a multi-task process, a linear layer L is constructed. pair . L represents the output vector of the cause clause prediction. pair (h ecp The output vector represents the judgment of whether the cause corresponds to the sentiment. The sum of the two output vectors is taken, and the sigmoid function is used to obtain the final probability that the sentence pair is a sentiment-cause sentence pair:
[0105]
[0106] Where y ecp It is the predicted probability of sentiment-cause sentence pairs in the sentiment-cause stream, y emo express The corresponding clause is the predicted probability of the sentiment clause. Finally, a threshold of 0.5 is used to determine whether a sentence pair is a sentiment-cause sentence pair.
[0107] By concatenating the three hidden state representations, we obtain the second sentence's representation of the hidden states:
[0108]
[0109] in Representing the implicit state of the cause clause in a cause-emotion clause pair. The implicit state representation of the sentiment candidate clause in the cause-sentiment clause pair.
[0110] Treating the extraction of cause-emotion sentence pairs as a multi-task process, a linear layer L is constructed. pair And L pair With L in step J pair Shared parameters. L represents the output vector for sentiment clause prediction. pair (h cep The output vector represents the judgment of whether the sentiment corresponds to the cause. The sum of the two output vectors is taken, and the sigmoid function is used to obtain the final probability that the sentence pair is a cause-sentiment sentence pair:
[0111]
[0112] Where y cep The predicted probability, Y, of cause-emotion sentence pairs in the cause-emotion stream. cau express The corresponding clause is the predicted probability of the cause clause. Finally, a threshold of 0.5 is used to determine whether the sentence pair is a cause-sentiment sentence pair.
[0113] The loss function is calculated based on the model's prediction results, and then the model parameters are updated through gradient backpropagation. The loss function is as follows:
[0114] Loss = Loss emo +Loss cau +Loss ecp +Loss cep
[0115] Loss emo =BCE(y emo y Temo )
[0116] Loss cau =BCE(y cau y Tcau )
[0117] Loss cep =BCE(y ecp y Tecp )
[0118] Loss cep =BCE(y cep y Tcep )
[0119] Where y Temo y Tcau y Tecp y Tcep These represent the true sentiment clause probability, cause clause probability, sentiment-cause clause pair probability, and cause-sentiment clause pair probability, respectively, with BCE representing binary cross-entropy.
[0120] Through the above steps, this invention achieves two-stream sentiment causal relationship extraction based on connective enhancement. Specifically, the model is implemented using the PyTorch and Huggingface Transformers libraries, with bert-base-chinese as the encoding model. The hidden state representation has 768 feature dimensions, and the batch size is set to 4. The AdamW optimizer is used for training, with a weight decay of 0.01 and an initial learning rate of 1e-5. The optimizer is warmed up in the first 10% of steps. For regularization, Dropout is used with a ratio of 0.1. Training uses a Chinese sentiment-causal pair extraction dataset.
[0121] (@inproceedings{xia-ding-2019-emotion,
[0122] title="Emotion-Cause Pair Extraction:ANew Task to Emotion Analysis in Texts",
[0123] author = "Xia,Rui and Ding,Zixiang",
[0124] booktitle="Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics",
[0125] month = jul,
[0126] year = "2019",
[0127] address="Florence,Italy",
[0128] publisher="Association for Computational Linguistics",
[0129] url="https: / / aclanthology.org / P19-1096",
[0130] doi="10.18653 / v1 / P19-1096",
[0131] pages = "1003--1012",
[0132] })
[0133] Example 2
[0134] This embodiment provides a two-stream sentiment causal relationship extraction system based on connective enhancement, which specifically includes the following modules:
[0135] (1) The hidden state representation module is used to encode the text and obtain the hidden state representation of each clause in the text.
[0136] The hidden state representation module includes:
[0137] (1.1) Token hidden state representation module, which is used to obtain the hidden state representation of all tokens in the text using the BERT model;
[0138] (1.2) Intermediate hidden state representation module, which is used to construct the intermediate hidden state representation of the clause using the clause-level attention layer based on the hidden state representation of all tokens in the text;
[0139] Specifically, in the intermediate hidden state representation module, the process of constructing the intermediate hidden state representation of the clause is as follows:
[0140] Take the set of hidden state representations of each Token in the clause, and calculate the weighted sum of each element in the set to calculate the intermediate hidden state representation of the clause.
[0141] (1.3) Clause hidden state representation, which is used for intermediate hidden state representation based on clauses. Graph attention network is used to establish the interaction between clauses, and finally the hidden state representation of each clause is obtained.
[0142] (2) The sentiment and cause sentence extraction module is used to extract all sentiment sentences and cause sentences by obtaining the probability that each clause in the text is a sentiment sentence and the probability that it is a cause sentence based on the known hidden state representation of the clause and the mapping relationship between the sentiment and cause.
[0143] (3) Clause pairing module, which is used to construct a first sentence pair set and a second sentence pair set according to the probability that each clause is an emotion sentence or a cause sentence; wherein, the elements of the first sentence pair set are emotion clause pairs with all candidate cause clause pairs; the elements of the second sentence pair set are cause clause pairs with all candidate emotion clause pairs.
[0144] (4) Connector extraction module, which uses the masked language model to process each clause pair in the first sentence pair set and the second sentence pair set respectively, and obtain each connector and its hidden state representation corresponding to each set.
[0145] (5) Causal relationship determination module, which is used to connect the hidden state representation of each clause in the first sentence pair set with the hidden state representation of the conjunction to obtain the first hidden state representation of the sentence pair; connect the hidden state representation of each clause in the second clause pair set with the hidden state representation of the conjunction to obtain the second hidden state representation of the sentence pair; according to the mapping relationship between the first hidden state representation of the sentence pair and the second hidden state representation of the sentence pair and the sentence pair respectively, the sentiment-cause sentence pair and the cause-sentiment sentence pair are extracted to determine the causal relationship of the two streams.
[0146] It should be noted that each module in this embodiment corresponds one-to-one with each step in Embodiment 1, and their specific implementation processes are the same, so they will not be repeated here.
[0147] Example 3
[0148] This embodiment provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in the above-described method for extracting causal relationships of two streams based on conjunction enhancement.
[0149] Example 4
[0150] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps in the above-described method for extracting dual-stream sentiment causality based on connector enhancement.
[0151] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0152] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for extracting causal relationships of sentiment from two streams based on conjunction enhancement, characterized in that, include: Encode the text to obtain the hidden state representation of each clause in the text; Based on the known mapping relationship between the hidden state representation of clauses and sentiment and cause, the probability of each clause in the text being a sentiment sentence and the probability of being a cause sentence are obtained, and all sentiment sentences and cause sentences are extracted. Based on the probability that each clause is an emotion clause or a cause clause, construct a first set of sentence pairs and a second set of sentence pairs; wherein, the elements of the first set of sentence pairs are emotion clauses and all candidate cause clauses; the elements of the second set of sentence pairs are cause clauses and all candidate emotion clauses. By using a masked language model to process each clause pair in the first set of sentence pairs and the second set of sentence pairs respectively, we can obtain each connector and its hidden state representation for each set. The hidden state representations of each clause in the first sentence pair set are connected with the hidden state representations of the conjunctions to obtain the first hidden state representation of the sentence pair; the hidden state representations of each clause in the second clause pair set are connected with the hidden state representations of the conjunctions to obtain the second hidden state representation of the sentence pair; based on the mapping relationship between the first and second hidden state representations of the sentence pair and the sentence pair, the sentiment-cause sentence pairs and cause-sentiment sentence pairs are extracted to determine the causal relationship of the two-stream sentiment.
2. The method for extracting causal relationships of two streams based on conjunction enhancement as described in claim 1, characterized in that, The process of representing the implicit state of each clause in the text is as follows: Use the BERT model to obtain the hidden state representation of all tokens in the text; Based on the hidden state representations of all tokens in the text, a clause-level attention layer is used to construct the intermediate hidden state representation of the clause; Based on the intermediate hidden state representation of clauses, a graph attention network is used to establish the interaction between clauses, and finally the hidden state representation of each clause is obtained.
3. The method for extracting causal relationships of two streams based on conjunction enhancement as described in claim 2, characterized in that, The process of constructing the intermediate implicit state representation of a clause is as follows: Take the set of hidden state representations of each Token in the clause, and calculate the weighted sum of each element in the set to calculate the intermediate hidden state representation of the clause.
4. The method for extracting causal relationships of two streams based on conjunction enhancement as described in claim 2, characterized in that, The process of obtaining each connector and its hidden state representation for each set includes: First, insert a special sentence separator [SEP] and a mask [MASK] token; Then, the probability of each connector is obtained using the probabilistic vocabulary of the masked language model: The sentence pairs with added conjunctions are re-encoded, and the hidden state representation of the conjunctions is obtained based on their position indices.
5. The method for extracting causal relationships of two streams based on conjunction enhancement as described in claim 1, characterized in that, The rules followed in obtaining each conjunction corresponding to each set include: First, search for a series of consecutive conjunctions from the beginning to the end of the candidate clauses; If a clause forms a pair with itself and has a head sequence, then delete the head sequence; If a causal connector exists in other connector sequences, directly select that causal connector as the predictor connector.
6. A two-stream sentiment causal relationship extraction system based on conjunction enhancement, characterized in that, include: The hidden state representation module is used to encode the text to obtain the hidden state representation of each clause in the text. The sentiment and cause sentence extraction module is used to extract all sentiment sentences and cause sentences by obtaining the probability that each clause in the text is a sentiment sentence and the probability that it is a cause sentence based on the known mapping relationship between the hidden state representation of the clause and the sentiment and cause, respectively. The clause pairing module is used to construct a first set of clause pairs and a second set of clause pairs based on the probability that each clause is a sentiment clause or a cause clause; wherein, the elements of the first set of clause pairs are sentiment clause pairs with all candidate cause clause pairs; the elements of the second set of clause pairs are cause clause pairs with all candidate sentiment clause pairs. The connector extraction module is used to process each clause pair in the first sentence pair set and the second sentence pair set using the masked language model, to obtain each connector and its hidden state representation for each set. The causal relationship determination module is used to connect the latent state representations of each clause in the first sentence pair set with the latent state representations of conjunctions to obtain the first latent state representation of the sentence pair; connect the latent state representations of each clause in the second clause pair set with the latent state representations of conjunctions to obtain the second latent state representation of the sentence pair; based on the mapping relationship between the first and second latent state representations of the sentence pair and the sentence pair respectively, the corresponding sentiment-cause sentence pairs and cause-sentiment sentence pairs are extracted to determine the causal relationship of the two streams.
7. The dual-stream sentiment causal relationship extraction system based on conjunction enhancement as described in claim 6, characterized in that, The hidden state representation module includes: The Token Hidden State Representation module is used to obtain the hidden state representation of all tokens in the text using the BERT model. The intermediate hidden state representation module is used to construct the intermediate hidden state representation of a clause based on the hidden state representations of all tokens in the text, using a clause-level attention layer. Clause hidden state representation is used for intermediate hidden state representation based on clauses. Graph attention network is used to establish the interaction between clauses, and finally the hidden state representation of each clause is obtained.
8. The dual-stream sentiment causal relationship extraction system based on conjunction enhancement as described in claim 7, characterized in that, In the intermediate hidden state representation module, the process of constructing the intermediate hidden state representation of the clause is as follows: Take the set of hidden state representations of each Token in the clause, and calculate the weighted sum of each element in the set to calculate the intermediate hidden state representation of the clause.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the two-stream sentiment causality extraction method based on connector enhancement as described in any one of claims 1-5.
10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the two-stream sentiment causal relationship extraction method based on connector enhancement as described in any one of claims 1-5.
Citation Information
Patent Citations
Emotion reason mining method based on dependency syntax and generalized causal network
CN110781369A
Emotion-reason pair extraction method and device
CN116578671A
