Document sentiment recognition method and device, electronic equipment and storage medium
By extracting opinion subjects and descriptions from documents and using a probabilistic graphical model to calculate weights, the problem of the influence of core opinions not being considered in document sentiment recognition is solved, resulting in more accurate sentiment recognition.
Patent Information
- Application Number
- CN202310660456.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-05
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2043-06-05
AI Technical Summary
Existing document sentiment recognition methods fail to adequately consider the interplay between core viewpoints, resulting in sentiment recognition methods that cannot accurately reflect genuine emotions.
By extracting opinion subjects and opinion descriptions from documents, a pre-trained probabilistic graphical model is used to determine the weights of target opinion subjects and calculate the sentiment scores of documents. This approach combines multi-task reading comprehension and multi-attention modules to improve the accuracy of opinion extraction.
This improves the accuracy of document sentiment recognition, enabling it to accurately reflect the true emotions conveyed in documents and enhancing the reference value of sentiment recognition.
Smart Images

Figure CN116701627B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of text analysis, and particularly relates to a document sentiment recognition method, a document sentiment recognition device, an electronic device and a storage medium. BACKGROUND
[0002] Current text sentiment recognition schemes basically use text classification models to classify the emotions of a piece of text. Industry research reports are in-depth analyses of some industry phenomena or policies by industry professionals. The emotional tendency thereof reflects the optimistic or pessimistic estimates of industry personnel on an object and has strong guiding significance. Therefore, the sentiment judgment of research reports has great value. Although the existing classification method can be used in most classification scenarios, in research reports, some unique expression structures are not very meaningful if directly used for sentiment judgment, and are prone to errors. In research reports, each paragraph describes different core points. Therefore, different core points are likely to contain different emotional trends. When calculating the overall sentiment of a research report, simply merging the core points into text and then using a classification model will ignore the emotional differences between different points. SUMMARY
[0003] The technical problem to be solved by the present application is to provide a document sentiment recognition method, a document sentiment recognition device, an electronic device and a storage medium, so as to solve the problem that the sentiment recognition of a document only classifies core points simply and fails to fully consider the mutual influence between core points, resulting in that the sentiment recognition of a document cannot accurately reflect the true sentiment.
[0004] In order to solve or to some extent improve the above technical problems, according to one aspect of the present application, a document sentiment recognition method is provided, comprising:
[0005] Extracting at least one set of corresponding point objects and point descriptions in the document;
[0006] Selecting at least one target point from at least one set of the point objects and the point descriptions, the target point comprising a corresponding target point object and a target point description;
[0007] Based on the text content of at least one target point, assigning a point score corresponding to at least one target point;
[0008] Determining the weight corresponding to at least one target point by a pre-trained probability graph model, and calculating the sentiment score of the document according to at least one point score and at least one weight.
[0009] In some embodiments, the extraction of the at least one set of the opinion object and the opinion description is based on an opinion extraction model, the opinion extraction model comprising: a first reading comprehension module and a second reading comprehension module;
[0010] The step of extracting the at least one set of the opinion object and the opinion description corresponding to each other in the document comprises:
[0011] The text content of the document is input into the first reading comprehension module and the second reading comprehension module, respectively;
[0012] At least one opinion object in the document is extracted based on the opinion object template in the first reading comprehension module;
[0013] At least one opinion object and the text content of the opinion object are input into the second reading comprehension module, and at least one opinion description corresponding to at least one opinion object is extracted by combining the opinion description template in the second reading comprehension module.
[0014] In some embodiments, the opinion extraction model further comprises a first multi-attention module and a second multi-attention module;
[0015] The step of selecting at least one target opinion from the at least one set of the opinion object and the opinion description comprises:
[0016] At least one opinion object is input into the first multi-attention module, and at least one target opinion object and the text location of the target opinion object in at least one opinion object are selected based on the target opinion matrix in the first multi-attention module;
[0017] At least one target opinion object, the text location, and at least one opinion description are input into the second multi-attention module, and at least one target opinion description corresponding to at least one target opinion object in at least one opinion description is determined based on the text location.
[0018] In some embodiments, the training loss of the opinion extraction model is the sum of the training loss of the opinion object and the training loss of the opinion description.
[0019] In some embodiments, the step of assigning an opinion score corresponding to at least one target opinion based on the text content of at least one target opinion comprises:
[0020] The text content of at least one target opinion is input into a pre-trained text classification model to classify at least one target opinion;
[0021] According to the correspondence between the preset categories and scores, the corresponding view score is assigned to each of the target views according to the category of the target view.
[0022] In some embodiments, the step of pre-training the probabilistic graph model comprises:
[0023] A probabilistic graph is created based on at least one target view of each of a plurality of documents, wherein the target view comprises a target view object and a target view description corresponding to each other, and each node in the probabilistic graph is a target view and a view score;
[0024] When the target views and view scores of a plurality of nodes are the same, the plurality of nodes are merged;
[0025] A sentiment score corresponding to each of the documents is assigned, and the weight of the edge of a node pair, which is two nodes connected by an edge, is calculated based on the number of occurrences of the node pair, the sentiment score of each document, and the view score of each target view.
[0026] In some embodiments, the step of determining the weight corresponding to each of the target views by the pre-trained probabilistic graph model, and calculating the sentiment score of the document based on the view score of at least one of the target views and the weight of at least one of the target views, comprises:
[0027] At least one of the target views is input into the pre-trained probabilistic graph model to determine the node corresponding to the target view;
[0028] The view score of at least one of the target views is multiplied by the weight of the edge of the corresponding node and summed to calculate the sentiment score of the document.
[0029] According to another aspect of the present application, a sentiment recognition device for a document is provided, comprising:
[0030] An extraction module configured to extract at least one set of view objects and view descriptions corresponding to each other in the document;
[0031] A selection module configured to select at least one target view from at least one of the view objects and the view descriptions, wherein the target view comprises a target view object and a target view description corresponding to each other;
[0032] An assignment module configured to assign a view score corresponding to each of the target views based on the text content of the target view;
[0033] The computing module is configured to determine a weight corresponding to each of the target viewpoints by using a pre-trained probabilistic graph model, and calculate a sentiment score of the document according to the viewpoint scores and the weights.
[0034] In some embodiments, the extraction of the at least one set of viewpoint objects and viewpoint descriptions is based on a viewpoint extraction model, and the viewpoint extraction model comprises a first reading comprehension module and a second reading comprehension module.
[0035] The extraction module is specifically configured to:
[0036] The text content of the document is input into the first reading comprehension module and the second reading comprehension module, respectively;
[0037] At least one viewpoint object in the document is extracted based on a viewpoint object template in the first reading comprehension module.
[0038] At least one viewpoint description corresponding to the at least one viewpoint object is extracted by inputting the at least one viewpoint object and the text content of the viewpoint object into the second reading comprehension module and combining a viewpoint description template in the second reading comprehension module.
[0039] In some embodiments, the viewpoint extraction model further comprises a first multi-attention module and a second multi-attention module.
[0040] The selection module is specifically configured to:
[0041] At least one target viewpoint object and a text location of the target viewpoint object are selected from the at least one viewpoint object based on a target viewpoint matrix in the first multi-attention module by inputting the at least one viewpoint object into the first multi-attention module.
[0042] At least one target viewpoint description corresponding to the at least one target viewpoint object is determined from the at least one viewpoint description based on the text location by inputting the at least one target viewpoint object, the text location, and the at least one viewpoint description into the second multi-attention module.
[0043] In some embodiments, the training loss of the viewpoint extraction model is the sum of the training loss of the viewpoint object and the training loss of the viewpoint description.
[0044] In some embodiments, the assignment module is specifically configured to:
[0045] The text content of the at least one target viewpoint is input into a pre-trained text classification model to classify the at least one target viewpoint.
[0046] According to the pre-set correspondence between the categories and the scores, the corresponding view score is assigned to each of the target views according to the category of the target view.
[0047] In some embodiments, the pre-training of the probabilistic graph model comprises:
[0048] A probabilistic graph is created based on at least one target view of each of a plurality of documents, wherein the target view comprises a target view object and a target view description corresponding to each other, and each node in the probabilistic graph is a target view and a view score;
[0049] When the target view and the view score of a plurality of nodes are the same, the plurality of nodes are merged;
[0050] A sentiment score corresponding to each of the documents is assigned, and the weight of the edge of a node pair is calculated based on the number of occurrences of the node pair, the sentiment score of each document, and the view score of each target view, wherein the node pair is two nodes connected by an edge.
[0051] In some embodiments, the computing module is specifically configured to:
[0052] At least one target view is input into a pre-trained probabilistic graph model to determine a node corresponding to the at least one target view;
[0053] The view score of the at least one target view is multiplied by the weight of the edge of the corresponding node, and the sentiment score of the document is calculated by summing the products.
[0054] According to still another aspect of the present application, an electronic device is provided, comprising a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface complete communication with each other through the communication bus;
[0055] The memory is used to store at least one executable instruction, and the executable instruction causes the processor to perform operations corresponding to the sentiment recognition method of the document according to any of the above embodiments.
[0056] According to still another aspect of the present application, a computer readable storage medium is provided, wherein the computer readable storage medium stores one or more programs, and the one or more programs, when executed by a processor, implement operations corresponding to the sentiment recognition method of the document according to any of the above embodiments.
[0057] The present application has obvious advantages and beneficial effects compared with the prior art. The document sentiment recognition method, the document sentiment recognition device, the electronic equipment and the computer readable storage medium of the present application can achieve considerable technical progress and practicality, and have wide industrial utilization value, and at least have the following advantages:
[0058] The present application first assigns values to the selected target viewpoints, then determines the weights of the target viewpoints in the document sentiment recognition, and finally calculates the sentiment score of the document through the assignment of the target viewpoints and the corresponding weights. The different target viewpoints with different sentiments in the document are fused, and the mutual influence between different target viewpoints is captured, so that the recognized document sentiment can accurately reflect the true sentiment of the document, thereby improving the reference value of the document sentiment recognition.
[0059] The above description is only a summary of the technical solutions of the present application. In order to more clearly understand the technical means of the present application, the content of the specification can be implemented, and in order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the following preferred embodiments are described in detail below, and the accompanying drawings are described as follows. BRIEF DESCRIPTION OF DRAWINGS
[0060] Figure 1 The flowchart of the document sentiment recognition method of an embodiment of the present application is shown in the figure.
[0061] Figure 2 The schematic block diagram of the viewpoint extraction model of an embodiment of the present application is shown in the figure.
[0062] Figure 3 The schematic diagram of the probabilistic graph model of an embodiment of the present application is shown in the figure.
[0063] Figure 4 The schematic block diagram of the document sentiment recognition device of an embodiment of the present application is shown in the figure.
[0064] Figure 5 The schematic block diagram of the electronic equipment of an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0065] In order to further illustrate the technical means and effects adopted by the present application to achieve the predetermined invention purpose, the specific implementation and effects of the document sentiment recognition method, the document sentiment recognition device, the electronic equipment and the storage medium according to the present application are described in detail as follows.
[0066] Figure 1A document sentiment recognition method according to an embodiment of the present application is shown, which is applied to an electronic device. The electronic device includes a smart terminal device, a computer device and / or a cloud installed with a computer program, the smart terminal device includes but is not limited to a smart phone, a PAD; the computer device includes but is not limited to a personal computer, a notebook computer, an industrial computer, a network host, a single network server, a plurality of network server sets; the cloud is composed of a large number of computers or network servers based on cloud computing, wherein cloud computing is a kind of distributed computing, which is a virtual supercomputer composed of a group of loosely coupled computer sets.
[0067] The present application firstly extracts the target opinion of the document, which includes the target opinion object and the target opinion description, then identifies the sentiment category of each target opinion through the classification model, and clusters the target opinion description according to the target opinion object, finally fuses the sentiments of different target opinions in one document through the probabilistic graph model, and finally obtains the sentiment score of the document.
[0068] Specifically, referring to Figure 1 According to an embodiment of the present application, a document sentiment recognition method is provided, which includes:
[0069] Step S10, extracting at least one set of corresponding opinion object and opinion description in the document.
[0070] In the extraction of document opinions, keyword matching or bold statement recognition and other methods are usually used, and such methods have low coverage of the opinions in the document. Based on this, the present application proposes a multi-task extraction model based on prompt learning+reading comprehension to extract the opinion object and the opinion description of the text.
[0071] The opinion object is the description object of the opinion in the document, and the opinion description is the description word of the object in the opinion. For example, in "component price reduction will release backlog demand", the opinion object is "component price reduction", and the opinion description is "release backlog demand", which is used to describe the impact of the opinion object. Of course, this single sentence is only used to illustrate the opinion object and the opinion description, and the present application is not limited to the extraction of opinions in a single sentence. The opinion extraction of the present application is for part of the paragraphs or the entire content of the document.
[0072] Taking a financial research report as an example, the summary or the front part of the content of the financial research report usually represents the core content of the research report. In this case, the sentiment recognition of the financial research report only needs to extract the opinions from the summary or the front part of the content of the financial research report.
[0073] In an embodiment, the extraction of the opinion object and the opinion description of the document is completed based on a pre-constructed opinion extraction model, which includes a first reading comprehension module and a second reading comprehension module. The reading comprehension module of the present application can use the bert series, such as roberta, etc. Considering that the opinion extraction model includes two reading comprehension modules, in order to reduce the parameter amount, a relatively small model can be used, such as 6-layer roberta, etc.
[0074] In an embodiment, step S10 specifically includes:
[0075] Step 100, the text content of the document is respectively input into the first reading comprehension module and the second reading comprehension module.
[0076] As shown in the present application, two reading comprehension modules are provided in the opinion extraction model, which are used to extract the opinion object and the opinion description through different reading comprehension modules, so that each reading comprehension module can focus on extracting the corresponding content, and the mutual interference in the extraction process is avoided. Figure 2
[0077] Step 102, at least one opinion object in the document is extracted based on the opinion object template in the first reading comprehension module.
[0078] As shown in the opinion object template, the opinion object template is pre-constructed. For example, the opinion object template can include "what is the opinion object?", "what is the opinion object in the text?", "where is the opinion object in the text?", etc. Of course, the above is only an example, and specific supplements can be made according to actual conditions. Figure 2 It should be noted that the opinion object template can be pre-stored in the first reading comprehension module, or can be input into the first reading comprehension module together with the document, and the present application is not limited to the storage time of the opinion object template.
[0079] In this step, the opinion object template is used as a question, and the first reading comprehension module extracts the content in the document corresponding to the question in the opinion object template based on the opinion object template, that is, at least one opinion object of the document can be obtained.
[0080] Step 104, at least one opinion object and the text content of the opinion object are input into the second reading comprehension module, and at least one opinion description corresponding to at least one opinion object is extracted by combining the opinion description template in the second reading comprehension module.
[0081] As shown in the present application, two reading comprehension modules are provided in the opinion extraction model, which are used to extract the opinion object and the opinion description through different reading comprehension modules, so that each reading comprehension module can focus on extracting the corresponding content, and the mutual interference in the extraction process is avoided.
[0082] Figure 2 The illustrated opinion description template is pre-built. For example, the opinion description template can include "what is the opinion description", "what are the conclusions on the opinion", and the like. Of course, the above is only an example, and can be supplemented according to actual conditions.
[0083] It should be noted that the opinion description template can be pre-stored in the second reading comprehension module, or can be input into the second reading comprehension module together with the document, and the present application is not limited by the storage time of the opinion description template.
[0084] In this step, the opinion object and the text content of the opinion object extracted based on the first reading comprehension module are input into the second reading comprehension module. After extracting the content corresponding to the question in the opinion description template in the document, at least one opinion description can be obtained. Then, according to the position of the text content of the opinion object in the document, the extracted opinion description and the opinion object can be corresponded to obtain at least one set of corresponding opinion object and opinion description.
[0085] It can be known that the opinion description in the document is a description of the opinion object, therefore, the distance between the opinion object and the corresponding opinion description will not be too far, and therefore, based on the position of the text content of the opinion object in the document, the opinion object and the opinion description can be corresponded.
[0086] Step S20, at least one target opinion is selected from at least one set of opinion object and opinion description, the target opinion includes corresponding target opinion object and target opinion description.
[0087] In a document, there will be more opinion objects, and accordingly, more opinion descriptions, which need to be selected from multiple opinion objects and opinion descriptions as target opinion objects and target opinion descriptions to form target opinions.
[0088] In an embodiment, as shown in the figure, Figure 2 The opinion extraction model further includes a first multi-attention module and a second multi-attention module. The first multi-attention module and the second multi-attention module are used to select at least one target opinion from at least one set of opinion object and opinion description extracted in step S10. The target opinion includes a target opinion object and a target opinion description.
[0089] In this embodiment, step S20 specifically includes:
[0090] Step 200, at least one opinion object is input into the first multi-attention module, and at least one target opinion object and the text position of the target opinion object are selected from at least one opinion object based on the target opinion matrix in the first multi-attention module.
[0091] In this step, the target view matrix is an array composed of a plurality of target views summarized from a large number of documents, and the plurality of target views include positive views and negative views, wherein the positive views are, for example, "consumption recovery", "performance exceeds expectations", "R&D expenses increase", and the like, and the negative views are, for example, "net profit decrease", "cost increase", and the like.
[0092] It should be noted that the target view matrix can be pre-stored in the first multi-attention module, or can be input into the first multi-attention module together with the at least one view object, and the present application is not limited by the storage time of the target view matrix.
[0093] In selecting the target view object, the at least one view object extracted in step S10 is input into the first multi-attention module, and the at least one view object and the target view matrix are interacted with multi-attention, and the part of the view object in the at least one view object that is closest to the target view expression in the target view matrix is selected as the target view object. At the same time, the text position of the target view object in the document is determined.
[0094] By setting the target view matrix, the present application can effectively improve the accuracy of selecting the target view object, and further improve the effectiveness of the sentiment recognition of the document.
[0095] In step 202, at least one target view object, a text position, and at least one view description are input into a second multi-attention module, and at least one target view description corresponding to the at least one target view object in the at least one view description is determined based on the text position.
[0096] In this step, the at least one target view object selected by step 200 and its corresponding text position and at least one view description are input into the second multi-attention module. It is known that the target view description corresponding to the target view object is usually close to each other in the document, and thus the target view description corresponding to the target view object can be selected by the positional relationship between the corresponding view object and the view description, and each group of corresponding target view object and target view description is taken as a target view.
[0097] In an embodiment, the training loss of the view extraction model in the training process is the sum of the losses of the view object and the view description. That is, in the training of the view extraction model, the losses of the view object and the view description need to be considered at the same time, and thus the accuracy of the extraction can be guaranteed when the view extraction model after training is used to extract the view object and the view description.
[0098] In step S30, based on the text content of the at least one target view, a view score corresponding to the at least one target view is assigned respectively.
[0099] The classification of the target opinion can be based on a text classification model, which can employ a textCNN, or a deep neural network model, etc.
[0100] In an embodiment, step S30 specifically comprises:
[0101] Step 300, input the text content of at least one target opinion into a pre-trained text classification model to classify the at least one target opinion.
[0102] In this step, the text content corresponding to the target opinion, i.e. the text content of the target opinion object and the target opinion description, is input into the text classification model, and the target opinion is classified by the text classification model to determine the category corresponding to each target opinion.
[0103] For example, the categories of the target opinion can include strong positive, general positive, neutral, and negative.
[0104] Step 302, based on a pre-set correspondence between the category and the score, a corresponding opinion score is assigned to each target opinion according to the category of the at least one target opinion.
[0105] In this step, the pre-set correspondence between the target opinion category and the score is set, for example, the score of strong positive is 2, the score of general positive is 1, the score of neutral is 0, and the score of negative is -2. After setting the correspondence between the category and the score, different opinion scores can be assigned to target opinions of different categories according to the correspondence.
[0106] Step S40, determine the weight corresponding to each target opinion by a pre-trained probability graph model, and calculate the sentiment score of the document according to the at least one opinion score and the at least one weight.
[0107] The probability graph model needs to be trained first, which needs to create a probability graph based on at least one target opinion of each document in a plurality of documents. As shown in Figure 3 Each node (circle in the figure) in the probability graph model includes a target opinion and its corresponding opinion score. The selection of the target opinion and the assignment of the opinion score can be completed by the above method, which will not be described here.
[0108] In this probability graph model, the horizontal direction represents the target opinion in each document, and the vertical direction represents multiple documents. When one or more target opinions and their corresponding opinion scores in two documents are the same, the nodes corresponding to the same target opinion are merged.
[0109] In the probabilistic graph model, two nodes (i.e. the target aspect and the aspect score) that continuously appear in a document are connected, and the line segment of the connection is an edge. Since the probabilistic graph model includes a merged node, the merged node has multiple edges, and the number of node pairs including the merged node is also multiple. A node pair is two nodes connected by an edge between adjacent nodes.
[0110] As described above, the number of node pairs depends on the number of node mergers, which proves the size of the weight of the target aspect corresponding to the node in the document. Based on this principle, the number of edges corresponding to the node can be determined by the number of node pairs, and the number of edges of the node determines the weight of the node.
[0111] In addition, when creating a probabilistic graph model, a sentiment score corresponding to multiple documents is manually assigned. Then, by the aspect score of each target aspect in the document, the number of node pairs (determining the number of edges corresponding to the node), and the sentiment score of the document, the weight of each edge corresponding to the node is determined, and then the weight of the node can be determined according to the number of edges corresponding to the node.
[0112] For example, a document includes four target aspects (aspect_1, aspect_2, aspect_3, aspect_4), and the scores of the target aspects are (senti_1, senti_2, senti_3, senti_4), respectively. The sentiment score of the document is senti_i. Assuming that the number of edges corresponding to the four target aspect nodes is 1, 2, 3, and 4, respectively, and the weight of each edge is w. The formula is:
[0113] senti_1×w+senti_2×2w+senti_3×3w+senti_4×4w=senti_i;
[0114] When the aspect score of the target aspect and the sentiment score of the document are known values, the value of the weight w of each edge can be calculated by the above formula.
[0115] Step S40 specifically includes:
[0116] Step 400, input at least one target aspect into a pre-trained probabilistic graph model to determine a node corresponding to the at least one target aspect.
[0117] In this step, the selected at least one target aspect is input into the pre-trained probabilistic graph model, and the nodes in the probabilistic graph model corresponding to the at least one target aspect are selected.
[0118] Step 402, respectively, multiply the view score of at least one target view and the weight of the edge of the corresponding node, and then sum up to calculate the sentiment score of the document.
[0119] In this step, after determining the node corresponding to the target view, the weight of each target view is determined according to the weight of the edge of the node, and then the sentiment score of the document is calculated according to the view score of the target view and the weight of the target view.
[0120] Specifically, the view score of each target view is multiplied by the weight corresponding thereto, and then the products are added to obtain the sentiment score of the document.
[0121] The present application can reflect the mutual influence between different target views, and obtain a more factual sentiment score of the document.
[0122] According to another embodiment of the present application, a document sentiment recognition device is provided, as shown in Figure 4 The device comprises an extraction module 10, a selection module 20, an assignment module 30 and a calculation module 40.
[0123] The extraction module 10 is configured to extract at least one set of mutually corresponding view objects and view descriptions in the document.
[0124] In the extraction of document views, keyword matching or bold sentence recognition is usually used, which has low coverage of the views in the document. Based on this, the present application proposes a multi-task extraction model based on prompt learning + reading comprehension to extract the view objects and view descriptions of the text.
[0125] The view object is the description object of the view in the document, and the view description is the description word of the object in the view. For example, in "component price reduction will release backlog demand", the view object is "component price reduction", and the view description is "release backlog demand", which is used to describe the impact of the view object. Of course, this single sentence is only used to illustrate the view object and the view description, and is not the only view extraction of the present application. The view extraction of the present application is for part of the document or the whole content of the document.
[0126] Taking a financial research report as an example, the summary or the front part of the financial research report usually represents the core content of the research report. In this case, the sentiment recognition of the financial research report only needs to extract the views of the summary or the front part of the content of the financial research report.
[0127] In an embodiment, the extraction of the opinion object and the opinion description of the document is completed based on a pre-constructed opinion extraction model, which includes a first reading comprehension module and a second reading comprehension module. The reading comprehension module of the present application can be a bert series, such as roberta, etc. Considering that the opinion extraction model includes two reading comprehension modules, in order to reduce the parameter amount, a relatively small model can be used, such as a 6-layer roberta, etc.
[0128] In this embodiment, the extraction module 10 is specifically configured to: input the text content of the document into the first reading comprehension module and the second reading comprehension module respectively; extract at least one of the opinion objects in the document based on the opinion object template in the first reading comprehension module; input the at least one opinion object and the text content of the opinion object into the second reading comprehension module, and extract at least one opinion description corresponding to the at least one opinion object in combination with the opinion description template in the second reading comprehension module.
[0129] In an embodiment, as shown in Figure 2 The opinion extraction model of the present application is provided with two reading comprehension modules, which are used to extract the opinion object and the opinion description through different reading comprehension modules respectively, so that each reading comprehension module can focus on extracting the corresponding content, and the mutual interference in the extraction process can be avoided.
[0130] As shown in Figure 2 The opinion object template is pre-constructed. For example, the opinion object template can include "what is the opinion object?", "what is the opinion object in the text?", "where is the opinion object in the text?", etc. Of course, the above is only an example, and specific supplements can be made according to actual conditions.
[0131] It should be noted that the opinion object template can be pre-stored in the first reading comprehension module, or can be input into the first reading comprehension module together with the document, and the present application is not limited by the storage time of the opinion object template.
[0132] In this embodiment, the opinion object template is used as a question, and the first reading comprehension module extracts the content in the document corresponding to the question in the opinion object template based on the opinion object template, that is, at least one opinion object of the document can be obtained.
[0133] As shown in Figure 2 The opinion description template is pre-constructed. For example, the opinion description template can include "what is the opinion description?", "what are the conclusions on the opinion?", etc. Of course, the above is only an example, and specific supplements can be made according to actual conditions.
[0134] It should be noted that the viewpoint description template can be pre-stored in the second reading comprehension module, or can be input into the second reading comprehension module together with the document, and the present application is not limited by the storage time of the viewpoint description template.
[0135] The viewpoint object and the text content of the viewpoint object extracted based on the first reading comprehension module are input into the second reading comprehension module, and after extracting the content corresponding to the question in the viewpoint description template in the document, at least one viewpoint description is obtained. Then, according to the position of the text content of the viewpoint object in the document, the extracted viewpoint description and the viewpoint object are corresponded to obtain at least one set of viewpoint objects and viewpoint descriptions corresponding to each other.
[0136] It can be known that the viewpoint description in the document is a description of the viewpoint object, therefore, the distance between the viewpoint object and the corresponding viewpoint description will not be too far, and therefore, based on the position of the text content of the viewpoint object in the document, the viewpoint object and the viewpoint description can be corresponded.
[0137] The selecting module 20 is configured to select at least one target viewpoint in the at least one set of viewpoint objects and viewpoint descriptions, and the target viewpoint includes a target viewpoint object and a target viewpoint description corresponding to each other.
[0138] In a document, there will be more viewpoint objects, and correspondingly, more viewpoint descriptions, and it is necessary to select the viewpoint objects and viewpoint descriptions that need to be focused on as target viewpoint objects and target viewpoint descriptions from the multiple viewpoint objects and viewpoint descriptions to form a target viewpoint.
[0139] In an embodiment, as shown in Figure 2 The viewpoint extraction model further includes a first multi-attention module and a second multi-attention module. The first multi-attention module and the second multi-attention module are used to select at least one target viewpoint in the at least one set of viewpoint objects and viewpoint descriptions extracted by the extracting module 10. The target viewpoint includes a target viewpoint object and a target viewpoint description.
[0140] In this embodiment, the selecting module 20 is specifically configured to: input the at least one viewpoint object into the first multi-attention module, select at least one target viewpoint object and the text position of the target viewpoint object in the at least one viewpoint object based on the target viewpoint matrix in the first multi-attention module; input the at least one target viewpoint object, the text position, and the at least one viewpoint description into the second multi-attention module, and determine at least one target viewpoint description corresponding to the at least one target viewpoint object in the at least one viewpoint description based on the text position.
[0141] In this embodiment, the target opinion matrix is an array of multiple target opinions summarized from a large number of documents, and the multiple target opinions include positive opinions and negative opinions, wherein the positive opinions are, for example, “consumption recovery”, “performance exceeding expectations”, “R&D expenses increasing”, and the like, and the negative opinions are, for example, “net profit decreasing”, “cost increasing”, and the like.
[0142] It should be noted that the target opinion matrix can be pre-stored in the first multi-attention module, or can be input into the first multi-attention module together with the at least one opinion object, and the present application is not limited by the storage time of the target opinion matrix.
[0143] When selecting the target opinion object, the at least one opinion object extracted by the extraction module 10 is input into the first multi-attention module, and the at least one opinion object and the target opinion matrix are subjected to multi-attention interaction, and the part of the opinion object that is closest to the expression of the target opinion in the target opinion matrix is selected as the target opinion object. At the same time, the text position of the target opinion object in the document is determined.
[0144] By setting the target opinion matrix, the present application can effectively improve the accuracy of selecting the target opinion object, and further improve the effectiveness of the sentiment recognition of the document.
[0145] In this embodiment, the at least one target opinion object selected and the corresponding text position and the at least one opinion description are input into the second multi-attention module. It can be known that the target opinion descriptions corresponding to the target opinion objects are usually close to each other in the document, and thus the target opinion description corresponding to the target opinion object can be selected through the positional relationship between the corresponding opinion object and the opinion description, and each set of corresponding target opinion object and target opinion description is taken as a target opinion.
[0146] In an embodiment, the training loss of the opinion extraction model in the training process is the sum of the losses of the opinion object and the opinion description. That is, in the training of the opinion extraction model, the losses of the opinion object and the opinion description need to be considered at the same time, and thus the opinion extraction model after training can guarantee the accuracy of the extraction of the opinion object and the opinion description.
[0147] The assignment module 30 is configured to assign a corresponding opinion score to the at least one target opinion based on the text content of the at least one target opinion.
[0148] The classification of the target opinion can be based on a text classification model, which can use textCNN or a deep neural network model, etc.
[0149] In an embodiment, the assigning module 30 is specifically configured to: input the text content of the at least one target opinion into the pre-trained text classification model to classify the at least one target opinion; and assign a corresponding opinion score to the at least one target opinion according to the category of the at least one target opinion based on a pre-set correspondence between categories and scores.
[0150] In this embodiment, the text content corresponding to the target opinion, i.e., the text content of the target opinion object and the target opinion description, is input into the text classification model, the target opinion is classified by the text classification model, and the category corresponding to each target opinion is determined.
[0151] For example, the categories of the target opinion can include strong positive, general positive, neutral, and negative.
[0152] The correspondence between the categories of the target opinion and the scores is pre-set, for example, the score of strong positive is 2, the score of general positive is 1, the score of neutral is 0, and the score of negative is -2. After setting the correspondence between the categories and the scores, different opinion scores can be assigned to target opinions of different categories according to the correspondence.
[0153] The calculating module 40 is configured to determine the weight corresponding to each target opinion by the pre-trained probabilistic graph model, and calculate the sentiment score of the document according to the at least one opinion score and the at least one weight.
[0154] To train the probabilistic graph model, a probabilistic graph needs to be created based on the at least one target opinion of each document in a plurality of documents. As shown in FIG. 2, each node (circle in the figure) in the probabilistic graph model includes a target opinion and a corresponding opinion score. The selection of the target opinion and the assignment of the opinion score can be completed by the above method, which will not be described here. Figure 3
[0155] In the probabilistic graph model, the horizontal direction represents the target opinions in each document, and the vertical direction represents the plurality of documents. When one or more target opinions and their corresponding opinion scores in two documents are the same, the nodes corresponding to the same target opinions are merged.
[0156] In the probabilistic graph model, two nodes (i.e., target opinions and opinion scores) that appear continuously in a document are connected, and the line segment of the connection is an edge. Because the probabilistic graph model includes merged nodes, the merged nodes have multiple edges, and the number of node pairs including the merged nodes is also multiple. A node pair is two nodes connected by an edge between adjacent nodes.
[0157] From the above, the number of node pairs depends on the number of times of node merging, which proves the size of the weight of the target view corresponding to the node in the document. Based on this principle, the number of edges corresponding to the node can be determined by the number of occurrences of the node pair, and the number of edges of the node determines the weight of the node.
[0158] In addition, when creating the probabilistic graph model, the sentiment scores corresponding to the plurality of documents are manually assigned respectively. Further, the weight of each edge corresponding to the node is determined by the view score of each target view in the document, the number of occurrences of the node pair (determining the number of edges corresponding to the node), and the sentiment score of the document, and then the weight of the node can be determined according to the number of edges corresponding to the node.
[0159] For example, a document includes four target views (aspect_1, aspect_2, aspect_3, aspect_4), and the scores of the target views are (senti_1, senti_2, senti_3, senti_4) respectively. The sentiment score of the document is senti_i. Assuming that the number of edges corresponding to the four target views is 1, 2, 3, and 4 respectively, and the weight of each edge is w. Then the formula is:
[0160] senti_1×w+senti_2×2w+senti_3×3w+senti_4×4w=senti_i;
[0161] When the view score of the target view and the sentiment score of the document are known values, the value of the weight w of each edge can be calculated by the above formula.
[0162] In an embodiment, the calculation module 40 is specifically configured to: input at least one target view into a pre-trained probabilistic graph model to determine the weight of the edge of the node corresponding to the at least one target view; multiply the view score of the at least one target view and the weight of the edge of the corresponding node respectively, and then sum up to calculate the sentiment score of the document.
[0163] The selected at least one target view is input into the pre-trained probabilistic graph model, and the nodes in the probabilistic graph model corresponding to the at least one target view are selected.
[0164] After determining the node corresponding to the target view, the weight of each target view is determined according to the weight of the edge of the node, and then the sentiment score of the document is calculated according to the view score of the target view and the weight of the target view.
[0165] Specifically, the view score of each target view is multiplied by the weight corresponding thereto, and then the products are added to obtain the sentiment score of the document.
[0166] The application can reflect the mutual influence between different target opinions, and obtain a more factual sentiment score of the document.
[0167] It should be noted that:
[0168] The algorithms and displays presented herein are not inherently related to any particular computer, virtual apparatus, or other device. Various general purpose devices can be used with these teachings based on the description herein. Those skilled in the art will recognize that structures for a variety of these devices are readily apparent in light of the above description. Moreover, the present application is not necessarily limited to any particular programming language. It will be appreciated that a variety of programming languages can be used to implement the teachings of the application described herein, and any references below to specific languages are provided for disclosure of enablement of the best mode of the application.
[0169] In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the application can be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been described in detail in order to not obscure the understanding of this description.
[0170] Similarly, it is to be understood that the mechanical details of the application sometimes are presented in terms of sequences of actions to be taken by persons, devices or mechanisms. It is to be appreciated that in some instances the specifics of certain actions can not be relevant to an accurate description of how to make or use an embodiment of the application for the purposes of the present application. Moreover, not all instances necessarily show identical details, as some details can be employed and others omitted or adiopated in some weather, without departing from the overall concept.
[0171] Those skilled in the art will appreciate that the modules in the devices in the embodiments can be adapted and placed in one or more devices other than the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and furthermore can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive, all combinations of all features disclosed in this specification (including the accompanying claims, abstract and drawings) and all processes or units of any methods or apparatuses so disclosed can be used. Unless explicitly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract and drawings) can be replaced by alternative features providing the same, equivalent or similar functionality.
[0172] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.
[0173] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the document retrieval device according to embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0174] This invention provides a non-volatile computer-readable storage medium storing at least one executable instruction that can execute the document retrieval method in any of the above method embodiments.
[0175] Figure 5 The diagram shows a structural schematic of an embodiment of the electronic device of the present invention. The specific embodiments of the present invention do not limit the specific implementation of the electronic device.
[0176] like Figure 5 As shown, the electronic device may include: a processor 1002, a communications interface 1004, a memory 1006, and a communications bus 1008.
[0177] The processor 1002, communication interface 1004, and memory 1006 communicate with each other via communication bus 1008. Communication interface 1004 is used to communicate with other network elements such as clients or other servers. The processor 1002 executes program 1010, specifically performing the relevant steps described in the above-described document retrieval embodiment for electronic devices.
[0178] Specifically, program 1010 may include program code that includes computer operation instructions.
[0179] The processor 1002 can be a central processing unit (CPU) or an application specific integrated circuit (ASIC) or one or more integrated circuits configured to perform the embodiments of the present application. The one or more processors included in the electronic device can be of the same type or different types, such as one or more CPUs and one or more ASICs.
[0180] The memory 1006 is configured to store a program 1010. The memory 1006 can include a high speed RAM memory and can also include a non-volatile memory such as at least one disk memory.
[0181] The program 1010 can be specifically configured to cause the processor 1002 to perform the operations corresponding to the above-described embodiments of the document retrieval.
[0182] It should be noted that the above-described embodiments are illustrative of the present application rather than limiting the present application, and alternative embodiments can be designed by those skilled in the art without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in the claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The application can be implemented by means of both hardware and software, and the present application can be realized by means of a suitably programmed computer. In a unit claim enumerating several means, the several means can be embodied by one and the same item of hardware. The use of the words first, second and third, etc. do not imply any order. These words can be understood as names.
Claims
1. A method for document sentiment recognition, characterized in that, The method comprises the following steps: extracting at least one set of corresponding opinion objects and opinion descriptions in the document; selecting at least one target opinion from at least one set of the opinion objects and the opinion descriptions, the target opinion comprising a corresponding target opinion object and a target opinion description; assigning a corresponding opinion score to at least one target opinion based on the text content of the target opinion; determining a weight corresponding to at least one target opinion by using a pre-trained probabilistic graph model, and calculating a sentiment score of the document according to at least one opinion score and at least one weight; wherein the pre-training step of the probabilistic graph model comprises: creating a probabilistic graph based on at least one target opinion of each document in a plurality of documents, wherein the target opinion comprises a corresponding target opinion object and a target opinion description, and each node in the probabilistic graph is a target opinion and an opinion score; when the target opinions and opinion scores of multiple nodes are the same, the multiple nodes are merged; assigning a corresponding sentiment score to each document, and calculating the weight of the edge of the node according to the number of node pairs, the sentiment score of each document, and the opinion score of each target opinion, wherein the node pair is two nodes connected by an edge. 2.The method of claim 1, wherein, The extraction of at least one set of opinion objects and opinion descriptions is based on an opinion extraction model, and the opinion extraction model comprises a first reading comprehension module and a second reading comprehension module. The step of extracting at least one set of corresponding opinion objects and opinion descriptions in the document comprises: inputting the text content of the document into the first reading comprehension module and the second reading comprehension module respectively; extracting at least one opinion object in the document based on the opinion object template in the first reading comprehension module; inputting at least one opinion object and the text content of the opinion object into the second reading comprehension module, and extracting at least one opinion description corresponding to at least one opinion object based on the opinion description template in the second reading comprehension module.
3. The method of claim 2, wherein, The opinion extraction model further comprises a first multi-attention module and a second multi-attention module. The step of selecting at least one target opinion from at least one set of opinion objects and opinion descriptions comprises: inputting at least one opinion object into the first multi-attention module, and selecting at least one target opinion object and the text location of the target opinion object in at least one opinion object based on the target opinion matrix in the first multi-attention module; inputting at least one target opinion object, the text location, and at least one opinion description into the second multi-attention module, and determining at least one target opinion description corresponding to at least one target opinion object in at least one opinion description based on the text location.
4. The method of claim 3, wherein, The training loss of the opinion extraction model is the sum of the training loss of the opinion object and the training loss of the opinion description.
5. The method of claim 1-4, wherein, The step of assigning a corresponding opinion score to at least one target opinion based on the text content of the target opinion comprises: inputting text content of at least one of the target opinions into a pre-trained text classification model to classify the at least one of the target opinions; assigning a corresponding opinion score to the at least one of the target opinions based on a pre-set correspondence between categories and scores according to the category of the at least one of the target opinions.
6. The method of claim 1, wherein, The step of determining the weight corresponding to each of the at least one of the target opinions by using the pre-trained probabilistic graph model and calculating the sentiment score of the document according to the at least one of the opinion scores and the at least one of the weights comprises: inputting the at least one of the target opinions into a pre-trained probabilistic graph model to determine a corresponding node of the at least one of the target opinions; multiplying the opinion score of the at least one of the target opinions by the weight of the edge of the corresponding node and summing up to calculate the sentiment score of the document.
7. A document emotion recognition device, characterized in that, comprise: an extraction module configured to extract at least one set of corresponding opinion objects and opinion descriptions in the document; a selection module configured to select at least one target opinion from the at least one set of the opinion objects and the opinion descriptions, the target opinion comprising a corresponding target opinion object and a target opinion description; an assignment module configured to assign a corresponding opinion score to the at least one of the target opinions based on the text content of the at least one of the target opinions; a calculation module configured to determine the weight corresponding to each of the at least one of the target opinions by using the pre-trained probabilistic graph model and calculate the sentiment score of the document according to the at least one of the opinion scores and the at least one of the weights; a model training module configured to create a probabilistic graph based on at least one target opinion of each of a plurality of documents, wherein the target opinion comprises a corresponding target opinion object and a target opinion description, and each node in the probabilistic graph is a target opinion and an opinion score; and when the target opinions and the opinion scores of a plurality of nodes are the same, the plurality of nodes are merged; assigning a corresponding sentiment score to each of the documents, and calculating the weight of the edge of the node by using the number of occurrences of the node pair, the sentiment score of each of the documents, and the opinion score of each of the target opinions, wherein the node pair is two nodes connected by an edge.
8. An electronic device comprising: a processor, a memory, a communication interface, and a communication bus, the processor, the memory, and the communication interface being in communication with each other through the communication bus; The memory is used to store at least one executable instruction, and the executable instruction causes the processor to perform the operation corresponding to the sentiment recognition method of the document according to any one of claims 1-6.
9. A computer readable storage medium, wherein, The computer readable storage medium stores one or more programs, and the one or more programs, when executed by the processor, implement the operation corresponding to the sentiment recognition method of the document according to any one of claims 1-6.
Citation Information
Patent Citations
Discrimination method for text emotional tendency
CN107577665A
Text processing method and system
CN113220885A
Emotion analysis method and device, equipment and storage medium
CN116187319A