A news comment filtering method and system based on key sentence groups and news original text

By obtaining the key sentence group of the original news text, combining GPT-2, RoBERTa and Sentence-BERT models, news comments that match the emotional and semantics of the original news text are generated, and the problems of mismatch and insufficient diversity in the existing technology are solved, and the problem of mismatch and insufficient diversity is achieved. High focus and diversity of comments.

CN114443829BActive Publication Date: 2024-11-29GUANGZHOU CITY POLYTECHNIC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111616647.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-27
Publication Date
2024-11-29
Estimated Expiration
2041-12-27

AI Technical Summary

Technical Problem

The prior art is difficult to generate news comments that match the emotions and semantics of the original news text, and the comments are not diverse and focused.

Method used

By obtaining the key sentence group of the original news text, using the GPT-2 model to generate initial comments, the RoBERTa model performs sentiment analysis, and semantic matching is performed through the Sentence-BERT model to filter mismatched comments, and finally generate focused and diverse news comments.

Benefits of technology

It effectively avoids texts that are not related to the core meaning, improves the focus and diversity of comments, and ensures that the comments match the emotions and semantics of the original text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114443829B_ABST
    Figure CN114443829B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for filtering news comments based on key sentence groups and news original text, including: obtaining a key sentence group corresponding to the news original text, and calculating multiple first news comments corresponding to the key sentence group according to the GPT-2 model; performing sentiment analysis on the key sentence group and the corresponding first news comments according to the RoBERTa model to obtain the second news comments corresponding to the key sentence group; performing semantic matching on the key sentence group and the corresponding second news comments to obtain the third news comments corresponding to the key sentence group, and completing the filtering of news comments on the key sentence group. The present invention sequentially selects the key sentence groups corresponding to the news original text and generates multiple news comments, enriching the diversity of news comments, and performs sentiment analysis and semantic matching on the generated news comments to filter news comments that do not match the sentiment and semantics of the news original text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of information interaction, and in particular to a news comment filtering method and system based on key sentence groups and news original texts. Background Art

[0002] Natural language generation is the process of converting non-text data into text data through computer processing. Automatic text generation is the process of taking text, images, data, etc. as input and outputting text through computer processing. Natural language generation only includes the process of generating data into text. For example, question generation, text summary generation, comment generation, etc. Therefore, text generation technology will inevitably provide strong help to news media. With the development of the Internet and the news industry, a variety of news are published on the Internet, and a large number of news comments are generated. News comments provide a wide range of information and rich personal opinions. Users can not only express their own opinions, but also read other people's opinions, which can attract users' attention and encourage interaction between users.

[0003] At present, the automatic comment generation task is a common task in text generation. It has a similar goal to the text summarization task, that is, to generate short texts related to the long text. However, the automatic comment generation task does not require the generation of summaries, but rather the generation of comments that are related to the long text. Comments that can radiate some new semantic information from the semantics of the long text are more in line with the results required by the automatic comment generation task. The most widely used summary generation model is the Pointer-Generator Network. It combines the generation ability of the Seq2Seq model and the word copying ability of the Pointer Network model, solving the problem that the generated text is difficult to accurately repeat the factual details of the original text and cannot handle out-of-date words (OOV) in the original text. At the same time, a coverage mechanism is proposed to solve the problem of repeated fragments in the generated summary. In addition, the Attention mechanism is also widely used in the field of text generation. The existing model is a pre-trained model based on the deep bidirectional Transformer encoder (BERT model). It pre-trains deep bidirectional representations based on the left and right contexts of all layers, so the obtained feature vector has contextual information and better understands the text. The candidate text is decoded and analyzed in combination with the BeamSearch algorithm to obtain the generated text. However, since the special [MASK] tag in the BERT pre-training task does not appear in the actual prediction, it causes a mismatch between pre-training and fine-tuning, affecting the performance of the model. In addition, BERT cuts into more fine-grained WordPieces during word segmentation to solve the OOV problem. At the same time, when predicting the [MASK] part, it may only [MASK] mark part of the word, which also affects the performance of the model.

[0004] The above two classic models are applied to the news comment generation task. For the summary generation model based on the pointer generation network, although it can well solve the problems of ambiguous meaning and repeated words in the generated comments, it still does not focus on the core content of the source text. Instead, it summarizes some less important information, and even has semantics irrelevant to the news content. In addition, some sentences cannot be expressed smoothly. For the BERT model, although it can well grasp the semantics of the original news and understand the meaning of the news, it cannot generate text well because it is composed of multiple bidirectional encoders, which leads to repeated words in the generated news comments. There are also cases where the generated sentences are not smooth. In addition, the above models cannot make the generated news comments consistent with the original text, and cannot make the generated news comments diverse. Summary of the invention

[0005] The invention provides a news comment filtering method based on the original news text and a device thereof, so as to solve the technical problem that the news comment does not match the original text emotion and semantics.

[0006] In order to solve the above technical problems, an embodiment of the present invention provides a news comment filtering method based on key sentence groups, comprising:

[0007] Obtain a key sentence group corresponding to the original news text, and calculate, based on the GPT-2 model, multiple first news comments corresponding to the key sentence group; wherein one key sentence group corresponds to multiple first news comments;

[0008] According to the RoBERTa model, sentiment analysis is performed on the key sentence group and the corresponding first news comment to obtain a second news comment corresponding to the key sentence group;

[0009] Semantic matching is performed on the key sentence group and the corresponding second news comments to obtain third news comments corresponding to the key sentence group, thereby completing filtering of news comments on the key sentence group.

[0010] Furthermore, the obtaining of a key sentence group corresponding to the original news text is specifically:

[0011] Preprocessing the original news text to obtain vectorized text;

[0012] By using the TextRank algorithm, the text is divided into a plurality of sentences, and the importance of the plurality of sentences is calculated respectively; wherein one sentence corresponds to one importance;

[0013] The importances are sorted in descending order, the top M importances are obtained, and the M sentences corresponding to the top M importances are concatenated according to the order of the original news texts;

[0014] The M sentences are sequentially selected through a sliding window algorithm to obtain a plurality of key sentence groups corresponding to the original news text;

[0015] According to the selection order, one key sentence group is extracted in turn from the multiple key sentence groups.

[0016] Furthermore, the multiple first news comments corresponding to the key sentence group are calculated based on the GPT-2 model, specifically:

[0017] According to the key sentence group, a corresponding word embedding matrix and a position matrix are calculated;

[0018] According to the word embedding matrix and the position matrix, combined with the layer normalization processing and decoder module of the GPT-2 model, multiple first news comments corresponding to the key sentence group are calculated.

[0019] Further, the sentiment analysis is performed on the key sentence group and the corresponding first news comment according to the RoBERTa model to obtain the second news comment corresponding to the key sentence group, specifically:

[0020] According to the RoBERTa model, respectively calculating the first sentiment score of the key sentence group and the second sentiment score of each of the first news comments;

[0021] All the first news comments having the same second sentiment score as the first sentiment score are used as the second news comments corresponding to the key sentence group.

[0022] Furthermore, the semantic matching of the key sentence group and the corresponding second news comment to obtain the third news comment corresponding to the key sentence group is specifically:

[0023] According to the Sentence-BERT model, obtaining a first feature vector of the key sentence group and a corresponding second feature vector of the second news comment;

[0024] The corresponding cosine similarity is calculated according to the first feature vector and the second feature vector, and all the second news comments with cosine similarity greater than a preset threshold are used as the third news comments corresponding to the key sentence group.

[0025] In order to solve the same technical problem, the present invention also provides a news comment filtering method based on the original news text, comprising:

[0026] Obtaining a news original text, and extracting a plurality of key sentence groups from the news original text;

[0027] According to the above-mentioned news comment filtering method based on key sentence groups, the news comments of the multiple key sentence groups are filtered in turn to obtain the news comments corresponding to each key sentence group;

[0028] The news comments corresponding to all the key sentence groups are taken as the news comments of the original news, and the news comments of the original news are filtered.

[0029] In order to solve the same technical problem, the present invention also provides a news comment filtering system based on key sentence groups, comprising:

[0030] A news comment generation module is used to obtain a key sentence group corresponding to the original news text, and calculate multiple first news comments corresponding to the key sentence group according to the GPT-2 model; wherein one key sentence group corresponds to multiple first news comments;

[0031] A sentiment analysis module, configured to perform sentiment analysis on the key sentence group and the corresponding first news comment according to a RoBERTa model, to obtain a second news comment corresponding to the key sentence group;

[0032] The semantic matching module is used to perform semantic matching on the key sentence group and the corresponding second news comments, obtain the third news comments corresponding to the key sentence group, and complete the filtering of the news comments on the key sentence group.

[0033] Furthermore, the news comment generation module further includes:

[0034] A preprocessing unit, used for preprocessing the original news text to obtain vectorized text;

[0035] A division unit, used to divide the text into multiple sentences by using a TextRank algorithm, and respectively calculate the importance of the multiple sentences; wherein one sentence corresponds to one importance;

[0036] A sorting and splicing unit, used to sort the importance in descending order, obtain the top M importances, and splice the M sentences corresponding to the top M importances according to the order of the original news text;

[0037] A selection unit is used to select the spliced ​​M sentences in sequence through a sliding window algorithm to obtain multiple key sentence groups corresponding to the original news text, and extract one key sentence group from the multiple key sentence groups in sequence according to the selection order;

[0038] The news comment generation unit is used to calculate the corresponding word embedding matrix and position matrix according to the key sentence group, and calculate multiple first news comments corresponding to the key sentence group according to the word embedding matrix and the position matrix in combination with the layer normalization processing and decoder module of the GPT-2 model.

[0039] Furthermore, the sentiment analysis module further includes:

[0040] A sentiment analysis unit, configured to calculate, according to a RoBERTa model, a first sentiment score of each of the key sentence groups and a second sentiment score of each of the first news comments;

[0041] The first filtering unit is configured to take all the first news comments having the same second sentiment score as the first sentiment score as the second news comments corresponding to the key sentence group.

[0042] Furthermore, the semantic matching module further includes:

[0043] A feature vector acquisition unit, used for acquiring a first feature vector of the key sentence group and a second feature vector of the corresponding second news comment according to a Sentence-BERT model;

[0044] The second filtering unit is used to calculate the corresponding cosine similarity according to the first feature vector and the second feature vector, and take all the second news comments with cosine similarity greater than a preset threshold as the third news comments corresponding to the key sentence group, so as to complete the filtering of the news comments of the key sentence group.

[0045] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0046] Select the key sentence groups corresponding to the original news text, use the GPT-2 model to generate multiple news comments corresponding to the key sentence groups, avoid reading text irrelevant to the core meaning, and use the RoBERTa model to perform sentiment analysis on the key sentence groups and the corresponding multiple news comments to filter out news comments that do not match the sentiment of the original news text. At the same time, perform semantic matching on news comments that pass sentiment analysis to solve the problem that the generated news comments are not consistent with the meaning of the original news text.

[0047] Furthermore, after the sentiment analysis and semantic matching of multiple news comments corresponding to the key sentence groups are completed, the key sentence groups are reselected based on the original news text, and the generation and filtering of all news comments are iteratively completed, which not only improves the focus of news comments, but also enriches the diversity of news comments. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1: A flow chart of an embodiment of a news comment filtering method based on key sentence groups provided by the present invention;

[0049] Figure 2 : A schematic diagram of a sliding window algorithm of an embodiment of a news comment filtering method based on key sentence groups provided by the present invention;

[0050] Figure 3 : A structural diagram of a GPT-2 model of an embodiment of a news comment filtering method based on key sentence groups provided by the present invention;

[0051] Figure 4 : A structural diagram of a multi-head self-attention mechanism of an embodiment of a news comment filtering method based on key sentence groups provided by the present invention;

[0052] Figure 5 : A schematic diagram of the structure of a multi-layer bidirectional Transformer encoder of an embodiment of a news comment filtering method based on key sentence groups provided by the present invention;

[0053] Figure 6 : A structural diagram of a BERT model of an embodiment of a news comment filtering method based on key sentence groups provided by the present invention;

[0054] Figure 7 : A schematic diagram of the structures of a RoBERTa model and a Sentence-BERT model of an embodiment of a news comment filtering method based on key sentence groups provided by the present invention;

[0055] Figure 8 : A flow chart of an embodiment of a news comment filtering method based on news original text provided by the present invention;

[0056] Fig. 9 : A structural diagram of a news comment filtering system based on key sentence groups provided by the present invention;

[0057] Fig.10 : A structural diagram of a news comment generation module of a news comment filtering system based on key sentence groups provided by the present invention;

[0058] Fig.11 : A structural schematic diagram of a sentiment analysis module of a news comment filtering system based on key sentence groups provided by the present invention;

[0059] Fig.12 : A structural schematic diagram of a semantic matching module of a news comment filtering system based on key sentence groups provided by the present invention. DETAILED DESCRIPTION

[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0061] Embodiment 1:

[0062] Please refer to Figure 1 , a news comment filtering method based on key sentence groups provided by an embodiment of the present invention, comprising:

[0063] S1: Obtain a key sentence group corresponding to the original news text, and calculate multiple first news comments corresponding to the key sentence group based on the GPT-2 model; wherein, one key sentence group corresponds to multiple first news comments.

[0064] S11: Preprocess the original news text to obtain vectorized text.

[0065] In this embodiment, specifically, the preprocessing of the news original text includes:

[0066] ① Chinese and English processing: For the original news text, if it is Chinese, spaces are added between words, and if it is English and numbers, no processing is done; ② Space segmentation: Chinese and English words are segmented by spaces, but if it is English, the words are also divided into a limited set of common sub-word units through Wordpiece; ③ Add tags: Add special tokens, such as [CLS] and [SEP], to get the input form "[CLS] News original text [SEP]"; ④ Word mapping ID: According to the vocabulary, all words are mapped to the ID of the corresponding vocabulary index; ⑤ Truncation / padding processing: If the sentence length in the original news text is greater than the specified length (512), it needs to be truncated to the specified length. If the sentence length is less than the specified length (512), it is padded to the specified length to ensure the consistency of the input; ⑥ Vectorization: Vectorize the sentence.

[0067] After the above preprocessing, vectorized text is obtained.

[0068] S12: The vectorized text is divided into multiple sentences by using the TextRank algorithm, and the importance of the multiple sentences is calculated respectively; wherein one sentence corresponds to one importance.

[0069] In this embodiment, specifically, the vectorized text is divided according to complete sentences in the text to obtain a corresponding sentence set T, where the sentence set T contains n sentences.

[0070] T=[S1,S2,…Sn ] (1)

[0071] Segment n sentences and remove stop words. Each sentence corresponds to m candidate keywords.

[0072]

[0073] in, S i represents the i-th sentence, S j represents the jth sentence.

[0074] According to formula (3), the similarity between adjacent sentences is calculated, where all sentences are assumed to be adjacent.

[0075]

[0076] Among them, w k Indicates candidate keywords, |S i | indicates sentence S i The total number of words, |S j | indicates sentence S j The total number of words.

[0077] Construct a graph G = (V, E), where V is the sentence set T and E is the sentence similarity calculated by formula (3), thus obtaining an undirected weighted graph.

[0078] According to formula (4), the weights are iteratively propagated to calculate the importance values ​​of n sentences.

[0079]

[0080] Among them, w ji Represents sentence S i and sentence S j The similarity between jk Represents sentence S j and sentence S k The similarity between i Represents node V i (i.e., sentence S i ), V j Represents node V j (i.e., sentence S j ), V k Represents node V k (i.e., sentence S k ), d represents the damping coefficient, the value range is [0,1], In(V i ) indicates pointing to V i The collection of Out(V j ) indicates V j The collection indicated.

[0081] S13: sort the importance in descending order, obtain the first M importances, and concatenate the M sentences corresponding to the first M importances according to the order of the original news text.

[0082] In this embodiment, M=6, wherein the first 6 sentences corresponding to the importance are used as the key sentences of the original news text.

[0083] S14: Using a sliding window algorithm, the concatenated M sentences are selected in sequence to obtain multiple key sentence groups corresponding to the original news text.

[0084] In this embodiment, specifically, please refer to Figure 2 , the 6 key sentences after splicing are selected for key sentence groups through the sliding window mechanism, so that the machine can simulate people's reading habits to "read" the key sentences. The sliding window selection in this way is more conducive to focusing on the content selected by the sliding window, so as to generate news comments related to it. At the same time, it is also conducive to generating news comments in many aspects. The sliding window algorithm (Sliding WindowAlgorithm) uses a sub-window of a specified size to perform specific operations while traversing the entire list to reduce the nesting depth of the loop. In this article, the sliding window size is set to 2, that is, only 2 key sentences are selected each time as the key sentence group, and the sliding window operation is performed in the key sentence list. The selected key sentence group is input into the subsequent model.

[0085] S15: extracting one key sentence group from the multiple key sentence groups in sequence according to the selection order.

[0086] S16: According to the key sentence group, the corresponding word embedding matrix and position matrix are calculated.

[0087] In this embodiment, specifically, according to formula (5), the input X of the GPT-2 model calculated using the key sentence group is:

[0088] X=wte+wpe (5)

[0089] in, represents the word embedding matrix, k is the vocabulary size, d emb is the word vector dimension, represents the position matrix, and l is the length of the text.

[0090] S17: Based on the word embedding matrix and the position matrix, combined with the layer normalization processing and decoder module of the GPT-2 model, multiple first news comments corresponding to the key sentence group are calculated.

[0091] In this embodiment, please refer to Figure 3The GPT-2 model consists of N (this embodiment uses a small model, so N = 12) decoder modules. Each decoder module mainly consists of two parts. One part is a multi-head self-attention layer with mask. Please refer to Figure 4 The multi-head self-attention mechanism not only expands the model's ability to focus on different positions, but also enhances the attention mechanism's ability to express words within a sentence. The mask can shield the information from all words to the right of the current calculation position during the self-attention calculation to prevent interference with the self-attention calculation. The other part is the feedforward network layer, which enhances the representation ability.

[0092] In this embodiment, specifically, X is input to the layer for normalization, and then the self-attention calculation with mask is performed. According to equations (6), (7), (8), (9), and (10), it is the transposed multiplication of the query vector and the key vector to represent the attention of the input word vector to each word vector in the sentence, and then the bitwise multiplication of the mask matrix masks the information after each word, thereby preventing dependence on future words. Finally, the residual connection is added to obtain the output Z to prevent the gradient from disappearing.

[0093] Z=X+MultiHead(Q,K,V) (6)

[0094] MutiHead(Q,K,V)=Concat(head1,head2,…,head h )W O (7)

[0095] Q,K,V=LayerNorm(X)W Q ,LayerNorm(X)W K ,LayerNorm(X)W V (8)

[0096] head i =Attention(QW i Q ,KW i K ,VW i V ) (9)

[0097]

[0098] Among them, W O is an additional weight matrix that compresses the result of multi-head concatenation into a dimension that conforms to the input of the feedforward network layer; Q, K, V represent the Query, Key, and Value vectors of the input after layer normalization, and W Q , W K , W Vare their weight matrices, and W i Q , W i K , W i V is the weight matrix of each head mapping; Mask is the mask matrix, which is a lower triangular matrix; d k is the dimension of Q and K vectors.

[0099] According to formula (11), Z is input into the layer for normalization, and the result is passed through the feedforward network layer, which is composed of two fully connected layers, and then the activation function is used to enhance the feature expression ability. Finally, the residual connection is added to obtain the output FFN(Z) of the decoder module.

[0100] FFN(Z)=max(0,LayerNorm(Z)W1+b1)W2+b2 (11)

[0101] Among them, W1, b1, W2, and b2 are the weight parameters of the fully connected layer.

[0102] Finally, according to formula (12), the output FFN(Z) of the decoder module is normalized again to obtain the output of the GPT-2 model.

[0103] output=LayerNorm(FFN(Z)) (12)

[0104] S2: Based on the RoBERTa model, sentiment analysis is performed on the key sentence group and the corresponding first news comment to obtain the second news comment corresponding to the key sentence group.

[0105] S21: According to the RoBERTa model, the first sentiment scores of the key sentence groups and the second sentiment scores of each first news comment are calculated respectively.

[0106] In this embodiment, the multiple first news comments output by the GPT-2 model and the corresponding key sentence groups are used as the input of the RoBERTa model, and the word sequence is obtained through BPE processing, and then the word vector matrix (TE), sentence vector matrix (SE), and position vector matrix (PE) are obtained. After the three vector matrices are superimposed, the final word embedding matrix is ​​obtained, which is expressed as:

[0107] content=TE content +SE content +PE content (13)

[0108] comment=TE comment +SE comment +PE comment (14)

[0109] in, h represents the dimension of the hidden layer.

[0110] After passing through multiple layers of bidirectional Transformer encoders, please refer to Figure 5 , respectively get the first sentiment score of the key sentence group content And the corresponding second sentiment score of each first news comment comment , expressed as:

[0111] score content =RoBERTa(content) (15)

[0112] score comment =RoBERTa(comment) (16)

[0113] Among them, score represents the output vector of the last hidden layer of the RoBERTa model.

[0114] S22: All first news comments whose second sentiment scores are the same as the first sentiment scores are taken as second news comments corresponding to the key sentence groups.

[0115] In this embodiment, specifically, the first sentiment score of the matched key sentence is matched to see whether it is the same as the second sentiment score of the first news comment. If so, the first news comment is retained; otherwise, it is discarded, and all first news comments whose second sentiment scores are the same as the first sentiment scores are taken as the second news comments corresponding to the key sentence group.

[0116] S3: semantically matching the key sentence group and the corresponding second news comment to obtain the third news comment corresponding to the key sentence group, and completing the filtering of the news comments on the key sentence group.

[0117] S31: According to the Sentence-BERT model, a first feature vector of the key sentence group and a second feature vector of the corresponding second news comment are obtained.

[0118] In this embodiment, the news comments and the corresponding key sentence groups after sentiment analysis are input into the Sentence-BERT model. First, the vector output at the [CLS] position in the BERT model is taken as the feature vector of the key sentence group. The structure of the BERT model can be found in Figure 6 .

[0119] S32: Calculate the corresponding cosine similarity according to the first eigenvector and the second eigenvector, and use all the second news comments with cosine similarity greater than a preset threshold as the third news comments corresponding to the key sentence group, thereby completing the filtering of the news comments on the key sentence group.

[0120] In this embodiment, specifically, the cosine similarity is calculated based on the first feature vector of the key sentence group and the second feature vector of the corresponding second news comment through an average pooling layer. It is expressed as:

[0121] similarity=cosine_sim(u,v) (17)

[0122] Among them, u represents the feature vector of the key sentence, and v represents the feature vector of the news comment.

[0123] Finally, if the value of the cosine similarity is greater than a preset threshold, the second news comment is retained as the third news comment corresponding to the key sentence group, otherwise it is discarded.

[0124] In this embodiment, the RoBERTa model is an enhanced version of the BERT model. Its model structure is consistent with BERT, but adjustments have been made in three aspects. First, the training time is longer, the batch size is larger, and BPE is used to process data, which increases the vocabulary size. The second is to dynamically adjust the Masking mechanism so that the Masking situation in each round is different, which is more convenient and saves memory. The third is to remove the NSP part. Sentence-BERT also solves the shortcomings of the BERT model. Through the framework of the twin network model, it is input into the parameter-sharing BERT model to obtain the sentence representation vector, which is then used for cosine similarity calculation for semantic matching. The reduction in parameters increases the speed of the Sentence-BERT model, which is of practical value to the industry. For the specific structure of the RoBERTa model and the Sentence-BERT model, please refer to Figure 7 .

[0125] In this embodiment, specifically, the GPT-2 model is obtained by training a training set based on the BERT model; wherein the training set includes multiple initial news original texts and corresponding multiple initial news comments, and before using the training set to train the model, the training set is preprocessed, and the preprocessing includes: ① HTML processing: removing the influence of HTML tags; ② removing meaningless long numeric strings; ③ special character processing: processing \u, \n, ④ Remove empty news and empty comments; ⑤ Filter short news: Filter out data with a news original length of less than 20 to reduce noise; ⑥ Chinese and English processing: For the original news, if it is Chinese, add spaces between words, and if it is English and numbers, do not process; ⑦ Space segmentation: Chinese and English are segmented by spaces, but if it is English, the words are divided into a limited set of common sub-word units through Wordpiece; ⑧ Splice news and comments: Add special tokens such as [CLS] and [SEP], and splice the original news and news comments to obtain the input form "[CLS] News original [SEP] News comment [SEP]"; ⑨ Word mapping ID: According to the vocabulary, all words are mapped to the ID of the corresponding vocabulary index; ⑩ Truncation / padding processing: If the sentence length in the original news is greater than the specified length (512), it needs to be truncated to the specified length. If the sentence length is less than the specified length (512), it is padded to the specified length to ensure the consistency of the input; Vectorization: Vectorize the sentences.

[0126] Embodiment 2:

[0127] Please refer to Figure 8 , a news comment filtering method based on news original text provided by an embodiment of the present invention, comprising:

[0128] S4: Obtain the original news text and extract multiple key sentence groups from the original news text.

[0129] S5: According to the news comment filtering method based on key sentence groups described in the first embodiment, news comments are filtered on multiple key sentence groups in turn to obtain news comments corresponding to each key sentence group.

[0130] S6: news comments corresponding to all key sentence groups are taken as news comments of the original news, thereby completing the filtering of news comments of the original news.

[0131] In this embodiment, specifically, according to the news comment filtering method based on key sentence groups described in Example 1, a key sentence group is selected each time through a sliding window algorithm, and corresponding news comments are generated based on the key sentence group. After sentiment analysis and semantic matching are performed on the generated news comments, news comments corresponding to the key sentence group after filtering are obtained, and then the next key sentence group is selected through the sliding window algorithm, and the above steps are repeated until the news comments corresponding to all key sentence groups in the original news text are filtered.

[0132] Embodiment three:

[0133] Please refer to Fig. 9 , a news comment filtering system based on key sentence groups provided by an embodiment of the present invention, comprising:

[0134] The news comment generation module 1 is used to obtain a key sentence group corresponding to the original news text, and calculate multiple first news comments corresponding to the key sentence group according to the GPT-2 model; wherein one key sentence group corresponds to multiple first news comments.

[0135] Sentiment analysis module 2 is used to perform sentiment analysis on the key sentence group and the corresponding first news comment according to the RoBERTa model to obtain the second news comment corresponding to the key sentence group.

[0136] The semantic matching module 3 is used to perform semantic matching on the key sentence group and the corresponding second news comment, obtain the third news comment corresponding to the key sentence group, and complete the filtering of the news comment on the key sentence group.

[0137] For further information, please refer to Fig.10 , the news comment generation module 1 also includes:

[0138] A preprocessing unit is used to preprocess the original news text to obtain vectorized text;

[0139] A division unit is used to divide the text into multiple sentences by using the TextRank algorithm, and respectively calculate the importance of the multiple sentences; wherein one sentence corresponds to one importance;

[0140] A sorting and splicing unit is used to sort the importance in descending order, obtain the top M importances, and splice the M sentences corresponding to the top M importances according to the order of the original news text;

[0141] A selection unit is used to select the concatenated M sentences in sequence through a sliding window algorithm to obtain multiple key sentence groups corresponding to the original news text, and extract one key sentence group from the multiple key sentence groups in sequence according to the selection order;

[0142] The news comment generation unit is used to calculate the corresponding word embedding matrix and position matrix according to the key sentence group, and calculate multiple first news comments corresponding to the key sentence group based on the word embedding matrix and position matrix in combination with the layer normalization processing and decoder module of the GPT-2 model.

[0143] For further information, please refer to Fig.11 , sentiment analysis module 2, also includes:

[0144] A sentiment analysis unit, used for respectively calculating the first sentiment score of the key sentence group and the second sentiment score of each first news comment according to the RoBERTa model;

[0145] The first filtering unit is used to take all first news comments whose second sentiment scores are the same as the first sentiment scores as second news comments corresponding to the key sentence group.

[0146] For further information, please refer to Fig.12 , the semantic matching module 3 further includes:

[0147] A feature vector acquisition unit, used for acquiring a first feature vector of a first key sentence and a second feature vector of a corresponding second news comment according to a Sentence-BERT model;

[0148] The second filtering unit is used to calculate the corresponding cosine similarity according to the first eigenvector and the second eigenvector, and take all the second news comments with cosine similarity greater than a preset threshold as the third news comments corresponding to the key sentence group, so as to complete the filtering of the news comments on the key sentence group.

[0149] Compared with the prior art, all embodiments of the present invention have the following beneficial effects:

[0150] Select the key sentence groups corresponding to the original news text, use the GPT-2 model to generate multiple news comments corresponding to the key sentence groups, avoid reading text irrelevant to the core meaning, and use the RoBERTa model to perform sentiment analysis on the key sentence groups and the corresponding multiple news comments to filter out news comments that do not match the sentiment of the original news text. At the same time, perform semantic matching on news comments that pass sentiment analysis to solve the problem that the generated news comments are not consistent with the meaning of the original news text.

[0151] Furthermore, after the sentiment analysis and semantic matching of multiple news comments corresponding to the key sentence groups are completed, the key sentence groups are reselected based on the original news text, and the generation and filtering of all news comments are iteratively completed, which not only improves the focus of news comments, but also enriches the diversity of news comments.

[0152] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.

Claims

1. A news comment filtering method based on key sentence groups, characterized in that: include: Obtain a key sentence group corresponding to the original news text, and calculate multiple first news comments corresponding to the key sentence group according to the GPT-2 model; wherein one key sentence group corresponds to multiple first news comments; According to the RoBERTa model, sentiment analysis is performed on the key sentence group and the corresponding first news comment to obtain a second news comment corresponding to the key sentence group; Performing semantic matching on the key sentence group and the corresponding second news comments to obtain third news comments corresponding to the key sentence group, and completing filtering of news comments on the key sentence group; The step of obtaining a key sentence group corresponding to the original news text is as follows: Preprocessing the original news text to obtain vectorized text; By using the TextRank algorithm, the text is divided into a plurality of sentences, and the importance of the plurality of sentences is calculated respectively; wherein one sentence corresponds to one importance; The importances are sorted in descending order, the top M importances are obtained, and the M sentences corresponding to the top M importances are concatenated according to the order of the original news texts; The M sentences are sequentially selected through a sliding window algorithm to obtain a plurality of key sentence groups corresponding to the original news text; Extracting one key sentence group from the plurality of key sentence groups in sequence according to the selection order; The TextRank algorithm is used to divide the text into multiple sentences, and the importance of the multiple sentences is calculated respectively, specifically: Divide the vectorized text into complete sentences in the text to get the corresponding sentence set ; Among them, the sentence set Contains n sentences, ; Segment n sentences and remove stop words. Each sentence corresponds to m candidate keywords. ;in, , , Indicates Sentences, Indicates Sentences; According to the following formula, the similarity between adjacent sentences is calculated: Among them, by default, all sentences are adjacent. Indicates candidate keywords, Expressing sentences The total number of words, Expressing sentences The total number of words; Build the graph , we get an undirected weighted graph, where For sentence set , is the sentence similarity; According to the following formula, iteratively propagate weights to calculate the importance values ​​of n sentences: in, Expressing sentences and sentences The similarity between Expressing sentences and sentences The similarity between Representation Node (i.e. sentence ), Representation Node (i.e. sentence ), Representation Node (i.e. sentence ), Represents the damping coefficient, and its value range is , Indicates direction A collection of express The collection indicated; The multiple first news comments corresponding to the key sentence group are calculated according to the GPT-2 model, specifically: According to the key sentence group, a corresponding word embedding matrix and a position matrix are calculated; According to the word embedding matrix and the position matrix, combined with the layer normalization processing and the decoder module of the GPT-2 model, multiple first news comments corresponding to the key sentence group are calculated; The method of performing sentiment analysis on the key sentence group and the corresponding first news comment according to the RoBERTa model to obtain the second news comment corresponding to the key sentence group is as follows: According to the RoBERTa model, respectively calculating the first sentiment score of the key sentence group and the second sentiment score of each of the first news comments; taking all the first news comments having the same second sentiment score as the first sentiment score as the second news comments corresponding to the key sentence group; The first sentiment score of the key sentence group and the second sentiment score of each of the first news comments are calculated according to the RoBERTa model, specifically: The multiple first news comments output by the GPT-2 model and the corresponding key sentence groups are used as the input of the RoBERTa model, and the word sequence is obtained through BPE processing, and then the word vector matrix TE, sentence vector matrix SE and position vector matrix PE are obtained; According to the following formula, the three vector matrices are superimposed to obtain the final word embedding matrix: in, , , represents the dimension of the hidden layer; According to the following formula, after passing through the multi-layer bidirectional Transformer encoder, the first sentiment scores of the key sentence groups are obtained respectively. and the corresponding second sentiment score of each first news comment : in, Represents the output vector of the last hidden layer of the RoBERTa model; The semantic matching of the key sentence group and the corresponding second news comment to obtain the third news comment corresponding to the key sentence group is specifically: According to the Sentence-BERT model, obtaining a first feature vector of the key sentence group and a corresponding second feature vector of the second news comment; The corresponding cosine similarity is calculated according to the first feature vector and the second feature vector, and all the second news comments with cosine similarity greater than a preset threshold are used as the third news comments corresponding to the key sentence group.

2. A news comment filtering method based on the original news, characterized in that: include: Obtaining a news original text, and extracting a plurality of key sentence groups from the news original text; According to the news comment filtering method based on key sentence groups according to claim 1, the news comments are filtered on the multiple key sentence groups in sequence to obtain news comments corresponding to each key sentence group; The news comments corresponding to all the key sentence groups are taken as the news comments of the original news, and the news comments of the original news are filtered.

3. A news comment filtering system based on key sentence groups, characterized in that: include: A news comment generation module, used to obtain a key sentence group corresponding to the original news text, and calculate multiple first news comments corresponding to the key sentence group according to the GPT-2 model; wherein one key sentence group corresponds to multiple first news comments; A sentiment analysis module, configured to perform sentiment analysis on the key sentence group and the corresponding first news comment according to a RoBERTa model, to obtain a second news comment corresponding to the key sentence group; A semantic matching module, used for performing semantic matching on the key sentence group and the corresponding second news comment, obtaining a third news comment corresponding to the key sentence group, and completing filtering of the news comments on the key sentence group; Wherein, the news comment generation module further includes: A preprocessing unit, used for preprocessing the original news text to obtain vectorized text; A division unit is used to divide the text into multiple sentences by using a TextRank algorithm, and respectively calculate the importance of the multiple sentences; wherein one sentence corresponds to one importance; wherein the text is divided into multiple sentences by using a TextRank algorithm, and the importance of the multiple sentences is respectively calculated, specifically: Divide the vectorized text into complete sentences in the text to get the corresponding sentence set ; Among them, the sentence set Contains n sentences, ; Segment n sentences and remove stop words. Each sentence corresponds to m candidate keywords. ;in, , , Indicates Sentences, Indicates Sentences; According to the following formula, the similarity between adjacent sentences is calculated: Among them, by default, all sentences are adjacent. Indicates candidate keywords, Expressing sentences The total number of words, Expressing sentences The total number of words; Build the graph , we get an undirected weighted graph, where For sentence set , is the sentence similarity; According to the following formula, iteratively propagate weights to calculate the importance values ​​of n sentences: in, Expressing sentences and sentences The similarity between Expressing sentences and sentences The similarity between Representation Node (i.e. sentence ), Representation Node (i.e. sentence ), Representation Node (i.e. sentence ), Represents the damping coefficient, and its value range is , Indicates direction A collection of express The collection indicated; A sorting and splicing unit, used to sort the importance in descending order, obtain the top M importances, and splice the M sentences corresponding to the top M importances according to the order of the original news text; A selection unit is used to select the spliced ​​M sentences in sequence through a sliding window algorithm to obtain multiple key sentence groups corresponding to the original news text, and extract one key sentence group from the multiple key sentence groups in sequence according to the selection order; A news comment generation unit, configured to calculate a corresponding word embedding matrix and a position matrix according to the key sentence group, and calculate a plurality of first news comments corresponding to the key sentence group according to the word embedding matrix and the position matrix in combination with the layer normalization processing and the decoder module of the GPT-2 model; Wherein, the sentiment analysis module further includes: The sentiment analysis unit is used to calculate the first sentiment score of the key sentence group and the second sentiment score of each of the first news comments according to the RoBERTa model; wherein the first sentiment score of the key sentence group and the second sentiment score of each of the first news comments are calculated according to the RoBERTa model, specifically: The multiple first news comments output by the GPT-2 model and the corresponding key sentence groups are used as the input of the RoBERTa model, and the word sequence is obtained through BPE processing, and then the word vector matrix TE, sentence vector matrix SE and position vector matrix PE are obtained; According to the following formula, the three vector matrices are superimposed to obtain the final word embedding matrix: in, , , represents the dimension of the hidden layer; According to the following formula, after passing through the multi-layer bidirectional Transformer encoder, the first sentiment scores of the key sentence groups are obtained respectively. and the corresponding second sentiment score of each first news comment : in, Represents the output vector of the last hidden layer of the RoBERTa model; A first filtering unit, configured to take all the first news comments having the same second sentiment score as the first sentiment score as the second news comments corresponding to the key sentence group; Wherein, the semantic matching module further includes: A feature vector acquisition unit, configured to acquire a first feature vector of the key sentence group and a second feature vector of the corresponding second news comment according to a Sentence-BERT model; The second filtering unit is used to calculate the corresponding cosine similarity according to the first feature vector and the second feature vector, and take all the second news comments with cosine similarity greater than a preset threshold as the third news comments corresponding to the key sentence group, so as to complete the filtering of the news comments of the key sentence group.

Citation Information

Patent Citations

  • Game comment processing method and related equipment

    CN111104512A

  • News comment viewpoint sentence identification method

    CN113722482A