Text analysis method and device
The text analysis method employs neural network models and preprocessing to improve the accuracy of analyzing complex text by identifying entities and sentiments, addressing the limitations of existing NLP technologies.
Patent Information
- Application Number
- CN202411132713.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-08-16
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-06
AI Technical Summary
Existing natural language processing technologies face challenges in accurately analyzing complex text content due to the increasing complexity of text, leading to suboptimal opinion word analysis accuracy.
A text analysis method involving entity recognition, viewpoint recognition, and opinion classification using neural network models like BERT and CRF, along with preprocessing techniques, to identify and categorize entity and opinion information in text.
Enhances the accuracy and comprehensiveness of text analysis by determining entity and sentiment categories, providing a targeted and efficient analysis of complex text content.
Smart Images

Figure CN119088963A_ABST
Abstract
Description
[0001] This application claims the priority of the Chinese patent application filed with the China Patent Office on August 16, 2023, with application number "202311036560.8" and invention name "Text Analysis Method and Device", all contents of which are recorded in this application by reference. Technical Field
[0002] The present application relates to the field of artificial intelligence technology, and in particular to a text analysis method. The present application also relates to a text analysis device, a computing device, and a computer-readable storage medium. Background Art
[0003] Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. The application scenarios of natural language processing can be divided into several tasks, including identifying and extracting words from a text, identifying the subject, predicate, object, attributive, adverbial, complement from a text, finding answers from the text according to the question, analyzing the viewpoint of a text, etc.
[0004] Among them, when analyzing the opinions in a text, the opinion words in the text are usually extracted first, and then the opinion words are directly analyzed to obtain the analysis results of the text opinions.
[0005] However, as the text content becomes more and more complex, the accuracy requirements for opinion word analysis are also getting higher and higher. Summary of the invention
[0006] In view of this, the embodiment of the present application provides a text analysis method to solve the technical defects existing in the prior art. The embodiment of the present application also provides a text analysis device, a computing device, and a computer-readable storage medium.
[0007] According to a first aspect of an embodiment of the present application, a text analysis method is provided, comprising:
[0008] Obtain the text to be analyzed, perform entity recognition on the text to be analyzed, and determine the entity information of the entity words in the text to be analyzed;
[0009] According to the entity information, point of view recognition is performed on the text to be analyzed to determine the point of view information for the entity words in the text to be analyzed;
[0010] Opinion classification is performed based on opinion information to determine the opinion category and sentiment category of the text to be analyzed.
[0011] According to a second aspect of an embodiment of the present application, there is provided a text analysis device, comprising:
[0012] An entity recognition module is configured to obtain a text to be analyzed, perform entity recognition on the text to be analyzed, and determine entity information of entity words in the text to be analyzed;
[0013] The opinion recognition module is configured to perform opinion recognition on the text to be analyzed based on the entity information, and determine the opinion information for the entity words in the text to be analyzed;
[0014] The classification module is configured to perform opinion classification based on the opinion information and determine the opinion category and sentiment category of the text to be analyzed.
[0015] According to a third aspect of an embodiment of the present application, there is provided a computing device, including:
[0016] Memory and processor;
[0017] The memory is used to store computer executable instructions, and the processor implements the steps of the above text analysis method when executing the computer executable instructions.
[0018] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the above-mentioned text analysis method are implemented.
[0019] According to a fifth aspect of an embodiment of the present application, a chip is provided, which stores a computer program, and the computer program implements the steps of the above-mentioned text analysis method when executed by the chip.
[0020] The text analysis method provided in the present application first obtains the text to be analyzed, performs entity recognition on the text to be analyzed, and determines the entity information of the entity words in the text to be analyzed. Secondly, based on the entity information, the text to be analyzed is subjected to viewpoint recognition, and the viewpoint information for the entity words in the text to be analyzed is determined. Finally, viewpoint classification is performed based on the viewpoint information to determine the viewpoint category and sentiment category of the text to be analyzed. The classification is determined based on the entity information of the entity words and the viewpoint information for the entity words, and a comprehensive classification result for the viewpoints in the text is obtained, thereby achieving an accurate and comprehensive analysis of the complex text content. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a structural schematic diagram of a text analysis method provided by an embodiment of the present application;
[0022] Figure 2 is a flowchart of a text analysis method provided by an embodiment of the present application;
[0023] Figure 3 is a flow chart of a method for identifying viewpoints in a text analysis method provided in an embodiment of the present application;
[0024] Figure 4This is a flowchart of a semantic classification method in a text analysis method provided in an embodiment of the present application;
[0025] Figure 5 This is a flowchart of a method for performing semantic classification using a semantic classification model in a text analysis method provided in an embodiment of the present application;
[0026] Figure 6 It is a flow chart of a classification method based on a semantic classification model in a text analysis method provided in an embodiment of the present application;
[0027] Figure 7 It is a flowchart of a method for determining a text analysis result in a text analysis method provided in an embodiment of the present application;
[0028] Figure 8 It is a flow chart of a method for performing entity recognition using an entity recognition model in a text analysis method provided in an embodiment of the present application;
[0029] Fig. 9 It is a flowchart of a method for training an entity recognition model in a text analysis method provided in an embodiment of the present application;
[0030] Fig.10 This is a flow chart of a method for performing opinion recognition using an opinion recognition model in a text analysis method provided in an embodiment of the present application;
[0031] Fig.11 This is a flow chart of a method for performing opinion recognition using an opinion recognition model in a text analysis method provided in an embodiment of the present application;
[0032] Fig.12 This is a flow chart of a method for performing opinion recognition using an opinion recognition model in a text analysis method provided in an embodiment of the present application;
[0033] Fig.13 is a flowchart showing a method for training a semantic classification model in a text analysis method provided in an embodiment of the present application;
[0034] Fig.14 It is a processing flow chart of a training method for an entity recognition model, an opinion recognition model, and a semantic classification model in a text analysis method provided in an embodiment of the present application;
[0035] Fig.15A is a processing flow chart of a text analysis method applied to user comments provided by an embodiment of the present application;
[0036] Fig. 15B It is a structural diagram of a text analysis method applied to user book reviews provided by an embodiment of the present application;
[0037] Fig.16 is a structural schematic diagram of a text analysis device provided by an embodiment of the present application;
[0038] Fig.17 It is a structural block diagram of a computing device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0039] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0040] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0041] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first.
[0042] First, the terms involved in one or more embodiments of the present invention are explained.
[0043] BERT (Bidirectional Encoder Representation from Transformers) model: a bidirectional attention neural network model. The BERT model can predict the current word through the left and right contexts and predict the next sentence through the current sentence. The goal of the BERT model is to use large-scale unlabeled corpus training to obtain text semantic representations containing rich semantic information, and then fine-tune the semantic representation of the text in a specific NLP task, and finally successfully apply it to the NLP task.
[0044] Normalized exponential function (softmax): It can "compress" a K-dimensional vector containing any real number into another K-dimensional real number vector, so that the range of each element is between (0,1) and the sum of all elements is 1. It is often used to solve multi-classification problems.
[0045] The LSTM (Long short-term memory) model is a special recurrent neural network model. The LSTM model can have a forward LSTM model, a reverse LSTM model, or a BiLSTM model, which can capture past feature information, future feature information, and past and future feature information to obtain context encoding information.
[0046] Conditional Random Field (CRF): A serialization labeling algorithm that can effectively capture the transition probability between labeled sequences through a unilateral Markov chain.
[0047] Attention mechanism: A weighted average algorithm of a specific relationship matrix is performed on the text information input into the natural language processing model, so that the text information processed by the model combines multiple information to obtain more accurate processing results.
[0048] In the present application, a text analysis method is provided. The present application also relates to a text analysis device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0049] Figure 1 A structural schematic diagram of a text analysis system provided by an embodiment of the present application is shown. The execution subject of the text analysis method provided by the embodiment of the present application is a server 101 with a text analysis function; the execution subject for training the neural network model in the text analysis method provided by the embodiment of the present application is a training terminal 102, and the training terminal 102 can be a training server or a terminal with a model training function. The above-mentioned terminal can be any electronic product that can perform human-computer interaction with a user, such as a PC (Personal Computer), a mobile phone, a Pocket PC, a tablet computer, etc.
[0050] The server 101 and the training end 102 in the text conversion system can be integrated into one device or can be independent devices. In the case of independent devices, the server 101 and the training end 102 can be a server, a server cluster composed of multiple servers, or a cloud computing service center, which is not limited in the present embodiment.
[0051] The server 101 with text analysis function first obtains the text to be analyzed, performs entity recognition on the text to be analyzed, determines the entity information of the entity words in the text to be analyzed, and then performs opinion recognition on the text to be analyzed based on the entity information, determines the opinion information for the entity words in the text to be analyzed, and finally classifies the opinions based on the opinion information to determine the opinion category and sentiment category of the text to be analyzed. The training terminal 102 can obtain a training sample set and train a preset neural network (entity recognition model, opinion recognition model, semantic classification model) based on the training sample set.
[0052] The specific text analysis method will be described in detail in the subsequent embodiments.
[0053] Figure 2 A flowchart of a text analysis method provided according to an embodiment of the present application is shown, which specifically includes the following steps:
[0054] Step 202: Obtain the text to be analyzed, perform entity recognition on the text to be analyzed, and determine the entity information of the entity words in the text to be analyzed.
[0055] The text to be analyzed is a text sentence consisting of multiple characters containing entity words and opinion words, and may be one or more comments from a web page or application, one or more chat records, an article, etc.
[0056] Entity words are entity noun words that refer to something, and can be proper nouns, such as names of people, places, books, movies, TV shows, and products, etc., or specific nouns, such as Mr. Li (General Manager Li), Mr. Zhang (Engineer Zhang), etc. Specifically, one or more texts to be analyzed are obtained, and the texts to be analyzed are determined to be texts to be analyzed.
[0057] The entity information is information representing the entity words in the text to be analyzed, and may be information representing the position of the entity words in the text to be analyzed, or may be information representing the number of the entity words in the text to be analyzed.
[0058] The text to be analyzed can be obtained by querying a database of a web page or an application, obtaining comments to be analyzed, and determining them as the text to be analyzed. The text to be analyzed can also be obtained by obtaining a certain instant messaging communication software to determine the text to be analyzed. The text to be analyzed can also be obtained by using a web page text acquisition tool to obtain a database of a communication software or an information exchange platform, obtaining one or more chat records to be analyzed, or an article on a web page, and determining them as the text to be analyzed.
[0059] Specifically, a text to be analyzed is obtained, and a preset entity recognition method is used to recognize the text to be analyzed, so as to determine entity information of entity words in the text to be analyzed.
[0060] The pre-set entity recognition method can be a manual recognition method or a machine recognition method. Correspondingly, the entity recognition of the text to be analyzed can be performed by using an entity recognition model to recognize entity words in the text to be analyzed, or by using manual recognition to recognize entity words in the text to be analyzed, or by using an entity word recognition tool to recognize entity words in the text to be analyzed, which is not limited here.
[0061] According to the text to be analyzed, the entity information of the entity words in the text to be analyzed is identified, which lays an information foundation for the subsequent opinion identification based on the entity information and obtaining the opinion information for the entity words.
[0062] Step 204: Based on the entity information, point of view recognition is performed on the text to be analyzed to determine point of view information for the entity words in the text to be analyzed.
[0063] Opinion information is information that can represent opinion words corresponding to entity words. Opinion words are words with certain emotional tendencies. They can be adjectives or adverbs, such as big, wonderful, and interesting, or verbs, such as like, hate, and envy, or nouns, such as classic, saint, and genius.
[0064] The opinion information is information about opinion words representing entity words, which may be information about the position of opinion words representing entity words in the text to be analyzed, or information about the number of opinion words representing entity words in the text to be analyzed.
[0065] Specifically, according to the entity information, a preset opinion recognition method is used to perform opinion recognition on the text to be analyzed, and opinion information on the entity words in the text to be analyzed is determined.
[0066] The pre-set opinion recognition method may be a manual recognition method or a machine recognition method. Correspondingly, the opinion recognition of the text to be analyzed may be to recognize the opinion information of the entity words in the text to be analyzed by using an opinion recognition model, or to recognize the opinion information of the entity words in the text to be analyzed by using manual recognition, or to recognize the opinion information of the entity words in the text to be analyzed by using an opinion recognition tool, which is not limited here.
[0067] According to the text to be analyzed and the entity information, the opinion information for the entity words in the text to be analyzed is identified, which lays an information foundation for the subsequent determination of the opinion category and the sentiment category based on the opinion information. Moreover, because the opinion words are targeted at the entity words, the opinion words and the entity words are combined in a targeted manner, making the results of the subsequent analysis clearer.
[0068] Step 206: Perform opinion classification based on the opinion information to determine the opinion category and sentiment category of the text to be analyzed.
[0069] The opinion category of opinion words is the category of the comment direction of the opinion, including: perception, length, content, delivery, customer service, record, etc. The sentiment category of opinion words is the category of the sentiment tendency of the opinion words, including: positive category, negative category, neutral category. For example, the category of the opinion word "like" is the positive category, the category of the opinion word "boring" is the negative category, and the category of the opinion word "strange" is the neutral category.
[0070] Specifically, opinion classification is performed based on opinion information, and a pre-set opinion classification method is used to determine the opinion category and sentiment category of the text to be analyzed.
[0071] The pre-set opinion classification method may be a manual classification method or a machine classification method. Correspondingly, opinion classification based on opinion information may be to classify the opinion categories and sentiment categories of opinion words in the text to be analyzed using an opinion classification model, or to classify the opinion categories and sentiment categories of opinion words in the text to be analyzed using manual classification, or to classify the opinion categories and sentiment categories of opinion words in the text to be analyzed using an opinion classification tool, which is not limited here.
[0072] A text analysis method provided in an embodiment of the present application first obtains a text to be analyzed, identifies entity information of entity words in the text to be analyzed based on the text to be analyzed, then identifies opinion information for the entity words in the text to be analyzed based on the text to be analyzed and the entity information, and finally determines opinion categories and sentiment categories based on the opinion information. The classification is determined based on the entity information of the entity words and the opinion information for the entity words, and a comprehensive classification result for the opinions in the text is obtained, achieving accurate and comprehensive analysis of complex text content.
[0073] Optionally, before performing entity recognition on the text to be analyzed and determining entity information of entity words in the text to be analyzed in step 202, the method further includes:
[0074] The text to be analyzed is preprocessed to obtain the preprocessed text to be analyzed.
[0075] Preprocessing can be to perform phrase segmentation on the text to be analyzed, which is composed of multiple characters. Commonly used phrase segmentation methods include: jieba word segmentation, HanLP word segmentation, SnowNLP, THULAC, FoolNLTK, etc., which are not limited here. For example, the text to be analyzed is "The number of gold medals won by the Chinese team in this year's Winter Olympics hit a record high", and the text to be analyzed after phrase segmentation is "This year / Winter Olympics / Chinese team / 's / number of / gold / medals / hit / a / record high".
[0076] Preprocessing can also be to perform phrase segmentation on the text to be analyzed and then perform vectorization processing. The specific vectorization processing method can be: VSM vector space model processing method, local sensitive hash processing method, word2vec processing method, which is not limited here. For example, the text to be analyzed is "The number of gold medals won by the Chinese team in this year's Winter Olympics hit a record high", and the text to be analyzed obtained after vectorization processing is "{XXXXXXXXX2 (vector eigenvalue), 364 (this year), 78 (Winter Olympics), 15 (Chinese team), 78 (of), 33 (number of gold medals), 17 (hit), 0011 (historical high)}".
[0077] Preprocessing can also be to remove redundant words in the text to be analyzed. Redundant words are words that do not represent any entity or any opinion. For example, the text to be analyzed is "This year's Winter Olympics China's gold medal count hit a record high", where redundant words include "this year", "of", and "number of gold medals". After removing redundant words, the text to be analyzed after removing redundant words is obtained. "Winter Olympics China's team hits a record high"
[0078] By preprocessing the text to be analyzed, the preprocessed text to be analyzed is obtained, and subsequent recognition and analysis processing can be performed based on the features of the preprocessed text to be analyzed, without directly performing subsequent recognition and analysis processing on the text to be analyzed, thereby improving processing efficiency.
[0079] Alternatively, if Figure 3 A flowchart of a method for identifying viewpoints in a text analysis method provided in one embodiment of the present application is shown. Figure 2 In the embodiment, the entity information includes the first position information of the entity word. Step 204 performs opinion recognition on the text to be analyzed based on the entity information to determine the opinion information for the entity word in the text to be analyzed, including the following specific steps:
[0080] Step 2040: According to the text to be analyzed and the first position information, opinion information located after the entity word is identified from the text to be analyzed as opinion information for the entity word.
[0081] The first position information is one of the entity information of the entity word. The text to be analyzed may include multiple entity words, so the first position information can be the collection of all entity word position information. For example, the text to be analyzed is "Although the plot of The Count of Monte Cristo is full of ups and downs, it is too long. In comparison, the narrative of The Lady of the Camellias is more concise and more thought-provoking." Among them, the position information of the entity words "The Count of Monte Cristo" and "The Lady of the Camellias" are {1,5} and {25,27} respectively, and the first position information is {(1,5); (25,27)}.
[0082] The opinion information of the entity word is the opinion information of the opinion word after the entity word. Because the text to be analyzed may include multiple entity words, it is necessary to determine the entity word to which each opinion word is directed. Based on the grammatical habits of natural language, the opinion word after the entity word is the opinion word directed to the entity word, and the opinion information of the opinion word is the opinion information directed to the entity word. Continuing with the above example, the opinion words in the text to be analyzed are "ups and downs", "too long", "concise", and "thought-provoking", but there are two entity words "The Count of Monte Cristo" and "The Lady of the Camellias". The opinion words "ups and downs" and "too long" after "The Count of Monte Cristo" are set as the opinion words of the entity word "The Count of Monte Cristo", and the opinion information of the opinion words "ups and downs" and "too long" is the opinion information of the entity word "The Count of Monte Cristo".
[0083] Specifically, according to the text to be analyzed and the first position information, a preset opinion recognition method is used to recognize opinion information located after the entity word from the text to be analyzed as opinion information for the entity word.
[0084] By identifying the opinion information after the entity word in the text to be analyzed as the opinion information for the entity word based on the text to be analyzed and the first position information, and identifying the opinion information after the entity word from the text to be analyzed as the opinion information for the entity word based on the first position information, the position of the opinion information is clarified, and the opinion information is obtained in a more targeted manner, laying the foundation for the follow-up.
[0085] Alternatively, if Figure 4 A flowchart of a semantic classification method in a text analysis method provided in one embodiment of the present application is shown. Figure 2 In the embodiment, the opinion information includes the second position information of the opinion words. Step 206 classifies opinions based on the opinion information to determine the opinion category and sentiment category of the text to be analyzed, including the following specific steps:
[0086] Step 2060: Extract opinion words from the text to be analyzed based on the second position information.
[0087] The second position information is one of the viewpoint information of the entity word. There may be multiple viewpoint words of the entity word of the text to be analyzed, so the second position information can be a set of position information of the viewpoint information of the entity word. For example, the text to be analyzed is "Although the plot of "The Count of Monte Cristo" is ups and downs, it is too long. In comparison, the narrative of "La Dame aux Camélias" is more concise and more thought-provoking." The position information of the viewpoint words "ups and downs" and "too long" of the entity word "The Count of Monte Cristo" are {11,14} and {16,19} respectively, and the position information of the viewpoint words "concise" and "thought-provoking" of the entity word "La Dame aux Camélias" are {33,34} and {37,40} respectively, so the second position information is ({11,14}, {16,19}, {33,34}, {37,40}).
[0088] Optionally, based on the first position information, a first entity word is extracted from the text to be analyzed, and then based on the second position information, opinion words for the first entity word are extracted, and this step is repeated until all entity words and all opinion words are extracted.
[0089] Specifically, the first position information is compared with the character positions in the text to be analyzed, and the first entity word is extracted from the text to be analyzed. Then, the character positions in the text to be analyzed are compared with the second position information, and the opinion words for the first entity word are extracted from the text to be analyzed.
[0090] Continuing with the above example, the entity word "The Count of Monte Cristo" in the text to be analyzed is identified, and then the character positions in the text to be analyzed are compared according to the second position information ({11,14}, {16,19}, {33,34}, {37,40}), and the opinion words "ups and downs" and "too long" for the entity word "The Count of Monte Cristo" are extracted from the text to be analyzed.
[0091] Optionally, the text to be analyzed is annotated according to the first position information and the second position information to obtain the text to be analyzed annotated with the first position information label and the second position information label, and entity words and opinion words are extracted in position order.
[0092] The text extraction module can extract the character text marked with tags according to the tags in the text to be extracted.
[0093] Continuing with the above example, the text to be analyzed, "Although the plot of The Count of Monte Cristo is full of ups and downs, it is too long. In comparison, the narrative of The Lady of the Camellias is more concise and more thought-provoking," is annotated according to the first position information ({1,5}; {25,27}) and the second position information ({11,14}, {16,19}, {33,34}, {37,40}). The text to be analyzed annotated with the first position information label and the second position information label is "(N_Start_1) The plot of The Count of Monte Cristo (N_End_5) is (V_Start_1 1) It is full of ups and downs (V_End_14), but (V_Start_16) it is too long (V_End_19). In comparison, (N_Start_25) The Lady of the Camellias (N_End_27) is more (V_Start_33) concise (V_Start_34) and more (V_Start_37) thought-provoking (V_End_40). "Using the text extraction module, we extract "The Count of Monte Cristo", "up and downs", "too long", "The Lady of the Camellias", "concise", and "thought-provoking" in order of position.
[0094] Step 2062: Based on the opinion words, the text to be analyzed is opinion-classified to determine the opinion category and sentiment category of the text to be analyzed.
[0095] For example, based on the opinion words "ups and downs", "too long", "concise", and "thought-provoking", the analysis text "Although the plot of "The Count of Monte Cristo" is ups and downs, it is too long. In comparison, the narrative of "The Lady of the Camellias" is more concise and more thought-provoking." is classified, and the opinion category and emotion category of the text to be analyzed are determined as: ("ups and downs", content, positive category), ("too long", length, negative category), ("concise", length, positive category), ("thought-provoking", content, positive category).
[0096] In the embodiment of the present application, by extracting opinion words, the opinion classification is performed on the text to be analyzed based on the opinion words, and the opinion category and sentiment category of the opinion words are obtained. There is no need to perform semantic classification based on the entire text to be analyzed, but only based on the opinion words. Such a semantic classification method greatly improves the efficiency of semantic classification.
[0097] Optionally, Figure 5 The flowchart of a method for semantic classification using a semantic classification model in a text analysis method provided by an embodiment of the present application is shown. Step 206 includes the following specific steps:
[0098] Step 2064: Input the opinion words into the semantic classification model, use the semantic classification model to classify the opinion of the text to be analyzed, and determine the opinion category and sentiment category of the text to be analyzed, wherein the semantic classification model is pre-trained based on opinion word samples labeled with opinion categories and sentiment categories.
[0099] The semantic classification model is a natural language processing model that can classify opinion words and obtain the opinion category and sentiment category of the opinion words.
[0100] For example, the opinion words "ups and downs", "too long", "concise", and "thought-provoking" are input into the semantic classification model, and the semantic classification model is used to classify the opinion of the analysis text "Although the plot of "The Count of Monte Cristo" is ups and downs, it is too long. In comparison, the narrative of "The Lady of the Camellias" is more concise and more thought-provoking." The opinion category and emotion category of the text to be analyzed are determined as: ("ups and downs", content, positive category), ("too long", length, negative category), ("concise", length, positive category), ("thought-provoking", content, positive category).
[0101] In the embodiment of the present application, a semantic classification model is used to classify the opinions of the text to be analyzed, and the opinion category and sentiment category of the text to be analyzed are determined, thereby improving the classification efficiency of opinion classification and further improving the overall text analysis efficiency.
[0102] Alternatively, if Figure 6 The flowchart of a classification method based on a semantic classification model in a text analysis method provided by an embodiment of the present application is shown, and the semantic classification model includes a BERT model, a softmax layer, an opinion category judgment submodule, and an emotion category judgment submodule. Step 2064 includes the following specific steps:
[0103] Step 20640: Input the opinion words into the BERT model to obtain the semantic features of the opinion words.
[0104] The BERT model will encode the input opinion words and then identify all the characters in the opinion words according to the character encoding of the opinion words, and then obtain the semantic features of the opinion words.
[0105] Specifically, the opinion words are input into the BERT model, the semantic feature vectors of the opinion words are output, and the semantic features of the opinion words are determined based on the semantic feature vectors.
[0106] For example, the BERT model encodes the input opinion word "ups and downs" and obtains the feature vector of "ups and downs" as E_token, and determines the corresponding semantic feature token.
[0107] The BERT model encodes the input opinion words to obtain the semantic features of the opinion words, laying the feature foundation for subsequently obtaining the normalized values of the opinion words.
[0108] Step 20642: Input the semantic features into the softmax layer to obtain the normalized values of the opinion words.
[0109] Specifically, the semantic features are input into the softmax layer, and the normalized values of the opinion words are obtained based on the probability calculation method.
[0110] Continuing with the above example, the semantic feature token of "ups and downs" is input into the softmax layer, and based on the probability calculation method, the normalized value of "ups and downs" is obtained to be 0.23.
[0111] The softmax layer normalizes the semantic features of opinion words to obtain the normalized values of opinion words, laying the data foundation for obtaining multiple opinion categories later.
[0112] Step 20644: Input the normalized value into the opinion category judgment submodule to obtain the opinion category of the opinion word.
[0113] Specifically, the normalized value is input into the opinion category judgment submodule, and compared with the preset threshold value of each opinion category to obtain the opinion category of the opinion word.
[0114] The normalized value of the opinion word is input into the opinion category judgment submodule, and compared with the preset threshold of each opinion category to obtain the preset probability of each opinion category, and the opinion category with the maximum probability is determined as the opinion category of the opinion word.
[0115] Continuing with the above example, the normalized value of "ups and downs" of 0.23 is input into the opinion category judgment submodule, and compared with the preset threshold of each opinion category to determine that the probability of "ups and downs" being "content" is 84%, the probability of being "perception" is 12%, and the probability of being "length" is 4%, and the "content" with the highest probability is determined to be the opinion category.
[0116] Step 20646: Input the normalized value of the opinion word and the opinion category of the opinion word into the emotion category judgment submodule to obtain the emotion category of the opinion word.
[0117] The sentiment category judgment submodule has an attention mechanism. The attention mechanism in the sentiment category submodel will perform a weighted average algorithm of a specific relationship matrix on the normalized values of the opinion words and the opinion categories of the opinion words input into the sentiment classification submodule, so that the normalized values of the opinion words can be combined with the opinion categories, thereby obtaining a more accurate sentiment category.
[0118] Specifically, the normalized value of the opinion word and the opinion category of the opinion word are input into the sentiment category judgment submodule, and the sentiment category of the opinion word is obtained based on the attention mechanism.
[0119] The opinion words and opinion categories of the opinion words are input into the emotion category judgment submodule. Based on the attention mechanism, they are compared with the preset threshold of each emotion category to obtain the preset probability of each emotion category, and the emotion category with the highest probability is determined as the emotion category of the opinion words. The classification result output layer outputs the opinion category and emotion category of the opinion words, and the process is repeated until the classification results of all opinion words are obtained.
[0120] Continuing with the above example, the normalized value of "ups and downs" 0.23 and the opinion category "content" are input into the emotion category judgment submodule. Based on the attention mechanism, the probability of the positive category is 93%, the probability of the neutral category is 6%, and the probability of the negative category is 1%. The "positive category" with the highest probability is determined to be the emotion category. The classification result output layer outputs the opinion category and emotion category of the opinion words. Repeat this process until the classification results of all opinion words are obtained.
[0121] In an embodiment of the present application, by extracting opinion words and then inputting the opinion words into a semantic classification model, after serial processing by a BERT model, a softmax functional layer, an opinion category judgment submodule and a sentiment category judgment submodule, subsequent classification can be performed based on the normalized values of the opinion words. After obtaining the opinion category, the sentiment category can be determined in combination with the opinion category and the opinion words, thereby making the sentiment category more accurate.
[0122] Alternatively, if Figure 7 A flowchart of a method for determining text analysis results in a text analysis method provided in an embodiment of the present application is shown. After step 206, the method further includes:
[0123] Step 2066: For any emotion category, concatenate the opinion words and opinion categories belonging to the emotion category to obtain the opinion concatenation result of the emotion category.
[0124] For example, according to step 206, the opinion categories and sentiment categories of all opinion words in the text to be analyzed, "Although the plot of The Count of Monte Cristo is full of ups and downs, it is too long. In comparison, the narration of The Lady of the Camellias is more concise and more thought-provoking." are: ("up and downs", content, positive category), ("too long", length, negative category), ("concise", length, positive category), ("thought-provoking", content, positive category).
[0125] For the positive category, the opinion words "ups and downs", "content", "concise", "length", "thought-provoking", and "content" belonging to the positive category are spliced to obtain the opinion splicing result of the positive category ("ups and downs"-content-"concise"-length-"thought-provoking"-content-positive). For the negative category, the opinion word "too long" belonging to the negative category is spliced to obtain the opinion splicing result of the negative category ("too long"-length-negative).
[0126] Step 2068: Determine the text analysis result of the text to be analyzed based on the concatenation results of the entity words and the viewpoints of each sentiment category.
[0127] Specifically, based on the entity words and the opinion concatenation results of each sentiment category of the opinion corresponding to the entity words, the text analysis results of the text to be analyzed are further concatenated.
[0128] Continuing with the above example, we obtain the splicing results of opinions in the positive category ("ups and downs" - "concise" - "thought-provoking" - positive) and the splicing results of opinions in the negative category ("too long" - negative). According to the entity words "The Count of Monte Cristo" and "The Lady of the Camellias", the splicing results of opinions in the positive category and the splicing results of opinions in the negative category, we further splice to obtain the text analysis results of the text to be analyzed ("The Count of Monte Cristo" - "ups and downs" - content - positive; "The Count of Monte Cristo" - "too long" - length - negative; "The Lady of the Camellias" - "concise" - length - "thought-provoking" - content - positive).
[0129] In the embodiment of the present application, for any sentiment category, the viewpoint concatenation result of the sentiment category is determined, and the text analysis result is determined according to the entity words and the viewpoint concatenation results of each sentiment category. It can correspond to multiple different viewpoints of the entity words, and obtain a more targeted and richer text analysis result.
[0130] Optionally, Figure 8 A flowchart of a method for performing entity recognition using an entity recognition model in a text analysis method provided by an embodiment of the present application is shown. Step 202 performs entity recognition on the text to be analyzed and determines the entity information of the entity words in the text to be analyzed, including the following specific steps:
[0131] Step 220: Input the text to be analyzed into an entity recognition model, and use the entity recognition model to identify entity information of entity words in the text to be analyzed, wherein the entity recognition model is pre-trained based on sample text annotated with entity information.
[0132] The entity recognition model is a natural language processing model that can identify entity words in the text to be analyzed and obtain the entity information of the entity words.
[0133] Optionally, the entity recognition model consists of a BERT model and a softmax layer.
[0134] In the prior art, an entity recognition model composed of an LSTM model and a CRF layer is used to recognize the entity information of entity words in the text to be analyzed. In the embodiments of the present application, an entity recognition model composed of a BERT model and a softmax layer is used. Compared with the LSTM model, the BERT model has a higher recognition accuracy for entity words because it has more fully connected layers in the model and has an attention mechanism. Since the CRF layer needs to first perform text sequence annotation on the text, and then capture the transition probability between the sequences with labeled tags according to the algorithm of the unilateral Markov chain based on the labeled tags, and then recognize the entity words, it is difficult to meet the recognition efficiency requirements of entity words in a large number of texts to be analyzed. Compared with the CRF layer, the softmax layer can compress each character range to between (0, 1), which can meet the normalization requirements for the recognition of multiple entity words.
[0135] Specifically, the text to be analyzed is input into the entity recognition model, and the entity recognition model recognizes the entity words in the text to be analyzed and labels each entity word, adding an information label to each entity word to represent the entity information of the entity word.
[0136] If the entity information of the entity word is the first and last characters of the entity word, then the first and last characters of the entity word are determined as the information label and added to the text to be analyzed. For example, if the text to be analyzed is "The number of gold medals of the Chinese team in this year's Winter Olympics has reached a record high", the entity recognition model recognizes the entity words in the text to be analyzed, determines that the entity words are "Winter Olympics" and "Chinese team", and determines the first character ("Winter" and "Chinese") and the last character ("Olympics" and "team") of the entity word as the information label and adds them to the text to be analyzed, obtaining "This year (Winter) Winter Olympics (Olympics) (Chinese) Chinese team (team)'s number of gold medals has reached a record high".
[0137] If the entity information of the entity word is the position information of the entity word in the text to be analyzed, then the position information is determined as the information label and added to the text to be analyzed. Continuing with the above example, the position information of the entity words "Winter Olympics" and "Chinese team" is {3, 5} (the 3rd character to the 5th character) and {6, 8} (the 6th character to the 8th character), then the position information is determined as the information label (N_Start_3), (N_End_5), (N_Start_6), (N_End_8) and added to the text to be analyzed, obtaining "This year (N_Start_3) Winter Olympics (N_End_5) (N_Start_6) Chinese team (N_End_8)'s number of gold medals has reached a record high".
[0138] In the embodiment of the present application, an entity recognition model is used to perform entity recognition on the text to be analyzed, and the entity information of the text to be analyzed is determined, which improves the recognition efficiency of entity recognition and further improves the overall text analysis efficiency.
[0139] Alternatively, if Fig. 9 The flowchart of a method for training an entity recognition model in a text analysis method provided by an embodiment of the present application is shown. Before inputting the text to be analyzed into the entity recognition model and using the entity recognition model to identify the entity information of the entity words in the text to be analyzed, the following specific steps are also included:
[0140] Step 902: Obtain a training sample set, wherein the training sample set includes a plurality of sample texts annotated with entity information.
[0141] The training sample is a text sentence composed of multiple characters and containing entity words and opinion words, wherein the entity word can be one or more, the opinion word can be one or more, and the entity information of each entity word is annotated.
[0142] Specifically, the training sample set is determined according to the usage scenario of the entity recognition model. For example, if the usage scenario of the entity model is user reviews on a book sales website, a set of multiple text sentences containing book entity words are selected from the user review history database of the book sales website, and the entity words therein are annotated with entity information.
[0143] Step 904: extract any sample text from the training sample set, input any sample text into the pre-trained entity recognition model, and obtain entity recognition information in any sample text.
[0144] Only the text content of any sample is extracted from the training samples, and the annotated entity information is not extracted, which can be used as a comparison basis to calculate the first loss value in the subsequent step.
[0145] The pre-trained entity recognition model is an open source natural language processing model that can identify entity words in training sample texts and obtain entity information of entity words. The pre-trained entity recognition model can be composed of a BERT model and a softmax layer. The BERT model has a higher recognition accuracy for entity words in training sample texts, and the softmax layer can meet the normalization requirements for the recognition of multiple entity words.
[0146] The entity recognition information may be the location information of the entity word in the training sample.
[0147] Specifically, the training sample text is input into the pre-trained entity recognition model, the pre-trained entity recognition model recognizes the entity words in the training sample text, and labels each entity word, adding an information label to each entity word to indicate the entity recognition information of the entity word.
[0148] Step 906: Calculate a first loss value based on the entity recognition information and the entity information annotated by any sample text.
[0149] The first loss value is a value used to evaluate the performance of the entity recognition model. It is a value calculated after inputting the training samples labeled with entity information and the recognition results labeled with entity recognition information obtained by the pre-trained entity recognition model into a preset loss function, wherein the preset loss function can be a 0-1 loss function, an absolute value loss function, etc., which is not limited here.
[0150] Specifically, the entity word position marked with the entity recognition information tag and the entity word position marked with the entity information tag in the sample text are taken as input, and a preset loss function is used to calculate a first loss value.
[0151] Step 908: According to the first loss value, adjust the model parameters of the entity recognition model, and return to execute to extract any sample text from the training sample set, input any sample text into the pre-trained entity recognition model, and obtain the entity recognition information in any sample text.
[0152] Step 910: When the training stop condition is met, stop training the entity recognition model to obtain a trained entity recognition model.
[0153] The training stop condition can be to determine whether the first loss value is greater than a preset threshold for the first loss value, or to determine whether the number of training times reaches a preset training times threshold, or to determine both the threshold for the first loss value and the threshold for the number of training times, which is not limited here.
[0154] Correspondingly, when the training stop condition is reached, the training of the entity recognition model is stopped, and the trained entity recognition model can be:
[0155] (1) Compare the first loss value with a preset first loss value threshold. If the first loss value is greater than the first loss value threshold, stop training the entity recognition model to obtain a trained entity recognition model.
[0156] By comparing the first loss value with the first loss value threshold, it is determined whether to stop training and obtain a trained entity recognition model, so that the entity recognition accuracy of the trained entity recognition model can be high.
[0157] (2) Counting the number of training samples input into a preset entity recognition model and a preset first quantity threshold, if the number is equal to the preset first quantity threshold, stopping the training of the entity recognition model to obtain a trained entity recognition model.
[0158] By comparing the number of training samples input into the preset entity recognition model with the first number threshold, it is determined whether to stop training and obtain the trained entity recognition model, which can improve the training efficiency of the entity recognition model.
[0159] (3) Count the number of training samples input into the preset entity recognition model and compare it with the preset first quantity threshold. If the number is equal to the preset first quantity threshold, then compare the first loss value with the preset first loss value threshold. If the first loss value is greater than the first loss value threshold, stop training the entity recognition model to obtain the trained entity recognition model.
[0160] By first comparing the number of training samples input into the preset entity recognition model with the first number threshold, and then comparing the first loss value with the first loss value threshold, it is determined whether to stop training and obtain the trained entity recognition model. An entity recognition model with high entity recognition accuracy can be obtained while meeting the training efficiency requirements of the entity recognition model.
[0161] In the embodiment of the present application, a trained entity recognition model is obtained, which lays a model foundation for obtaining entity recognition information.
[0162] Optionally, Fig.10 A flowchart of a method for performing opinion recognition using an opinion recognition model in a text analysis method provided by an embodiment of the present application is shown. According to entity information, opinion recognition is performed on the text to be analyzed, and opinion information for entity words in the text to be analyzed is determined, including the following specific steps:
[0163] Step 2042: Input the text to be analyzed and the entity information into the opinion recognition model, and use the opinion recognition model to identify the opinion information for the entity words in the text to be analyzed, wherein the opinion extraction model is pre-trained based on sample text annotated with opinion information.
[0164] The opinion recognition model is a natural language processing model that can identify opinion words for entity words in the text to be analyzed and obtain opinion information for the entity words.
[0165] Specifically, the text to be analyzed with entity information marked is input into the entity recognition model. The opinion recognition model recognizes the opinion words for the entity words in the text to be analyzed, and marks each opinion word, adding an information label to each opinion word to indicate the opinion information for the entity word.
[0166] If the opinion information for the entity word is the first character and the last character of the opinion word for the entity word, the first character and the last character of the opinion word are determined as information tags and added to the text to be analyzed. Continuing with the above step 204 example, the text to be analyzed is "This year (Winter) Winter Olympics (meeting) (in) the number of gold medals of the Chinese team (team) hit a record high", the opinion recognition model identifies the opinion words for the entity words of the text to be analyzed, determines that the opinion words are "historical high", and determines the first character ("history") and the last character ("high") of the opinion word (historical high) for the entity word (Chinese team) as information tags, and adds them to the text to be analyzed, and obtains "This year (Winter) Winter Olympics (meeting) (in) the number of gold medals of the Chinese team (team) hit a record high (high)".
[0167] If the opinion information for the entity word is the position information of the opinion word for the entity word in the text to be analyzed, the position information is determined as an information tag and added to the text to be analyzed. Continuing the above step 204 example "This year (N_Start_3) Winter Olympics (N_End_5) (N_Start_6) The number of gold medals of the Chinese team (N_End_8) hit a record high", the position information of the opinion word "historical high" is {14, 17} (the 14th character to the 17th character), then the position information is determined as information tags (V_Start_14), (V_End_17), added to the text to be analyzed, and "This year (N_Start_3) Winter Olympics (N_End_5) (N_Start_6) The number of gold medals of the Chinese team (N_End_8) hit a record high (V_Start_14) (V_End_17)".
[0168] In the embodiment of the present application, a viewpoint recognition model is used to perform viewpoint recognition on the text to be analyzed, and the viewpoint information of the text to be analyzed is determined, thereby improving the recognition efficiency of viewpoint recognition and further improving the overall text analysis efficiency.
[0169] Optionally, Fig.11 A flowchart of a method for training a viewpoint recognition model in a text analysis method provided in an embodiment of the present application is shown, including:
[0170] Step 1102: Input any sample text and entity recognition information into a pre-trained opinion recognition model to obtain opinion recognition information in any sample text.
[0171] The entity recognition information in any sample text and the corresponding sample text are input into a pre-trained opinion recognition model to obtain the opinion recognition information in any sample text.
[0172] The pre-trained opinion recognition model is an open source natural language processing model that can recognize opinion terms of entity words in training sample texts and obtain opinion information for opinion terms of entity words. The pre-trained opinion recognition model can be composed of a BERT model and a softmax layer. The BERT model has a higher recognition accuracy for opinion terms of entity words in training sample texts, and the softmax layer can meet the normalization requirements for opinion term recognition of multiple entity words.
[0173] Step 1104: Calculate a second loss value according to the opinion identification information and the opinion information annotated in any sample text.
[0174] The second loss value is used to evaluate the performance of the opinion recognition model. It is the value calculated after inputting the training samples labeled with opinion information and the opinion recognition results labeled with opinion recognition information obtained by the pre-trained opinion recognition model into a preset loss function, wherein the preset loss function can be a 0-1 loss function, an absolute value loss function, etc., which is not limited here.
[0175] Specifically, the opinion word position marked with the opinion identification information tag and the opinion word position marked with the opinion information tag in the sample text are taken as input, and a preset loss function is used to calculate the second loss value.
[0176] Step 1106: Adjust the model parameters of the opinion recognition model according to the second loss value.
[0177] Step 1108: When the training stop condition is met, stop training the viewpoint recognition model to obtain a trained viewpoint recognition model.
[0178] The training stop condition can be to determine whether the second loss value is greater than a preset threshold for the second loss value, or to determine whether the number of training times reaches a preset training times threshold, or to determine both the threshold for the second loss value and the threshold for the number of training times, which is not limited here.
[0179] Correspondingly, when the training stop condition is reached, the training of the viewpoint recognition model is stopped, and the trained viewpoint recognition model can be:
[0180] (1) Compare the second loss value with a preset second loss value threshold. If the first loss value is greater than the second loss value threshold, stop training the viewpoint recognition model to obtain a trained viewpoint recognition model.
[0181] By comparing the second loss value with the second loss value threshold, it is determined whether to stop training and obtain a trained viewpoint recognition model, so that the trained viewpoint recognition model can have high viewpoint recognition accuracy.
[0182] (2) Counting the number of training samples input into the preset opinion recognition model and a preset second number threshold M, if the number is equal to the preset second number threshold, stopping the training of the opinion recognition model to obtain a trained opinion recognition model.
[0183] By comparing the number of training samples input into the preset opinion recognition model with the second number threshold, it is determined whether to stop training and obtain the trained opinion recognition model, which can improve the training efficiency of the opinion recognition model.
[0184] (3) Count the number of training samples input into the preset opinion recognition model and compare it with the preset second quantity threshold. If the number is equal to the preset second quantity threshold, and compare the second loss value with the preset second loss value threshold, if the second loss value is greater than the second loss value threshold, stop training the opinion recognition model to obtain the trained opinion recognition model.
[0185] By first comparing the number of training samples input into the preset opinion recognition model with the second number threshold N, and then comparing the second loss value with the second loss value threshold, it is determined whether to stop training and obtain the trained opinion recognition model. Under the condition that the training efficiency requirement of the opinion recognition model is met, an opinion recognition model with high opinion recognition accuracy can be obtained.
[0186] In the embodiment of the present application, a trained opinion recognition model is obtained, which lays a model foundation for obtaining opinion recognition information.
[0187] Fig.12 A flowchart of a method for performing opinion recognition using an opinion recognition model in a text analysis method provided by an embodiment of the present application is shown. According to entity information, opinion recognition is performed on the text to be analyzed, and opinion information for entity words in the text to be analyzed is determined, including the following specific steps:
[0188] Step 2068: Based on the opinion information, use a semantic classification model to determine the opinion category and sentiment category of the text to be analyzed, wherein the semantic classification model is pre-trained based on opinion word samples labeled with opinion categories and sentiment categories.
[0189] Specifically, according to the opinion information, opinion words in the text to be analyzed are extracted, and the opinion words are input into a semantic classification model to obtain the opinion category and sentiment category of the opinion words.
[0190] If the view information is the first and last characters of the view word for an entity word, extract the view word from the text to be analyzed based on the first and last characters, and input the view word into the semantic classification model to obtain the view category and sentiment category of the view word. Continuing with the example in step 206 above, the view information is the first character ("Li") and the last character ("Gao") of the view word. Based on this view information, extract the view word ("historical new high") from the text to be analyzed, and input this view word ("historical new high") into the semantic classification model to obtain the view category of the view word as "record" and the sentiment category as "positive category".
[0191] If the view information is the position information of the view word for an entity word in the text to be analyzed, extract the view word from the text to be analyzed based on this position information, and input the view word into the semantic classification model to obtain the view category of the view word. For example, if the position information is {14, 17}, then determine the information tags (V_Start_14) and (V_End_17) based on this position information, and extract the view word ("historical new high") from the text to be analyzed. Input this view word ("historical new high") into the semantic classification model to obtain the view category of the view word as "record" and the sentiment category as "positive category".
[0192] In the embodiments of the present application, the semantic classification model is used to perform semantic classification on the text to be analyzed, determine the view information of the text to be analyzed, improve the recognition efficiency of semantic classification, and thus improve the overall text analysis efficiency.
[0193] Optionally, as Fig.13 shows a flowchart of a training method for a semantic classification model in a text analysis method provided by an embodiment of the present application, including:
[0194] Step 1302: Extract target view words from any sample text according to the view recognition information.
[0195] Specifically, according to the view recognition information of one or more view words, that is, the position information of the view words, extract one or more target view words from any text.
[0196] Step 1304: Input the target view words into the pre-trained semantic classification model to obtain the target view category and target sentiment category of the target view words.
[0197] Specifically, the pre-trained semantic classification model includes a BERT model, a softmax layer, a view category judgment sub-module, a sentiment category judgment sub-module, and a classification result output layer.
[0198] One or more target opinion words are input into the pre-trained semantic classification model. The BERT model encodes one or more target opinion words, and then all characters in one or more target opinion words can be identified according to the character encoding of one or more target opinion words, and the opinion category information and sentiment category information are predicted. The softmax layer normalizes the predicted opinion category information to obtain the normalized value of one or more target opinion words. The normalized value of the target opinion word is input into the opinion category judgment submodule to obtain the probability of each opinion category. The normalized value of the target opinion word and the probability of each opinion category are input into the sentiment category judgment submodule. Based on the attention mechanism, the probability of each sentiment category is obtained. The classification result output layer selects one or more opinion categories and one or more sentiment categories with the maximum probability as the classification result, and outputs the classification result.
[0199] Step 1306: Calculate a third loss value based on the target opinion category and the opinion category of the target opinion words marked in any sample text, and calculate a fourth loss value based on the target emotion category and the emotion category of the target opinion words marked in any sample text.
[0200] The third loss value is used to evaluate the opinion classification performance of the semantic classification model. It is the value calculated after inputting one or more identified target opinion categories and one or more opinion categories in any sample text into a preset loss function, wherein the preset loss function can be a 0-1 loss function, an absolute value loss function, etc., which is not limited here.
[0201] The fourth loss value is used to evaluate the sentiment classification performance of the semantic classification model. It is the value calculated after inputting one or more identified target sentiment categories and one or more sentiment categories in any sample text into a preset loss function, wherein the preset loss function can be a 0-1 loss function, an absolute value loss function, etc., which is not limited here.
[0202] Step 1308: Adjust the model parameters of the semantic classification model according to the third loss value and the fourth loss value.
[0203] Optionally, the parameters of the opinion category judgment submodule in the semantic classification model are first adjusted according to the third loss value, and then the parameters of the emotion category judgment submodule in the semantic classification model are adjusted according to the fourth loss value.
[0204] Optionally, based on the third loss value and the fourth loss value, parameters of the opinion category judgment submodule and parameters of the emotion category judgment submodule in the semantic classification model are adjusted accordingly according to the module weights of the semantic classification model.
[0205] Step 1310: When the training stop condition is met, stop training the semantic classification model to obtain a trained semantic classification model.
[0206] The training stop condition can be to determine whether the third loss value is greater than a preset threshold for the third loss value and whether the fourth loss value is greater than a preset threshold for the fourth loss value, or to determine whether the number of training times reaches a preset training times threshold, or to determine both the threshold for the third loss value and the threshold for the fourth loss value and the training times threshold, which is not limited here.
[0207] Correspondingly, when the training stop condition is reached, the training of the semantic classification model is stopped, and the trained semantic classification model can be:
[0208] (1) Compare the third loss value with a preset third loss value threshold and compare the fourth loss value with a preset fourth loss value threshold. If the third loss value is greater than the third loss value threshold and the fourth loss value is greater than the fourth loss value threshold, stop training the semantic classification model to obtain a trained semantic classification model.
[0209] By comparing the third loss value with the third loss value threshold, and the fourth loss value with the fourth loss value threshold, it is determined whether to stop training and obtain a trained semantic classification model, so that the semantic classification accuracy of the trained semantic model is high.
[0210] (2) Counting the number of target opinion words input into the preset semantic classification model and a preset third quantity threshold, if the number is equal to the preset third quantity threshold, stopping the training of the semantic classification model to obtain the trained semantic classification model.
[0211] By comparing the number of target viewpoint words input into the preset semantic classification model with the third quantity threshold, it is determined whether to stop training and obtain the trained semantic classification model, which can improve the training efficiency of the semantic classification model.
[0212] (3) Count the number of target opinion words input into the preset semantic model and compare it with the preset third quantity threshold. If the number is equal to the preset third quantity threshold, then compare the third loss value and the fourth loss value with the preset third loss value threshold and the fourth loss value threshold respectively. If the third loss value is greater than the third loss value threshold and the fourth loss value is greater than the third loss value threshold, stop training the semantic classification model to obtain the trained semantic classification model.
[0213] By first comparing the number of target viewpoint words input into the preset semantic classification model with the third number threshold, and then comparing the third loss value and the fourth loss value with the third loss value threshold and the fourth loss value threshold respectively, it is determined whether to stop training and obtain the trained semantic classification model. A semantic classification model with high semantic classification accuracy can be obtained while meeting the training efficiency requirements of the semantic classification model.
[0214] In the embodiment of the present application, a trained semantic classification model is obtained, which lays a model foundation for classifying various opinion words and obtaining opinion classification and sentiment classification.
[0215] Fig.14 A processing flow chart of a training method for an entity recognition model, an opinion recognition model, and a semantic classification model in a text analysis method provided in an embodiment of the present application is shown, which specifically includes the following steps:
[0216] Step 1402: Obtain training sample set D.
[0217] The training sample set includes multiple sample texts annotated with entity information.
[0218] Step 1404: extract any sample text D1 from the training sample set, input any sample text D1 into the pre-trained entity recognition model M1, and obtain entity recognition information d11 in any sample text.
[0219] Step 1406: Calculate a first loss value (d11-d11') / d11' according to the entity recognition information d11 and the entity information d11' annotated by any sample text.
[0220] Step 1408: According to the first loss value (d11-d11') / d11', adjust the model parameters of the entity recognition model M1, and return to execute to extract any sample text D2 from the training sample set, input any sample text D2 into the pre-trained entity recognition model M1, and obtain the entity recognition information d21 in any sample text.
[0221] Step 1410: When the training stop condition is met, stop training the entity recognition model M1 to obtain the trained entity recognition model M1.
[0222] Step 1412: Input any sample text D2 and entity recognition information d21 into the pre-trained opinion recognition model M2 to obtain opinion recognition information d22 in any sample text.
[0223] Step 1414: Calculate a second loss value (d22-d22') / d22' according to the opinion identification information d22 and the opinion information d22' annotated on any sample text.
[0224] Step 1416: Adjust the model parameters of the viewpoint recognition model M2 according to the second loss value (d22-d22') / d22'.
[0225] Step 1418: When the training stop condition is met, stop training the viewpoint recognition model M2 to obtain the trained viewpoint recognition model M2.
[0226] Step 1420: Extract the target opinion word A from any sample text according to the opinion identification information d22.
[0227] Step 1422: Input the target opinion word A into the pre-trained semantic classification model M3 to obtain the target opinion category a1 and the target emotion category a2 of the target opinion word.
[0228] Step 1424: Calculate the third loss value (a1-a1') / a1' based on the target opinion category a1 and the opinion category a1' of the target opinion words marked in any sample text, and calculate the fourth loss value (a2-a2') / a2' based on the target emotion category a2 and the emotion category a2' of the target opinion words marked in any sample text.
[0229] Step 1426: Adjust the model parameters of the semantic classification model M3 according to the third loss value (a1-a1') / a1' and the fourth loss value (a2-a2') / a2'.
[0230] Optionally, the parameters of the opinion category judgment submodule M31 in the semantic classification model M3 are first adjusted according to the third loss value (a1-a1') / a1', and then the parameters of the emotion category judgment submodule M32 in the semantic classification model M3 are adjusted according to the fourth loss value (a2-a2') / a2'.
[0231] Optionally, according to the third loss value (a1-a1') / a1' and the fourth loss value (a2-a2') / a2', the parameters of the opinion category judgment submodule M31 and the parameters of the emotion category judgment submodule M32 in the semantic classification model M3 are adjusted accordingly according to the module weights of the semantic classification model.
[0232] Step 1428: When the training stop condition is met, stop training the semantic classification model M3 to obtain the trained semantic classification model M3.
[0233] In the embodiment of the present application, the pre-trained entity recognition model, opinion recognition model, and semantic classification model are jointly trained in sequence using the same training sample set, so that the models have stronger relevance when facing the same application scenario, thereby ensuring that the entity recognition model, opinion recognition model, and semantic classification model are more applicable in the application scenario, and the text analysis results are more accurate.
[0234] The following combination Fig.15A and attached Fig. 15B Taking the application of the text analysis method provided in this application to user book reviews as an example, the text analysis method is further explained. Fig.15A A processing flow chart of a text analysis method applied to user book reviews provided by an embodiment of the present application is shown. Fig. 15B A structural schematic diagram of a text analysis method applied to user book reviews provided by an embodiment of the present application is shown, which specifically includes the following steps:
[0235] Step 1502: Obtain the text to be analyzed.
[0236] The text to be analyzed is "The book series "XXX" is very exciting, but a bit long."
[0237] Step 1504: preprocess the text to be analyzed to obtain the preprocessed text to be analyzed.
[0238] The text to be analyzed "This set of books "XXX" is very exciting, but a little long" is pre-processed by phrase segmentation to obtain the processed text to be analyzed "This set of books "XXX" is very exciting, but / the length is / a little / long".
[0239] Step 1506: Based on the text to be analyzed, use the entity recognition model M1 to identify the first position information of the entity word in the text to be analyzed.
[0240] According to the preprocessed text to be analyzed "《XXX》 / this set of books / is very exciting, but / the length / is / a / bit / long", the entity recognition model M1 is used to identify the first position information of the entity word "《XXX》" in the text to be analyzed as {1,2}.
[0241] Step 1508: Based on the text to be analyzed and the first position information, using the opinion recognition model M2, the opinion information located after the entity word is identified from the text to be analyzed as the second position information for the entity word.
[0242] According to the text to be analyzed "《XXX》 / this set of books / is / very / wonderful, / but / it / is / a / little / long" and the first position information {1,2}, the opinion recognition model M2 is used to identify the opinion information ("very / wonderful" {6,10}) and ("long" {15,15}) located after the entity word "《XXX》" from the text to be analyzed as the second position information ({6,10}, {15,15}) for the entity word.
[0243] Step 1510: Extract opinion words from the text to be analyzed based on the second position information.
[0244] According to the second position information ({6, 10}, {15, 15}), the opinion words "very exciting" and "long" are extracted from the text to be analyzed.
[0245] Step 1512: Input the opinion words into the semantic classification model M3 to obtain the opinion category and sentiment category of the opinion words.
[0246] The opinion words "very exciting" and "long" are input into the semantic classification model M3, and the opinion categories of the opinion words are perception and length, and the sentiment categories are positive and negative.
[0247] Step 1514: For any emotion category, concatenate the opinion words and opinion categories belonging to the emotion category to obtain the opinion concatenation result of the emotion category.
[0248] For the positive category, the opinion word "very wonderful" belonging to the positive category is spliced to obtain the opinion splicing result of the positive category ("very wonderful"-perception-positive).
[0249] For the negative category, the opinion word “long” belonging to the negative category is spliced to obtain the opinion splicing result of the negative category (“long”-length-negative).
[0250] Step 1516: Determine the text analysis result of the text to be analyzed based on the concatenation results of the entity words and the viewpoints of each sentiment category.
[0251] According to the entity word "XXX", the splicing results of opinions in the positive category ("very exciting"-perception-positive) and the splicing results of opinions in the negative category ("long"-length-negative), the text analysis results of the text to be analyzed "The book "XXX" is very exciting, but a bit long" are determined to be ("XXX"-"very exciting"-perception-positive; "XXX"-"long"-length-negative).
[0252] Through the embodiments of the present application, in the scenario of user book reviews, multiple opinion categories and sentiment categories are determined based on the information of the book title and the opinion information on the book, and comprehensive analysis results for user book reviews are obtained, thereby achieving accurate and efficient analysis of complex user book reviews.
[0253] Corresponding to the above method embodiment, the present application also provides a text analysis device embodiment, Fig.16 FIG. 1 is a schematic diagram showing the structure of a text analysis device provided by an embodiment of the present application. Fig.16 As shown, the device comprises:
[0254] The entity recognition module 1602 is configured to obtain a text to be analyzed, perform entity recognition on the text to be analyzed, and determine entity information of entity words in the text to be analyzed;
[0255] The opinion recognition module 1604 is configured to perform opinion recognition on the text to be analyzed based on the entity information, and determine the opinion information for the entity words in the text to be analyzed.
[0256] The semantic classification module 1606 is configured to perform opinion classification based on the opinion information, and determine the opinion category and sentiment category of the text to be analyzed.
[0257] Optionally, the device further comprises:
[0258] The text preprocessing module is configured to preprocess the text to be analyzed to obtain the preprocessed text to be analyzed.
[0259] Optionally, the opinion identification module 1604 is further configured to identify opinion information located after the entity word from the text to be analyzed as the opinion information for the entity word according to the text to be analyzed and the first position information.
[0260] Optionally, the semantic classification module 1606 is further configured to extract opinion words from the text to be analyzed according to the second position information, and to perform opinion classification on the text to be analyzed based on the opinion words to determine the opinion category and sentiment category of the text to be analyzed.
[0261] Optionally, the semantic classification module 1606 is further configured to input opinion words into a semantic classification model, use the semantic classification model to classify the opinion of the text to be analyzed, and determine the opinion category and sentiment category of the text to be analyzed, wherein the semantic classification model is pre-trained based on opinion word samples labeled with opinion categories and sentiment categories.
[0262] Optionally, the semantic classification module 1606 is further configured to input the opinion words into the BERT model to obtain the semantic features of the opinion words, input the semantic features into the softmax layer to obtain the normalized values of the opinion words, input the normalized values into the opinion category judgment submodule to obtain the opinion category of the opinion words, input the normalized values and the opinion category into the emotion category judgment submodule to obtain the emotion category of the opinion words.
[0263] Optionally, the device further comprises:
[0264] The opinion splicing module is configured to splice the opinion words and opinion categories belonging to any emotion category to obtain the opinion splicing result of the emotion category;
[0265] The determination module is configured to determine the text analysis result of the text to be analyzed based on the entity words and the viewpoint concatenation results of each sentiment category.
[0266] Optionally, the entity recognition module 1602 is further configured to input the text to be analyzed into an entity recognition model, and use the entity recognition model to identify entity information of entity words in the text to be analyzed, wherein the entity recognition model is pre-trained based on sample text annotated with entity information.
[0267] Optionally, the device further comprises:
[0268] The first training module is configured to extract any sample text from the training sample set, input any sample text into a pre-trained entity recognition model, and obtain entity recognition information in any sample text; calculate a first loss value based on the entity recognition information and the entity information annotated by any sample text; adjust the model parameters of the entity recognition model based on the first loss value, and return to execute the extraction of any sample text from the training sample set, input any sample text into the pre-trained entity recognition model, and obtain entity recognition information in any sample text; when the training stop condition is met, stop training the entity recognition model to obtain the trained entity recognition model.
[0269] Optionally, the opinion recognition module 1604 is further configured to input the text to be analyzed and the entity information into an opinion recognition model, and use the opinion recognition model to identify the opinion information for the entity words in the text to be analyzed, wherein the opinion extraction model is pre-trained based on sample text annotated with opinion information.
[0270] Optionally, the device further comprises:
[0271] The second training module is configured to input any sample text and entity recognition information into a pre-trained opinion recognition model to obtain the opinion recognition information in any sample text; calculate a second loss value based on the opinion recognition information and the opinion information annotated in any sample text; adjust the model parameters of the opinion recognition model based on the second loss value; and stop training the opinion recognition model when the training stop condition is met to obtain a trained opinion recognition model.
[0272] Optionally, the semantic classification module 1606 is further configured to determine the opinion category and sentiment category of the text to be analyzed based on the opinion information using a semantic classification model, wherein the semantic classification model is pre-trained based on opinion word samples labeled with opinion categories and sentiment categories.
[0273] Optionally, the device further comprises:
[0274] The third training module is configured to extract target opinion words from any sample text based on opinion identification information; input the target opinion words into a pre-trained semantic classification model to obtain a target opinion category and a target emotion category of the target opinion words; calculate a third loss value based on the target opinion category and the opinion category of the target opinion words marked in any sample text, and calculate a fourth loss value based on the target emotion category and the emotion category of the target opinion words marked in any sample text; adjust the model parameters of the semantic classification model based on the third loss value and the fourth loss value; and stop training the semantic classification model when the training stop condition is met to obtain a trained semantic classification model.
[0275] The above is a schematic scheme of a text analysis device of the present embodiment. It should be noted that the technical scheme of the text analysis device and the technical scheme of the above-mentioned text analysis method belong to the same concept. For details not described in detail in the technical scheme of the text analysis device, please refer to the description of the technical scheme of the above-mentioned text analysis method. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method, and each functional module is not an actual functional division or separation definition. The device claim defined by such a group of functional modules should be understood as a functional module architecture that mainly implements the solution through the computer program recorded in the specification, and should not be understood as a physical device that mainly implements the solution through hardware.
[0276] The text analysis device provided in the embodiment of the present application first obtains the text to be analyzed, performs entity recognition on the text to be analyzed, and determines the entity information of the entity words in the text to be analyzed. Secondly, based on the entity information, the text to be analyzed is subjected to viewpoint recognition, and the viewpoint information for the entity words in the text to be analyzed is determined. Finally, viewpoint classification is performed based on the viewpoint information to determine the viewpoint category and sentiment category of the text to be analyzed. The classification is determined based on the entity information of the entity words and the viewpoint information for the entity words, and a comprehensive classification result for the viewpoints in the text is obtained, thereby achieving accurate and comprehensive analysis of complex text content.
[0277] Fig.17 The block diagram of a computing device provided by an embodiment of the present application is shown. The components of the computing device 1700 include but are not limited to a memory 1710 and a processor 1720. The processor 1720 is connected to the memory 1710 via a bus 1730, and the database 1750 is used to store data.
[0278] The computing device 1700 also includes an access device 1740, which enables the computing device 1700 to communicate via one or more networks 1760. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1740 may include one or more of any type of network interface (e.g., a network interface card (NIC)) of wired or wireless, such as an IEEE 802.12 wireless local area network (WLAN) wireless interface, a world microwave interconnection access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0279] In one embodiment of the present application, the above components of the computing device 1700 and Fig.17 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.17 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0280] Computing device 1700 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. Computing device 1700 may also be a mobile or stationary server.
[0281] The processor 1720 is used to execute computer executable instructions of the text analysis method.
[0282] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above text analysis method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above text analysis method.
[0283] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which are used in a text analysis method when executed by a processor.
[0284] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned text analysis method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned text analysis method.
[0285] An embodiment of the present application further provides a chip storing a computer program, which implements the steps of the text analysis method when executed by the chip.
[0286] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0287] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0288] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0289] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0290] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.
Claims
1. A text analysis method, characterized in that: include: Acquire a text to be analyzed, perform entity recognition on the text to be analyzed, and determine entity information of entity words in the text to be analyzed; According to the entity information, point of view recognition is performed on the text to be analyzed to determine point of view information for the entity word in the text to be analyzed; Opinion classification is performed based on the opinion information to determine the opinion category and sentiment category of the text to be analyzed.
2. The method according to claim 1, characterized in that Before performing entity recognition on the text to be analyzed and determining entity information of entity words in the text to be analyzed, the method further includes: The text to be analyzed is preprocessed to obtain the preprocessed text to be analyzed.
3. The method according to claim 1, characterized in that The entity information includes first position information of the entity word; The step of performing opinion recognition on the text to be analyzed based on the entity information to determine opinion information for the entity words in the text to be analyzed includes: According to the text to be analyzed and the first position information, opinion information located after the entity word is identified from the text to be analyzed as opinion information for the entity word.
4. The method according to claim 1 or 3, characterized in that: The opinion information includes second position information of the opinion word; The performing of opinion classification based on the opinion information to determine the opinion category and sentiment category of the text to be analyzed includes: extracting the opinion words from the text to be analyzed according to the second position information; Based on the opinion words, the text to be analyzed is opinion-classified to determine the opinion category and sentiment category of the text to be analyzed.
5. The method according to claim 4, characterized in that The step of classifying the text to be analyzed based on the opinion words to determine the opinion category and sentiment category of the text to be analyzed includes: The opinion words are input into a semantic classification model, and the semantic classification model is used to classify the opinion of the text to be analyzed to determine the opinion category and sentiment category of the text to be analyzed, wherein the semantic classification model is pre-trained based on opinion word samples labeled with opinion categories and sentiment categories.
6. The method according to claim 5, characterized in that The semantic classification model includes: a BERT model, a softmax layer, an opinion category judgment submodule, and an emotion category judgment submodule; The step of inputting the opinion words into a semantic classification model, using the semantic classification model to classify the opinion of the text to be analyzed, and determining the opinion category and sentiment category of the text to be analyzed includes: Inputting the opinion words into the BERT model to obtain semantic features of the opinion words; Inputting the semantic features into the softmax layer to obtain normalized values of the opinion words; Inputting the normalized value into the opinion category determination submodule to obtain the opinion category of the opinion word; The normalized value and the opinion category are input into the emotion category judgment submodule to obtain the emotion category of the opinion word.
7. The method according to claim 1, characterized in that The opinion information includes opinion information of a plurality of opinion words; After classifying the opinions based on the opinion information and determining the opinion category and sentiment category of the text to be analyzed, the method further includes: For any emotion category, concatenate the opinion words and opinion categories belonging to the emotion category to obtain the opinion concatenation result of the emotion category; The text analysis result of the text to be analyzed is determined according to the entity words and the viewpoint concatenation results of each sentiment category.
8. The method according to claim 1, characterized in that The performing entity recognition on the text to be analyzed to determine entity information of entity words in the text to be analyzed includes: The text to be analyzed is input into an entity recognition model, and the entity information of entity words in the text to be analyzed is recognized using the entity recognition model, wherein the entity recognition model is pre-trained based on sample text annotated with entity information.
9. The method according to claim 8, characterized in that Before inputting the text to be analyzed into an entity recognition model and using the entity recognition model to identify entity information of entity words in the text to be analyzed, the method further includes: Acquire a training sample set, wherein the training sample set includes a plurality of sample texts annotated with entity information; Extracting any sample text from the training sample set, inputting the any sample text into a pre-trained entity recognition model, and obtaining entity recognition information in the any sample text; Calculating a first loss value according to the entity recognition information and the entity information annotated by any one of the sample texts; According to the first loss value, adjusting the model parameters of the entity recognition model, and returning to execute the step of extracting any sample text from the training sample set, inputting the any sample text into the pre-trained entity recognition model, and obtaining entity recognition information in the any sample text; When the training stop condition is met, the training of the entity recognition model is stopped to obtain the trained entity recognition model.
10. The method according to claim 9, characterized in that The step of performing opinion recognition on the text to be analyzed based on the entity information to determine opinion information for the entity words in the text to be analyzed includes: The text to be analyzed and the entity information are input into an opinion recognition model, and the opinion recognition model is used to identify the opinion information for the entity words in the text to be analyzed, wherein the opinion extraction model is pre-trained based on sample text annotated with opinion information.
11. The method according to claim 10, characterized in that The sample text is also annotated with opinion information; After extracting any sample text from the training sample set, inputting the any sample text into a pre-trained entity recognition model, and obtaining entity recognition information in the any sample text, the method further includes: Inputting the any sample text and the entity recognition information into a pre-trained opinion recognition model to obtain the opinion recognition information in the any sample text; Calculating a second loss value according to the opinion identification information and the opinion information annotated by any one of the sample texts; According to the second loss value, adjusting the model parameters of the opinion recognition model; When the training stop condition is met, the training of the viewpoint recognition model is stopped to obtain the trained viewpoint recognition model.
12. The method according to claim 11, characterized in that The performing of opinion classification based on the opinion information to determine the opinion category and sentiment category of the text to be analyzed includes: Based on the opinion information, the opinion category and sentiment category of the text to be analyzed are determined using a semantic classification model, wherein the semantic classification model is pre-trained based on opinion word samples labeled with opinion categories and sentiment categories.
13. The method according to claim 12, characterized in that The sample text is also annotated with opinion categories and sentiment categories of opinion words; After inputting the any sample text and the entity recognition information into a pre-trained opinion recognition model to obtain the opinion recognition information in the any sample text, the method further includes: Extracting target opinion words from any of the sample texts according to the opinion identification information; Inputting the target opinion words into a pre-trained semantic classification model to obtain a target opinion category and a target emotion category of the target opinion words; Calculating a third loss value according to the target opinion category and the opinion category of the target opinion word marked in any one of the sample texts; Calculating a fourth loss value according to the target sentiment category and the sentiment category of the target opinion word marked in any one of the sample texts; Adjusting the model parameters of the semantic classification model according to the third loss value and the fourth loss value; When the training stop condition is met, the training of the semantic classification model is stopped to obtain the trained semantic classification model.
14. The method according to any one of claims 8 to 13, characterized in that The entity recognition model consists of a BERT model and a softmax layer.
15. A text analysis device, characterized in that: include: An entity recognition module is configured to obtain a text to be analyzed, perform entity recognition on the text to be analyzed, and determine entity information of entity words in the text to be analyzed; A viewpoint identification module is configured to perform viewpoint identification on the text to be analyzed according to the entity information, and determine the viewpoint information for the entity word in the text to be analyzed; The classification module is configured to perform opinion classification based on the opinion information and determine the opinion category and sentiment category of the text to be analyzed.
16. A computing device, characterized in that: include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the text analysis method according to any one of claims 1 to 14.
17. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by a processor, the steps of the text analysis method described in any one of claims 1 to 14 are implemented.
Citation Information
Cited By
English training method, system and device and storage medium
CN120496378A
