CN116257623A - Text emotion classification model training method, text emotion classification method and equipment - Google Patents

Text emotion classification model training method, text emotion classification method and equipment Download PDF

Info

Publication number
CN116257623A
CN116257623A CN202211091826.4A CN202211091826A CN116257623A CN 116257623 A CN116257623 A CN 116257623A CN 202211091826 A CN202211091826 A CN 202211091826A CN 116257623 A CN116257623 A CN 116257623A
Authority
CN
China
Prior art keywords
emotion
text
sample
entity
determining
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.)
Granted
Application number
CN202211091826.4A
Other languages
Chinese (zh)
Other versions
CN116257623B (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.)
China Bond Jinke Information Technology Co ltd
Original Assignee
China Bond Jinke Information Technology 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 China Bond Jinke Information Technology Co ltd filed Critical China Bond Jinke Information Technology Co ltd
Priority to CN202211091826.4A priority Critical patent/CN116257623B/en
Publication of CN116257623A publication Critical patent/CN116257623A/en
Application granted granted Critical
Publication of CN116257623B publication Critical patent/CN116257623B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/35Clustering; Classification
    • G06F16/355Class or cluster creation or modification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/237Lexical tools
    • G06F40/242Dictionaries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a text emotion classification model training method, a text emotion classification method and a text emotion classification device, which are applied to the technical fields of natural language processing and artificial intelligence, wherein the method comprises the following steps: respectively performing word segmentation on a plurality of text samples, and determining an entity feature vector sequence and an emotion feature vector sequence of the text samples based on word segmentation results corresponding to the text samples; determining entity characterization corresponding to the text sample based on the entity feature vector sequence; determining emotion characterization corresponding to the text sample based on the emotion feature vector sequence, the emotion dictionary in the general field and the emotion dictionary in the specific field; determining emotion classification prediction results corresponding to all entities in a text sample based on entity characterization and emotion characterization corresponding to the sample text; based on the emotion classification prediction result, adjusting model parameters of the initial text emotion classification model to obtain the text emotion classification model. The method can improve the applicability of the text emotion classification model and the accuracy of emotion classification results.

Description

Text emotion classification model training method, text emotion classification method and equipment
Technical Field
The invention relates to the technical field of natural language processing and artificial intelligence, in particular to a text emotion classification model training method, a text emotion classification method and equipment.
Background
Emotion analysis, also known as opinion mining, is used to determine the emotional tendency of a text corpus. Determining emotional tendencies has significant utility in a variety of fields, for example, in the financial field, the results of emotional analysis may reflect stock market fluctuations, reveal cash flows of businesses, and measure credit risk, among others.
At present, a text emotion classification model is usually obtained by model training of some documents or sentences, so that when text emotion is classified, the text emotion classification model can be trained in advance to obtain an emotion classification result of the text.
However, the text emotion classification model obtained through training in the above manner is poor in applicability, so that the accuracy of the determined emotion classification result is poor.
Disclosure of Invention
The invention provides a text emotion classification model training method, a text emotion classification method and text emotion classification equipment, which are used for solving the defect that in the prior art, the text emotion classification model is poor in applicability, so that the determined emotion classification result is poor in accuracy, improving the applicability of the text emotion classification model and improving the accuracy of the emotion classification result.
The invention provides a text emotion classification model training method, which comprises the following steps:
word segmentation processing is carried out on the plurality of text samples respectively, and word segmentation results corresponding to the text samples are obtained;
based on word segmentation results corresponding to the text samples, respectively determining an entity feature vector sequence and an emotion feature vector sequence of the text samples;
determining entity characterization corresponding to each text sample based on the entity feature vector sequence;
determining emotion characterizations corresponding to each text sample based on the emotion feature vector sequence, an emotion dictionary of a general field and an emotion dictionary of a specific field, wherein the emotion dictionary of the general field comprises a plurality of first words and emotion classifications of the first words in the general field, and the emotion dictionary of the specific field comprises a plurality of second words and emotion classifications of the second words in the specific field;
determining emotion classification prediction results corresponding to all entities in the text samples based on the entity representation and the emotion representation corresponding to all the sample texts;
and adjusting model parameters of the initial text emotion classification model based on the emotion classification prediction result to obtain the text emotion classification model.
According to the training method of the text emotion classification model provided by the invention, the emotion characterization corresponding to each text sample is determined based on the emotion feature vector sequence, the emotion dictionary of the general field and the emotion dictionary of the specific field, and the training method comprises the following steps:
determining an initial emotion feature matrix corresponding to each text sample based on the emotion dictionary of the general field and the emotion dictionary of the specific field;
performing linear transformation on the initial emotion feature matrix to obtain a transformed feature matrix;
respectively determining a first weight value corresponding to the emotion dictionary in the general field and a second weight value corresponding to the emotion dictionary in the specific field;
determining emotion characterization corresponding to each word segmentation result based on the emotion feature vector sequence, the first weight value, the second weight value and emotion features corresponding to each word segmentation result in the transformed feature matrix;
and determining emotion characterization corresponding to the text sample based on emotion characterization corresponding to each word segmentation result in the text sample.
According to the training method of the text emotion classification model provided by the invention, based on word segmentation results corresponding to the text samples, the entity feature vector sequence and emotion feature vector sequence of the text samples are respectively determined, and the training method comprises the following steps:
Determining word vector sequences of the text samples based on word segmentation results corresponding to the text samples;
inputting the word vector sequence of each text sample into a sequential deep neural network to obtain a shared feature vector corresponding to each text sample;
and respectively determining an entity feature vector sequence and an emotion feature vector sequence of each text sample based on the shared feature vector corresponding to each text sample.
According to the training method of the text emotion classification model provided by the invention, the emotion feature vector sequence in each text sample is determined based on the shared feature vector corresponding to each text sample, and the training method comprises the following steps:
acquiring a first entity representation corresponding to each text sample in the previous iteration process;
determining a first association degree of the first entity representation and an emotion analysis task;
and determining an emotion feature vector sequence in each text sample in the iterative process of the round based on the shared feature vector corresponding to each text sample and the first association degree.
According to the training method of the text emotion classification model provided by the invention, based on the shared feature vector corresponding to each text sample, the entity feature vector sequence of each text sample is determined, and the training method comprises the following steps:
Acquiring a first emotion representation corresponding to each text sample in the previous iteration process;
determining a second association degree of the first emotion characterization and an entity extraction task;
and determining an entity feature vector sequence in each text sample in the iterative process of the round based on the shared feature vector corresponding to each text sample and the second association degree.
According to the text emotion classification model training method provided by the invention, the emotion classification prediction result corresponding to each entity in each text sample is determined based on the entity representation and the emotion representation corresponding to each sample text, and the method comprises the following steps:
determining the probability that each word segmentation result in each sample text is an entity based on the entity representation corresponding to each sample text;
determining the probability of each word segmentation result in each sample text belonging to each type of emotion based on the emotion characterization corresponding to each sample text;
and determining emotion classification prediction results corresponding to the entities in the text sample based on the probability that each word segmentation result is an entity and the probability that each word segmentation result belongs to each type of emotion.
The invention also provides a text emotion classification method, which comprises the following steps:
Acquiring a text to be analyzed;
inputting the text to be analyzed into a text emotion classification model to obtain emotion classification results of all entities in the text to be analyzed; the text emotion classification model is trained based on the training method of the text emotion classification model in any mode.
The invention also provides a text emotion classification model training device, which comprises:
the processing module is used for respectively carrying out word segmentation processing on the plurality of text samples to obtain word segmentation results corresponding to the text samples;
the determining module is used for respectively determining an entity feature vector sequence and an emotion feature vector sequence of each text sample based on word segmentation results corresponding to the text samples;
the determining module is further configured to determine an entity representation corresponding to each text sample based on the entity feature vector sequence;
the determining module is further configured to determine, based on the emotion feature vector sequence, an emotion dictionary in a general field and an emotion dictionary in a specific field, emotion characterizations corresponding to each text sample, where the emotion dictionary in the general field includes a plurality of first words and emotion classifications of each first word in the general field, and the emotion dictionary in the specific field includes a plurality of second words and emotion classifications of each second word in the specific field;
The determining module is further configured to determine an emotion classification prediction result corresponding to each entity in each text sample based on the entity representation and the emotion representation corresponding to each sample text;
and the adjusting module is used for adjusting model parameters of the initial text emotion classification model based on the emotion classification prediction result to obtain the text emotion classification model.
The invention also provides a text emotion classification device, which comprises:
the acquisition module is used for acquiring the text to be analyzed;
the processing module is used for inputting the text to be analyzed into a text emotion classification model to obtain emotion classification results of all entities in the text to be analyzed; the text emotion classification model is trained according to the training method of the text emotion classification model in any mode.
The invention also provides electronic equipment, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the training method of the text emotion classification model or the text emotion classification method when executing the program.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a text emotion classification model training method or a text emotion classification method as described in any of the above.
The invention also provides a computer program product comprising a computer program which when executed by a processor implements the text emotion classification model training method or text emotion classification method as described in any of the above.
According to the text emotion classification model training method, the text emotion classification method and the text emotion classification device, characteristics of the text field are considered when the text emotion classification model is trained. Specifically, the emotion classification of each text sample is guided by adopting an emotion dictionary in the general field and an emotion dictionary in the specific field so as to obtain emotion feature vectors corresponding to each word segmentation result in each text sample. Because language knowledge of each vocabulary is integrated, the understanding capability of emotion classification or emotion polarity is enhanced, so that the applicability of a text emotion classification model can be improved, and the accuracy of a classification result is higher when the text emotion classification model is used for classifying emotion of texts in a specific field.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a text emotion classification model training method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a training process of a text emotion classification model;
FIG. 3 is a schematic diagram of a message selective delivery mechanism;
FIG. 4 is a schematic diagram of a task-oriented attention mechanism according to an embodiment of the present invention;
FIG. 5 is a schematic flow chart of emotion knowledge integration;
FIG. 6 is a schematic flow chart of a text emotion classification method according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a training device for text emotion classification models according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a text emotion classification device according to an embodiment of the present invention;
fig. 9 is a schematic entity structure diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. 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.
In practical application, the emotion tendencies or emotion classifications of all the entities in the text corpus are determined, and the method has important significance. For example, in the financial field, the result of emotion classification may reflect stock market fluctuations, reveal cash flows of enterprises, and measure credit risk, etc., for example, in "AA car month delivery amount continuously increases, BB cars drop out the first three due to chip shortage", it can be clearly seen that emotion of entity institution "AA car" is positive, while emotion for "BB car" is negative. Thus, fine-grained entity-level emotion analysis helps to better understand the relevant condition of a particular subject, thereby providing more targeted and accurate guidance for decision making. At present, when emotion classification is carried out, model training is usually carried out through some sentences or documents, and a text emotion classification model is obtained. However, some words may not have emotion polarities in general fields, but may have specific meanings or emotion polarities in specific fields, for example, in financial fields, there are a large number of terms such as "bear market", "flat warehouse" or "flat dish" and the like, and these words have specific emotion polarities in financial fields. Therefore, in the model training mode in the prior art, the characteristics of the language in the specific field are not considered, so that the applicability of the text emotion classification model obtained by training is reduced, and the accuracy of the emotion classification result of the text in the specific field is low.
In view of the above problems, the embodiment of the invention provides a training method for a text emotion classification model, which can adopt an emotion dictionary in a general field and an emotion dictionary in a specific field to determine emotion feature vectors corresponding to word segmentation results in each text sample when training the text emotion classification model. Because language knowledge of each vocabulary is integrated, the understanding capability of emotion classification or emotion polarity is enhanced, so that the applicability of a text emotion classification model can be improved, and the accuracy of a classification result is higher when the text emotion classification model is used for classifying emotion of texts in a specific field.
The text emotion classification model training method provided by the embodiment of the invention can be applied to scenes for emotion classification of texts in certain specific fields, wherein the specific fields can comprise financial fields, medical fields, education fields and the like.
The text emotion classification model training method of the present invention is described below with reference to fig. 1 to 6. The execution body of the embodiment of the invention can be any device capable of training the text emotion classification model, such as electronic equipment, such as a terminal or a server.
Fig. 1 is a schematic flow chart of a text emotion classification model training method according to an embodiment of the present invention, as shown in fig. 1, the method includes:
step 101: and respectively carrying out word segmentation processing on the plurality of text samples to obtain word segmentation results corresponding to the text samples.
In this step, the text samples may include text of a specific field and text of a general field, wherein the more the number and variety of the text samples, the higher the applicability and accuracy of the trained text emotion classification model.
After obtaining a plurality of text samples, the electronic device performs word segmentation on each text sample, so that a word segmentation result of each text sample can be obtained. For example, after the word "AA car monthly delivery amount continuously increases", it is possible to obtain "AA", "car", "month", "delivery amount", "continuously" and "increase".
Step 102: and respectively determining an entity feature vector sequence and an emotion feature vector sequence of each text sample based on word segmentation results corresponding to each text sample.
In this step, after the word segmentation result corresponding to each text sample is obtained, a word vector sequence corresponding to each text sample is determined based on the word segmentation result, so as to execute an emotion analysis task and an entity extraction task, so as to determine an entity feature vector sequence and an emotion feature vector sequence corresponding to each text sample. The entity feature vector sequence comprises entity feature vectors corresponding to each word segment, and the entity feature vectors are used for representing the features of the entities in each text sample. Similarly, the emotion feature vector sequence includes emotion feature vectors corresponding to each word, which are used for representing emotion polarities of entities in each text sample.
Step 103: and determining entity characterization corresponding to each text sample based on the entity feature vector.
In this step, a task-oriented attention mechanism may be used to drive the text emotion classification model to pay attention to text segments related to entities and their emotions in a specific domain, where the purpose of the entity attention mechanism is to find and focus on entity term information to obtain importance of different terms on entity extraction, and the emotion attention mechanism directs the text emotion classification model to pay attention to emotion terms in sample text for distinguishing emotion categories.
After the entity feature vectors corresponding to the segmentation words are determined, the attention weight can be obtained through an entity attention mechanism, and the entity characterization corresponding to each text sample can be determined through the attention weight and the entity feature vectors.
Step 104: and determining emotion characterization corresponding to each text sample based on the emotion feature vector sequence, the emotion dictionary in the general field and the emotion dictionary in the specific field.
The emotion dictionary of the general field comprises a plurality of first words and emotion classifications of the first words in the general field, and the emotion dictionary of the specific field comprises a plurality of second words and emotion classifications of the second words in the specific field.
In this step, a large number of emotion words can be covered in the emotion dictionary in the general field and the emotion dictionary in the specific field, and since emotion words are basic units for conveying emotion in a sample text, the role of emotion classification should be emphasized when generating a text representation. The emotion dictionary of the general field comprises emotion classifications of a plurality of first words in the general field, and the emotion dictionary of the specific field comprises emotion classifications of a plurality of second words in the specific field. For example, by looking up the polarities of "fraud" and "success" in the emotion dictionary, it is easier to determine that the polarity of the sentence containing "fraud" is negative and the polarity of the sentence containing "success" is positive.
For example, the first words included in the emotion dictionary of the general domain may be understood as words applicable to all domains, and emotion classification of each first word in the general domain may be understood as emotion polarities applicable to each first word in all domains. The plurality of second words included in the emotion dictionary of the specific field may be understood as words applicable to the specific field, such as "bear market", "flat warehouse" or "churn" of the financial field, etc., and the emotion classification of each second word in the specific field may be understood as emotion polarity applicable to each second word in the specific field, wherein the specific field may include, for example, the financial field, the medical field, the mechanical field, the educational field, etc.
It should be appreciated that there may be an overlap of a first word included in the above-described general-domain emotion dictionary and a second word included in the domain-specific emotion dictionary, and that the emotion classifications in the emotion dictionaries in the different domains may be the same or different. The emotion dictionary in the general field may be one or a plurality of emotion dictionaries, and similarly, the emotion dictionary in the specific field may be one or a plurality of emotion dictionaries.
After the emotion feature vector sequence is determined, emotion characterization corresponding to each text sample can be determined based on the emotion dictionary in the general field and the emotion dictionary in the specific field. According to the embodiment of the invention, wider knowledge can be covered through the emotion dictionary in the general field and the emotion dictionary in the specific field, namely the combined mixed dictionary, so that rich emotion characterization can be constructed. Therefore, guidance can be provided for emotion classification of the text, and accuracy of emotion characterization corresponding to each determined text sample is improved.
Step 105: and determining emotion classification prediction results corresponding to the entities in the text samples based on the entity characterization and emotion characterization corresponding to the text samples.
In this step, after determining the entity representation and the emotion representation corresponding to each sample text, the probability that each word segmentation result included in each sample text is an entity may be determined based on the entity representation, and the probability that each sample text belongs to each type of emotion, such as the probability that each sample text belongs to a negative emotion, the probability that each sample text belongs to a neutral emotion, and the probability that each sample text belongs to a positive emotion, may be determined based on the emotion representation. The electronic device may determine emotion classification prediction results corresponding to the entities in the text samples based on the probability that each word segmentation result is an entity and the probability that each word segmentation result belongs to each type of emotion. The emotion classification prediction result is an entity emotion label pair, for example, the emotion classification result of the entity a is negative, the emotion classification result of the entity B is positive, and the like.
Step 106: based on the emotion classification prediction result, adjusting model parameters of the initial text emotion classification model to obtain the text emotion classification model.
In this step, each sample text has labeled entity tags and tag information pairs of emotion classification result tags corresponding to each entity tag. After determining the emotion classification prediction result, the electronic device determines a loss function based on the emotion classification prediction result and a pre-labeled label information pair. Illustratively, in the training phase, the initial text emotion classification model may be trained using cross entropy Loss, where the total Loss function Loss is determined based on the following equation (1):
Loss=λL sen +(1-λ)L tar (1)
Wherein L is sen And L tar Can be determined based on the following formula (2) and formula (3), respectively:
Figure SMS_1
Figure SMS_2
wherein lambda is the hyper-parameter to be adjusted, L sen And L tar Loss functions of emotion analysis tasks and entity extraction tasks are respectively performed, loss is a total Loss function, n represents the number of word segmentation results in a text sample,
Figure SMS_3
representing word vector x i For emotion polarity->
Figure SMS_4
Probability of->
Figure SMS_5
Representing word vector x i For emotion polarity->
Figure SMS_6
Is a probability of (2).
It should be appreciated that by repeatedly performing the above steps, after performing through a plurality of iterations, when the text emotion classification model is in a converged state, the resulting model may be determined as the text emotion classification model.
According to the text emotion classification model training method provided by the embodiment of the invention, characteristics of the text field are considered when the text emotion classification model is trained. Specifically, the emotion classification of each text sample is guided by adopting an emotion dictionary in the general field and an emotion dictionary in the specific field so as to obtain emotion characteristics corresponding to each text sample. Because language knowledge of each vocabulary is integrated, the understanding capability of emotion classification or emotion polarity is enhanced, so that the applicability of a text emotion classification model can be improved, and the accuracy of a classification result is higher when the text emotion classification model is used for classifying emotion of texts in a specific field.
For example, based on the embodiment shown in fig. 1, the determining the entity feature vector sequence and the emotion feature vector sequence of each text sample based on the word segmentation result corresponding to each text sample in the step 102 may be implemented as follows:
based on word segmentation results corresponding to the text samples, determining word vector sequences of the text samples, and inputting the word vector sequences of the text samples into a sequential deep neural network to obtain shared feature vectors corresponding to the text samples; and respectively determining an entity feature vector sequence and an emotion feature vector sequence of each text sample based on the shared feature vector corresponding to each text sample.
Specifically, fig. 2 is a schematic diagram of a training process of a text emotion classification model, as shown in fig. 2, for each text sample, when the electronic device obtains a word segmentation result s= { w corresponding to the text sample 1 ,w 2 ,...,w n After } the word segmentation result s= { w 1 ,w 2 ,...,w n Inputting into a pre-training model to generate a word vector sequence X= { X 1 ,x 2 ,...,x n }, where X ε R d×n N represents the sentence length and d represents the dimension of the word vector.
Inputting the word vector sequence X into a sequential deep neural network to generate a shared feature sequence of task sharing corresponding to the text sample
Figure SMS_7
Where T ε {0,1,2,., T }, H (0) Represents the initialized value, and T represents the number of iterations. On each time step, based on the previous hidden state +.>
Figure SMS_8
And the current input vector x i To calculate hidden states
Figure SMS_9
Backward hidden state->
Figure SMS_10
By the latter hidden state +.>
Figure SMS_11
And the current input vector x i And (5) calculating to obtain the product. Current hidden state->
Figure SMS_12
Is a hidden state connection in two directions.
H is initialized based on the shared encoder to obtain an initialization vector
Figure SMS_13
Sharing feature vector H (0) The input used as the entity extraction task and emotion analysis task, i.e., the entity extraction task and emotion analysis task, can obtain the same initial representation. In the subsequent iteration process, the sequence is combined with information transmitted by the opposite task component and transmitted by the message selection transmission mechanism to update the H characteristic vector sequence of different tasks.
Wherein the entity extraction task is generally regarded as a sequence marking task, and the output of the target entity extraction task is as follows for the text sample S
Figure SMS_14
Wherein->
Figure SMS_15
Labels B, I and O represent the beginning, inside and outside of the entity word, respectively. Emotion analysis task aims at predicting emotion polarity corresponding to target entity>
Figure SMS_16
Wherein the method comprises the steps of
Figure SMS_17
Representing positive, neutral and negative emotions, respectively.
In this embodiment, after word vector sequences of each text sample are input into a sequential deep neural network to obtain shared feature vectors corresponding to each text sample, entity feature vector sequences and emotion feature vector sequences of each text sample can be respectively determined based on the shared feature vectors corresponding to each text sample.
Further, in the step of determining the emotion feature vector sequence in each text sample based on the shared feature vector corresponding to each text sample, the following manner can be implemented:
acquiring a first entity representation corresponding to each text sample in the previous iteration process; determining a first association degree of the first entity representation and the emotion analysis task; and determining the emotion feature vector sequence in each text sample in the iterative process of the round based on the shared feature vector and the first association degree corresponding to each text sample.
Specifically, in order to enable the entity extraction task and the emotion analysis task to cooperatively work, as shown in fig. 2, a message selective transmission mechanism is provided in the embodiment of the present invention, so as to aggregate task feature information in a previous iteration, and update the shared hidden vector in a current iteration by using the knowledge. In terms of message delivery, conventional methods often simply connect features from different tasks, but do not fully exploit the synergy between tasks, which can lead to meaningless feature fusion, even impeding training and reasoning of text emotion classification models. In contrast, in the embodiment of the present invention, the information flow of the task is explicitly controlled in an adaptive manner. Specifically, the soft control unit is designed to adaptively adjust messaging, maximize beneficial interactions, and suppress mismatch fusion. In a specific implementation process, the first degree of association between the first entity representation and the emotion analysis task is determined, so that the benefit degree of the first entity representation obtained in the previous iteration process on the emotion analysis task is determined through the first degree of association. Thus, based on the first degree of association, entity tokens that are beneficial to the emotion analysis task may be selected, while entity tokens that are not beneficial to the emotion analysis task may be filtered out. Specifically, the calculation can be performed by the following formula (4) and formula (5):
Figure SMS_18
G E1 =σ(Z E1 ) (5)
Wherein W is E1 And W is h1 Representing a weight matrix, Z E1 The characteristics of the message are represented and,
Figure SMS_19
a first entity representation, b, representing a word vector corresponding to each word segmentation result in the text sample in the previous iteration process h1 Represents bias, σ represents a sigmoid function. G E1 For relationship gating, the greater the g value, the more beneficial the information to the emotion analysis task, and vice versa.
Specifically, the emotion feature vector of the word vector corresponding to each word segmentation result in the text sample can be determined based on the following formula (6):
Figure SMS_20
wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure SMS_21
emotion feature vector representing word vector corresponding to ith word segmentation result in text sample in t-th iteration process, and ++>
Figure SMS_22
Representation ofShared feature vector of word vector corresponding to ith word segmentation result in t-th iteration process,/word vector corresponding to ith word segmentation result>
Figure SMS_23
Relation gate representing word vector corresponding to ith word segmentation result in text sample in t-th iteration process,/I>
Figure SMS_24
And the first entity representation of the word vector corresponding to the ith word segmentation result in the text sample in the t-1 th iteration process is represented.
The first entity representation of the word vector corresponding to all word segmentation results in the text sample forms the entity representation corresponding to the text sample
Figure SMS_25
Emotion feature vectors of word vectors corresponding to all word segmentation results in the text sample form an emotion feature vector sequence H corresponding to the text sample s(t)
In this embodiment, first, through the shared feature vector corresponding to the text sample and the first entity representation corresponding to the text sample in the previous iteration process, the emotion feature vector sequence in each text sample in the current iteration process is determined. And then, determining the emotion feature vector sequence in the subsequent iteration process by screening entity characterization beneficial to emotion classification. Based on the selective interaction mechanism of the information, the information flow between the tasks is controlled in a self-adaptive mode, so that the information of the two tasks, namely the entity extraction task and the emotion classification task, can be used in a staggered mode, and the cooperative effect between the tasks can be realized.
Further, based on the shared feature vector corresponding to each text sample, determining the entity feature vector sequence of each text sample can be achieved by the following manner:
acquiring a first emotion representation corresponding to each text sample in the previous iteration process; determining a second association degree of the first emotion characterization and the entity extraction task; and determining the entity feature vector sequence in each text sample in the iterative process of the round based on the shared feature vector and the second association degree corresponding to each text sample.
Specifically, fig. 3 is a schematic diagram of a message selective delivery mechanism, as shown in fig. 2 and 3, in which a soft control unit is designed to adaptively regulate message delivery, maximize beneficial interactions, and suppress mismatch fusion. In a specific implementation process, the second association degree of the first emotion characterization and the entity extraction task is determined, so that the benefit degree of the first emotion characterization obtained in the previous iteration process on the entity extraction task is determined through the second association degree. Thus, emotion characterizations that are beneficial to the entity extraction task may be selected based on the second degree of association, while emotion characterizations that are not beneficial to the entity extraction task may be filtered out. Specifically, the calculation can be performed by the following formula (7) and formula (8):
Figure SMS_26
G E2 =σ(Z E2 ) (8)
Wherein W is E2 And W is h2 Representing a weight matrix, Z E2 The characteristics of the message are represented and,
Figure SMS_27
b, representing a first emotion representation of a word vector corresponding to each word segmentation result in a text sample in the previous iteration process h2 Represents bias, σ represents a sigmoid function. G E2 For relationship gating, the greater the g value, the more beneficial the information for the emotion classification task, and vice versa.
Specifically, the entity feature vector of the word vector corresponding to each word segmentation result in the text sample may be determined based on the following formula (9):
Figure SMS_28
wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure SMS_29
entity feature vector representing word vector corresponding to ith word segmentation result in text sample in t-th iteration process, ++>
Figure SMS_30
Shared feature vector representing word vector corresponding to ith word segmentation result in t-th iteration process,/>
Figure SMS_31
Relation gate representing word vector corresponding to ith word segmentation result in text sample in t-th iteration process,/I>
Figure SMS_32
And the first emotion characterization of the word vector corresponding to the ith word segmentation result in the text sample in the t-1 th iteration process is represented.
The first emotion representation of the word vector corresponding to all word segmentation results in the text sample forms emotion representation corresponding to the text sample
Figure SMS_33
The entity feature vectors of the word vectors corresponding to all word segmentation results in the text sample form an entity feature vector sequence H corresponding to the text sample e(t)
In this embodiment, first, through the shared feature vector corresponding to the text sample and the first emotion characterization corresponding to the text sample in the previous iteration process, the entity feature vector sequence in each text sample in the current iteration process is determined. And then, extracting beneficial emotion characterization for the entity by screening to determine an entity feature vector sequence in a subsequent iteration process. Based on the selective interaction mechanism of the information, the information flow between the tasks is controlled in a self-adaptive mode, so that the information of the two tasks, namely the entity extraction task and the emotion classification task, can be used in a staggered mode, and the cooperative effect between the tasks can be realized.
Fig. 4 is a schematic diagram of a task-oriented attention mechanism provided by an embodiment of the present invention, and as shown in fig. 4, when determining entity representations corresponding to each text sample based on an entity feature vector sequence, the embodiment of the present invention proposes a task-oriented attention mechanism to drive a text emotion classification model to pay attention to text segments related to entities and emotion in a specific domain. The purpose of the entity's attention mechanism isEntity term information is searched and focused to acquire importance of different words to entity extraction, and the emotion attention mechanism guides the text emotion classification model to pay attention to emotion words for distinguishing emotion categories in sentences. In the word vector sequence x= { X 1 ,x 2 ,...,x n Input to a sequential deep neural network to generate a shared feature sequence of task sharing corresponding to the text sample
Figure SMS_34
Based on the shared feature sequence, obtaining the entity feature vector of the ith word segmentation result through entity representation>
Figure SMS_35
The entity feature vectors of all word segmentation results in the sample text form an entity feature vector sequence H e(t) After the physical attention mechanism, the attention weight is counted as +.>
Figure SMS_36
By->
Figure SMS_37
Update word hiding state obtaining
Figure SMS_38
For example, based on the foregoing embodiments, the determining, in step 104, the emotion representation corresponding to each text sample based on the emotion feature vector sequence, the emotion dictionary in the general field, and the emotion dictionary in the specific field may be implemented in the following manner:
determining an initial emotion feature matrix corresponding to each text sample based on the emotion dictionary of the general field and the emotion dictionary of the specific field; performing linear transformation on the initial emotion feature matrix to obtain a transformed feature matrix; respectively determining a first weight value corresponding to the emotion dictionary in the general field and a second weight value corresponding to the emotion dictionary in the specific field; determining emotion characterization corresponding to each word segmentation result based on the emotion feature vector sequence, the first weight value and the second weight value and the emotion features corresponding to each word segmentation result in the transformed feature matrix; and determining emotion characterization corresponding to the text sample based on emotion characterization corresponding to each word segmentation result in the text sample.
In particular, a high quality emotion dictionary can cover a large number of emotion words, which are the basic units in the text that convey emotion, and should be emphasized in generating a text representation of emotion classification. Therefore, emotion-related clues can be used as criteria for supervising the generation of attention weights, and in the embodiment of the invention, an emotion dictionary enhanced emotion attention mechanism is provided.
Fig. 5 is a schematic flow chart of emotion knowledge integration, and as shown in fig. 2, fig. 4 and fig. 5, emotion category labels of emotion words in an emotion dictionary in a general field and an emotion dictionary in a specific field can be converted into discrete values. In order to ensure the integrity and relativity of emotion expression, the invention not only introduces an emotion dictionary in the general field, but also needs to use the emotion dictionary in the specific field to form a mixed dictionary, and the mixed dictionary can cover wider knowledge, thereby integrating the language knowledge of each vocabulary and enhancing the understanding capability of emotion classification or emotion polarity. Thus, for each sample text, determining the dictionary vector U corresponding to each word segmentation result in the sample text by querying the emotion dictionary of the general domain and the emotion dictionary of the specific domain L And vector U of dictionary L As an initial emotion feature matrix. Wherein, if there is word segmentation result of the emotion dictionary beyond the general field and the emotion dictionary in the specific field, zero vector filling can be adopted to obtain a dictionary vector U L Illustratively, the word segmentation result includes a word and/or a word. If there is no word segmentation result of the emotion dictionary exceeding the general field and the emotion dictionary of the specific field, the joint vector of the word segmentation result in all k emotion dictionaries is used as the emotion representation of the word, namely, the dictionary vector U L
Further, in order to integrate the obtained emotion characteristics into the text emotion classification model, linear transformation is further required based on the following formula (10) and formula (11) to obtain a transformed feature matrix M L
M L =W L U L (10)
Figure SMS_39
Wherein L is { L ∈ }) 1 ,L 2 ,....,L k The k emotion dictionaries are represented,
Figure SMS_40
representing emotion characteristics provided by the ith word segmentation result in emotion dictionary, W L Representing a weight matrix.
Because each emotion dictionary has its unique emotion features, it is not easy to combine emotion features in the integration of emotion features in k emotion dictionaries. In this embodiment of the present invention, a weighting policy is proposed to dynamically adjust the weights of emotion features from each emotion dictionary. Specifically, the emotion characteristics of each word segmentation result are defined based on the following formula (12):
Figure SMS_41
Wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure SMS_42
representing emotion characteristics corresponding to the ith word segmentation result,/->
Figure SMS_43
Representing the dynamic weights of the j-th emotion dictionary, it will be appreciated that +.>
Figure SMS_44
Comprises a first weight value corresponding to an emotion dictionary in the general field and a second weight value corresponding to an emotion dictionary in the specific field>
Figure SMS_45
Weight matrix representing word segmentation result based on jth emotion dictionary,/for each word>
Figure SMS_46
Representing the feature vector of the ith word segmentation result after linear transformation based on the jth emotion dictionary, wherein the feature vectors of all word segmentation results after linear transformation in all emotion dictionaries form a feature matrix M after linear transformation L
Here, dynamic weights
Figure SMS_47
Calculated according to formula (13):
Figure SMS_48
wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure SMS_49
and f is a feedforward neural network, wherein the weight matrix representing the word segmentation result is based on the jth emotion dictionary.
In determining the emotion characteristics of each word segmentation result
Figure SMS_50
Thereafter, the updated emotion matrix is applied to the emotion attention weight according to the following formula (14):
Figure SMS_51
finally, the emotion characterization for each word can be updated according to the following equation (15):
Figure SMS_52
wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure SMS_53
representing emotion characterizations corresponding to an ith word segmentation result in a text sample in the iterative process of the round, wherein emotion characterizations corresponding to all word segmentation results in the text sample form emotion characterizations corresponding to the text sample, and n represents the number of word segmentation results in the text sample and the weight of the word segmentation results >
Figure SMS_54
Representing emotion feature vectors corresponding to ith word segmentation result in a text sample in the iterative process of the round, wherein emotion feature vectors corresponding to all word segmentation results in the text sample form an emotion feature vector sequence, and the emotion feature vector sequence is represented by->
Figure SMS_55
Transposed matrix representing learning parameters +.>
Figure SMS_56
All represent a weight matrix.
In this embodiment, by determining a first weight value corresponding to the emotion dictionary in the general field and a second weight value corresponding to the emotion dictionary in the specific field, and determining emotion characterizations corresponding to each word segmentation result based on the emotion feature vector sequence, the first weight value, the second weight value and emotion features corresponding to each word segmentation result in the transformed feature matrix, the emotion characterizations corresponding to the text sample are determined, and as characteristics of the text field are considered, a dynamic weight-dividing strategy is proposed to introduce the emotion dictionary in the general field and the emotion dictionary in the specific field to guide emotion classification, so that the understanding capability of the text emotion classification model on field knowledge and semantic information is improved, the applicability of the text emotion classification model is improved, and the text emotion classification model is more accurate.
Illustratively, step 105 may include, based on the above embodiments:
Determining the probability that each word segmentation result in each sample text is an entity based on the entity representation corresponding to each sample text; based on the emotion characterization corresponding to each sample text, determining the probability that each word segmentation result in each sample text belongs to each type of emotion; and determining emotion classification prediction results corresponding to the entities in the text sample based on the probability that each word segmentation result is an entity and the probability that each word segmentation result belongs to each type of emotion.
Specifically, after the T rounds of iteration, the probability that each word segmentation result is an entity in each sample text may be determined based on the following formula (16), and the probability that each word segmentation result belongs to each emotion type may be determined based on the following formula (17):
Figure SMS_57
Figure SMS_58
wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure SMS_61
representing word vector x i For emotion polarity->
Figure SMS_63
Probability of (1), wherein->
Figure SMS_65
Respectively representing positive, neutral and negative emotions, W represents weight +.>
Figure SMS_60
Representing emotion characterization of the ith word segmentation result after T rounds of iteration, and b representing bias. />
Figure SMS_62
Representing word vector x i For emotion polarity->
Figure SMS_64
Wherein>
Figure SMS_66
Labels B, I and O represent the beginning, inside and outside of the entity word, respectively, < >>
Figure SMS_59
And representing the entity representation of the ith word segmentation result after T rounds of iteration.
Further, after the two tasks generate the prediction results, the entity emotion label pair needs to be further obtained to form a joint output, that is, to output the emotion classification result prediction of each entity. Considering that the extracted entity may be composed of a plurality of words, and the predicted polarity of each word may be different, in the embodiment of the present invention, the number of each type of polarity in the entity word may be counted, where the polarity type with the highest frequency in the predicted result is taken as the final emotion type of the entity, for example, for "AA car", if the predicted emotion polarity of "AA" is negative and the emotion polarity of "car" is positive, the number of times that the emotion polarity of "AA" is predicted to be negative and the number of times that the emotion polarity of "car" is predicted to be positive are respectively counted, and the polarity with the high number of times is taken as the emotion polarity of "AA car", that is, the emotion classification result. For other situations, the polarity of the first word in the current entity is used as the final emotion classification result, namely, the emotion label, for example, if the emotion polarity of "AA" is predicted to be negative times as many times as the emotion polarity of "car" is predicted to be positive times, the emotion polarity of "AA" is determined to be the emotion polarity of "AA car", namely, the emotion classification result of "AA car".
In this embodiment, the emotion classification prediction result corresponding to each entity in the text sample may be determined based on the probability that each word segmentation result is an entity and the probability that each word segmentation result belongs to each emotion, and the emotion classification result at the entity level may be obtained based on the text emotion classification model obtained by training the emotion classification prediction result, so that the emotion classification result may be more accurate.
Fig. 6 is one of flow diagrams of a text emotion classification method according to an embodiment of the present invention, as shown in fig. 6, where the embodiment of the present invention includes:
step 601: and acquiring a text to be analyzed.
In this step, the text to be analyzed may be a text in a general field or a text in a specific field.
Step 602: inputting the text to be analyzed into a text emotion classification model to obtain emotion classification results of all entities in the text to be analyzed.
The text emotion classification model is trained based on the modes described in the previous embodiments.
Inputting the text to be analyzed into a pre-trained text emotion classification model to obtain emotion classification results of each entity and each entity in the text to be analyzed, wherein the emotion classification results can be understood as emotion polarities, and include positive, neutral or negative.
According to the text emotion classification method provided by the embodiment of the invention, the emotion classification result of each entity in the text to be analyzed can be obtained by inputting the text to be analyzed into the text emotion classification model, and as the text field is considered in training the text emotion classification model, the emotion dictionary of the general field and the emotion dictionary of the specific field can be adopted to guide the emotion classification of the word segmentation result in each text sample so as to determine the emotion characterization corresponding to each text sample, and the language knowledge of each word is integrated, so that the understanding capability of emotion classification or emotion polarity is enhanced, the applicability of the text emotion classification model can be improved, and the accuracy of the classification result is higher when the text emotion classification model is adopted to classify the emotion of the text in the specific field.
The text emotion classification model training device provided by the invention is described below, and the text emotion classification model training device described below and the text emotion classification model training method described above can be correspondingly referred to each other.
Fig. 7 is a schematic structural diagram of a training device for text emotion classification model according to an embodiment of the present invention, as shown in fig. 7, the device includes:
The processing module 11 is configured to perform word segmentation processing on a plurality of text samples, so as to obtain word segmentation results corresponding to the text samples;
a determining module 12, configured to determine an entity feature vector sequence and an emotion feature vector sequence of each text sample based on a word segmentation result corresponding to each text sample;
the determining module 12 is further configured to determine, based on the entity feature vector sequence, an entity representation corresponding to each text sample;
the determining module 12 is further configured to determine, based on the emotion feature vector sequence, a universal domain emotion dictionary and a specific domain emotion dictionary, emotion characterizations corresponding to each text sample, where the universal domain emotion dictionary includes a plurality of first words and emotion classifications of each first word in the universal domain, and the specific domain emotion dictionary includes a plurality of second words and emotion classifications of each second word in the specific domain;
the determining module 12 is further configured to determine an emotion classification prediction result corresponding to each entity in each text sample based on the entity representation and the emotion representation corresponding to each sample text;
and the adjusting module 13 is used for adjusting the model parameters of the initial text emotion classification model based on the emotion classification prediction result to obtain the text emotion classification model.
Optionally, the determining module 12 is specifically configured to:
determining an initial emotion feature matrix corresponding to each text sample based on the emotion dictionary of the general field and the emotion dictionary of the specific field;
performing linear transformation on the initial emotion feature matrix to obtain a transformed feature matrix;
respectively determining a first weight value corresponding to the emotion dictionary in the general field and a second weight value corresponding to the emotion dictionary in the specific field;
determining emotion characterization corresponding to each word segmentation result based on the emotion feature vector sequence, the first weight value, the second weight value and emotion features corresponding to each word segmentation result in the transformed feature matrix;
and determining emotion characterization corresponding to the text sample based on emotion characterization corresponding to each word segmentation result in the text sample.
Optionally, the determining module 12 is specifically configured to:
determining word vector sequences of the text samples based on word segmentation results corresponding to the text samples;
inputting the word vector sequence of each text sample into a sequential deep neural network to obtain a shared feature vector corresponding to each text sample;
And respectively determining an entity feature vector sequence and an emotion feature vector sequence of each text sample based on the shared feature vector corresponding to each text sample.
Optionally, the determining module 12 is specifically configured to:
acquiring a first entity representation corresponding to each text sample in the previous iteration process;
determining a first association degree of the first entity representation and an emotion analysis task;
and determining an emotion feature vector sequence in each text sample in the iterative process of the round based on the shared feature vector corresponding to each text sample and the first association degree.
Optionally, the determining module 12 is specifically configured to:
acquiring a first emotion representation corresponding to each text sample in the previous iteration process;
determining a second association degree of the first emotion characterization and an entity extraction task;
and determining an entity feature vector sequence in each text sample in the iterative process of the round based on the shared feature vector corresponding to each text sample and the second association degree.
Optionally, the determining module 12 is specifically configured to:
determining the probability that each word segmentation result in each sample text is an entity based on the entity representation corresponding to each sample text;
Determining the probability of each word segmentation result in each sample text belonging to each type of emotion based on the emotion characterization corresponding to each sample text;
and determining emotion classification prediction results corresponding to the entities in the text sample based on the probability that each word segmentation result is an entity and the probability that each word segmentation result belongs to each type of emotion.
The apparatus of the present embodiment may be used to execute the method of any one of the foregoing electronic device side method embodiments, and specific implementation processes and technical effects of the apparatus are similar to those of the electronic device side method embodiments, and specific details of the electronic device side method embodiments may be referred to in the detailed description of the electronic device side method embodiments, which are not repeated herein.
Fig. 8 is a schematic structural diagram of a text emotion classification device according to an embodiment of the present invention, as shown in fig. 8, where the device includes:
an obtaining module 21, configured to obtain a text to be analyzed;
the processing module 22 is configured to input the text to be analyzed into a text emotion classification model to obtain emotion classification results of each entity in the text to be analyzed; the text emotion classification model is obtained by training according to a training device of the text emotion classification model shown in fig. 7.
The apparatus of the present embodiment may be used to execute the method of any one of the foregoing electronic device side method embodiments, and specific implementation processes and technical effects of the apparatus are similar to those of the electronic device side method embodiments, and specific details of the electronic device side method embodiments may be referred to in the detailed description of the electronic device side method embodiments, which are not repeated herein.
Fig. 9 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention, where, as shown in fig. 9, the electronic device may include: processor 910, communication interface (Communications Interface), memory 930, and communication bus 940, wherein processor 910, communication interface 920, and memory 930 communicate with each other via communication bus 940. Processor 910 can invoke logic instructions in memory 930 to perform a text emotion classification model training method comprising: word segmentation processing is carried out on the plurality of text samples respectively, and word segmentation results corresponding to the text samples are obtained; based on word segmentation results corresponding to the text samples, respectively determining an entity feature vector sequence and an emotion feature vector sequence of the text samples; determining entity characterization corresponding to each text sample based on the entity feature vector sequence; determining emotion characterizations corresponding to each text sample based on the emotion feature vector sequence, an emotion dictionary of a general field and an emotion dictionary of a specific field, wherein the emotion dictionary of the general field comprises a plurality of first words and emotion classifications of the first words in the general field, and the emotion dictionary of the specific field comprises a plurality of second words and emotion classifications of the second words in the specific field; determining emotion classification prediction results corresponding to all entities in the text samples based on the entity representation and the emotion representation corresponding to all the sample texts; and adjusting model parameters of the initial text emotion classification model based on the emotion classification prediction result to obtain the text emotion classification model.
Processor 910 can invoke logic instructions in memory 930 to perform a text emotion classification method comprising: acquiring a text to be analyzed; inputting the text to be analyzed into a text emotion classification model to obtain emotion classification results of all entities in the text to be analyzed; the text emotion classification model is trained according to the training method of the text emotion classification model in any of the previous embodiments.
Further, the logic instructions in the memory 930 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, 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 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.
In another aspect, the present invention also provides a computer program product, where the computer program product includes a computer program, where the computer program can be stored on a non-transitory computer readable storage medium, and when the computer program is executed by a processor, the computer can execute the text emotion classification model training method provided by the above methods, and the method includes: word segmentation processing is carried out on the plurality of text samples respectively, and word segmentation results corresponding to the text samples are obtained; based on word segmentation results corresponding to the text samples, respectively determining an entity feature vector sequence and an emotion feature vector sequence of the text samples; determining entity characterization corresponding to each text sample based on the entity feature vector sequence; determining emotion characterizations corresponding to each text sample based on the emotion feature vector sequence, an emotion dictionary of a general field and an emotion dictionary of a specific field, wherein the emotion dictionary of the general field comprises a plurality of first words and emotion classifications of the first words in the general field, and the emotion dictionary of the specific field comprises a plurality of second words and emotion classifications of the second words in the specific field; determining emotion classification prediction results corresponding to all entities in the text samples based on the entity representation and the emotion representation corresponding to all the sample texts; and adjusting model parameters of the initial text emotion classification model based on the emotion classification prediction result to obtain the text emotion classification model.
When the computer program is executed by a processor, the computer can execute the text emotion classification method provided by the methods, and the method comprises the following steps: acquiring a text to be analyzed; inputting the text to be analyzed into a text emotion classification model to obtain emotion classification results of all entities in the text to be analyzed; the text emotion classification model is trained according to the training method of the text emotion classification model in any of the previous embodiments.
In yet another aspect, the present invention further provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the text emotion classification model training method provided by the above methods, the method comprising: word segmentation processing is carried out on the plurality of text samples respectively, and word segmentation results corresponding to the text samples are obtained; based on word segmentation results corresponding to the text samples, respectively determining an entity feature vector sequence and an emotion feature vector sequence of the text samples; determining entity characterization corresponding to each text sample based on the entity feature vector sequence; determining emotion characterizations corresponding to each text sample based on the emotion feature vector sequence, an emotion dictionary of a general field and an emotion dictionary of a specific field, wherein the emotion dictionary of the general field comprises a plurality of first words and emotion classifications of the first words in the general field, and the emotion dictionary of the specific field comprises a plurality of second words and emotion classifications of the second words in the specific field; determining emotion classification prediction results corresponding to all entities in the text samples based on the entity representation and the emotion representation corresponding to all the sample texts; and adjusting model parameters of the initial text emotion classification model based on the emotion classification prediction result to obtain the text emotion classification model.
The computer program, when executed by a processor, implements the text emotion classification method provided by the methods, the method comprising: acquiring a text to be analyzed; inputting the text to be analyzed into a text emotion classification model to obtain emotion classification results of all entities in the text to be analyzed; the text emotion classification model is trained according to the training method of the text emotion classification model in any of the previous embodiments.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A text emotion classification model training method, comprising:
word segmentation processing is carried out on the plurality of text samples respectively, and word segmentation results corresponding to the text samples are obtained;
based on word segmentation results corresponding to the text samples, respectively determining an entity feature vector sequence and an emotion feature vector sequence of the text samples;
determining entity characterization corresponding to each text sample based on the entity feature vector sequence;
determining emotion characterizations corresponding to each text sample based on the emotion feature vector sequence, an emotion dictionary of a general field and an emotion dictionary of a specific field, wherein the emotion dictionary of the general field comprises a plurality of first words and emotion classifications of the first words in the general field, and the emotion dictionary of the specific field comprises a plurality of second words and emotion classifications of the second words in the specific field;
Determining emotion classification prediction results corresponding to all entities in the text samples based on the entity representation and the emotion representation corresponding to all the sample texts;
and adjusting model parameters of the initial text emotion classification model based on the emotion classification prediction result to obtain the text emotion classification model.
2. The training method of text emotion classification model according to claim 1, wherein determining emotion characterizations corresponding to each text sample based on the emotion feature vector sequence, the universal domain emotion dictionary, and the specific domain emotion dictionary comprises:
determining an initial emotion feature matrix corresponding to each text sample based on the emotion dictionary of the general field and the emotion dictionary of the specific field;
performing linear transformation on the initial emotion feature matrix to obtain a transformed feature matrix;
respectively determining a first weight value corresponding to the emotion dictionary in the general field and a second weight value corresponding to the emotion dictionary in the specific field;
determining emotion characterization corresponding to each word segmentation result based on the emotion feature vector sequence, the first weight value, the second weight value and emotion features corresponding to each word segmentation result in the transformed feature matrix;
And determining emotion characterization corresponding to the text sample based on emotion characterization corresponding to each word segmentation result in the text sample.
3. The training method of text emotion classification model of claim 1, wherein determining an entity feature vector sequence and an emotion feature vector sequence of each text sample based on word segmentation results corresponding to each text sample, respectively, comprises:
determining word vector sequences of the text samples based on word segmentation results corresponding to the text samples;
inputting the word vector sequence of each text sample into a sequential deep neural network to obtain a shared feature vector corresponding to each text sample;
and respectively determining an entity feature vector sequence and an emotion feature vector sequence of each text sample based on the shared feature vector corresponding to each text sample.
4. The text emotion classification model training method of claim 3, wherein determining an emotion feature vector sequence in each text sample based on the shared feature vector corresponding to each text sample comprises:
acquiring a first entity representation corresponding to each text sample in the previous iteration process;
Determining a first association degree of the first entity representation and an emotion analysis task;
and determining an emotion feature vector sequence in each text sample in the iterative process of the round based on the shared feature vector corresponding to each text sample and the first association degree.
5. The training method of text emotion classification model of claim 3 or 4, wherein determining a sequence of entity feature vectors for each text sample based on the shared feature vector for each text sample, comprises:
acquiring a first emotion representation corresponding to each text sample in the previous iteration process;
determining a second association degree of the first emotion characterization and an entity extraction task;
and determining an entity feature vector sequence in each text sample in the iterative process of the round based on the shared feature vector corresponding to each text sample and the second association degree.
6. The training method of text emotion classification model according to any one of claims 1 to 4, wherein determining an emotion classification prediction result corresponding to each entity in each text sample based on the entity representation and the emotion representation corresponding to each sample text comprises:
Determining the probability that each word segmentation result in each sample text is an entity based on the entity representation corresponding to each sample text;
determining the probability of each word segmentation result in each sample text belonging to each type of emotion based on the emotion characterization corresponding to each sample text;
and determining emotion classification prediction results corresponding to the entities in the text sample based on the probability that each word segmentation result is an entity and the probability that each word segmentation result belongs to each type of emotion.
7. A text emotion classification method, comprising:
acquiring a text to be analyzed;
inputting the text to be analyzed into a text emotion classification model to obtain emotion classification results of all entities in the text to be analyzed; the text emotion classification model is trained by the training method of the text emotion classification model according to any one of claims 1 to 6.
8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the text emotion classification model training method of any of claims 1 to 6 or the text emotion classification method of claim 7 when the program is executed by the processor.
9. A non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor implements the text emotion classification model training method of any of claims 1 to 6 or the text emotion classification method of claim 7.
10. A computer program product comprising a computer program which, when executed by a processor, implements a text emotion classification model training method as claimed in any one of claims 1 to 6 or implements a text emotion classification method as claimed in claim 7.
CN202211091826.4A 2022-09-07 2022-09-07 Text emotion classification model training method, text emotion classification method and equipment Active CN116257623B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211091826.4A CN116257623B (en) 2022-09-07 2022-09-07 Text emotion classification model training method, text emotion classification method and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211091826.4A CN116257623B (en) 2022-09-07 2022-09-07 Text emotion classification model training method, text emotion classification method and equipment

Publications (2)

Publication Number Publication Date
CN116257623A true CN116257623A (en) 2023-06-13
CN116257623B CN116257623B (en) 2023-11-28

Family

ID=86678078

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211091826.4A Active CN116257623B (en) 2022-09-07 2022-09-07 Text emotion classification model training method, text emotion classification method and equipment

Country Status (1)

Country Link
CN (1) CN116257623B (en)

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001052109A1 (en) * 2000-01-13 2001-07-19 Stanley Benjamin Smith Process and system for gathering and handling information
CN103761311A (en) * 2014-01-23 2014-04-30 中国矿业大学 Sentiment classification method based on multi-source field instance migration
US20150170304A1 (en) * 2013-12-13 2015-06-18 Innovative Web, Inc. Methods and systems for projecting earnings and creating earnings tools within an online career network
CN108108351A (en) * 2017-12-05 2018-06-01 华南理工大学 A kind of text sentiment classification method based on deep learning built-up pattern
US20190095432A1 (en) * 2017-09-26 2019-03-28 Baidu Online Network Technology (Beijing) Co., Ltd. Method and apparatus for building text classification model, and text classification method and apparatus
CN109684634A (en) * 2018-12-17 2019-04-26 北京百度网讯科技有限公司 Sentiment analysis method, apparatus, equipment and storage medium
CN110517121A (en) * 2019-09-23 2019-11-29 重庆邮电大学 Method of Commodity Recommendation and the device for recommending the commodity based on comment text sentiment analysis
CN110704622A (en) * 2019-09-27 2020-01-17 北京明略软件***有限公司 Text emotion classification method and device and electronic equipment
CN111191463A (en) * 2019-12-30 2020-05-22 杭州远传新业科技有限公司 Emotion analysis method and device, electronic equipment and storage medium
CN111538835A (en) * 2020-03-30 2020-08-14 东南大学 Social media emotion classification method and device based on knowledge graph
CN112784041A (en) * 2021-01-06 2021-05-11 河海大学 Chinese short text emotion orientation analysis method
CN113887206A (en) * 2021-09-15 2022-01-04 北京三快在线科技有限公司 Model training and keyword extraction method and device
CN114912458A (en) * 2021-02-08 2022-08-16 西门子股份公司 Emotion analysis method and device and computer readable medium

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001052109A1 (en) * 2000-01-13 2001-07-19 Stanley Benjamin Smith Process and system for gathering and handling information
US20150170304A1 (en) * 2013-12-13 2015-06-18 Innovative Web, Inc. Methods and systems for projecting earnings and creating earnings tools within an online career network
CN103761311A (en) * 2014-01-23 2014-04-30 中国矿业大学 Sentiment classification method based on multi-source field instance migration
US20190095432A1 (en) * 2017-09-26 2019-03-28 Baidu Online Network Technology (Beijing) Co., Ltd. Method and apparatus for building text classification model, and text classification method and apparatus
CN108108351A (en) * 2017-12-05 2018-06-01 华南理工大学 A kind of text sentiment classification method based on deep learning built-up pattern
CN109684634A (en) * 2018-12-17 2019-04-26 北京百度网讯科技有限公司 Sentiment analysis method, apparatus, equipment and storage medium
CN110517121A (en) * 2019-09-23 2019-11-29 重庆邮电大学 Method of Commodity Recommendation and the device for recommending the commodity based on comment text sentiment analysis
CN110704622A (en) * 2019-09-27 2020-01-17 北京明略软件***有限公司 Text emotion classification method and device and electronic equipment
CN111191463A (en) * 2019-12-30 2020-05-22 杭州远传新业科技有限公司 Emotion analysis method and device, electronic equipment and storage medium
CN111538835A (en) * 2020-03-30 2020-08-14 东南大学 Social media emotion classification method and device based on knowledge graph
CN112784041A (en) * 2021-01-06 2021-05-11 河海大学 Chinese short text emotion orientation analysis method
CN114912458A (en) * 2021-02-08 2022-08-16 西门子股份公司 Emotion analysis method and device and computer readable medium
CN113887206A (en) * 2021-09-15 2022-01-04 北京三快在线科技有限公司 Model training and keyword extraction method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
周浩;李翔;刘功申;: "相关信息加权的自适应多标签分类算法", 计算机应用与软件, no. 01, pages 245 - 249 *
宋佳颖;贺宇;付国宏;: "领域相关的汉语情感词典扩展", 中文信息学报, no. 06, pages 79 - 86 *

Also Published As

Publication number Publication date
CN116257623B (en) 2023-11-28

Similar Documents

Publication Publication Date Title
CN111858945B (en) Deep learning-based comment text aspect emotion classification method and system
Ilie et al. Context-aware misinformation detection: A benchmark of deep learning architectures using word embeddings
CN111161740A (en) Intention recognition model training method, intention recognition method and related device
CN110502753A (en) A kind of deep learning sentiment analysis model and its analysis method based on semantically enhancement
US20220343139A1 (en) Methods and systems for training a neural network model for mixed domain and multi-domain tasks
Dedeepya et al. Detecting cyber bullying on twitter using support vector machine
Chandra et al. Utilizing gated recurrent units to retain long term dependencies with recurrent neural network in text classification
Nazarenko et al. Investigation of the Deep Learning Approaches to Classify Emotions in Texts.
Yuwono et al. Automated scoring of chatbot responses in conversational dialogue
Lin et al. Enhancing educational dialogue act classification with discourse context and sample informativeness
Xu et al. AI for social science and social science of AI: A survey
CN116257623B (en) Text emotion classification model training method, text emotion classification method and equipment
Song Distilling knowledge from user information for document level sentiment classification
Haaralahti Utilization of local large language models for business applications
Isaranontakul et al. A Study of Using GPT-3 to Generate a Thai Sentiment Analysis of COVID-19 Tweets Dataset
Ho et al. Deep neural networks for text: A review
Wang et al. FHTC: Few-shot hierarchical text classification in financial domain
de Sousa Multi language Email Classification Using Transfer learning
Sghaier et al. Relevance and importance in deep learning for open source data processing to enhance context
PRAKALYA P et al. BiDETECT: BiLSTM WITH BERT FOR HATE SPEECH DETECTION IN TWEETS.
Zamani et al. Crypto-sentiment Detection in Malay Text Using Language Models with an Attention Mechanism.
Bensghaier et al. Investigating the Use of Different Recurrent Neural Networks for Natural Language Inference in Arabic
Rahmadzani et al. Deep Learning for Sentiment Analysis in Indonesian Novel Review
Döbele Blockchain sentiment on sector analysis
MANKOLLI DISSERTATION THESIS

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