CN112860841B - Text emotion analysis method, device, equipment and storage medium - Google Patents

Text emotion analysis method, device, equipment and storage medium Download PDF

Info

Publication number
CN112860841B
CN112860841B CN202110084691.8A CN202110084691A CN112860841B CN 112860841 B CN112860841 B CN 112860841B CN 202110084691 A CN202110084691 A CN 202110084691A CN 112860841 B CN112860841 B CN 112860841B
Authority
CN
China
Prior art keywords
text data
emotion
training text
entity
training
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110084691.8A
Other languages
Chinese (zh)
Other versions
CN112860841A (en
Inventor
刘翔
丁甲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202110084691.8A priority Critical patent/CN112860841B/en
Priority to PCT/CN2021/083804 priority patent/WO2022156065A1/en
Publication of CN112860841A publication Critical patent/CN112860841A/en
Application granted granted Critical
Publication of CN112860841B publication Critical patent/CN112860841B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/31Indexing; Data structures therefor; Storage structures
    • G06F16/316Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the invention relates to the field of artificial intelligence and discloses a text emotion analysis method, a device, equipment and a storage medium, wherein the method comprises the following steps: acquiring training text data carrying a designated entity, and adding emotion type labels to the training text data; inputting the training text data into a bert model to obtain a prediction result of emotion categories of the appointed entity, and determining a loss function value of the emotion categories of the training text data; adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model with the adjusted weight parameters to obtain an emotion analysis model; inputting the text data to be tested into an emotion analysis model for analysis, and determining the emotion type corresponding to the text data to be tested. The method can automatically identify the emotion types of different entities and improve the accuracy of identifying the emotion types of the entities. The present invention relates to blockchain technology, such as training text data may be written into the blockchain for use in data forensics and other scenarios.

Description

Text emotion analysis method, device, equipment and storage medium
Technical Field
The present invention relates to the field of artificial intelligence, and in particular, to a text emotion analysis method, apparatus, device, and storage medium.
Background
The Internet is in various times, a huge amount of abundant text emotion information is presented in a social platform, and the text information can be used for mining text internal information and performing emotion analysis, so that the method has great practical significance for man-machine interaction and artificial intelligence. The traditional text emotion analysis research is mainly oriented to text at the level of chapters and sentences, and corresponding emotion polarity judgment is achieved. The researches show good application values in some application fields, such as network public opinion analysis, stock evaluation analysis and service evaluation. However, with the deep application, there is a demand for further obtaining emotion analysis results corresponding to the evaluation object attributes.
The traditional method for solving the text emotion analysis mainly comprises a machine learning algorithm, a regression algorithm, a classification algorithm and a deep learning algorithm, and the method can achieve a good effect on realizing the text without entities and only judging the accuracy of sentence description. Therefore, how to realize the identification of different emotion corresponding to different entities is very important.
Disclosure of Invention
The embodiment of the invention provides a text emotion analysis method, a device, equipment and a storage medium, which can automatically identify emotion types of different entities, can capture text information corresponding to the entities more clearly, and improves the accuracy of identifying the emotion types of the entities.
In a first aspect, an embodiment of the present invention provides a text emotion analysis method, where the method includes:
acquiring training text data carrying a designated entity, and adding emotion type labels to the training text data, wherein the emotion type labels comprise first emotion type labels and second emotion type labels, the first emotion type labels are used for indicating positive emotion types, and the second emotion type labels are used for indicating negative emotion types;
inputting the training text data into a preset bert model to obtain a prediction result of emotion categories corresponding to appointed entities in the training text data, and determining loss function values of the emotion categories of the training text data according to the prediction result;
adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model with the adjusted weight parameters to obtain an emotion analysis model;
inputting the text data to be tested into a training emotion analysis model for analysis, and determining emotion types corresponding to the text data to be tested.
Further, before inputting the training text data into a preset bert model to obtain a prediction result of the emotion type corresponding to the specified entity in the training text data, the method further includes:
Classifying the training text data added with emotion type labels, and dividing the training text data into three types of data, wherein the three types of data comprise training text data carrying a specified entity, entity data and label data;
inputting the training text data into a preset bert model to obtain a prediction result of emotion categories corresponding to specified entities in the training text data, wherein the method comprises the following steps:
and inputting the training text data carrying the appointed entity, the entity data and the tag data into a preset bert model to obtain a prediction result of the emotion type corresponding to the appointed entity in the training text data.
Further, the inputting the training text data carrying the specified entity, the entity data and the tag data into a preset bert model to obtain a prediction result of the emotion category corresponding to the specified entity in the training text data, including:
inputting training text data, entity data and tag data carrying a specified entity in the training text data into the bert model to obtain word vectors of emotion categories corresponding to the specified entity in the training text data;
and determining a prediction result of the emotion category corresponding to the appointed entity in the training text data according to the word vector.
Further, the determining the loss function value of the emotion classification of the training text data according to the prediction result includes:
acquiring weight word vectors of the training text data from the appointed entity in the training text data;
and determining a loss function value of emotion classification of the training text data according to the weight word vector and the word vector of the emotion classification corresponding to the appointed entity in the training text data obtained by the bert model.
Further, the obtaining the weight word vector of the training text data from the designated entity in the training text data includes:
acquiring a position index of the appointed entity in the training text data;
calculating indexes of related words associated with the specified entity in the training text data according to the position indexes of the specified entity in the training text data;
and determining a weight word vector corresponding to the appointed entity in the training text data according to the position index of the appointed entity and the index of the related word.
Further, the determining the loss function value of the emotion classification of the training text data according to the weighted word vector and the word vector of the emotion classification corresponding to the appointed entity in the training text data obtained by the bert model includes:
Performing splicing processing on the weight word vector and the word vector of the emotion category corresponding to the appointed entity in the training text data obtained by the bert model to obtain a target word vector;
and determining a loss function value of the emotion classification of the training text data according to the target word vector, wherein the loss function value comprises a first loss function value of a positive emotion type and a second loss function value of a negative emotion type.
Further, the inputting the text data to be tested into the emotion analysis model obtained by training for analysis, and determining the emotion type corresponding to the text data to be tested comprises the following steps:
inputting the text data to be tested into a training emotion analysis model for analysis, and determining the probability of emotion types corresponding to the text data to be tested;
and determining the emotion type with the highest probability as the emotion type corresponding to the text data to be tested according to the probability of the emotion type corresponding to the text data to be tested.
In a second aspect, an embodiment of the present invention provides a text emotion analysis device, including:
the system comprises an acquisition unit, a judgment unit and a judgment unit, wherein the acquisition unit is used for acquiring training text data carrying a specified entity and adding emotion type labels to the training text data, the emotion type labels comprise a first emotion type label and a second emotion type label, the first emotion type label is used for indicating a positive emotion type, and the second emotion type label is used for indicating a negative emotion type;
The determining unit is used for inputting the training text data into a preset bert model, obtaining a prediction result of the emotion type corresponding to the appointed entity in the training text data, and determining a loss function value of the emotion classification of the training text data according to the prediction result;
the training unit is used for adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model with the adjusted weight parameters to obtain an emotion analysis model;
the test unit is used for inputting the text data to be tested into the emotion analysis model obtained through training for analysis, and determining the emotion type corresponding to the text data to be tested.
In a third aspect, an embodiment of the present invention provides a computer device, including a processor, an input device, an output device, and a memory, where the processor, the input device, the output device, and the memory are connected to each other, and the memory is configured to store a computer program that supports a text emotion analysis apparatus to perform the method described above, where the computer program includes a program, and where the processor is configured to invoke the program to perform the method of the first aspect described above.
In a fourth aspect, embodiments of the present invention provide a computer-readable storage medium storing a computer program for execution by a processor to implement the method of the first aspect.
According to the embodiment of the invention, training text data carrying a specified entity can be obtained, emotion type labels are added to the training text data, the training text data is input into a preset bert model, a predicted result of emotion types corresponding to the specified entity in the training text data is obtained, and a loss function value of emotion classification of the training text data is determined according to the predicted result; adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model with the adjusted weight parameters to obtain an emotion analysis model; inputting the text data to be tested into a training emotion analysis model for analysis, and determining emotion types corresponding to the text data to be tested. By the implementation mode, emotion types of different entities can be automatically identified, and accuracy of identifying emotion types of the entities is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a text emotion analysis method provided by an embodiment of the invention;
FIG. 2 is a schematic block diagram of a text emotion analysis device according to an embodiment of the present invention;
fig. 3 is a schematic block diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The text emotion analysis method provided by the embodiment of the invention can be applied to a text emotion analysis device, and in some embodiments, the text emotion analysis device is arranged in a computer device. In certain embodiments, the computer device includes, but is not limited to, one or more of a smart phone, tablet, laptop, etc.
The text emotion analysis method provided by the embodiment of the invention is schematically described below with reference to fig. 1.
Referring to fig. 1, fig. 1 is a schematic flowchart of a text emotion analysis method according to an embodiment of the present invention, and as shown in fig. 1, the method may be performed by a text emotion analysis device, where the text emotion analysis device is disposed in a computer device. Specifically, the method of the embodiment of the invention comprises the following steps.
S101: acquiring training text data carrying an appointed entity, and adding emotion type labels to the training text data, wherein the emotion type labels comprise first emotion type labels and second emotion type labels, the first emotion type labels are used for indicating positive emotion types, and the second emotion type labels are used for indicating negative emotion types.
In the embodiment of the invention, the text emotion analysis device can acquire training text data carrying a specified entity and add emotion type labels to the training text data, wherein the emotion type labels comprise a first emotion type label and a second emotion type label, the first emotion type label is used for indicating a positive emotion type, and the second emotion type label is used for indicating a negative emotion type. In some embodiments, the positive emotion classification includes a neutral emotion classification.
In some embodiments, the specified entity is a specified type of entity, which may include, but is not limited to, a target object, which may be information of a person, an object, an event, etc., for example, the specified entity may be company information, which may include, but is not limited to, a company name, a company universal identification code, etc.
In one embodiment, when acquiring the training text data carrying the specified entity, the text emotion analysis device may acquire the text data to be processed carrying the specified entity from the database, or may search some text data to be processed about the existence of the specified entity from the external network, and divide the text data to be processed into the training text data and the text data to be tested according to a specified proportion. For example, when the text data to be processed is divided into training text data and text data to be tested according to a specified proportion, the training text data and the test text data can be divided into 4:1.
In one embodiment, when the emotion type label is added to the training text data, the emotion type label can be manually added to the training text data carrying the specified entity. In certain embodiments, the emotion classification tags include, but are not limited to, one or more of numbers, letters, words, etc. In one example, the emotion classification label for the second emotion classification may be labeled 0 and the emotion classification label for the first emotion classification may be labeled 1.
S102: inputting the training text data into a preset bert model to obtain a prediction result of emotion categories corresponding to the appointed entity in the training text data, and determining a loss function value of the emotion categories of the training text data according to the prediction result.
In the embodiment of the invention, the text emotion analysis device can input the training text data into a preset bert model to obtain the prediction result of the emotion type corresponding to the appointed entity in the training text data, and determine the loss function value of the emotion classification of the training text data according to the prediction result.
In one embodiment, before inputting the training text data into a preset bert model to obtain a prediction result of emotion type corresponding to a specified entity in the training text data, the text emotion analysis device may classify the training text data after adding emotion type labels into three types of data, where the three types of data include training text data carrying the specified entity, entity data and label data; and inputting the training text data carrying the appointed entity, the entity data and the tag data into a preset bert model to obtain a prediction result of the emotion type corresponding to the appointed entity in the training text data. In some embodiments, the entity data is used to indicate the specified entity, where the entity data may include, but is not limited to, an entity name, and the like.
In one embodiment, when inputting the training text data, entity data and tag data carrying the specified entity into a preset bert model to obtain a prediction result of an emotion type corresponding to the specified entity in the training text data, the text emotion analysis device may input the training text data, entity data and tag data carrying the specified entity in the training text data into the bert model to obtain a word vector of the emotion type corresponding to the specified entity in the training text data; and determining a prediction result of the emotion category corresponding to the appointed entity in the training text data according to the word vector.
In one embodiment, the text emotion analysis device may acquire a weighted word vector of the training text data from the specified entity in the training text data when determining a loss function value of emotion classification of the training text data according to the prediction result; and determining a loss function value of emotion classification of the training text data according to the weight word vector and the word vector of the emotion classification corresponding to the appointed entity in the training text data obtained by the bert model.
In one embodiment, the text emotion analysis device may acquire a position index of the specified entity in the training text data when acquiring the weight word vector of the training text data from the specified entity in the training text data; calculating indexes of related words associated with the appointed entity in the training text data according to the position indexes of the appointed entity in the training text data; and determining a weight word vector corresponding to the appointed entity in the training text data according to the position index of the appointed entity and the index of the related word.
For example, assume that an entity a company stock swell and an entity B company stock swell and stock swell are near and far, respectively, relative to the entity a company, while the corresponding weights are also large and small, respectively. If w1 and w2 respectively represent weights of stock swell and stock swell, and c1 and c2 respectively represent word vectors of stock swell of entity A company and stock swell of entity B company, the word vector of stock swell of entity A company becomes weight word vector w1 x c1, and the word vector of stock swell of entity B company becomes weight word vector w2 x c2.
In one embodiment, when determining a loss function value of emotion classification of the training text data according to the weighted word vector and the word vector of emotion type corresponding to the appointed entity in the training text data obtained by the bert model, the text emotion analysis device may perform concatenation processing on the weighted word vector and the word vector of emotion type corresponding to the appointed entity in the training text data obtained by the bert model to obtain a target word vector; and determining a loss function value of the emotion classification of the training text data according to the target word vector, wherein the loss function value comprises a first loss function value of a positive emotion type and a second loss function value of a negative emotion type.
For example, when the weighted word vector and the word vector of the emotion category corresponding to the specified entity in the training text data obtained by the bert model are subjected to stitching processing to obtain a target word vector, the weighted word vector of the entity a company is assumed to be: [0.1,0.2,0.3 … 0.9.9 ], the word vector of the emotion category corresponding to the entity A company in the training text data obtained by the entity A company through the bert model is as follows: [1.1,1.2,1.3 … 1.9], and [0.1,0.2,0.3 … 0.9] and [1.1,1.2,1.3 … 1.9] are subjected to splicing treatment to obtain a target word vector: [0.1,0.2,0.3 … 1.8,1.9].
S103: and adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model after the weight parameters are adjusted to obtain an emotion analysis model.
According to the embodiment of the invention, the text emotion analysis device can adjust the weight parameters of the bert model according to the loss function value, and retrain the bert model with the adjusted weight parameters to obtain the emotion analysis model.
In one embodiment, the text emotion analysis device may adjust the weight parameter of the bert model according to the first loss function value of the positive emotion type and the second loss function value of the negative emotion type, and retrain the bert model after adjusting the weight parameter to obtain an emotion analysis model.
S104: inputting the text data to be tested into a training emotion analysis model for analysis, and determining emotion types corresponding to the text data to be tested.
According to the embodiment of the invention, the text emotion analysis device can input the text data to be tested into the emotion analysis model obtained through training for analysis, and the emotion type corresponding to the text data to be tested is determined.
In one embodiment, when the text emotion analysis device inputs text data to be tested into an emotion analysis model obtained through training to analyze, and determines an emotion type corresponding to the text data to be tested, the text data to be tested can be input into the emotion analysis model obtained through training to analyze, and the probability of the emotion type corresponding to the text data to be tested is determined; and determining the emotion type with the highest probability as the emotion type corresponding to the text data to be tested according to the probability of the emotion type corresponding to the text data to be tested.
In the embodiment of the invention, a text emotion analysis device can acquire training text data carrying a specified entity, add emotion type labels to the training text data, input the training text data into a preset bert model to obtain a prediction result of emotion types corresponding to the specified entity in the training text data, and determine loss function values of emotion classifications of the training text data according to the prediction result; adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model with the adjusted weight parameters to obtain an emotion analysis model; inputting the text data to be tested into a training emotion analysis model for analysis, and determining emotion types corresponding to the text data to be tested. By the implementation mode, emotion types of different entities can be automatically identified, and accuracy of identifying emotion types of the entities is improved.
The embodiment of the invention also provides a text emotion analysis device which is used for executing the unit of the method. Specifically, referring to fig. 2, fig. 2 is a schematic block diagram of a text emotion analysis device according to an embodiment of the present invention. The text emotion analysis device of the present embodiment includes: an acquisition unit 201, a determination unit 202, a training unit 203, and a test unit 204.
An obtaining unit 201, configured to obtain training text data carrying a specified entity, and add an emotion type tag to the training text data, where the emotion type tag includes a first emotion type tag and a second emotion type tag, the first emotion type tag is used to indicate a positive emotion type, and the second emotion type tag is used to indicate a negative emotion type;
a determining unit 202, configured to input the training text data into a preset bert model, obtain a prediction result of an emotion category corresponding to a specified entity in the training text data, and determine a loss function value of the emotion classification of the training text data according to the prediction result;
the training unit 203 is configured to adjust a weight parameter of the bert model according to the loss function value, and retrain the bert model after the weight parameter is adjusted to obtain an emotion analysis model;
the testing unit 204 is configured to input text data to be tested into a trained emotion analysis model for analysis, and determine an emotion type corresponding to the text data to be tested.
Further, before inputting the training text data into a preset bert model to obtain a prediction result of the emotion category corresponding to the specified entity in the training text data, the determining unit 202 is further configured to:
Classifying the training text data added with emotion type labels, and dividing the training text data into three types of data, wherein the three types of data comprise training text data carrying a specified entity, entity data and label data;
the determining unit 202 inputs the training text data into a preset bert model, and is specifically configured to:
and inputting the training text data carrying the appointed entity, the entity data and the tag data into a preset bert model to obtain a prediction result of the emotion type corresponding to the appointed entity in the training text data.
Further, when the determining unit 202 inputs the training text data, the entity data and the tag data carrying the specified entity into a preset bert model to obtain a prediction result of the emotion type corresponding to the specified entity in the training text data, the determining unit is specifically configured to:
inputting training text data, entity data and tag data carrying a specified entity in the training text data into the bert model to obtain word vectors of emotion categories corresponding to the specified entity in the training text data;
And determining a prediction result of the emotion category corresponding to the appointed entity in the training text data according to the word vector.
Further, when the determining unit 202 determines the loss function value of the emotion classification of the training text data according to the prediction result, the determining unit is specifically configured to:
acquiring weight word vectors of the training text data from the appointed entity in the training text data;
and determining a loss function value of emotion classification of the training text data according to the weight word vector and the word vector of the emotion classification corresponding to the appointed entity in the training text data obtained by the bert model.
Further, when the determining unit 202 obtains the weight word vector of the training text data from the specified entity in the training text data, the determining unit is specifically configured to:
acquiring a position index of the appointed entity in the training text data;
calculating indexes of related words associated with the specified entity in the training text data according to the position indexes of the specified entity in the training text data;
and determining a weight word vector corresponding to the appointed entity in the training text data according to the position index of the appointed entity and the index of the related word.
Further, the determining unit 202 is specifically configured to, when determining the loss function value of the emotion classification of the training text data according to the weighted word vector and the word vector of the emotion classification corresponding to the specified entity in the training text data obtained by the bert model:
performing splicing processing on the weight word vector and the word vector of the emotion category corresponding to the appointed entity in the training text data obtained by the bert model to obtain a target word vector;
and determining a loss function value of the emotion classification of the training text data according to the target word vector, wherein the loss function value comprises a first loss function value of a positive emotion type and a second loss function value of a negative emotion type.
Further, the test unit 204 inputs the text data to be tested into the emotion analysis model obtained by training for analysis, and is specifically configured to:
inputting the text data to be tested into a training emotion analysis model for analysis, and determining the probability of emotion types corresponding to the text data to be tested;
and determining the emotion type with the highest probability as the emotion type corresponding to the text data to be tested according to the probability of the emotion type corresponding to the text data to be tested.
In the embodiment of the invention, a text emotion analysis device can acquire training text data carrying a specified entity, add emotion type labels to the training text data, input the training text data into a preset bert model to obtain a prediction result of emotion types corresponding to the specified entity in the training text data, and determine loss function values of emotion classifications of the training text data according to the prediction result; adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model with the adjusted weight parameters to obtain an emotion analysis model; inputting the text data to be tested into a training emotion analysis model for analysis, and determining emotion types corresponding to the text data to be tested. By the implementation mode, emotion types of different entities can be automatically identified, and accuracy of identifying emotion types of the entities is improved.
Referring to fig. 3, fig. 3 is a schematic block diagram of a computer device according to an embodiment of the present invention. The apparatus in this embodiment as shown in the figure may include: one or more processors 301; one or more input devices 302, one or more output devices 303, and a memory 304. The processor 301, the input device 302, the output device 303, and the memory 304 are connected via a bus 305. The memory 304 is used for storing a computer program comprising a program, and the processor 301 is used for executing the program stored in the memory 304. Wherein the processor 301 is configured to invoke the program execution:
Acquiring training text data carrying a designated entity, and adding emotion type labels to the training text data, wherein the emotion type labels comprise first emotion type labels and second emotion type labels, the first emotion type labels are used for indicating positive emotion types, and the second emotion type labels are used for indicating negative emotion types;
inputting the training text data into a preset bert model to obtain a prediction result of emotion categories corresponding to appointed entities in the training text data, and determining loss function values of the emotion categories of the training text data according to the prediction result;
adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model with the adjusted weight parameters to obtain an emotion analysis model;
inputting the text data to be tested into a training emotion analysis model for analysis, and determining emotion types corresponding to the text data to be tested.
Further, when the processor 301 inputs the training text data, the entity data and the tag data carrying the specified entity into a preset bert model to obtain a prediction result of the emotion type corresponding to the specified entity in the training text data, the method is specifically used for:
Inputting training text data, entity data and tag data carrying a specified entity in the training text data into the bert model to obtain word vectors of emotion categories corresponding to the specified entity in the training text data;
and determining a prediction result of the emotion category corresponding to the appointed entity in the training text data according to the word vector.
Further, when the processor 301 determines the loss function value of emotion classification of the training text data according to the prediction result, the processor is specifically configured to:
acquiring weight word vectors of the training text data from the appointed entity in the training text data;
and determining a loss function value of emotion classification of the training text data according to the weight word vector and the word vector of the emotion classification corresponding to the appointed entity in the training text data obtained by the bert model.
Further, when the processor 301 obtains the weight word vector of the training text data from the specified entity in the training text data, the method is specifically used for:
acquiring a position index of the appointed entity in the training text data;
calculating indexes of related words associated with the specified entity in the training text data according to the position indexes of the specified entity in the training text data;
And determining a weight word vector corresponding to the appointed entity in the training text data according to the position index of the appointed entity and the index of the related word.
Further, when the processor 301 determines the loss function value of the emotion classification of the training text data according to the weight word vector and the word vector of the emotion classification corresponding to the specified entity in the training text data obtained by the bert model, the processor is specifically configured to:
performing splicing processing on the weight word vector and the word vector of the emotion category corresponding to the appointed entity in the training text data obtained by the bert model to obtain a target word vector;
and determining a loss function value of the emotion classification of the training text data according to the target word vector, wherein the loss function value comprises a first loss function value of a positive emotion type and a second loss function value of a negative emotion type.
Further, the processor 301 inputs the text data to be tested into the emotion analysis model obtained by training for analysis, and is specifically configured to:
inputting the text data to be tested into a training emotion analysis model for analysis, and determining the probability of emotion types corresponding to the text data to be tested;
And determining the emotion type with the highest probability as the emotion type corresponding to the text data to be tested according to the probability of the emotion type corresponding to the text data to be tested.
In the embodiment of the invention, the computer equipment can acquire training text data carrying a specified entity, add emotion type labels to the training text data, input the training text data into a preset bert model to obtain a prediction result of emotion types corresponding to the specified entity in the training text data, and determine loss function values of the emotion classifications of the training text data according to the prediction result; adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model with the adjusted weight parameters to obtain an emotion analysis model; inputting the text data to be tested into a training emotion analysis model for analysis, and determining emotion types corresponding to the text data to be tested. By the implementation mode, emotion types of different entities can be automatically identified, and accuracy of identifying emotion types of the entities is improved.
It should be appreciated that in embodiments of the present invention, the processor 301 may be a central processing unit (CenSral Processing UniS, CPU), which may also be other general purpose processors, digital signal processors (DigiSal Signal Processor, DSPs), application Specific Integrated Circuits (ASICs), off-the-shelf programmable gate arrays (Field-Programmable GaSe Array, FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The input device 302 may include a touch pad, a microphone, etc., and the output device 303 may include a display (LCD, etc.), a speaker, etc.
The memory 304 may include read only memory and random access memory and provides instructions and data to the processor 301. A portion of memory 304 may also include non-volatile random access memory. For example, the memory 304 may also store information of device type.
In a specific implementation, the processor 301, the input device 302, and the output device 303 described in the embodiments of the present invention may execute the implementation described in the embodiment of the method described in fig. 1 provided in the embodiments of the present invention, and may also execute the implementation of the text emotion analysis device described in fig. 2 in the embodiments of the present invention, which is not described herein again.
The embodiment of the invention also provides a computer readable storage medium, and the computer readable storage medium stores a computer program, which when executed by a processor, implements the text emotion analysis method described in the embodiment corresponding to fig. 1, and also implements the text emotion analysis device in the embodiment corresponding to fig. 2, which is not described herein.
The computer readable storage medium may be an internal storage unit of the text emotion analysis device according to any of the foregoing embodiments, for example, a hard disk or a memory of the text emotion analysis device. The computer readable storage medium may be an external storage device of the text emotion analysis device, for example, a plug-in hard disk, a smart Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like provided in the text emotion analysis device. Further, the computer-readable storage medium may further include both an internal storage unit and an external storage device of the text emotion analysis device. The computer readable storage medium is used for storing the computer program and other programs and data required by the text emotion analysis device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a computer-readable storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a terminal, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned computer-readable storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes. The computer readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created from the use of blockchain nodes, and the like.
It is emphasized that to further guarantee the privacy and security of the data, the data may also be stored in a blockchain node. The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The Blockchain (Blockchain), which is essentially a decentralised database, is a string of data blocks that are generated by cryptographic means in association, each data block containing a batch of information of network transactions for verifying the validity of the information (anti-counterfeiting) and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, an application services layer, and the like.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention.

Claims (5)

1. A method of text emotion analysis, said method comprising:
acquiring training text data carrying a designated entity, and adding emotion type labels to the training text data, wherein the emotion type labels comprise first emotion type labels and second emotion type labels, the first emotion type labels are used for indicating positive emotion types, and the second emotion type labels are used for indicating negative emotion types;
Inputting the training text data into a preset bert model to obtain a prediction result of emotion categories corresponding to appointed entities in the training text data, and determining loss function values of the emotion categories of the training text data according to the prediction result;
adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model with the adjusted weight parameters to obtain an emotion analysis model;
inputting text data to be tested into a training emotion analysis model for analysis, and determining emotion types corresponding to the text data to be tested;
before inputting the training text data into a preset bert model to obtain a predicted result of the emotion type corresponding to the appointed entity in the training text data, the method further comprises the following steps:
classifying the training text data added with emotion type labels, and dividing the training text data into three types of data, wherein the three types of data comprise training text data carrying a specified entity, entity data and label data;
inputting the training text data into a preset bert model to obtain a prediction result of emotion categories corresponding to specified entities in the training text data, wherein the method comprises the following steps:
Inputting the training text data carrying the appointed entity, the entity data and the tag data into a preset bert model to obtain a prediction result of the emotion type corresponding to the appointed entity in the training text data;
inputting the training text data carrying the appointed entity, the entity data and the tag data into a preset bert model to obtain a prediction result of the emotion type corresponding to the appointed entity in the training text data, wherein the method comprises the following steps:
inputting training text data, entity data and tag data carrying a specified entity in the training text data into the bert model to obtain word vectors of emotion categories corresponding to the specified entity in the training text data;
determining a prediction result of the emotion type corresponding to the appointed entity in the training text data according to the word vector;
the step of determining the loss function value of the emotion classification of the training text data according to the prediction result comprises the following steps:
acquiring weight word vectors of the training text data from the appointed entity in the training text data;
determining a loss function value of emotion classification of the training text data according to the weight word vector and the word vector of the emotion classification corresponding to the appointed entity in the training text data obtained by the bert model;
The obtaining the weight word vector of the training text data from the appointed entity in the training text data comprises the following steps:
acquiring a position index of the appointed entity in the training text data;
calculating indexes of related words associated with the specified entity in the training text data according to the position indexes of the specified entity in the training text data;
determining a weight word vector corresponding to the appointed entity in the training text data according to the position index of the appointed entity and the index of the related word;
the determining the loss function value of the emotion classification of the training text data according to the weight word vector and the word vector of the emotion classification corresponding to the appointed entity in the training text data obtained by the bert model comprises the following steps:
performing splicing processing on the weight word vector and the word vector of the emotion category corresponding to the appointed entity in the training text data obtained by the bert model to obtain a target word vector;
and determining a loss function value of the emotion classification of the training text data according to the target word vector, wherein the loss function value comprises a first loss function value of a positive emotion type and a second loss function value of a negative emotion type.
2. The method according to claim 1, wherein the inputting the text data to be tested into the trained emotion analysis model for analysis, determining the emotion type corresponding to the text data to be tested, includes:
inputting the text data to be tested into a training emotion analysis model for analysis, and determining the probability of emotion types corresponding to the text data to be tested;
and determining the emotion type with the highest probability as the emotion type corresponding to the text data to be tested according to the probability of the emotion type corresponding to the text data to be tested.
3. A text emotion analyzing device, comprising:
the system comprises an acquisition unit, a judgment unit and a judgment unit, wherein the acquisition unit is used for acquiring training text data carrying a specified entity and adding emotion type labels to the training text data, the emotion type labels comprise a first emotion type label and a second emotion type label, the first emotion type label is used for indicating a positive emotion type, and the second emotion type label is used for indicating a negative emotion type;
the determining unit is used for inputting the training text data into a preset bert model, obtaining a prediction result of the emotion type corresponding to the appointed entity in the training text data, and determining a loss function value of the emotion classification of the training text data according to the prediction result;
The training unit is used for adjusting the weight parameters of the bert model according to the loss function values, and retraining the bert model with the adjusted weight parameters to obtain an emotion analysis model;
the test unit is used for inputting the text data to be tested into a trained emotion analysis model for analysis, and determining emotion types corresponding to the text data to be tested;
the determining unit inputs the training text data into a preset bert model, and is further used for:
classifying the training text data added with emotion type labels, and dividing the training text data into three types of data, wherein the three types of data comprise training text data carrying a specified entity, entity data and label data;
the determining unit inputs the training text data into a preset bert model, and is specifically used for obtaining a prediction result of the emotion type corresponding to the appointed entity in the training text data:
inputting the training text data carrying the appointed entity, the entity data and the tag data into a preset bert model to obtain a prediction result of the emotion type corresponding to the appointed entity in the training text data;
The determining unit inputs the training text data carrying the specified entity, the entity data and the tag data into a preset bert model, and is specifically used for when obtaining a prediction result of the emotion type corresponding to the specified entity in the training text data:
inputting training text data, entity data and tag data carrying a specified entity in the training text data into the bert model to obtain word vectors of emotion categories corresponding to the specified entity in the training text data;
determining a prediction result of the emotion type corresponding to the appointed entity in the training text data according to the word vector;
the determining unit is specifically configured to, when determining the loss function value of emotion classification of the training text data according to the prediction result:
acquiring weight word vectors of the training text data from the appointed entity in the training text data;
determining a loss function value of emotion classification of the training text data according to the weight word vector and the word vector of the emotion classification corresponding to the appointed entity in the training text data obtained by the bert model;
the determining unit is specifically configured to, when acquiring the weight word vector of the training text data from the specified entity in the training text data:
Acquiring a position index of the appointed entity in the training text data;
calculating indexes of related words associated with the specified entity in the training text data according to the position indexes of the specified entity in the training text data;
determining a weight word vector corresponding to the appointed entity in the training text data according to the position index of the appointed entity and the index of the related word;
the determining unit is specifically configured to, when determining the loss function value of emotion classification of the training text data according to the weight word vector and the word vector of the emotion classification corresponding to the specified entity in the training text data obtained by the bert model:
performing splicing processing on the weight word vector and the word vector of the emotion category corresponding to the appointed entity in the training text data obtained by the bert model to obtain a target word vector;
and determining a loss function value of the emotion classification of the training text data according to the target word vector, wherein the loss function value comprises a first loss function value of a positive emotion type and a second loss function value of a negative emotion type.
4. A computer device comprising a processor, an input device, an output device and a memory, the processor, the input device, the output device and the memory being interconnected, wherein the memory is adapted to store a computer program, the computer program comprising a program, the processor being configured to invoke the program to perform the method of any of claims 1-2.
5. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program, which is executed by a processor to implement the method of any of claims 1-2.
CN202110084691.8A 2021-01-21 2021-01-21 Text emotion analysis method, device, equipment and storage medium Active CN112860841B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110084691.8A CN112860841B (en) 2021-01-21 2021-01-21 Text emotion analysis method, device, equipment and storage medium
PCT/CN2021/083804 WO2022156065A1 (en) 2021-01-21 2021-03-30 Text sentiment analysis method and apparatus, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110084691.8A CN112860841B (en) 2021-01-21 2021-01-21 Text emotion analysis method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112860841A CN112860841A (en) 2021-05-28
CN112860841B true CN112860841B (en) 2023-10-24

Family

ID=76009053

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110084691.8A Active CN112860841B (en) 2021-01-21 2021-01-21 Text emotion analysis method, device, equipment and storage medium

Country Status (2)

Country Link
CN (1) CN112860841B (en)
WO (1) WO2022156065A1 (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113420122A (en) * 2021-06-24 2021-09-21 平安科技(深圳)有限公司 Method, device and equipment for analyzing text and storage medium
CN113723083B (en) * 2021-07-15 2023-05-26 东华理工大学 BERT model-based weighted passive supervision text emotion analysis method
CN113609390A (en) * 2021-08-06 2021-11-05 北京金堤征信服务有限公司 Information analysis method and device, electronic equipment and computer readable storage medium
CN113722441B (en) * 2021-08-31 2023-09-05 平安银行股份有限公司 Similar text generation method, device, equipment and storage medium
CN113704452B (en) * 2021-08-31 2023-08-25 平安银行股份有限公司 Data recommendation method, device, equipment and medium based on Bert model
CN114386436B (en) * 2022-01-21 2023-07-18 平安科技(深圳)有限公司 Text data analysis method, model training method, device and computer equipment
CN116244440B (en) * 2023-02-28 2024-02-13 深圳市云积分科技有限公司 Text emotion classification method, device, equipment and medium
CN115878808A (en) * 2023-03-03 2023-03-31 有米科技股份有限公司 Training method and device for hierarchical label classification model

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110516245A (en) * 2019-08-27 2019-11-29 蓝盾信息安全技术股份有限公司 Fine granularity sentiment analysis method, apparatus, computer equipment and storage medium
CN110704622A (en) * 2019-09-27 2020-01-17 北京明略软件系统有限公司 Text emotion classification method and device and electronic equipment
CN111950273A (en) * 2020-07-31 2020-11-17 南京莱斯网信技术研究院有限公司 Network public opinion emergency automatic identification method based on emotion information extraction analysis

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11580350B2 (en) * 2016-12-21 2023-02-14 Microsoft Technology Licensing, Llc Systems and methods for an emotionally intelligent chat bot
US10896385B2 (en) * 2017-07-27 2021-01-19 Logmein, Inc. Real time learning of text classification models for fast and efficient labeling of training data and customization
CN110442857A (en) * 2019-06-18 2019-11-12 平安科技(深圳)有限公司 Emotion intelligent determination method, device and computer readable storage medium
CN111444709B (en) * 2020-03-09 2022-08-12 腾讯科技(深圳)有限公司 Text classification method, device, storage medium and equipment
CN111695033B (en) * 2020-04-29 2023-06-27 平安科技(深圳)有限公司 Enterprise public opinion analysis method, enterprise public opinion analysis device, electronic equipment and medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110516245A (en) * 2019-08-27 2019-11-29 蓝盾信息安全技术股份有限公司 Fine granularity sentiment analysis method, apparatus, computer equipment and storage medium
CN110704622A (en) * 2019-09-27 2020-01-17 北京明略软件系统有限公司 Text emotion classification method and device and electronic equipment
CN111950273A (en) * 2020-07-31 2020-11-17 南京莱斯网信技术研究院有限公司 Network public opinion emergency automatic identification method based on emotion information extraction analysis

Also Published As

Publication number Publication date
WO2022156065A1 (en) 2022-07-28
CN112860841A (en) 2021-05-28

Similar Documents

Publication Publication Date Title
CN112860841B (en) Text emotion analysis method, device, equipment and storage medium
CN110163478B (en) Risk examination method and device for contract clauses
CN110276066B (en) Entity association relation analysis method and related device
CN111324739B (en) Text emotion analysis method and system
CN112686022A (en) Method and device for detecting illegal corpus, computer equipment and storage medium
CN109360089A (en) Credit risk prediction technique and device
CN110377733A (en) A kind of text based Emotion identification method, terminal device and medium
CN116150367A (en) Emotion analysis method and system based on aspects
CN108846292A (en) Desensitization process method and device
CN113590945B (en) Book recommendation method and device based on user borrowing behavior-interest prediction
CN113705792A (en) Personalized recommendation method, device, equipment and medium based on deep learning model
CN113704452B (en) Data recommendation method, device, equipment and medium based on Bert model
CN111639903A (en) Review processing method for architecture change and related equipment
CN112732910B (en) Cross-task text emotion state evaluation method, system, device and medium
CN115080864A (en) Artificial intelligence based product recommendation method and device, computer equipment and medium
CN115470790A (en) Method and device for identifying named entities in file
CN114493853A (en) Credit rating evaluation method, credit rating evaluation device, electronic device and storage medium
CN113837836A (en) Model recommendation method, device, equipment and storage medium
CN113836297A (en) Training method and device for text emotion analysis model
CN112307757A (en) Emotion analysis method, device and equipment based on auxiliary task and storage medium
CN114153939A (en) Text recognition method and device
CN111950265A (en) Domain lexicon construction method and device
CN111831818A (en) Text information identification method, text information identification device and storage medium
Sindhu et al. Aspect based opinion mining leveraging weighted bigru and CNN module in parallel
CN115204120B (en) Insurance field triplet extraction method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant