CN116975289A - Text attribute-level emotion classification method based on semantic information and related equipment - Google Patents

Text attribute-level emotion classification method based on semantic information and related equipment Download PDF

Info

Publication number
CN116975289A
CN116975289A CN202310879054.9A CN202310879054A CN116975289A CN 116975289 A CN116975289 A CN 116975289A CN 202310879054 A CN202310879054 A CN 202310879054A CN 116975289 A CN116975289 A CN 116975289A
Authority
CN
China
Prior art keywords
word
information
target sentence
attribute
local
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.)
Pending
Application number
CN202310879054.9A
Other languages
Chinese (zh)
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 Telecom Technology Innovation Center
China Telecom Corp Ltd
Original Assignee
China Telecom Technology Innovation Center
China Telecom Corp 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 Telecom Technology Innovation Center, China Telecom Corp Ltd filed Critical China Telecom Technology Innovation Center
Priority to CN202310879054.9A priority Critical patent/CN116975289A/en
Publication of CN116975289A publication Critical patent/CN116975289A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • G06F16/353Clustering; Classification into predefined classes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/044Recurrent networks, e.g. Hopfield networks
    • G06N3/0442Recurrent networks, e.g. Hopfield networks characterised by memory or gating, e.g. long short-term memory [LSTM] or gated recurrent units [GRU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Abstract

The disclosure provides a text attribute-level emotion classification method and related equipment based on semantic information, and relates to the technical field of natural language processing. The method comprises the following steps: obtaining local context characterization information, global context characterization information and context characterization information of attribute words of each word in a target sentence in a text to be classified, so as to determine local semantic information and global semantic information of each word in the target sentence according to the local context characterization information, the global context characterization information and the context characterization information of the attribute words of each word; and determining the emotion classification result of the target sentence according to the local semantic information and the global semantic information of each word in the target sentence. When the emotion polarity of the target sentence is determined, the influence of the local semantic information of the words around the attribute words on the emotion polarity of the target sentence and the influence of the global semantic information on the emotion polarity of the target sentence are simultaneously focused, so that the accuracy of emotion classification of the text to be classified is improved.

Description

Text attribute-level emotion classification method based on semantic information and related equipment
Technical Field
The disclosure relates to the technical field of natural language processing, in particular to a text attribute-level emotion classification method based on semantic information and related equipment.
Background
With the rapid development of internet technology, tens of thousands of data are generated daily on an internet platform and application, and the huge amount of data contains the views and ideas of people on various things such as certain commodities, events, people and the like. How to make a machine automatically mine the views and ideas of people from massive data, understand the semantics of the text, and identify the emotion tendencies (positive, negative and neutral) in the text is a research hotspot in the current academia and industry.
Attribute-level emotion classification is a key subtask of attribute-level emotion analysis, aimed at identifying emotion polarities (positive, negative, neutral) for different entities or different attributes of entities in a sentence. In recent years, although a certain progress is made by an attribute-level emotion classification method based on a deep neural network, the attribute-level emotion classification method still has some defects in the aspect of text semantics of modeling attribute word dependence, and sentence global semantic information is not effectively utilized and modeled; the existing attribute-level emotion classification method has weaker capability of modeling local semantic information between the attribute words and the context words; in addition, the existing method has a defect in the capability of integrating local semantic information and sentence global semantic information. For this reason, there is a need for an attribute-level emotion classification method capable of effectively utilizing local semantic information and global semantic information of sentences.
It should be noted that the information disclosed in the above background section is only for enhancing understanding of the background of the present disclosure and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The disclosure provides a text attribute-level emotion classification method and related equipment based on semantic information, which at least overcome the problem that the local semantic information and the global semantic information of sentences cannot be effectively utilized to carry out attribute-level emotion classification in the related technology to a certain extent.
Other features and advantages of the present disclosure will be apparent from the following detailed description, or may be learned in part by the practice of the disclosure.
According to one aspect of the present disclosure, there is provided a text attribute-level emotion classification method based on semantic information, including:
obtaining a text to be classified, wherein the text to be classified comprises: at least one sentence, each sentence comprising: a plurality of words, the plurality of words comprising: attribute words;
determining local context characterization information, global context characterization information and context characterization information of attribute words of each word in a target sentence, wherein the target sentence is any sentence in the text to be classified;
Determining local semantic information of the target sentence according to the local context representation information of each word, the context representation information of the attribute word and the distance information of each word and the attribute word in the target sentence;
determining global semantic information of each word in the target sentence according to the global context characterization information of each word in the target sentence;
and determining an attribute-level emotion classification result of the target sentence according to the local semantic information and the global semantic information of each word in the target sentence.
In some embodiments, the determining the local context characterization information, the global context characterization information, and the context characterization information for each word in the target sentence includes:
inputting each word in the target sentence into a pre-trained local characterization information acquisition model, and outputting local context characteristic information of each word in the target sentence;
and inputting the local context characteristic information of each word in the target sentence into a pre-trained global characterization information acquisition model, and outputting the global context characterization information of each word in the target sentence.
In some embodiments, the determining the local context characterization information, the global context characterization information, and the context characterization information for each word in the target sentence further includes:
Inputting each attribute word in the target sentence into the pre-trained local characterization information acquisition model, and outputting the context characterization information of each attribute word in the target sentence;
and carrying out average pooling on the context representation information of each attribute word in the target sentence to obtain the context representation information of the attribute word in the target sentence.
In some embodiments, the determining the local semantic information of the target sentence according to the local context characterization information of each word, the context characterization information of the attribute word, and the distance information of each word and the attribute word in the target sentence includes:
the local context representation information of each word, the context representation information of the attribute word and the distance information of each word and the attribute word in the target sentence are input into a pre-trained local semantic information acquisition model, and the local semantic information of each word in the target sentence is output.
In some embodiments, before inputting the local context characterization information for each word, the context characterization information for the attributed word, and the distance information for each word to the attributed word in the target sentence into the pre-trained local semantic information retrieval model, the method further comprises:
Obtaining distance information of each word and attribute word in the target sentence according to the following formula;
wherein l i For the target sentenceAnd the relative distance information between the ith word and the attribute words in the target sentence, k is a super parameter, k is less than or equal to n, and n is the number of words in the target sentence.
In some embodiments, the determining global semantic information for each word in the target sentence according to the global context characterization information for each word in the target sentence includes:
and inputting the global context representation information of each word in the target sentence into a pre-trained global semantic information acquisition model, and outputting the global semantic information of each word in the target sentence.
In some embodiments, the determining the attribute-level emotion classification result of the target sentence according to the local semantic information and the global semantic information of each word in the target sentence includes:
and inputting the local semantic information and the global semantic information of each word in the target sentence into a pre-trained semantic enhanced emotion classification model, and outputting an attribute-level emotion classification result of the target sentence.
According to another aspect of the present disclosure, there is also provided a text attribute-level emotion classification device based on semantic information, including:
The text acquisition module is configured to acquire a text to be classified, wherein the text to be classified comprises: at least one sentence, each sentence comprising: a plurality of words, the plurality of words comprising: attribute words;
the characteristic information acquisition module is configured to determine local context characteristic information, global context characteristic information and context characteristic information of attribute words of each word in a target sentence, wherein the target sentence is any sentence in the text to be classified;
the local semantic information acquisition module is configured to determine the local semantic information of the target sentence according to the local context characterization information of each word, the context characterization information of the attribute word and the distance information of each word and the attribute word in the target sentence;
the global semantic information acquisition module is configured to determine global semantic information of each word in the target sentence according to the global context characterization information of each word in the target sentence;
and the emotion classification module is configured to determine an attribute-level emotion classification result of the target sentence according to the local semantic information and the global semantic information of each word in the target sentence.
According to another aspect of the present disclosure, there is also provided an electronic device including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the text attribute-level emotion classification method based on semantic information of any one of the above via execution of the executable instructions.
According to another aspect of the present disclosure, there is also provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the text attribute-level emotion classification method based on semantic information of any one of the above.
According to another aspect of the present disclosure, there is also provided a computer program product comprising a computer program which, when executed by a processor, implements the text attribute-level emotion classification method based on semantic information of any one of the above.
According to the text attribute-level emotion classification method based on semantic information and the related equipment, local semantic information and global semantic information of each word in a target sentence are determined by acquiring local context characterization information, global context characterization information and context characterization information of attribute words of each word in the target sentence in the text to be classified; according to the method, when the emotion polarity of the target sentence is determined, the local semantic information and the global semantic information of the target sentence are fully utilized, so that the local semantic information of surrounding words of the attribute words in the target sentence is fully focused, the emotion polarity of the attribute words is judged from a global view, and the emotion polarity is judged by integrating the local semantic information and the global semantic information, thereby improving the accuracy of emotion classification of texts to be classified.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure. It will be apparent to those of ordinary skill in the art that the drawings in the following description are merely examples of the disclosure and that other drawings may be derived from them without undue effort.
FIG. 1 illustrates a flow chart of a text attribute-level emotion classification method based on semantic information in an embodiment of the present disclosure;
FIG. 2 illustrates a flow chart for determining local context characterization information, global context characterization information for each word in a target sentence in an embodiment of the present disclosure;
FIG. 3 illustrates a flow chart of determining contextual characterization information of an attribute word in a target sentence in an embodiment of the present disclosure;
FIG. 4 illustrates an algorithm flow diagram for a text attribute-level emotion classification model in an embodiment of the present disclosure;
FIG. 5 illustrates a flow chart for emotion classification using a text attribute-level emotion classification model in an embodiment of the present disclosure;
FIG. 6 is a schematic diagram of a text attribute-level emotion classification device based on semantic information according to an embodiment of the present disclosure;
fig. 7 shows a block diagram of a computer device implementing a text attribute-level emotion classification method based on semantic information in an embodiment of the present disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments may be embodied in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
Furthermore, the drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus a repetitive description thereof will be omitted. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software or in one or more hardware modules or integrated circuits or in different networks and/or processor devices and/or microcontroller devices.
Fig. 1 shows a flowchart of a text attribute-level emotion classification method based on semantic information in an embodiment of the present disclosure, and as shown in fig. 1, the text attribute-level emotion classification method based on semantic information provided in the embodiment of the present disclosure includes the following steps:
s102, acquiring a text to be classified, wherein the text to be classified comprises: at least one sentence, each sentence comprising: a plurality of words, the plurality of words comprising: attribute words.
The text to be classified can be text needing attribute-level emotion classification, and sentences in the text generally comprise some attribute words which can be used for representing emotion classification, for example, words which are used for evaluating various things such as certain commodities, events or people in certain comment text; the attribute word is a word specified from the text to be classified.
In some embodiments, after the text to be classified is obtained, an attribute word that each sentence has is obtained from each sentence in the text to be classified.
S104, determining local context characterization information, global context characterization information and context characterization information of attribute words of each word in a target sentence, wherein the target sentence is any sentence in the text to be classified.
The local context representation information of each word can be vector representation obtained by vectorizing the context information of each word in the target sentence; the global context characterization information of each word may be a vector representation obtained by further encoding the local context characterization information of each word, and the context characterization information of the attribute word is a vector representation obtained by performing vectorization processing on the context information of the attribute word in the target sentence.
In some embodiments, the context information of each word and the context information of the attribute word in the target sentence are respectively input into a pre-trained deep learning model for processing, so as to obtain local context characterization information of each word and context characterization information of the attribute word; and inputting the local context characterization information of each word in the target sentence into a pre-trained coding model for processing to obtain global context characterization information of each word in the target sentence.
S106, determining the local semantic information of the target sentence according to the local context representation information of each word, the context representation information of the attribute word and the distance information of each word and the attribute word in the target sentence.
The distance information of each word and the attribute word is used for representing the distance information between each word and the attribute word closest to the word in the target sentence; the local semantic information of the target sentence is a result obtained by processing the local context characterization information of each word, the context characterization information of the attribute word and the distance information of each word and the attribute word through a local distance perception attention mechanism.
In some embodiments, the distance information of each word from the attributed term may be the relative distance information of the word from the attributed term, obtained by the position of each word in the target sentence: setting the position index of a word in a sentence as a, wherein the attribute word consists of a single word, and the position index of the attribute word as b, so that the relative distance information of the word and the attribute word is |a-b|; if the attribute word contains a plurality of words, calculating the relative distance information of each word in the word and the attribute word, and taking the minimum value of the calculated relative distance information as the relative distance information of the word and the attribute word.
S108, determining global semantic information of each word in the target sentence according to the global context characterization information of each word in the target sentence.
The global semantic information of each word in the target sentence is a result obtained by processing global context characterization information of each word in the target sentence through a global attention mechanism.
S110, determining an attribute-level emotion classification result of the target sentence according to the local semantic information and the global semantic information of each word in the target sentence.
The attribute-level emotion classification result of the target sentence is the attribute-level emotion of the target sentence, and can be positive emotion, negative emotion or neutral emotion.
FIG. 2 is a flowchart illustrating the determination of local context characterization information and global context characterization information for each word in a target sentence in an embodiment of the present disclosure, as illustrated in FIG. 2, including the steps of:
s202, inputting each word in the target sentence into a pre-trained local characterization information acquisition model, and outputting local context characteristic information of each word in the target sentence.
The local characterization information acquisition model is used for carrying out vectorization processing on the context information of each word of the target sentence so as to obtain the local context characteristic information of each word in the target sentence.
In some embodiments, each word in the target sentence is input into a pre-trained local characterization information acquisition model for processing, where the local characterization information acquisition model may be a BERT (transform-based bi-directional encoding, bidirectional Encoder Representations from Transformer) model for inputting the context s= { w of the target sentence 1 ,w 2 ,...,w n Conversion to upper and lower Wen Biaozheng of each word in the target sentenceWherein S is a set of each word in the target sentence, w n Is the nth word in the target sentence; h c For each word in the target sentence, a set of local context tokens is composed, ++>Representing a contextual representation of the i-th word in the sentence.
S204, inputting the local context characteristic information of each word in the target sentence into a pre-trained global characterization information acquisition model, and outputting the global context characterization information of each word in the target sentence.
The pre-trained global characterization information acquisition model is used for encoding the local context characteristic information of each word in the target sentence so as to obtain global context characterization information of each word in the target sentence.
In some embodiments, H obtained in step S202 above is used c Inputting a pre-trained global characterization information acquisition model for processing, wherein the global characterization information acquisition model can be a Bi-LSTM (Bi-directional Long Short-Term Memory) model to obtain H c Corresponding forward characterizationAnd backward characterization->Splice->And->Obtaining the output of Bi-LSTM model >As a target sentenceGlobal context characterization information for each word in (1), wherein H e For each word in the target sentence, a set of global context tokens is composed, +.>Representing a contextual representation of the i-th word in the sentence.
FIG. 3 is a flowchart illustrating determining context characterization information of an attribute word in a target sentence in an embodiment of the present disclosure, where, as shown in FIG. 3, determining context characterization information of an attribute word in a target sentence in an embodiment of the present disclosure includes:
s302, inputting each attribute word in the target sentence into a pre-trained local characterization information acquisition model, and outputting the context characterization information of each attribute word in the target sentence.
In some embodiments, the attribute term may be a= { a 1 ,a 2 ,...,a m ' A is the set of all attribute words in the target sentence, a m Inputting A into a BERT model for processing for the mth attribute word in the target sentence to obtain the context characterization information of each word in the attribute word And representing the context characterization information of the ith word in the attribute words.
S304, carrying out average pooling on the context representation information of each attribute word in the target sentence to obtain the context representation information of the attribute word in the target sentence.
In some embodiments, the context-characterizing information for each of the attributed words Performing average pooling processing to obtain context characterization information of attribute words in the target sentenceh a
As an optional embodiment, the embodiment provided in the present disclosure inputs the local context characterization information of each word, the context characterization information of the attribute word, and the distance information of each word and the attribute word in the target sentence into a pre-trained local semantic information acquisition model, and outputs the local semantic information of each word in the target sentence, where the distance information of each word and the attribute word in the target sentence is first calculated according to the following formula:
wherein l i For the relative distance information between the i-th word in the target sentence and the attribute word in the target sentence, k is a super parameter, k is less than or equal to n, and n is the number of words in the target sentence.
After distance information of each word and attribute word in the target sentence is obtained, local context representation information of each word in the target sentence is input into a Bi-LSTM model for processing, and global context representation information of each word in the target sentence is obtained; the global context representation information of each word, the context representation information of the attribute word and the distance information of each word and the attribute word in the target sentence are input into a pre-trained local semantic information acquisition model, wherein the local semantic information acquisition model processes the global context representation information of each word, the context representation information of the attribute word and the distance information of each word and the attribute word in the target sentence according to a local distance perception attention mechanism to obtain the local semantic information of each word in the target sentence, and the calculation process comprises the following formula:
Wherein u is i For the local semantic information of the ith word in the target sentence, W l B for being a set weight in the local distance aware attention mechanism l Is a local partA well-set bias in the distance-aware attentiveness mechanism.
As an optional embodiment, the embodiment provided in the present disclosure inputs global context characterization information of each word in a target sentence to a pre-trained global semantic information acquisition model, outputs global semantic information of each word in the target sentence, where the global semantic information acquisition model processes the global context characterization information of each word in the target sentence according to a global attention mechanism to obtain global semantic information of each word in the target sentence, and the calculation process is as follows:
v i =max_pooling(v i,: ) (4)
wherein v is ij For the semantic relatedness of the ith word and the jth word in the target sentence, W q And W is k Weights set for global attention mechanism, d e Characterizing the dimension, v, of information for the global context of each word in a target sentence i,: For the vector obtained by splicing the semantic relativity of the ith word of the target sentence and the rest words in the target sentence, max_pooling is a function for obtaining the maximum value, and v is obtained by using the max_pooling function i,: As global semantic information v of the ith word in the target sentence i
As an optional embodiment, the embodiment provided by the disclosure inputs the local semantic information and the global semantic information of each word in the target sentence into a pre-trained semantic enhanced emotion classification model, and outputs an attribute-level emotion classification result of the target sentence. When the semantic enhanced emotion classification model processes the local semantic information and the global semantic information of each word in a target sentence, the local semantic information and the global semantic information of each word in the target sentence are aggregated to obtain semantic enhanced attribute word-related emotion characterization information, and the calculation process is as follows:
r i =u i +v i (5)
wherein r is i Semantic information of i-th word in target sentence, p i Attention weight, h, for the i-th word in the target sentence asp And (5) attribute word related emotion characterization information for semantic enhancement of the calculated target sentence.
After obtaining h asp Then, the input is processed by a full-connection layer formed by a multi-layer perceptron to obtain attribute word related emotion characterization information h of the target sentence s ,h s For the relevance of the target sentence and each emotion polarity, for h s Carrying out normalization processing to obtain probability distribution of emotion polarity of the target sentence, and selecting emotion polarity corresponding to the maximum probability value in the probability distribution as emotion polarity of the target sentence, wherein the calculation process is as follows:
q=softmax(h s ) (8)
Wherein q is the probability distribution of emotion polarity to which the target sentence belongs, the softmax function is a normalization function, and q c For the emotion type label of emotion polarity to which the target sentence belongs, the argmax function is a function for acquiring emotion polarity labels corresponding to each probability in q, and y E [0, d-1]D is the class number of emotion polarities, y is the serial number of emotion polarity labels, and the argmax function is used for obtaining the serial number of emotion polarity labels corresponding to each probability in q.
In some embodiments, the emotion type tag may be set to be positive, negative and neutral, where c is { pos, neg, neu }, d=3, where number 0 corresponds to positive emotion, number 1 corresponds to negative emotion, number 2 corresponds to neutral emotion, and where y is e [0,2], so that the semantic enhanced emotion classification model may obtain numbers of emotion type tags corresponding to probabilities in q, and determine, according to the number of emotion type tags corresponding to the maximum probability value, that the emotion polarity of the target sentence is positive emotion, negative emotion or neutral emotion.
As an alternative embodiment, the present disclosure provides a text attribute-level emotion classification model employing a text attribute-level emotion classification method based on semantic information, the model comprising: a context modeling layer, a sentence modeling layer, a semantic enhancement layer, a full connection layer and a classification layer. Fig. 4 is a flowchart illustrating an algorithm for performing text emotion classification using the text attribute-level emotion classification model, and as shown in fig. 4, when performing emotion classification using the text attribute-level emotion classification model provided by an embodiment of the present disclosure, the algorithm includes the following steps:
S402, inputting the target sentence and the attribute words into a context modeling layer to obtain local context characterization information and context characterization information of each word in the target sentence.
In the step, the context modeling layer processes each word in the input target sentence and each word in the attribute word through the BERT model to obtain local context representation information of each word in the target sentence and context representation information of each word in the attribute word, and performs average pooling processing on the context representation information of each word in the attribute word to obtain the context representation information of the attribute word.
S404, inputting the context characterization information of each word in the target sentence to a sentence coding layer, and modeling the global context characterization information of each word in the target sentence.
In the step, the sentence coding layer processes the context representation information of each word in the target sentence through the Bi-LSTM model to obtain the global context representation information of each word in the target sentence.
S406, inputting global context representation information of each word, context representation of the attribute word and distance information in the target sentence output by the sentence coding layer to the semantic enhancement layer, modeling global semantic information and local semantic information of the sentence, and fusing the two semantic information to obtain semantic enhanced attribute word related emotion representation information.
In the step, firstly, calculating distance information of each word and attribute word in a target sentence through a formula (1) by a semantic enhancement layer; calculating the local semantic information of each word in the target sentence through a formula (2), and calculating the global semantic information of each word in the target sentence through a formula (3) and a formula (4); and finally, aggregating the local semantic information and the global semantic information of each word in the target sentence through formulas (5) to (7) to obtain the semantic enhanced attribute word related emotion characterization information of the target sentence.
S408, inputting the semantic enhanced attribute word related emotion characterization information into the full connection layer to obtain the attribute word related emotion characterization information of the target sentence.
In the step, the semantic enhanced attribute word related emotion characterization information of the target sentence is input into a full-connection layer formed by a multi-layer perceptron for processing to obtain the attribute word related emotion characterization information of the target sentence, wherein the attribute word related emotion characterization information of the target sentence is used for representing the relevance of the target sentence and each emotion polarity.
S410, the attribute word related emotion characterization information of the target sentence is input into the classification layer, and the emotion polarity of the attribute word is obtained.
In the step, the classification layer acquires probability distribution of emotion polarity to which the target sentence belongs through a formula (8), and acquires emotion polarity numbers corresponding to each probability value in the probability distribution through a formula (9), so as to determine emotion polarity to which the target sentence belongs according to emotion polarity numbers corresponding to the maximum probability value in the probability distribution.
As an alternative embodiment, fig. 5 illustrates specific steps for emotion classification using a text attribute-level emotion classification model provided by an embodiment of the present disclosure, including:
s502, inputting a target sentence context.
In this step, each word in the target sentence is input to the BERT model in the context modeling layer.
S504, inputting attribute words.
In this step, each attribute word determined from the target sentence is input to the BERT model in the context modeling layer.
S506, generating local context characterization information of each word in the target sentence.
In the step, the BERT model processes each word in the target sentence to obtain local context characterization information of each word in the target sentence, and inputs the local context characterization information into a sentence modeling layer.
S508, generating context characterization information of the attribute words in the target sentence.
In the step, the BERT model processes each attribute word determined in the target sentence to obtain the context representation information of each attribute word in the target sentence, and performs average pooling processing on the context representation information of each attribute word in the target sentence to obtain the context representation information of the attribute word in the target sentence.
In this step, the distance information of each word and each attribute word in the target sentence is calculated according to the formula (1), and the context characterization information of the attribute word and the distance information of each word and each attribute word in the target sentence are input into the semantic enhancement layer.
S510, global context characterization information of each word in the target sentence is generated.
In this step, the local context characterization information of each word in the target sentence generated in step S506 is input to the Bi-LSTM model in the sentence coding layer for processing, so as to obtain global context characterization information of each word in the target sentence, and the global context characterization information of each word in the target sentence is input to the semantic enhancement layer.
S512, input to the global attention mechanism.
In this step, the global context characterization information of each word in the target sentence generated in step S510 is input into a global attention mechanism, and global semantic information of each word in the target sentence is obtained by calculation according to formula (3) and formula (4).
S514, inputting the local distance perception attention mechanism.
In this step, the context characterization information of the attribute words in the target sentence generated in step S508, the distance information of each word and the attribute words in the target sentence, and the global context characterization information of each word in the target sentence generated in step S510 are input into a local distance perception attention mechanism, and global semantic information of each word in the target sentence is obtained by calculation according to formula (2).
After global semantic information and local semantic information of each word in the target sentence are obtained in steps S512 and S514, the local semantic information and the global semantic information of each word in the target sentence are aggregated according to formulas (5) to (7), and semantic enhanced attribute word related emotion characterization information of the target sentence input to the full-connection layer is obtained.
S518, inputting the attribute words to a full-connection layer for processing, and obtaining attribute word related emotion characterization information.
In this step, the semantically enhanced attribute word-related emotion characterization information obtained in step S516 is input into a full-connection layer for processing, so as to obtain attribute word-related emotion characterization information of the target sentence, where the full-connection layer includes a multi-layer perceptron, the attribute word-related emotion characterization information of the target sentence is used to represent the relevance of the target sentence to each emotion polarity, and the attribute word-related emotion characterization information of the target sentence is input into a classification layer.
S520, calculating emotion type probability distribution of the target sentence, and determining emotion polarity of the target sentence.
In the step, the attribute word related emotion characterization information of the target sentence obtained in the step S518 is processed through a formula (8), so as to obtain probability distribution of emotion polarity of the target sentence; and (3) acquiring emotion polarity numbers corresponding to each probability value in the probability distribution through a formula (9), and finally determining the emotion polarity of the target sentence according to the emotion polarity number corresponding to the maximum probability value in the probability distribution.
In summary, according to the text attribute-level emotion classification method based on semantic information provided by the embodiment of the present disclosure, local context characterization information, global context characterization information and context characterization information of attribute words of each word in a target sentence in a text to be classified are obtained to determine local semantic information and global semantic information of each word in the target sentence; according to the local semantic information and the global semantic information of each word in the target sentence, determining attribute word related emotion characterization information showing the relevance of the target sentence and each emotion polarity; and finally, determining the probability distribution of the emotion polarity of the target sentence according to the attribute word related emotion characterization information, and selecting the emotion polarity corresponding to the maximum probability value in the probability distribution as the emotion polarity of the target sentence. When the emotion polarity of the target sentence is determined, the method fully utilizes the local semantic information and the global semantic information of the target sentence, fully focuses on the local semantic information of surrounding words of the attribute words in the target sentence, judges the emotion polarity of the attribute words from a global view, and improves the accuracy of emotion classification of the text to be classified by integrating the local semantic information and the global semantic information.
Based on the same inventive concept, the embodiment of the disclosure also provides a text attribute-level emotion classification device based on semantic information, as described in the following embodiment. Since the principle of solving the problem of the embodiment of the device is similar to that of the embodiment of the method, the implementation of the embodiment of the device can be referred to the implementation of the embodiment of the method, and the repetition is omitted.
Fig. 6 shows a schematic diagram of a text attribute-level emotion classification device based on semantic information according to an embodiment of the present disclosure, as shown in fig. 6, the device includes:
the text obtaining module 602 is configured to obtain text to be classified, where the text to be classified includes: at least one sentence, each sentence comprising: a plurality of words, the plurality of words comprising: attribute words.
The token information acquisition module 604 is configured to determine local context token information, global context token information, and context token information of an attribute word for each word in a target sentence, where the target sentence is any one of the texts to be classified.
The local semantic information acquisition module 606 is configured to determine local semantic information of the target sentence according to the local context characterization information of each word, the context characterization information of the attribute word, and the distance information of each word and the attribute word in the target sentence.
The global semantic information acquisition module 608 is configured to determine global semantic information for each word in the target sentence based on the global context characterization information for each word in the target sentence.
The emotion classification module 610 is configured to determine an attribute-level emotion classification result of the target sentence according to the local semantic information and the global semantic information of each word in the target sentence.
It should be noted that, the text obtaining module 602, the characterizing information obtaining module 604, the local semantic information obtaining module 606, the global semantic information obtaining module 608, and the emotion classification module 610 correspond to S102 to S110 in the method embodiment, and the foregoing modules are the same as examples and application scenarios implemented by the corresponding steps, but are not limited to the disclosure of the foregoing method embodiment. It should be noted that the modules described above may be implemented as part of an apparatus in a computer system, such as a set of computer-executable instructions.
As an alternative embodiment, the token information acquisition module 604 is further configured to input each word in the target sentence into a pre-trained local token information acquisition model, and output local context feature information of each word in the target sentence; the local context characteristic information of each word in the target sentence is input into a pre-trained global characterization information acquisition model, and global context characterization information of each word in the target sentence is output.
As an optional embodiment, the characterizing information obtaining module 604 is further configured to input each attribute word in the target sentence into a pre-trained local characterizing information obtaining model, and output the contextual characterizing information of each attribute word in the target sentence; and carrying out average pooling on the context representation information of each attribute word in the target sentence to obtain the context representation information of the attribute word in the target sentence.
As an alternative embodiment, the local semantic information obtaining module 606 is further configured to input the local context characterization information of each word, the context characterization information of the attribute word, and the distance information of each word and the attribute word in the target sentence into a pre-trained local semantic information obtaining model, and output the local semantic information of each word in the target sentence.
As an alternative embodiment, the local semantic information acquisition module 606 is further configured to acquire distance information of each word and the attribute word in the target sentence according to formula (1).
As an alternative embodiment, the global semantic information obtaining module 608 is further configured to input the global context characterization information of each word in the target sentence into a pre-trained global semantic information obtaining model, and output the global semantic information of each word in the target sentence.
As an alternative embodiment, emotion classification module 610 is further configured to input the local semantic information and the global semantic information of each word in the target sentence into a pre-trained semantic enhanced emotion classification model, and output the attribute-level emotion classification result of the target sentence.
Those skilled in the art will appreciate that the various aspects of the present disclosure may be implemented as a system, method, or program product. Accordingly, various aspects of the disclosure may be embodied in the following forms, namely: an entirely hardware embodiment, an entirely software embodiment (including firmware, micro-code, etc.) or an embodiment combining hardware and software aspects may be referred to herein as a "circuit," module "or" system.
An electronic device 700 according to such an embodiment of the present disclosure is described below with reference to fig. 7. The electronic device 700 shown in fig. 7 is merely an example and should not be construed to limit the functionality and scope of use of embodiments of the present disclosure in any way.
As shown in fig. 7, the electronic device 700 is embodied in the form of a general purpose computing device. Components of electronic device 700 may include, but are not limited to: the at least one processing unit 710, the at least one memory unit 720, and a bus 730 connecting the different system components, including the memory unit 720 and the processing unit 710.
Wherein the storage unit stores program code that is executable by the processing unit 710 such that the processing unit 710 performs steps according to various exemplary embodiments of the present disclosure described in the above-described "exemplary methods" section of the present specification. For example, the processing unit 710 may perform the following steps of the method embodiment described above:
obtaining a text to be classified, wherein the text to be classified comprises: at least one sentence, each sentence comprising: a plurality of words, the plurality of words comprising: attribute words; determining local context characterization information, global context characterization information and context characterization information of attribute words of each word in a target sentence, wherein the target sentence is any sentence in a text to be classified; determining local semantic information of the target sentence according to the local context representation information of each word, the context representation information of the attribute word and the distance information of each word and the attribute word in the target sentence; determining global semantic information of each word in the target sentence according to the global context characterization information of each word in the target sentence; and determining an attribute-level emotion classification result of the target sentence according to the local semantic information and the global semantic information of each word in the target sentence.
The memory unit 720 may include readable media in the form of volatile memory units, such as Random Access Memory (RAM) 7201 and/or cache memory 7202, and may further include Read Only Memory (ROM) 7203.
The storage unit 720 may also include a program/utility 7204 having a set (at least one) of program modules 7205, such program modules 7205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
Bus 730 may be a bus representing one or more of several types of bus structures including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 700 may also communicate with one or more external devices 740 (e.g., keyboard, pointing device, bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 700, and/or any device (e.g., router, modem, etc.) that enables the electronic device 700 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 750. Also, electronic device 700 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet, through network adapter 760. As shown, network adapter 760 communicates with other modules of electronic device 700 over bus 730. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with electronic device 700, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, including several instructions to cause a computing device (may be a personal computer, a server, a terminal device, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
In particular, according to embodiments of the present disclosure, the process described above with reference to the flowcharts may be implemented as a computer program product comprising: and the computer program is executed by the processor to realize the text attribute-level emotion classification method based on the semantic information.
In an exemplary embodiment of the present disclosure, a computer-readable storage medium, which may be a readable signal medium or a readable storage medium, is also provided. In some possible implementations, various aspects of the disclosure may also be implemented in the form of a program product comprising program code for causing a terminal device to carry out the steps according to the various exemplary embodiments of the disclosure as described in the "exemplary methods" section of this specification, when the program product is run on the terminal device.
More specific examples of the computer readable storage medium in the present disclosure may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In this disclosure, a computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Alternatively, the program code embodied on a computer readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
In particular implementations, the program code for carrying out operations of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
It should be noted that although in the above detailed description several modules or units of a device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit in accordance with embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into a plurality of modules or units to be embodied.
Furthermore, although the steps of the methods in the present disclosure are depicted in a particular order in the drawings, this does not require or imply that the steps must be performed in that particular order or that all illustrated steps be performed in order to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform, etc.
From the description of the above embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, including several instructions to cause a computing device (may be a personal computer, a server, a mobile terminal, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any adaptations, uses, or adaptations of the disclosure following the general principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

Claims (10)

1. A text attribute-level emotion classification method based on semantic information, comprising:
obtaining a text to be classified, wherein the text to be classified comprises: at least one sentence, each sentence comprising: a plurality of words, the plurality of words comprising: attribute words;
determining local context characterization information, global context characterization information and context characterization information of attribute words of each word in a target sentence, wherein the target sentence is any sentence in the text to be classified;
determining local semantic information of the target sentence according to the local context representation information of each word, the context representation information of the attribute word and the distance information of each word and the attribute word in the target sentence;
determining global semantic information of each word in the target sentence according to the global context characterization information of each word in the target sentence;
and determining an attribute-level emotion classification result of the target sentence according to the local semantic information and the global semantic information of each word in the target sentence.
2. The semantic information based text attribute-level emotion classification method of claim 1, wherein determining local context characterization information and global context characterization information for each word in a target sentence comprises:
Inputting each word in the target sentence into a pre-trained local characterization information acquisition model, and outputting local context characteristic information of each word in the target sentence;
and inputting the local context characteristic information of each word in the target sentence into a pre-trained global characterization information acquisition model, and outputting the global context characterization information of each word in the target sentence.
3. The semantic information based text attribute-level emotion classification method of claim 2, wherein said determining context characterization information of an attribute word in a target sentence comprises:
inputting each attribute word in the target sentence into the pre-trained local characterization information acquisition model, and outputting the context characterization information of each attribute word in the target sentence;
and carrying out average pooling on the context representation information of each attribute word in the target sentence to obtain the context representation information of the attribute word in the target sentence.
4. The text attribute-level emotion classification method based on semantic information of claim 1, wherein the determining the local semantic information of the target sentence according to the local context characterization information of each word, the context characterization information of an attribute word, and the distance information of each word and an attribute word in the target sentence comprises:
The local context representation information of each word, the context representation information of the attribute word and the distance information of each word and the attribute word in the target sentence are input into a pre-trained local semantic information acquisition model, and the local semantic information of each word in the target sentence is output.
5. The semantic information based text attribute-level emotion classification method of claim 4, wherein before inputting the local context characterization information of each word, the context characterization information of an attribute word, and the distance information of each word and an attribute word in the target sentence into a pre-trained local semantic information acquisition model, the method further comprises:
obtaining distance information of each word and attribute word in the target sentence according to the following formula;
wherein l i And k is a super parameter, k is less than or equal to n, and n is the number of words in the target sentence, wherein the k is the relative distance information between the ith word in the target sentence and the attribute word in the target sentence.
6. The semantic information based text attribute-level emotion classification method of claim 1, wherein said determining global semantic information for each word in the target sentence based on global context characterization information for each word in the target sentence comprises:
And inputting the global context representation information of each word in the target sentence into a pre-trained global semantic information acquisition model, and outputting the global semantic information of each word in the target sentence.
7. The text attribute-level emotion classification method based on semantic information of claim 1, wherein determining an attribute-level emotion classification result of the target sentence according to local semantic information and global semantic information of each word in the target sentence comprises:
and inputting the local semantic information and the global semantic information of each word in the target sentence into a pre-trained semantic enhanced emotion classification model, and outputting an attribute-level emotion classification result of the target sentence.
8. A text attribute-level emotion classification device based on semantic information, comprising:
the text acquisition module is configured to acquire a text to be classified, wherein the text to be classified comprises: at least one sentence, each sentence comprising: a plurality of words, the plurality of words comprising: attribute words;
the characteristic information acquisition module is configured to determine local context characteristic information, global context characteristic information and context characteristic information of attribute words of each word in a target sentence, wherein the target sentence is any sentence in the text to be classified;
The local semantic information acquisition module is configured to determine the local semantic information of the target sentence according to the local context characterization information of each word, the context characterization information of the attribute word and the distance information of each word and the attribute word in the target sentence;
the global semantic information acquisition module is configured to determine global semantic information of each word in the target sentence according to the global context characterization information of each word in the target sentence;
and the emotion classification module is configured to determine an attribute-level emotion classification result of the target sentence according to the local semantic information and the global semantic information of each word in the target sentence.
9. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the text attribute-level emotion classification method based on semantic information of any one of claims 1 to 7 via execution of the executable instructions.
10. A computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the semantic information based text attribute-level emotion classification method of any of claims 1 to 7.
CN202310879054.9A 2023-07-17 2023-07-17 Text attribute-level emotion classification method based on semantic information and related equipment Pending CN116975289A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310879054.9A CN116975289A (en) 2023-07-17 2023-07-17 Text attribute-level emotion classification method based on semantic information and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310879054.9A CN116975289A (en) 2023-07-17 2023-07-17 Text attribute-level emotion classification method based on semantic information and related equipment

Publications (1)

Publication Number Publication Date
CN116975289A true CN116975289A (en) 2023-10-31

Family

ID=88470623

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310879054.9A Pending CN116975289A (en) 2023-07-17 2023-07-17 Text attribute-level emotion classification method based on semantic information and related equipment

Country Status (1)

Country Link
CN (1) CN116975289A (en)

Similar Documents

Publication Publication Date Title
CN108985358B (en) Emotion recognition method, device, equipment and storage medium
CN112015859A (en) Text knowledge hierarchy extraction method and device, computer equipment and readable medium
CN111274815A (en) Method and device for mining entity attention points in text
CN111079432B (en) Text detection method and device, electronic equipment and storage medium
CN116720004B (en) Recommendation reason generation method, device, equipment and storage medium
EP4113357A1 (en) Method and apparatus for recognizing entity, electronic device and storage medium
CN112507628B (en) Risk prediction method and device based on deep bidirectional language model and electronic equipment
CN111625634A (en) Word slot recognition method and device, computer-readable storage medium and electronic device
JP2021106016A (en) Dialog generation method, device, electronic equipment, and medium
CN115238045B (en) Method, system and storage medium for extracting generation type event argument
CN115017425B (en) Location search method, location search device, electronic device, and storage medium
CN111597816A (en) Self-attention named entity recognition method, device, equipment and storage medium
CN111460224B (en) Comment data quality labeling method, comment data quality labeling device, comment data quality labeling equipment and storage medium
CN113918710A (en) Text data processing method and device, electronic equipment and readable storage medium
CN116861363A (en) Multi-mode feature processing method and device, storage medium and electronic equipment
CN113836308B (en) Network big data long text multi-label classification method, system, device and medium
CN115827865A (en) Method and system for classifying objectionable texts by fusing multi-feature map attention mechanism
CN112989024B (en) Method, device and equipment for extracting relation of text content and storage medium
CN116975289A (en) Text attribute-level emotion classification method based on semantic information and related equipment
CN115906838A (en) Text extraction method and device, electronic equipment and storage medium
CN112270179B (en) Entity identification method and device and electronic equipment
CN117131152B (en) Information storage method, apparatus, electronic device, and computer readable medium
CN113836940B (en) Knowledge fusion method and device in electric power metering field and computer equipment
CN117521674B (en) Method, device, computer equipment and storage medium for generating countermeasure information
CN117610569A (en) Operation and maintenance work sheet quality inspection method, device, equipment and medium

Legal Events

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