A method, device and medium for mining opinions of people's speeches in news
By extracting people's speeches from news texts, generating labels and training central opinion recognition models, combined with clustering and knowledge graphs, it solves the limitations of traditional methods in capturing the complexity of people's speeches and the definition of opinion objects, and achieves accurate opinion mining. and in-depth analysis.
Patent Information
- Application Number
- CN202410576751.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-10
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-05-10
AI Technical Summary
Existing technology is difficult to accurately capture the complexity and stance of characters' speeches in news texts, traditional sentiment analysis methods are difficult to migrate to characters' speeches, and opinion objects are defined as named entities, making it difficult to express news events.
By collecting news documents, preprocessing and extracting people's remarks, generating labels, building prompt templates, training central opinion recognition models, performing clustering and word segmentation, and building knowledge graphs to achieve opinion mining.
Accurately determine whether the person's speech is the central point of view, extract thematic events, gather speeches with similar themes, improve the depth and breadth of opinion mining, and provide valuable reference for research and decision-making.
Smart Images

Figure CN118504556B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic digital data processing, and in particular to a method, device and medium for mining opinions of news characters' speeches. Background Art
[0002] News usually contains a lot of information and opinions, and the speech of characters is an important part of it. Characters' speech often reflects their positions, attitudes and emotions. Mining the opinions of characters in news texts can help the public quickly and accurately grasp the core opinions of the news, clarify the attitudes of news characters, and form a more comprehensive understanding of the news.
[0003] At present, there is a lack of opinion mining paradigms for news texts in the field of opinion mining, and existing opinion mining methods hinder the migration of traditional opinion mining from user comments to character speeches. For example, patent CN111753058A provides a text opinion mining method and system that focuses on analyzing the emotions in user comments, while character speeches in news reports often do not carry clear emotions or have emotional ambiguity, that is, the same speech may express different emotions in different contexts, and traditional sentiment analysis methods are difficult to accurately capture this complexity. In addition, the position and attitude of a character cannot be directly expressed using emotions, which makes it impossible to migrate sentiment classification to character speeches in news. At the same time, traditional methods usually define opinion objects as named entities, while the opinion objects of character speeches are often one or more news events, and news events cannot be represented by a single named entity. Summary of the invention
[0004] In order to solve the above problems, this application proposes a method for analyzing the opinions of people in news, including:
[0005] Collecting news documents and preprocessing the news documents to obtain corresponding news corpus, and extracting character speeches that match trigger words from the news corpus based on a preset trigger word dictionary;
[0006] Generate labels corresponding to the character's speech, and construct a prompt template for connecting the character's speech and its corresponding label words; wherein each label corresponds to a label word;
[0007] Constructing a training sample according to the prompt template, training to obtain a central opinion recognition model, and judging whether the character's speech belongs to the central opinion through the central opinion recognition model;
[0008] Clustering the person's speech to obtain a clustering result consisting of several speech categories, and segmenting the clustering result to obtain a segmented word list of the person's speech;
[0009] For each speech category, selecting a specified character speech segmentation from the character speech segmentation list as a subject event corresponding to the speech category;
[0010] Based on the theme event and the character's speech, a knowledge graph corresponding to the character's speech is generated, so as to realize opinion mining of the character's speech through the knowledge graph.
[0011] In one implementation of the present application, a label corresponding to the character's speech is generated, and a prompt template for connecting the character's speech and its corresponding label word is constructed, specifically including:
[0012] Determine whether the news event mentioned in the person's speech is consistent with the news title to which the person's speech belongs, so as to generate a label corresponding to the person's speech; wherein the label includes 0 and 1;
[0013] Based on a preset tag word mapping dictionary, a mapping relationship between the tag and the tag word corresponding to the tag is constructed, so as to map the tag to a tag word to be filled in the prompt template according to the mapping relationship; wherein the tag word is used to indicate whether the person's speech matches the viewpoint of the news center;
[0014] Construct a prompt template for connecting the character's speech and its corresponding tag word; wherein the prompt template includes a discrete template, a continuous template and a dynamic continuous template.
[0015] In one implementation of the present application, the central opinion recognition model includes a prompt template layer, an input layer, a masked language model layer, and a label word mapping layer in a hierarchical connection order, and a training sample is constructed according to the prompt template to train the central opinion recognition model, which specifically includes:
[0016] Entering the prompt template into the prompt template layer;
[0017] Obtain the prompt template entered by the prompt template layer through the input layer, map the label corresponding to the character's speech to the corresponding label word according to the mapping relationship, and splice the prompt template with the character's speech, the news title, and the label word to obtain a training sample;
[0018] Input the training sample into the masked language model layer, convert the training sample into a training vector containing contextual semantics through the ERNIE pre-trained language model in the masked language model layer, and input the training vector into the label word mapping layer;
[0019] In the case where the prompt template is the discrete template, the training vector is mapped to a preset word list of the ERNIE pre-trained language model through the label word mapping layer, and the probability of the character's speech corresponding to different label words is predicted through the probability corresponding to each word vector related to the label word in the preset word list;
[0020] In the case where the prompt template is the continuous template and the dynamic continuous template, a dot product is performed between the training vector and the word vector corresponding to the label word to obtain the probability that the character's speech corresponds to different label words.
[0021] In one implementation of the present application, selecting a specified character speech segmentation from the character speech segmentation list as the subject event corresponding to the speech category specifically includes:
[0022] Calculate the word segmentation weights corresponding to the word segmentation list of the person's speech in the speech category by using a preset word segmentation weight calculation formula;
[0023] Rearranging the speech participles of each character in the speech participle list according to the order of the participle weights from large to small;
[0024] From the rearranged list of character speech segmentations, a preset number of designated character speech segmentations are selected as the theme events corresponding to the speech category.
[0025] In one implementation of the present application, the word segmentation weight corresponding to the character speech word segmentation list in the speech category is calculated by a preset word segmentation weight calculation formula, specifically including:
[0026]
[0027] Among them, t represents the character speech segmentation, s represents the character speech, d represents the news document, W represents the custom weight, S t represents the person's speech containing the person's speech segmentation word t, and M represents the person's speech in a single news document.
[0028] Frequency.
[0029] In one implementation of the present application, based on a preset trigger word dictionary, before extracting character speeches that match the trigger words from the news corpus, the method further includes:
[0030] Acquire the speech of the historical figure and perform word segmentation on the speech of the historical figure, and select trigger words for identifying the speech of the figure from the obtained word segmentation results;
[0031] Calculating the frequency of the trigger words, and selecting, according to the frequency, a trigger word with a frequency greater than a preset value from the trigger words as a seed word;
[0032] Determine a related word with the same meaning as the seed word, and use the related word as a new seed word, repeat the above process to expand the seed word until an expanded seed word is obtained;
[0033] Irrelevant words that do not match the trigger words are removed from the expanded seed words to obtain a trigger word dictionary.
[0034] In one implementation of the present application, judging whether the character's speech belongs to the central point of view through the central point of view recognition model specifically includes:
[0035] Inputting the character's speech into the central opinion recognition model, and outputting a label corresponding to the character's speech through the central opinion recognition model;
[0036] If the label is 0, the character's speech belongs to the central point of view; if the label is 1, the character's speech does not belong to the central point of view.
[0037] In one implementation of the present application, the person's speech is clustered to obtain a clustering result consisting of several speech categories, specifically including:
[0038] The character's speech is vectorized through the preset M3E pre-trained language model to obtain the corresponding static vector;
[0039] The static vector corresponding to the character's speech is reduced in dimension by using the U-MAP dimension reduction algorithm. The character's speech is clustered by using a hierarchical clustering algorithm for the static vector after dimension reduction to obtain a clustering result consisting of several speech categories.
[0040] The present application embodiment provides a device for mining opinions of people's speeches in news, the device comprising:
[0041] at least one processor;
[0042] and, a memory communicatively coupled to the at least one processor;
[0043] Among them, the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a method for mining people's speech and opinions in news as described in any of the above items.
[0044] The embodiment of the present application provides a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as follows:
[0045] A method for mining opinions and speeches of people in news as described in any of the above items.
[0046] The method for analyzing the opinions of people in news proposed in this application can bring the following beneficial effects:
[0047] Through the preset trigger word dictionary, the character's speech that matches the trigger words is extracted from the news corpus. Then, by constructing a prompt template and generating labels corresponding to the character's speech, a central opinion recognition model is trained. This model can accurately determine whether the character's speech belongs to the central opinion, avoiding the limitations of traditional sentiment analysis methods in sentiment analysis of character speech.
[0048] News events are treated as opinion objects, and thematic events related to people's speeches are extracted through steps such as clustering and word segmentation, which solves the limitation of traditional methods that define opinion objects as named entities.
[0049] Clustering people's speeches can bring together speeches with similar themes, making it easier to reflect the distribution and differences of opinions of different people or groups on a certain news topic, and helping researchers or analysts to gain a deeper understanding of people's opinions and attitudes.
[0050] By constructing a knowledge graph, the depth and breadth of opinion mining are further improved, providing valuable reference for research and decision-making in related fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0052] Figure 1 A flowchart of a method for mining opinions of people's speeches in news provided by an embodiment of the present application;
[0053] Figure 2 A schematic diagram of the structure of a device for mining opinions and speeches of news characters provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0055] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0056] like Figure 1 As shown, the embodiment of the present application provides a method for mining opinions of people's speeches in news, including:
[0057] S101: Collect news documents and pre-process them to obtain corresponding news corpus, and extract character speeches that match trigger words from the news corpus based on a preset trigger word dictionary.
[0058] News documents can be obtained through news websites, APIs or other sources. Depending on the source of the news, the server can use different methods, such as web crawlers or news APIs, to obtain news documents. Since the subsequent mining of people's opinions and views is based on news documents, after obtaining the news documents, the news documents need to be preprocessed to clean up irrelevant information in the news documents, such as news links, website names, release time, advertisements, and picture information. After completing the above processing, the news documents are divided into sentences through the preset trigger word dictionary, and the person's speech that meets the trigger words can be extracted from the news corpus. Trigger words refer to words used to identify people's speeches, such as "express", "say", "call", "point out", "emphasize", "believe", "announce", "mention", etc. When extracting people's speeches based on trigger words, first traverse each sentence in the news corpus and use regular expressions or string matching methods to find sentences containing trigger words. In the sentences containing trigger words, identify and extract the subject of the speech, that is, the person who made the speech, which can usually be achieved by analyzing sentence structure, name entity recognition, and other methods. Afterwards, the speech content related to the trigger word is extracted from the sentence, that is, the character's name and the character's specific expression. At this point, the extraction of the character's speech is completed.
[0059] It should be noted that the trigger word dictionary is a word set obtained by selecting seed words with higher frequencies and expanding the seed words in advance. During its construction process, the server needs to obtain the speeches of historical figures and segment the speeches of historical figures, and filter out the trigger words used to identify the speeches of the characters from the segmentation results. For the above trigger words, the frequency of the trigger words is calculated, and according to the frequency, the trigger words with a frequency greater than the preset value are selected from the trigger words as seed words. The preset value can be set according to the required word quantity, and this application does not impose any restrictions on this. After obtaining the seed words, due to the limited number of seed words, the seed words need to be expanded based on the preset synonym word forest, that is, it is necessary to determine the associated words with the same meaning as the seed words, and use the associated words as new seed words. Repeat the above process to continuously expand the seed words until the seed words can no longer be expanded, and then the expanded seed words are obtained. The expanded seed words may contain some synonyms that do not fit the category of trigger words for character speech, including garbled characters, numbers, symbols, and some trigger words that are irrelevant to character speech in meaning. Therefore, it is necessary to remove irrelevant words that do not match the trigger words from the expanded seed words to obtain a trigger word dictionary.
[0060] S102: Generate labels corresponding to the person's speech, and construct a prompt template for connecting the person's speech and its corresponding label words; wherein each label corresponds to a label word.
[0061] After extracting the person's speech, it is necessary to determine whether the person's speech is the central point in the news document. To determine whether a person's speech is a central point, it depends on whether the speech itself is consistent with the news title. Generally speaking, if the person's speech is consistent with the news title, it is a central point. For example, the news title is "Experts call for strengthening environmental protection measures to combat climate change." In this news report, the extracted person's speech is: Experts say we must take immediate action to strengthen environmental protection measures to slow the pace of climate change. This person's speech is a central point.
[0062] Based on this, the label corresponding to the person's speech can be generated according to whether the news event mentioned in the person's speech matches the news title to which the person's speech belongs. The label includes 0 and 1. If it matches, the label is set to 0, which is used to indicate that the person's speech can be used as the central point of the news. Otherwise, the label is set to 1, which means that the person's speech does not belong to the central point of the news.
[0063] The embodiment of the present application uses a prompt learning method to construct a prompt template and a label word mapping to identify the central viewpoint in the character's speech. The core idea of prompt learning is to convert the natural language processing task into a form of "filling in the blanks" or "cloze test". Specifically, by inserting specific prompts into the input text, the model is guided to predict or generate content related to these prompts, which can be discrete text tags or continuous embedded vectors. In this way, the training and application process of the model can be simplified. Therefore, after generating the labels corresponding to the character's speech, if prompt learning is to be performed, a prompt template for connecting the character's speech and its corresponding label words needs to be constructed. There is a mapping relationship between the label word and the label, and a mapping relationship between the label and the label word corresponding to the label needs to be constructed based on a preset label word mapping dictionary. In this way, according to the mapping relationship, the label can be mapped to the label word to be filled in the prompt template. The label word is used to indicate whether the character's speech matches the central viewpoint of the news, including "yes" and "no". Among them, the label word "yes" corresponds to the label "0", and the label word "no" corresponds to the label "1". By constructing a mapping relationship, the probability of the predicted label can be converted into the probability of the corresponding label word in the prompt template.
[0064] There are three types of prompt templates, namely, prompt templates including discrete templates, continuous templates and dynamic continuous templates.
[0065] The discrete template directly splices predefined prompt sentences based on the annotated person's speech and news headlines, for example, "This person's speech is related to the title [MASK]", where the [MASK] position is the predefined label words 'yes' and 'no'. In this template, the word vector matrix of the person's speech and the news headline is shared, and the word vector representation is generated by the same pre-trained language model. The vocabulary in both is mapped to the representation in the same word vector space. At this time, the prompt template is the discrete characters in the pre-trained model dictionary. The token id of the discrete characters remains fixed during the training process, which means that the model will not learn new character representations during the training process, but will continue to use the representations learned in the pre-trained model.
[0066] The continuous template uses a set of learnable continuity prompt vectors. It inputs predefined natural language prompts into the language model and then extracts the hidden state or output of the middle layer of the model as the continuity prompt vector. During fine-tuning, a knowledge template in a continuous space of length 10 is trained. By learning the correlation between the person's speech and the news headline, the model can obtain additional knowledge of a certain length, thereby improving the model performance.
[0067] Dynamic continuous template (is a template style formed by introducing prompt encoder based on continuous template, taking into account the mutual dependence or correlation between these pseudo-tags. The word vectors corresponding to the pseudo-tags in the continuous template are sent to the neural network multi-layer perceptron MLP for further representation, and then the obtained hidden state vector is concatenated with the word vector of the input sentence pair and input into the model. The vector of the prompt template in the dynamic continuous template is not shared with the word vector of the input character speech and news headline pair, and the parameters of the two are updated separately during the fine-tuning process.
[0068] S103: constructing training samples according to the prompt template, training a central opinion recognition model, and judging whether the character's speech belongs to the central opinion through the central opinion recognition model.
[0069] The above-constructed prompt template is only used to indicate how to connect the character's speech and the news headline. In the actual training process, it is necessary to introduce the above-mentioned prompt template to form a training sample, so as to simplify the model training process through prompt learning and obtain a trained central opinion recognition model. In an embodiment of the present application, the central opinion recognition model is constructed based on the ERNIE pre-trained language model, and includes a prompt template layer, an input layer, a masked language model layer and a label word mapping layer in order of hierarchical connection. It should be noted that when constructing the central opinion recognition model, it can also be constructed on the basis of other types of pre-trained language models, such as BERT, GPT, etc., which can be selected according to actual needs.
[0070] In one embodiment, the prompt template layer is located at the bottom layer of the central viewpoint recognition model. The prompt template constructed by the above content needs to be entered into the prompt template layer, and the entered prompt template needs to be transmitted to the input layer to provide a buffer for the designed prompt template.
[0071] The input layer can obtain the prompt template entered by the prompt template layer, and map the label corresponding to the character's speech to the corresponding label word according to the mapping relationship. The label word is used to fill in the prompt template, and the prompt template is spliced with the character's speech, news headline, and label word to obtain a training sample for model training. It should be noted that the Prompt Encoder included in the dynamic continuous template is a small neural network. The network does not pass through the input layer and directly inputs the pre-trained language model in the masked language model layer. Its parameters can be back-propagated and trained in the fine-tuning process through back-propagation, which plays an updating role for the dynamic continuous template.
[0072] After the discrete template and the continuous template generate training samples, the training samples are input into the masked language model layer. The masked language model layer uses the ERNIE pre-trained language model to convert the training samples into training vectors containing contextual semantics through the semantic representation ability of the pre-trained language model, and inputs the training vectors into the label word mapping layer.
[0073] The label mapping layer can predict label words according to different prompt templates, and map label words to labels to predict the probability of character speech under different labels. Different types of prompt templates have different corresponding prediction methods. When the prompt template is a discrete template, the training vector is mapped to the preset vocabulary of the ERNIE pre-trained language model through the MLM Head fully connected layer in the label word mapping layer, and the model-encoded vector is converted into the probability distribution of each word in the vocabulary. What the model ultimately needs is the probability of character speech corresponding to different label words. Therefore, the probability corresponding to the word vector related to the label word is extracted from the probability distribution output by the MLM Head, and the probability of character speech corresponding to different label words can be predicted. When the prompt template is a continuous template and a dynamic continuous template, there is no need to go through the fully connected layer. The training vector is directly dot-producted with the word vector corresponding to the label word. The word vector is generated by the ERNIE pre-trained language model. In this way, the probability of character speech corresponding to different label words can be obtained.
[0074] At this point, the training of the central opinion recognition model has been achieved through prompt learning. At this time, the central opinion recognition model can determine whether the task speech belongs to the central opinion, and map the predicted label words to labels based on the mapping relationship between labels and label words, and finally output the label probability.
[0075] Specifically, the character's speech is input into the central opinion recognition model, and the central opinion recognition model outputs the label corresponding to the character's speech. If the label is 0, it means that the character's speech belongs to the central opinion, otherwise, if the label is 1, the character's speech does not belong to the central opinion.
[0076] Identifying whether a person's speech belongs to the central point of view can enable users to understand the main idea of the news text more quickly, help users obtain key information more quickly, and avoid being distracted by secondary information or details.
[0077] S104: Clustering the person's speech to obtain a clustering result consisting of several speech categories, and segmenting the clustering result to obtain a segmented word list of the person's speech.
[0078] A large number of people's speeches often contain a lot of repeated, similar or related information. Through clustering, these speeches can be grouped according to their inherent characteristics or themes, which helps to better understand and analyze the diversity of people's speeches, extract key information and discover the potential relationship between speeches. Clustering can classify people's speeches with similar themes or opinions into one category, and can quickly summarize and integrate the core ideas in a large number of speeches, so as to more clearly understand the basic positions and views of different people or groups on a certain news topic, and realize in-depth mining of the opinions of news figures.
[0079] In one embodiment, the character speech is vectorized through the preset M3E pre-trained language model to obtain the corresponding static vector. The M3E model adopts the Transformer architecture, which can effectively capture the long-distance dependencies and semantic information in the text through a multi-layer self-attention mechanism and a feedforward neural network, thereby generating a high-dimensional vector representation for each character speech.
[0080] The M3E model obtains a high-dimensional static vector, which needs to be reduced in dimension through the U-MAP dimensionality reduction algorithm to reduce the static vector corresponding to the character's speech, thereby reducing the original static vector to a two-dimensional space that is easier to visualize and understand.
[0081] For the static vector after dimensionality reduction, the HDBSCAN hierarchical clustering algorithm is used to identify the clustering structure by considering the local density of the data, and the data points are grouped into compact clusters according to density accessibility. When clustering the vector after dimensionality reduction, the number of clusters is automatically determined, and each data point is assigned to the most appropriate cluster according to the distribution of the data, thereby obtaining a clustering result composed of several speech categories. There are many types of speech categories, which can be policy speech, cultural speech, etc.
[0082] After obtaining the clustering results, it is necessary to segment the clustering results corresponding to each speech category to obtain a segmented list of character speech. The character speech analysis list provides a data basis for the subsequent extraction of topic events.
[0083] S105: For each speech category, select a specified character speech segmentation from the character speech segmentation list as a theme event corresponding to the speech category.
[0084] Thematic event representation can provide a concise and comprehensive content summary, helping researchers or analysts to quickly understand the core content and main viewpoints of each type of person's speech. In addition, by comparing thematic event representations of different types of person's speech, it can reveal the differences and consensus of different groups or individuals on a certain issue, and can more deeply understand and analyze the content, viewpoints and trends of person's speech, providing strong support for research or decision-making in related fields. Therefore, it is necessary to select the specified person's speech segmentation from the person's speech segmentation list as the thematic event corresponding to the speech category.
[0085] Specifically, the word segmentation weight corresponding to the character speech word segmentation list in the speech category is calculated by a preset word segmentation weight calculation formula. According to the order of word segmentation weight from large to small, the character speech word segmentations in the character speech word segmentation list are rearranged, and then, from the rearranged character speech word segmentation list, a preset number of designated character speech word segmentations are selected as the theme event corresponding to the speech category. The preset number is set according to actual needs, and this application does not limit this.
[0086] The word segmentation weight calculation formula is a weight calculation implemented on the basis of the TF-DIF algorithm. The traditional TF-DIF algorithm comprehensively evaluates the contribution of words in news documents by combining word frequency and inverse document frequency. However, since the character's views have certain uniqueness in expression, in order to establish the connection between the character's speech segmentation and the character's speech, it is necessary to screen out keywords that are of high importance to the character's speech. Based on this, the embodiment of the present application introduces the concept of repetition rate to perform topic analysis on the character's speech in the same speech category. Unlike word frequency, which is calculated based on the total number of words in the entire news document, the repetition rate focuses on the number of sentences in the character's speech in the news document. For words that appear multiple times in the same sentence, they are regarded as appearing once in the sentence, so that they are not considered more important because of the number of times they appear. The repetition rate describes the inverse of the frequency of a character's speech segmentation in different character speeches, which can be expressed by the following formula:
[0087]
[0088] Where W represents the custom weight. As the number of repetitions increases, the value will also increase in a logarithmic manner. M represents the total number of comments in a single news document. S t It represents the person's speech containing the person's speech participle t, and Count is the measurement function.
[0089] Combining the repetition rate with the TF-DIF algorithm, we get the formula for calculating the word segmentation weight:
[0090]
[0091] Among them, t represents the character speech segmentation, s represents the character speech, d represents the news document, tf t,d Indicates the frequency of character speech segmentation in news documents, Represents inverse document frequency.
[0092] The above word segmentation weight calculation formula can highlight the importance of character speech segmentation in different character speeches and in the entire news document. In addition, the repetition rate can also be used to mine the core content of character speeches with low overall word frequency, thereby improving the accuracy of character speech opinion mining.
[0093] S106: Generate a knowledge graph corresponding to the character's speech based on the theme event and the character's speech, so as to realize opinion mining on the character's speech through the knowledge graph.
[0094] After determining whether a person's speech belongs to the central idea through the above process, and determining the theme event of each speech category, the embodiment of the present application provides a more intuitive analysis method. Through a preset knowledge graph tool, the clustering results are visualized to generate a corresponding person-theme event knowledge graph.
[0095] In this process, the central viewpoint, characters, character speech content and theme event representation must first be integrated through data processing tools to form an Excel data file that can be called. Then, using knowledge graph tools such as Vis.js, theme events and character speech are displayed in a graphical form, where each node represents a character, theme event, news headline or character speech, and the lines between nodes indicate that there is a connection between the character and the theme event. The central viewpoint belongs to the character speech, from which we can know the character's main views and attitudes towards the event.
[0096] The above are embodiments of the method proposed in this application. Based on the same idea, some embodiments of this application also provide devices and non-volatile computer storage media corresponding to the above methods.
[0097] Figure 2 The present invention provides a structural diagram of a device for mining opinions of people’s speeches in news. Figure 2 As shown, including:
[0098] at least one processor; and,
[0099] at least one processor is communicatively connected to a memory; wherein,
[0100] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that the at least one processor can execute a method for mining people's speech and opinions in news as described in any of the above items.
[0101] The embodiment of the present application provides a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as follows:
[0102] A method for mining opinions and speeches of people in news as described in any of the above items.
[0103] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0104] The devices and media provided in the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0105] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0106] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0107] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.
[0108] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0109] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0110] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0111] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0112] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0113] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for mining opinions of people's speeches in news, characterized by: The method comprises: Collecting news documents and preprocessing the news documents to obtain corresponding news corpus, and extracting character speeches that match trigger words from the news corpus based on a preset trigger word dictionary; Generate labels corresponding to the character's speech, and construct a prompt template for connecting the character's speech and its corresponding label words; wherein each label corresponds to a label word; Constructing a training sample according to the prompt template, training to obtain a central opinion recognition model, and judging whether the character's speech belongs to the central opinion through the central opinion recognition model; Clustering the person's speech to obtain a clustering result consisting of several speech categories, and segmenting the clustering result to obtain a segmented word list of the person's speech; For each speech category, selecting a specified character speech segmentation from the character speech segmentation list as a subject event corresponding to the speech category; According to the theme event and the character's speech, a knowledge graph corresponding to the character's speech is generated, so as to realize opinion mining of the character's speech through the knowledge graph; The central opinion recognition model includes a prompt template layer, an input layer, a masked language model layer and a label word mapping layer in a hierarchical connection order. A training sample is constructed according to the prompt template, and the central opinion recognition model is obtained through training, which specifically includes: Entering the prompt template into the prompt template layer; Obtain the prompt template entered by the prompt template layer through the input layer, map the label corresponding to the character's speech to the corresponding label word according to the mapping relationship, and splice the prompt template with the character's speech, the news title, and the label word to obtain a training sample; Input the training sample into the masked language model layer, convert the training sample into a training vector containing contextual semantics through the ERNIE pre-trained language model in the masked language model layer, and input the training vector into the label word mapping layer; In the case where the prompt template is a discrete template, the training vector is mapped to a preset word list of the ERNIE pre-trained language model through the label word mapping layer, and the probability of the character's speech corresponding to different label words is predicted through the probability corresponding to each word vector related to the label word in the preset word list; When the prompt template is a continuous template and a dynamic continuous template, a dot product is performed between the training vector and the word vector corresponding to the label word to obtain the probability that the character's speech corresponds to different label words.
2. The method for mining opinions of people's speeches in news according to claim 1, characterized in that: Generate a label corresponding to the character's speech, and construct a prompt template for connecting the character's speech and its corresponding label word, specifically including: Determine whether the news event mentioned in the person's speech is consistent with the news title to which the person's speech belongs, so as to generate a label corresponding to the person's speech; wherein the label includes 0 and 1; Based on a preset tag word mapping dictionary, a mapping relationship between the tag and the tag word corresponding to the tag is constructed, so as to map the tag to a tag word to be filled in the prompt template according to the mapping relationship; wherein the tag word is used to indicate whether the person's speech matches the viewpoint of the news center; Construct a prompt template for connecting the character's speech and its corresponding tag word; wherein the prompt template includes a discrete template, a continuous template and a dynamic continuous template.
3. The method for mining opinions of people's speeches in news according to claim 1, characterized in that: Selecting a specified character speech segmentation from the character speech segmentation list as a subject event corresponding to the speech category specifically includes: Calculate the word segmentation weights corresponding to the word segmentation list of the person's speech in the speech category by using a preset word segmentation weight calculation formula; Rearranging the speech participles of each character in the speech participle list according to the order of the participle weights from large to small; From the rearranged list of character speech segmentations, a preset number of designated character speech segmentations are selected as the theme events corresponding to the speech category.
4. The method for mining opinions of people's speeches in news according to claim 1, characterized in that: The word segmentation weight corresponding to the character speech word segmentation list in the speech category is calculated by a preset word segmentation weight calculation formula, specifically including: Among them, t represents the character speech segmentation, s represents the character speech, d represents the news document, W represents the custom weight, S t represents the person's speech containing the person's speech segmentation word t, M represents the total number of person's speeches in a single news document, tf t,d Indicates the frequency of character speech segmentation in news documents, Represents inverse document frequency.
5. The method for mining opinions of people's speeches in news according to claim 1, characterized in that: Based on a preset trigger word dictionary, before extracting character speeches that match the trigger words from the news corpus, the method further includes: Acquire the speech of the historical figure and perform word segmentation on the speech of the historical figure, and select trigger words for identifying the speech of the figure from the obtained word segmentation results; Calculating the frequency of the trigger words, and selecting, according to the frequency, a trigger word with a frequency greater than a preset value from the trigger words as a seed word; Determine a related word with the same meaning as the seed word, and use the related word as a new seed word, repeat the above process to expand the seed word until an expanded seed word is obtained; Irrelevant words that do not match the trigger words are removed from the expanded seed words to obtain a trigger word dictionary.
6. The method for mining opinions of people's speeches in news according to claim 1, characterized in that: Using the central opinion recognition model, determining whether the character's speech belongs to the central opinion includes: Inputting the character's speech into the central opinion recognition model, and outputting a label corresponding to the character's speech through the central opinion recognition model; If the label is 0, the character's speech belongs to the central point of view; if the label is 1, the character's speech does not belong to the central point of view.
7. The method for mining opinions of people's speeches in news according to claim 1, characterized in that: Clustering the person's speech to obtain a clustering result consisting of several speech categories, including: The character's speech is vectorized through the preset M3E pre-trained language model to obtain the corresponding static vector; The static vector corresponding to the character's speech is reduced in dimension by using the U-MAP dimension reduction algorithm. The character's speech is clustered by using a hierarchical clustering algorithm for the static vector after dimension reduction to obtain a clustering result consisting of several speech categories.
8. A device for mining opinions of people in news, characterized by: The device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; Wherein, the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a method for mining people's speech and opinions for news as described in any one of claims 1-7.
9. A non-volatile computer storage medium storing computer executable instructions, characterized in that: The computer executable instructions are configured to: A method for mining people's opinions and opinions in news as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Text viewpoint mining method and system
CN111753058A
User comment automatic recommendation method
CN107577759A
Fine-grained sentiment analysis method and device for catering industry comments
CN114969341A
Comment processing method and device, electronic equipment, storage medium and program product
CN117216184A
Picture grouping method and device, electronic equipment and storage medium
CN117649667A
