CN113569559B - Short text entity emotion analysis method, system, electronic equipment and storage medium - Google Patents

Short text entity emotion analysis method, system, electronic equipment and storage medium Download PDF

Info

Publication number
CN113569559B
CN113569559B CN202110839641.6A CN202110839641A CN113569559B CN 113569559 B CN113569559 B CN 113569559B CN 202110839641 A CN202110839641 A CN 202110839641A CN 113569559 B CN113569559 B CN 113569559B
Authority
CN
China
Prior art keywords
emotion
word
entity
text
words
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110839641.6A
Other languages
Chinese (zh)
Other versions
CN113569559A (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.)
Beijing Smart Starlight Information Technology Co ltd
Original Assignee
Beijing Smart Starlight 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 Beijing Smart Starlight Information Technology Co ltd filed Critical Beijing Smart Starlight Information Technology Co ltd
Priority to CN202110839641.6A priority Critical patent/CN113569559B/en
Publication of CN113569559A publication Critical patent/CN113569559A/en
Application granted granted Critical
Publication of CN113569559B publication Critical patent/CN113569559B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2415Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on parametric or probabilistic models, e.g. based on likelihood ratio or false acceptance rate versus a false rejection rate
    • 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/253Grammatical analysis; Style critique
    • 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
    • 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
    • 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/045Combinations of networks
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Molecular Biology (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Biology (AREA)
  • Probability & Statistics with Applications (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Machine Translation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a short text entity emotion analysis method, a system, electronic equipment and a storage medium, wherein the method comprises the following steps: obtaining a fusion word vector of the word according to the word vector, the position vector, the distance vector, the emotion vector, the syntax vector and the lexical vector of each word of the training text; inputting the fusion word vector into a TD_LSTM network to obtain an LSTM output vector of each training text; inputting word vectors corresponding to the entity words into the full-connection layer to obtain coded entity vectors corresponding to each training text; obtaining a correlation matrix according to the LSTM output vector and the coded entity vector, and inputting the correlation matrix into a full connection layer and calculating softmax to obtain an entity emotion probability value corresponding to each training text; optimizing according to the loss function to obtain an optimal short text entity emotion model; and predicting the text to be predicted according to the optimal model to obtain emotion tendencies. And the emotion tendencies of the entity are identified through the coaction of the multidimensional information, so that the accuracy of emotion analysis of the entity is improved.

Description

Short text entity emotion analysis method, system, electronic equipment and storage medium
Technical Field
The invention relates to the field of data processing, in particular to a short text entity emotion analysis method, a system, electronic equipment and a storage medium.
Background
The text entity emotion analysis method mainly comprises dictionary rule-based, machine learning-based and deep learning-based methods.
Dictionary rule-based methods are relatively early methods, and require that emotion dictionaries be continuously accumulated manually or statistically, and rules for distinguishing entity emotion tendencies be summarized manually. The method has the advantages of controllable comparison, strong interpretation, time and labor consumption and weak generalization capability.
The method based on machine learning has better applicability and generalization capability than the method based on dictionary rules. The entity emotion analysis is treated as a classification problem mainly by models such as SVM (support vector machine). The disadvantage is that the construction of features is too dependent, and good features require a lot of engineering work.
Based on the deep learning method, there are CNN, RNN, TD _LSTM, TC_LSTM, BERT and the like, and expression and semantic coding information of a text can be learned from a deeper and wider network structure. The deep learning-based method does not need to construct dictionary rules or characteristic engineering, and semantic information can be well represented based on deep network extraction capability of self-strengthening.
The deep learning-based method only depends on semantic information extracted by the method to carry out emotion analysis, and single semantic feature information causes the defect of inaccurate emotion analysis of entities.
Disclosure of Invention
In view of the above, the embodiments of the present invention provide a short text entity emotion analysis method, system, electronic device and storage medium, so as to solve the disadvantage of inaccurate short text entity emotion analysis in the prior art.
Therefore, the embodiment of the invention provides the following technical scheme:
according to a first aspect, an embodiment of the present invention provides a short text entity emotion analysis method, including:
acquiring word vectors, position vectors, distance vectors, emotion vectors, syntax vectors and lexical vectors corresponding to each word in each training text in a short text training set; the position vector is used for representing the position of the word in the text, the distance vector is used for representing the distance between the word and the emotion words matched with the entity words in the text, the emotion vector is used for representing the emotion tendency of the word, the syntax vector is used for representing the syntax information between the word and the emotion words matched with the entity words in the text, and the lexical vector is used for representing the part-of-speech information of the word;
Obtaining a fusion word vector corresponding to each word in each training text according to the word vector, the position vector, the distance vector, the emotion vector, the syntax vector and the lexical vector corresponding to each word in each training text;
respectively inputting the fusion word vector of each training text into a TD_LSTM network to obtain an LSTM output vector corresponding to each training text;
respectively inputting word vectors corresponding to each entity word into a full-connection layer to obtain coded entity vectors corresponding to each training text;
performing attention calculation on the LSTM output vector corresponding to each training text and the coded entity vector to obtain a correlation coefficient corresponding to each training text;
multiplying the correlation coefficient corresponding to each training text with the coded entity vector to obtain a correlation matrix corresponding to each training text;
inputting a correlation matrix corresponding to each training text into a full-connection layer, and obtaining an entity emotion probability value corresponding to each training text through softmax calculation;
obtaining a loss function according to the entity emotion probability value corresponding to each training text and the entity emotion true value corresponding to each training text, and performing iterative optimization on the loss function to obtain an optimal short text entity emotion model;
Acquiring a text to be predicted;
and inputting the text to be predicted into the optimal short text entity emotion model to obtain an entity emotion tendency result of the text to be predicted.
Optionally, the step of obtaining a word vector, a position vector, a distance vector, an emotion vector, a syntax vector and a lexical vector corresponding to each word in each training text in the short text training set includes:
acquiring a short text training set, wherein the short text training set comprises a plurality of training texts and entity words and emotion words corresponding to each training text;
respectively converting words in each training text into word vectors;
respectively converting the positions of words in each training text in the training text into position vectors;
respectively carrying out distance calculation on words and emotion words in each training text to obtain distance vectors of the words in each training text;
respectively carrying out emotion tendency calculation on words in each training text to obtain emotion vectors of the words in each training text;
respectively carrying out syntactic analysis on each training text through a syntactic analysis tool to obtain syntactic vectors of words in each training text;
and respectively carrying out part-of-speech analysis on each training text through a lexical analysis tool to obtain lexical vectors of words in each training text.
Optionally, the step of calculating the distance between the word and the emotion word in each training text to obtain the distance vector of the word in each training text includes:
when the words in the training text are non-entity words, the distance vectors corresponding to the words in the training text are zero vectors;
when the words in the training texts are entity words, searching is carried out in a preset emotion matching dictionary according to the entity words in each training text, and emotion words corresponding to entity word matching in each training text are determined, wherein the preset emotion matching dictionary comprises a plurality of entities and emotion words matched with the entities;
and respectively carrying out distance calculation on the entity words and the emotion words corresponding to the entity word collocations in each training text to obtain distance vectors of the entity words and the emotion words in each training text.
Optionally, the step of calculating emotion tendencies of the words in each training text to obtain emotion vectors of the words in each training text includes:
when the words in the training text are non-emotion words, the emotion vectors corresponding to the words in the training text are zero vectors;
when the words in the training texts are emotion words, searching is carried out in a preset emotion matching dictionary according to the emotion words in each training text, emotion tendencies corresponding to the emotion words in each training text are determined, and emotion vectors corresponding to the emotion words in each training text are obtained.
Optionally, the step of parsing each training text by a parsing tool to obtain a syntax vector of a word in each short text includes:
when the words in the training text are non-entity words, the syntax vectors corresponding to the words in the training text are zero vectors;
when the words in the training texts are entity words, searching in a preset emotion matching dictionary according to the entity words in each training text, and determining emotion words corresponding to the entity word matching in each training text;
and carrying out syntactic analysis on the entity words and the emotion words corresponding to the entity word collocations in each training text respectively to obtain syntactic vectors of the entity words and the emotion words in each training text.
Optionally, the calculation formula of the fused word vector corresponding to the word in the training text is as follows:
w_a(Dx,wi)=w_t(Dx,wi)+w_p(Dx,wi)+w_d(Dx,wi)+w_s(Dx,wi)
+w_f(Dx,wi)+w_g(Dx,wi)
wherein w_a (Dx, wi) is a fusion word vector corresponding to the i-th word wi in the x-th training text Dx; w_t (Dx, wi) is a word vector corresponding to the i-th word wi in the x-th training text Dx; w_p (Dx, wi) is a position vector corresponding to the i-th word wi in the x-th training text Dx; w_d (Dx, wi) is a distance vector corresponding to the i-th word wi in the x-th training text Dx; w_s (Dx, wi) is the emotion vector corresponding to the i-th word wi in the x-th training text Dx; w_f (Dx, wi) is a syntax vector corresponding to the i-th word wi in the x-th training text Dx; w_g (Dx, wi) is the lexical vector corresponding to the i-th word wi in the x-th training text Dx.
Optionally, after the step of multiplying the correlation coefficient corresponding to each training text by the encoded entity vector to obtain the correlation matrix corresponding to each training text, the method further includes:
acquiring preset cycle times;
and repeatedly calculating the correlation matrix according to the preset cycle times, and further extracting features to obtain an updated correlation matrix.
According to a second aspect, an embodiment of the present invention provides a short text entity emotion analysis system, including:
the first acquisition module is used for acquiring word vectors, position vectors, distance vectors, emotion vectors, syntax vectors and lexical vectors corresponding to each word in each training text in the short text training set; the position vector is used for representing the position of the word in the text, the distance vector is used for representing the distance between the word and the emotion words matched with the entity words in the text, the emotion vector is used for representing the emotion tendency of the word, the syntax vector is used for representing the syntax information between the word and the emotion words matched with the entity words in the text, and the lexical vector is used for representing the part-of-speech information of the word;
the first processing module is used for obtaining a fusion word vector corresponding to each word in each training text according to the word vector, the position vector, the distance vector, the emotion vector, the syntax vector and the lexical vector corresponding to each word in each training text;
The second processing module is used for respectively inputting the fusion word vector of each training text into the TD_LSTM network to obtain an LSTM output vector corresponding to each training text;
the third processing module is used for inputting word vectors corresponding to each entity word into the full-connection layer respectively to obtain coded entity vectors corresponding to each training text;
the fourth processing module is used for respectively carrying out attention calculation on the LSTM output vector corresponding to each training text and the coded entity vector to obtain a correlation coefficient corresponding to each training text;
the fifth processing module is used for multiplying the correlation coefficient corresponding to each training text with the coded entity vector to obtain a correlation matrix corresponding to each training text;
the sixth processing module is used for inputting the correlation matrix corresponding to each training text into the full-connection layer respectively, and obtaining an entity emotion probability value corresponding to each training text through softmax calculation;
the seventh processing module is used for obtaining a loss function according to the entity emotion probability value corresponding to each training text and the entity emotion reality value corresponding to each training text, and carrying out iterative optimization on the loss function to obtain an optimal short text entity emotion model;
The second acquisition module is used for acquiring the text to be predicted;
and the eighth processing module is used for inputting the text to be predicted into the optimal short text entity emotion model to obtain an entity emotion tendency result of the text to be predicted.
Optionally, the first acquisition module includes:
the first acquisition sub-module is used for acquiring a short text training set, wherein the short text training set comprises a plurality of training texts and entity words and emotion words corresponding to each training text;
the first processing submodule is used for respectively converting words in each training text into word vectors;
the second processing submodule is used for respectively converting the positions of words in each training text in the training text into position vectors;
the third processing sub-module is used for respectively carrying out distance calculation on the words and the emotion words in each training text to obtain distance vectors of the words in each training text;
the fourth processing submodule is used for respectively carrying out emotion tendency calculation on the words in each training text to obtain emotion vectors of the words in each training text;
a fifth processing sub-module, configured to parse each training text through a parsing tool to obtain a syntax vector of a word in each training text;
And the sixth processing sub-module is used for respectively carrying out part-of-speech analysis on each training text through a lexical analysis tool to obtain lexical vectors of words in each training text.
Optionally, the third processing sub-module includes:
the first processing unit is used for setting the distance vector corresponding to the word in the training text as a zero vector when the word in the training text is a non-entity word;
the second processing unit is used for searching in a preset emotion matching dictionary according to the entity words in each training text when the words in the training text are entity words, and determining emotion words corresponding to entity word matching in each training text, wherein the preset emotion matching dictionary comprises a plurality of entities and emotion words matched with the entities;
and the third processing unit is used for respectively carrying out distance calculation on the entity words and the emotion words corresponding to the entity word collocation in each training text to obtain distance vectors of the entity words and the emotion words in each training text.
Optionally, the fourth processing sub-module includes:
the fourth processing unit is used for setting the emotion vector corresponding to the word in the training text as a zero vector when the word in the training text is a non-emotion word;
And the fifth processing unit is used for searching in a preset emotion matching dictionary according to the emotion words in each training text when the words in the training text are emotion words, determining emotion tendencies corresponding to the emotion words in each training text and obtaining emotion vectors corresponding to the emotion words in each training text.
Optionally, the fifth processing submodule includes:
the sixth processing unit is used for setting the syntax vector corresponding to the word in the training text as a zero vector when the word in the training text is a non-entity word;
the seventh processing unit is used for searching in a preset emotion matching dictionary according to the entity words in each training text when the words in the training text are entity words, and determining emotion words corresponding to the entity word matching in each training text;
and the eighth processing unit is used for respectively carrying out syntactic analysis on the entity words and the emotion words corresponding to the entity word collocations in each training text to obtain syntactic vectors of the entity words and the emotion words in each training text.
Optionally, the calculation formula of the fused word vector corresponding to the word in the training text is as follows:
w_a(Dx,wi)=w_t(Dx,wi)+w_p(Dx,wi)+w_d(Dx,wi)+w_s(Dx,wi)
+w_f(Dx,wi)+w_g(Dx,wi)
wherein w_a (Dx, wi) is a fusion word vector corresponding to the i-th word wi in the x-th training text Dx; w_t (Dx, wi) is a word vector corresponding to the i-th word wi in the x-th training text Dx; w_p (Dx, wi) is a position vector corresponding to the i-th word wi in the x-th training text Dx; w_d (Dx, wi) is a distance vector corresponding to the i-th word wi in the x-th training text Dx; w_s (Dx, wi) is the emotion vector corresponding to the i-th word wi in the x-th training text Dx; w_f (Dx, wi) is a syntax vector corresponding to the i-th word wi in the x-th training text Dx; w_g (Dx, wi) is the lexical vector corresponding to the i-th word wi in the x-th training text Dx.
Optionally, the method further comprises: the third acquisition module is used for acquiring preset cycle times; and the ninth processing module is used for repeatedly calculating the correlation matrix according to the preset cycle times, and further extracting the characteristics to obtain an updated correlation matrix.
According to a third aspect, an embodiment of the present invention provides an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to cause the at least one processor to perform the short text entity emotion analysis method described in any of the first aspects above.
According to a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the short text entity emotion analysis method described in any one of the above first aspects.
The technical scheme of the embodiment of the invention has the following advantages:
the embodiment of the invention provides a short text entity emotion analysis method, a system, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring word vectors, position vectors, distance vectors, emotion vectors, syntax vectors and lexical vectors corresponding to each word in each training text in a short text training set; the position vector is used for representing the position of the word in the text, the distance vector is used for representing the distance between the word and the emotion words matched with the entity words in the text, the emotion vector is used for representing the emotion tendency of the word, the syntax vector is used for representing the syntax information between the word and the emotion words matched with the entity words in the text, and the lexical vector is used for representing the part-of-speech information of the word; obtaining a fusion word vector corresponding to each word in each training text according to the word vector, the position vector, the distance vector, the emotion vector, the syntax vector and the lexical vector corresponding to each word in each training text; respectively inputting the fusion word vector of each training text into a TD_LSTM network to obtain an LSTM output vector corresponding to each training text; respectively inputting word vectors corresponding to each entity word into a full-connection layer to obtain coded entity vectors corresponding to each training text; performing attention calculation on the LSTM output vector corresponding to each training text and the coded entity vector to obtain a correlation coefficient corresponding to each training text; multiplying the correlation coefficient corresponding to each training text with the coded entity vector to obtain a correlation matrix corresponding to each training text; inputting a correlation matrix corresponding to each training text into a full-connection layer, and obtaining an entity emotion probability value corresponding to each training text through softmax calculation; obtaining a loss function according to the entity emotion probability value corresponding to each training text and the entity emotion true value corresponding to each training text, and performing iterative optimization on the loss function to obtain an optimal short text entity emotion model; acquiring a text to be predicted; and inputting the text to be predicted into the optimal short text entity emotion model to obtain an entity emotion tendency result of the text to be predicted. According to the method, a fusion word vector corresponding to each word in each training text is obtained according to a word vector, a position vector, a distance vector, an emotion vector, a syntax vector and a lexical vector corresponding to each word in each training text, multidimensional information codes are fused in the fusion word vector, information characterization of short texts is enriched, and the relation between an entity and emotion words is enhanced; secondly, inputting the fusion word vector into a TD_LSTM network to obtain an LSTM output vector corresponding to each training text, and inputting the word vector corresponding to the entity word into a full-connection layer to obtain a coded entity vector corresponding to each training text; then, carrying out correlation calculation according to the LSTM output vector and the coded entity vector to obtain a correlation matrix, and inputting the correlation matrix into a full connection layer and softmax to calculate to obtain an entity emotion probability value corresponding to each training text; performing iterative optimization on the model according to the loss function to obtain an optimal short text entity emotion model; and finally, carrying out entity emotion prediction on the text to be predicted according to the optimal short text entity model to obtain emotion tendencies corresponding to the entities in the text to be predicted. The method utilizes the strong coding capability of the deep learning model, the text feature expression is enriched by a plurality of information dimensions, so that the fusion word vector is fused into rich semantic grammar context information, the relation between the entity and the emotion word is strengthened from the knowledge angle and the deep semantic coding angle, the emotion tendency of the entity is identified through the coaction of multidimensional information, the accuracy of emotion analysis of the entity is improved, and the confidence of the emotion tendency of the entity is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present 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 flowchart of a specific example of a short text entity emotion analysis method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a specific example of a short text entity emotion model corresponding to a short text entity emotion analysis method according to an embodiment of the present invention;
FIG. 3 is a block diagram of one specific example of a short text entity emotion analysis system of an embodiment of the present invention;
fig. 4 is a schematic diagram of an electronic device according to an embodiment of the invention.
Detailed Description
The following description of the embodiments of the present invention will be made apparent and fully in view of the accompanying drawings, in which some, but not all embodiments of the invention are shown. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The embodiment of the invention provides a short text entity emotion analysis method, which is shown in fig. 1 and comprises steps S1-S10.
Step S1: acquiring word vectors, position vectors, distance vectors, emotion vectors, syntax vectors and lexical vectors corresponding to each word in each training text in a short text training set; the position vector is used for representing the position of the word in the text, the distance vector is used for representing the distance between the word and the emotion words matched with the entity words in the text, the emotion vector is used for representing the emotion tendency of the word, the syntax vector is used for representing the syntax information between the word and the emotion words matched with the entity words in the text, and the lexical vector is used for representing the part-of-speech information of the word.
In this embodiment, the short text is a text whose word number is within a preset word number, and in this embodiment, the preset word number is set to 350, that is, the text whose word number is within 350 words is a short text, which is only schematically illustrated in this embodiment, and not limited thereto; of course, in other embodiments, the preset word number may also be set to other values, and may be set reasonably according to needs in practical applications.
In this embodiment, the word vector, the position vector, the distance vector, the emotion vector, the syntax vector and the lexical vector corresponding to the word have the same preset dimension. The specific preset dimension may be 256 dimensions, which is only schematically described in the present embodiment, but not limited thereto.
In this embodiment, a plurality of short texts on the internet are obtained, specifically including short texts derived from microblogs, micro messages, forums, comments, and the like, each short text is labeled, all labeled short texts are used as a short text training set, and each labeled short text is one training text in the short text training set. The specific labeling process is that firstly, short text data are acquired; then, carrying out named entity recognition on the short text to obtain a mechanism entity; labeling emotion tendencies (positive, negative and neutral) of each mechanism entity in the text, and obtaining emotion words matched with entity words through statistics. And marking the entity words and the emotion words matched with the entity words through the steps.
Firstly, word segmentation is carried out on the training texts to obtain corresponding words in each training text. And inputting the words in the training text into a word vector model to obtain word vectors corresponding to each word in the training text.
The position of the word in the training text is converted into a position vector corresponding to each word.
Respectively carrying out named entity recognition on the training texts to obtain entity words corresponding to each training text; and searching and comparing the entity words in each training text in a preset emotion matching dictionary to obtain emotion words corresponding to the entity word matching in each training text. And then, respectively calculating the distances between the entity words and the emotion words in the training texts, wherein the distances between the non-entity words and the emotion words in the training texts are 0, and mapping the obtained distances between each word and each emotion word into distance vectors to obtain the distance vectors corresponding to each word in each training text.
The distance between a word and an affective word refers specifically to the relative distance between the word and the affective word. The distance calculation is the relative distance between the word and the emotion word, for example, in the case of "Hua is that the noise reduction effect of the new earphone is particularly good", the distance value between the "particularly" and "good" is 1, and the distance value between the "effect" and "good" is 2. And multiplying the distance value by 0.1, and expanding the distance value to the same dimension as the word vector to obtain the distance vector.
And respectively comparing the words in each training text with emotion words contained in a preset emotion matching dictionary. If the word is an emotion word in the training text, the corresponding emotion word can be matched in a preset emotion matching dictionary, so that emotion tendency corresponding to the emotion word is determined, and emotion vectors corresponding to the emotion word in the training text are obtained; if the word is a non-emotion word in the training text, the matched emotion word cannot be found in the preset emotion matching dictionary, the non-emotion word has no emotion tendency, and the corresponding emotion vector is 0 vector. Thus, emotion vectors corresponding to each word in each training text are obtained.
In this example, the value of emotional tendency is preset, the positive tendency is 1, the negative tendency is-1, and the neutral tendency is 0. The emotion tendency value is expanded to the same dimension as the word vector to obtain an emotion vector, which is also called emotion tendency vector.
And obtaining the syntactic information of the emotion words matched by each word in each training text and the entity words in the training text from a syntactic analysis tool to obtain a syntactic vector. Specifically, the syntactic analysis tool may be a Hadamard LTP; of course, in other embodiments, other syntactic analysis tools in the prior art are also possible, and this is only schematically described in this embodiment, but not limited thereto. Specifically, the syntax information includes a main-predicate relationship and a centering relationship; this is only schematically described in the present embodiment, and is not limited thereto.
And acquiring part-of-speech information of each word in each training text from a lexical analysis tool to obtain lexical vectors. Specifically, the lexical analysis tool may be hundred degrees lac; of course, in other embodiments, other lexical analysis tools in the prior art are also possible, and this is only schematically described in this embodiment, and is not limited thereto. Specifically, the part-of-speech information includes nouns, verbs, proper nouns, adjectives; of course, in other embodiments, the part-of-speech information may also include other part-of-speech attributes, such as adverbs, etc., which are only schematically described in this embodiment, but not limited thereto, and may be reasonably set according to needs.
Step S2: and obtaining a fusion word vector corresponding to each word in each training text according to the word vector, the position vector, the distance vector, the emotion vector, the syntax vector and the lexical vector corresponding to each word in each training text.
In this embodiment, word vectors, position vectors, distance vectors, emotion vectors, syntax vectors and lexical vectors corresponding to each word in each training text are added to obtain a fused word vector corresponding to each word.
Specifically, the calculation formula of the fused word vector corresponding to the word in the training text is as follows. w_a (Dx, wi) =w_t (Dx, wi) +w_p (Dx, wi) +w_d (Dx, wi) +w_s (Dx, wi)
+w_f(Dx,wi)+w_g(Dx,wi)
Wherein w_a (Dx, wi) is a fusion word vector corresponding to the i-th word wi in the x-th training text Dx; w_t (Dx, wi) is a word vector corresponding to the i-th word wi in the x-th training text Dx; w_p (Dx, wi) is a position vector corresponding to the i-th word wi in the x-th training text Dx; w_d (Dx, wi) is a distance vector corresponding to the i-th word wi in the x-th training text Dx; w_s (Dx, wi) is the emotion vector corresponding to the i-th word wi in the x-th training text Dx; w_f (Dx, wi) is a syntax vector corresponding to the i-th word wi in the x-th training text Dx; w_g (Dx, wi) is the lexical vector corresponding to the i-th word wi in the x-th training text Dx.
Of course, in other embodiments, different weight coefficients may be set for each vector, and each vector may be weighted to obtain a fused word vector of each vector.
Step S3: and respectively inputting the fusion word vector of each training text into the TD_LSTM network to obtain the LSTM output vector corresponding to each training text.
In this embodiment, the physical words in the training texts are used as separation points, the physical words and the information on the left sides of the physical words are input into the td_lstm from left to right, the physical words and the information on the right sides of the physical words are input into the td_lstm from right to left, and the context information of the physical words is fused into the physical words, so as to obtain the LSTM output vector corresponding to each training text.
Step S4: and respectively inputting word vectors corresponding to each entity word into the full-connection layer to obtain the coded entity vectors corresponding to each training text.
In this embodiment, word vectors corresponding to each entity word are input into the full-connection layer to perform non-thread activation, so as to obtain encoded entity vectors corresponding to each training text.
Step S5: and respectively carrying out attention calculation on the LSTM output vector corresponding to each training text and the coded entity vector to obtain a correlation coefficient corresponding to each training text.
In this embodiment, the attention calculation is performed on the LSTM output vector containing the context information and output from the td_lstm and the entity vector encoded by the full connection layer, so as to obtain the correlation coefficient of the two.
Step S6: and multiplying the correlation coefficient corresponding to each training text with the coded entity vector to obtain a correlation matrix corresponding to each training text.
In this embodiment, a calculation formula of the correlation matrix corresponding to the training text is as follows.
att_Dx=Attention(w_wx,w_nx)*w_nx
Wherein att_dx is the correlation matrix of the xth training text Dx; w_wx is the LSTM output vector corresponding to the xth training text Dx; w_nx is the coded entity vector corresponding to the xth training text Dx; the Attention (w_wx, w_nx) is a correlation coefficient corresponding to the xth training text Dx.
Step S7: and respectively inputting the correlation matrix corresponding to each training text into a full-connection layer, and obtaining the entity emotion probability value corresponding to each training text through softmax calculation.
In the embodiment, the correlation matrix corresponding to each training text is input into the full-connection layer for dimension mapping; the dimension is determined according to the classification quantity of the emotion tendencies of the entity, if the final emotion tendencies of the entity are classified into 3 types, namely positive tendencies, negative tendencies and neutral tendencies, and the dimension of the correlation matrix is 256, the full-connection matrix maps 256 dimensions to 3 dimensions, and the 3-dimensional result corresponds to the scores of the positive, negative and neutral tendencies. And then, the output of the full-connection layer is subjected to softmax calculation, and the entity emotion tendency score is mapped to a probability interval of 0-1, so that an entity emotion probability value corresponding to each training text is obtained.
Step S8: obtaining a loss function according to the entity emotion probability value corresponding to each training text and the entity emotion true value corresponding to each training text, and carrying out iterative optimization on the loss function to obtain the optimal short text entity emotion model.
In this embodiment, the loss function is calculated by using ECLoss, that is, the difference between the probability value of the entity emotion of the calculation model and the true value of the entity emotion (the true value is determined by the labeling data), and the loss function is iteratively optimized according to the difference, so that the difference is smaller and smaller, and the optimal short text entity emotion model is obtained. And continuously updating parameters, and fitting the predicted value of the model to the true value of the sample as much as possible, so that the error between the predicted value and the true value is reduced, and the optimal model is trained.
Step S9: and obtaining the text to be predicted.
In this embodiment, a text to be predicted is obtained according to a prediction task.
Step S10: and inputting the text to be predicted into the optimal short text entity emotion model to obtain an entity emotion tendency result of the text to be predicted.
In this embodiment, a text to be predicted is input into an optimal model to perform entity emotion prediction, and an entity emotion tendency result output by an optimal short text entity emotion model is obtained, where the entity emotion tendency result includes positive tendency, negative tendency and neutral tendency.
For example, "Hua Ji Xin Ji Zhu Ding is particularly good in noise reduction effect" -the emotional tendency of the entity is positive tendency.
According to the word vector, the position vector, the distance vector, the emotion vector, the syntax vector and the lexical vector corresponding to each word in each training text, the fusion word vector corresponding to each word in each training text is obtained, multidimensional information codes are fused in the fusion word vector, the information representation of short texts is enriched, and the relation between entities and emotion words is enhanced; secondly, inputting the fusion word vector into a TD_LSTM network to obtain an LSTM output vector corresponding to each training text, and inputting the word vector corresponding to the entity word into a full-connection layer to obtain a coded entity vector corresponding to each training text; then, carrying out correlation calculation according to the LSTM output vector and the coded entity vector to obtain a correlation matrix, and inputting the correlation matrix into a full connection layer and softmax to calculate to obtain an entity emotion probability value corresponding to each training text; performing iterative optimization on the model according to the loss function to obtain an optimal short text entity emotion model; and finally, carrying out entity emotion prediction on the text to be predicted according to the optimal short text entity model to obtain emotion tendencies corresponding to the entities in the text to be predicted. The method utilizes the strong coding capability of the deep learning model, the text feature expression is enriched by a plurality of information dimensions, so that the fusion word vector is fused into rich semantic grammar context information, the relation between the entity and the emotion word is strengthened from the knowledge angle and the deep semantic coding angle, the emotion tendency of the entity is identified through the coaction of multidimensional information, the accuracy of emotion analysis of the entity is improved, and the confidence of the emotion tendency of the entity is improved.
Compared with a single deep learning method, the method integrates information of rich knowledge layers on the basis of the deep learning method, and greatly enhances the richness and the accuracy of semantic characterization, so that better effects can be obtained compared with the single deep learning method.
As an exemplary embodiment, step S1 includes steps S101-S107 in the step of obtaining a word vector, a position vector, a distance vector, an emotion vector, a syntax vector, and a lexical vector corresponding to each word in each training text in the short text training set.
Step S101: and acquiring a short text training set, wherein the short text training set comprises a plurality of training texts and entity words and emotion words corresponding to each training text.
In this embodiment, the short text training set includes a plurality of short text training texts, and entity words and emotion words contained in each training text. Specifically, the named entity recognition method in the prior art can be used for recognizing the named entities of the training texts to obtain the named entities corresponding to each training text, namely the entity words corresponding to the training texts. And extracting emotion words from the training texts by using an emotion word extraction method in the prior art to obtain emotion words corresponding to each training text. Specifically, the emotion words are obtained from an emotion dictionary.
Step S102: words in each training text are converted into word vectors respectively.
In this embodiment, a word2vec word vector model with a preset dimension is trained in advance based on multi-domain corpus, and word vectors are obtained from the model. Specifically, the preset dimension is set to 256 dimensions, and of course, in other embodiments, the preset dimension may also be set to other values, and may be set reasonably according to needs. The method for word segmentation of each training text in the training texts comprises the steps of word segmentation, wherein a specific word segmentation method can be that words in the training texts obtained after word segmentation are input into a word2vec word vector model to be converted into word vectors corresponding to the words, and the word vectors represent word context semantic information.
Step S103: the positions of words in each training text in the training text are converted into position vectors respectively.
In this embodiment, the position of the word in the training text is converted into a position vector, which is used to represent the position-coded information of the word. In this embodiment, the dimension of the position vector is also a preset dimension, and specifically, the preset dimension is set to 256 dimensions.
In this embodiment, sine and cosine position codes are used, and the position information of the words in the training text is encoded by using the linear variation characteristics of sine and cosine functions, so as to obtain the position vectors corresponding to the words.
Step S104: and respectively carrying out distance calculation on the words and the emotion words in each training text to obtain distance vectors of the words in each training text.
In this embodiment, each word in the training text is calculated in distance with the emotion word corresponding to the training text, so as to obtain a distance vector corresponding to each word in the training text.
Specifically, the distance calculation is a relative distance between the calculated word and the emotion word, for example, in "Hua is that the noise reduction effect of the new earphone is particularly good", the distance value between the "particularly" and "good" is 1, and the distance value between the "effect" and "good" is 2. After multiplying the distance value by 0.1, it is extended to the same dimension as the word vector.
Step S105: and respectively carrying out emotion tendency calculation on the words in each training text to obtain emotion vectors of the words in each training text.
In this embodiment, each word in each training text is compared with emotion words contained in a preset emotion matching dictionary. If the word is in the preset emotion matching dictionary, obtaining an emotion vector corresponding to the word according to emotion tendencies corresponding to the word in the preset emotion matching dictionary; if the word is not in the preset emotion matching dictionary, the emotion vector corresponding to the word is set to be a 0 vector.
The preset emotion matching dictionary comprises emotion words and emotion tendencies. The collocation can be obtained according to the statistical information.
Such as: friendly-front
Failure-negative
Step S106: and respectively carrying out syntactic analysis on each training text through a syntactic analysis tool to obtain the syntactic vector of the word in each training text.
In this embodiment, syntax information of emotion words matched by each word in each training text and entity words in the corresponding training text is obtained from a grammar analysis tool, and a syntax vector is obtained according to the syntax information of the words. Specifically, the syntax information includes a main-predicate relationship, a centering relationship, and the like.
Step S107: and respectively carrying out part-of-speech analysis on each training text through a lexical analysis tool to obtain lexical vectors of words in each training text.
In this embodiment, the part-of-speech analysis tool is used to segment each word in each training text to obtain part-of-speech information of each word in each training text, and the lexical vector corresponding to the word is obtained according to the part-of-speech information of the word. The specific process is that a part-of-speech vector matrix is obtained by randomly initializing a part-of-speech set, and a lexical vector is obtained by inquiring the part-of-speech vector matrix according to part-of-speech information of the word.
According to the short text training set, the multidimensional information vector corresponding to each training text is obtained, so that multidimensional information is encoded into the fusion word vector of the short text later, and the information representation of the short text is enriched.
As an exemplary embodiment, step S104 includes steps S1041-S1043 in the step of calculating the distance between the word and the emotion word in each training text, respectively, to obtain a distance vector of the word in each training text.
Step S1041: when the words in the training text are non-entity words, the distance vector corresponding to the words in the training text is zero vector.
In this embodiment, the distance vector is used to represent the distance between the word and the emotion word collocated with the entity word in the text. If the word is a non-entity word, the distance corresponding to the word does not need to be considered, and the distance vector corresponding to the non-entity word is set to be a 0 vector for facilitating subsequent unified calculation.
Step S1042: when the words in the training texts are entity words, searching is carried out in a preset emotion matching dictionary according to the entity words in each training text, and emotion words corresponding to entity word matching in each training text are determined, wherein the preset emotion matching dictionary comprises a plurality of entities and emotion words matched with the entities.
In this embodiment, if the word in the training text is an entity word, the distance between the entity word and the emotion word needs to be considered. Firstly, matching emotion words matched with entity words through a preset emotion matching dictionary.
And counting to obtain the co-occurrence probability of the entity words and the emotion words from the training corpus, and taking the entity words and the emotion words with the co-occurrence probability larger than the co-occurrence threshold value as a group of collocations to be placed into an emotion collocation dictionary. In this embodiment, the value of the co-occurrence threshold is 0.75, which is only schematically described in this embodiment, but not limited thereto; in other embodiments, the specific co-occurrence threshold value may be set reasonably according to actual needs.
Step S1043: and respectively carrying out distance calculation on the entity words and the emotion words corresponding to the entity word collocations in each training text to obtain distance vectors of the entity words and the emotion words in each training text.
In this embodiment, a distance calculation is performed on the entity word and the emotion word corresponding to the entity word collocation in each training text, so as to obtain a distance between the entity word and the emotion word corresponding to the collocation, and a distance vector is obtained according to the distance between the entity word and the emotion word.
The distance vector corresponding to the non-entity word is set as 0 vector, and the distance vector of the entity word and the matched emotion word is obtained according to the distance between the entity word and the emotion word, so that the relation between the entity and the emotion word is enhanced, and the effect of entity emotion analysis is improved.
As an exemplary embodiment, step S105 includes steps S1051-S1052 in the step of calculating emotion tendencies of words in each training text and obtaining emotion vectors of words in each training text.
Step S1051: when the words in the training text are non-emotion words, the emotion vectors corresponding to the words in the training text are null vectors.
In this embodiment, if the word in the training text is a non-emotion word, the emotion tendency of the word is not required to be considered, and in order to facilitate subsequent unified calculation, the emotion vector corresponding to the non-emotion word is set to be a 0 vector.
Step S1052: when the words in the training texts are emotion words, searching is carried out in a preset emotion matching dictionary according to the emotion words in each training text, emotion tendencies corresponding to the emotion words in each training text are determined, and emotion vectors corresponding to the emotion words in each training text are obtained.
In this embodiment, when a word in the training text is an emotion word, the emotion tendencies corresponding to the word need to be considered. And matching the corresponding emotion words according to a preset emotion matching dictionary, and obtaining emotion tendencies corresponding to the emotion words. The emotion tendencies corresponding to the emotion words in the preset emotion matching dictionary are counted based on a large amount of corpus.
Setting the emotion vector corresponding to the non-emotion word as a 0 vector, obtaining emotion tendencies corresponding to the emotion word according to a preset emotion matching dictionary, further obtaining emotion vectors corresponding to the emotion word, weakening the emotion tendencies of the non-emotion word and improving the confidence level of entity emotion.
As an exemplary embodiment, step S106 includes steps S1061-S1063 in the step of parsing each training text by a parsing tool to obtain a syntax vector of a word in each training text.
Step S1061: when the words in the training text are non-entity words, the syntax vector corresponding to the words in the training text is zero vector.
In this embodiment, the syntax vector is used to represent syntax information between words and emotion words collocated with entity words in the text. If the word in the training text is a non-entity word, the syntactic information of the word is not needed to be considered, and in order to facilitate subsequent unified calculation, the syntactic vector corresponding to the non-entity word is set to be a 0 vector.
Step S1062: when the words in the training texts are entity words, searching is carried out in a preset emotion matching dictionary according to the entity words in each training text, and emotion words corresponding to the entity word matching in each training text are determined.
In this embodiment, the words in the training text are entity words, and emotion words matched with the entity words are matched in a preset emotion matching dictionary.
Step S1063: and carrying out syntactic analysis on the entity words and the emotion words corresponding to the entity word collocations in each training text respectively to obtain syntactic vectors of the entity words and the emotion words in each training text.
In this embodiment, syntactic analysis is performed according to the entity words and emotion words corresponding to the entity word collocation, so as to obtain syntactic vectors of the entity words and emotion words.
The specific syntactic analysis may be implemented by means of syntactic analysis tools in the prior art. The syntactic analysis tool may be a Hadamard LTP; of course, in other embodiments, other syntactic analysis tools in the prior art, such as Stanford CoreNLP, may be used, and may be appropriately selected according to the need.
The method comprises the steps of setting a syntax vector corresponding to a non-entity word as a 0 vector, obtaining the syntax vectors of the entity word and the matched emotion word according to the syntax information of the entity word and the emotion word, strengthening the relation between the entity and the emotion word, improving the effect of entity emotion analysis and improving the confidence coefficient of entity emotion.
As an exemplary embodiment, step S6 further includes steps S11-S12 after the step of multiplying the correlation coefficient corresponding to each training text with the encoded entity vector to obtain the correlation matrix corresponding to each training text.
Step S11: and obtaining the preset cycle times.
Specifically, the preset cycle times are determined according to task requirements, data conditions and experimental results. In this embodiment, the preset cycle number is set to 6 times, however, in other embodiments, the preset cycle number may also be set to other values, such as 5 times or 7 times, and the like, and may be set reasonably according to needs.
Step S12: and repeatedly calculating the correlation matrix according to the preset cycle times, and further extracting features to obtain an updated correlation matrix.
In this embodiment, the correlation matrix is repeatedly calculated according to the preset cycle times, and features are extracted again on the basis of the features, so as to realize the extraction of the multi-layer features.
Through the steps, multi-layer feature extraction is carried out on the multidimensional information vector, the confidence of the correlation matrix is improved, the output of the short text entity emotion model is more accurate, and the accuracy of entity emotion analysis is improved.
In this embodiment, a block diagram of a specific example of the emotion model of the short text entity is shown in fig. 2.
In this embodiment, the multidimensional information is input into the td_lstm model to perform context semantic coding, and after vector representation with both context information and knowledge information is obtained, attention is calculated with the vector encoded by the full connection layer, so as to obtain the correlation between the entity and the context. The process can encode which emotion words in the entity are more relevant, and the emotion tendency information in the knowledge base is combined, so that the emotion analysis effect of the entity can be greatly improved. The method uses knowledge base information and does not depend on knowledge base information completely. When knowledge base information is not rich enough, the model can exert its strong context semantic coding capability. When the knowledge base information is rich enough, the knowledge base information can assist the model in improving the discrimination capability of the model.
The embodiment also provides a short text entity emotion analysis system, which is used for realizing the embodiment and the preferred implementation, and the description is omitted. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the system described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
The embodiment also provides a short text entity emotion analysis system, as shown in fig. 3, including:
the first acquisition module 1 is used for acquiring word vectors, position vectors, distance vectors, emotion vectors, syntax vectors and lexical vectors corresponding to each word in each training text in the short text training set; the position vector is used for representing the position of the word in the text, the distance vector is used for representing the distance between the word and the emotion words matched with the entity words in the text, the emotion vector is used for representing the emotion tendency of the word, the syntax vector is used for representing the syntax information between the word and the emotion words matched with the entity words in the text, and the lexical vector is used for representing the part-of-speech information of the word;
The first processing module 2 is configured to obtain a fused word vector corresponding to each word in each training text according to the word vector, the position vector, the distance vector, the emotion vector, the syntax vector and the lexical vector corresponding to each word in each training text;
the second processing module 3 is configured to input the fused word vector of each training text into the td_lstm network to obtain an LSTM output vector corresponding to each training text;
the third processing module 4 is configured to input word vectors corresponding to each entity word into the full-connection layer, so as to obtain encoded entity vectors corresponding to each training text;
the fourth processing module 5 is configured to perform attention computation on the LSTM output vector and the encoded entity vector corresponding to each training text, so as to obtain a correlation coefficient corresponding to each training text;
a fifth processing module 6, configured to multiply the correlation coefficient corresponding to each training text with the encoded entity vector to obtain a correlation matrix corresponding to each training text;
the sixth processing module 7 is configured to input the correlation matrix corresponding to each training text into the full-connection layer, and calculate the entity emotion probability value corresponding to each training text through softmax;
The seventh processing module 8 is configured to obtain a loss function according to the entity emotion probability value corresponding to each training text and the entity emotion reality value corresponding to each training text, and perform iterative optimization on the loss function to obtain an optimal short text entity emotion model;
a second obtaining module 9, configured to obtain a text to be predicted;
and the eighth processing module 10 is configured to input the text to be predicted into the optimal short text entity emotion model, and obtain an entity emotion tendency result of the text to be predicted.
As an exemplary embodiment, the first acquisition module includes:
the first acquisition sub-module is used for acquiring a short text training set, wherein the short text training set comprises a plurality of training texts and entity words and emotion words corresponding to each training text;
the first processing submodule is used for respectively converting words in each training text into word vectors;
the second processing submodule is used for respectively converting the positions of words in each training text in the training text into position vectors;
the third processing sub-module is used for respectively carrying out distance calculation on the words and the emotion words in each training text to obtain distance vectors of the words in each training text;
The fourth processing submodule is used for respectively carrying out emotion tendency calculation on the words in each training text to obtain emotion vectors of the words in each training text;
a fifth processing sub-module, configured to parse each training text through a parsing tool to obtain a syntax vector of a word in each training text;
and the sixth processing sub-module is used for respectively carrying out part-of-speech analysis on each training text through a lexical analysis tool to obtain lexical vectors of words in each training text.
As an exemplary embodiment, the third processing sub-module includes:
the first processing unit is used for setting the distance vector corresponding to the word in the training text as a zero vector when the word in the training text is a non-entity word;
the second processing unit is used for searching in a preset emotion matching dictionary according to the entity words in each training text when the words in the training text are entity words, and determining emotion words corresponding to entity word matching in each training text, wherein the preset emotion matching dictionary comprises a plurality of entities and emotion words matched with the entities;
and the third processing unit is used for respectively carrying out distance calculation on the entity words and the emotion words corresponding to the entity word collocation in each training text to obtain distance vectors of the entity words and the emotion words in each training text.
As an exemplary embodiment, the fourth processing sub-module includes:
the fourth processing unit is used for setting the emotion vector corresponding to the word in the training text as a zero vector when the word in the training text is a non-emotion word;
and the fifth processing unit is used for searching in a preset emotion matching dictionary according to the emotion words in each training text when the words in the training text are emotion words, determining emotion tendencies corresponding to the emotion words in each training text and obtaining emotion vectors corresponding to the emotion words in each training text.
As an exemplary embodiment, the fifth processing submodule includes:
the sixth processing unit is used for setting the syntax vector corresponding to the word in the training text as a zero vector when the word in the training text is a non-entity word;
the seventh processing unit is used for searching in a preset emotion matching dictionary according to the entity words in each training text when the words in the training text are entity words, and determining emotion words corresponding to the entity word matching in each training text;
and the eighth processing unit is used for respectively carrying out syntactic analysis on the entity words and the emotion words corresponding to the entity word collocations in each training text to obtain syntactic vectors of the entity words and the emotion words in each training text.
As an exemplary embodiment, the calculation formula of the fused word vector corresponding to the word in the training text is as follows:
w_a(Dx,wi)=w_t(Dx,wi)+w_p(Dx,wi)+w_d(Dx,wi)+w_s(Dx,wi)
+w_f(Dx,wi)+w_g(Dx,wi)
wherein w_a (Dx, wi) is a fusion word vector corresponding to the i-th word wi in the x-th training text Dx; w_t (Dx, wi) is a word vector corresponding to the i-th word wi in the x-th training text Dx; w_p (Dx, wi) is a position vector corresponding to the i-th word wi in the x-th training text Dx; w_d (Dx, wi) is a distance vector corresponding to the i-th word wi in the x-th training text Dx; w_s (Dx, wi) is the emotion vector corresponding to the i-th word wi in the x-th training text Dx; w_f (Dx, wi) is a syntax vector corresponding to the i-th word wi in the x-th training text Dx; w_g (Dx, wi) is the lexical vector corresponding to the i-th word wi in the x-th training text Dx.
As an exemplary embodiment, further comprising: the third acquisition module is used for acquiring preset cycle times; and the ninth processing module is used for repeatedly calculating the correlation matrix according to the preset cycle times to obtain an updated correlation matrix.
The short text entity emotion analysis system of the present embodiment is presented in the form of functional units, where the units refer to ASIC circuits, processors and memories executing one or more software or fixed programs, and/or other devices that can provide the above-described functionality.
Further functional descriptions of the above respective modules are the same as those of the above corresponding embodiments, and are not repeated here.
The embodiment of the invention also provides an electronic device, as shown in fig. 4, which includes one or more processors 71 and a memory 72, and in fig. 4, one processor 71 is taken as an example.
The controller may further include: an input device 73 and an output device 74.
The processor 71, memory 72, input device 73 and output device 74 may be connected by a bus or otherwise, for example in fig. 4.
The processor 71 may be a central processing unit (Central Processing Unit, CPU). The processor 71 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations of the above. A general purpose processor may be a microprocessor or any conventional processor or the like.
The memory 72 is used as a non-transitory computer readable storage medium for storing non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the short text entity emotion analysis method in the embodiments of the present application. The processor 71 executes various functional applications of the server and data processing, i.e., implements the short text entity emotion analysis method of the above-described method embodiments, by running non-transitory software programs, instructions, and modules stored in the memory 72.
Memory 72 may include a storage program area that may store an operating system, at least one application program required for functionality, and a storage data area; the storage data area may store data created according to the use of a processing device operated by the server, or the like. In addition, memory 72 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 72 may optionally include memory located remotely from processor 71, such remote memory being connectable to the network connection device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 73 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the processing device of the server. The output device 74 may include a display device such as a display screen.
One or more modules are stored in the memory 72 that, when executed by the one or more processors 71, perform the method shown in fig. 1.
It will be appreciated by those skilled in the art that implementing all or part of the above-described embodiment method may be implemented by a computer program indicating relevant hardware, and the executed program may be stored in a computer readable storage medium, where the program may include the above-described embodiment method of short text entity emotion analysis. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a Flash Memory (Flash Memory), a Hard Disk (HDD), or a Solid State Drive (SSD); the storage medium may also comprise a combination of memories of the kind described above.
Although embodiments of the present invention have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope of the invention as defined by the appended claims.

Claims (10)

1. A method for emotion analysis of a short text entity, comprising:
acquiring word vectors, position vectors, distance vectors, emotion vectors, syntax vectors and lexical vectors corresponding to each word in each training text in a short text training set; the position vector is used for representing the position of the word in the text, the distance vector is used for representing the distance between the word and the emotion words matched with the entity words in the text, the emotion vector is used for representing the emotion tendency of the word, the syntax vector is used for representing the syntax information between the word and the emotion words matched with the entity words in the text, and the lexical vector is used for representing the part-of-speech information of the word;
Obtaining a fusion word vector corresponding to each word in each training text according to the word vector, the position vector, the distance vector, the emotion vector, the syntax vector and the lexical vector corresponding to each word in each training text;
respectively inputting the fusion word vector of each training text into a TD_LSTM network to obtain an LSTM output vector corresponding to each training text;
respectively inputting word vectors corresponding to each entity word into a full-connection layer to obtain coded entity vectors corresponding to each training text;
performing attention calculation on the LSTM output vector corresponding to each training text and the coded entity vector to obtain a correlation coefficient corresponding to each training text;
multiplying the correlation coefficient corresponding to each training text with the coded entity vector to obtain a correlation matrix corresponding to each training text;
inputting a correlation matrix corresponding to each training text into a full-connection layer, and obtaining an entity emotion probability value corresponding to each training text through softmax calculation;
obtaining a loss function according to the entity emotion probability value corresponding to each training text and the entity emotion true value corresponding to each training text, and performing iterative optimization on the loss function to obtain an optimal short text entity emotion model;
Acquiring a text to be predicted;
and inputting the text to be predicted into the optimal short text entity emotion model to obtain an entity emotion tendency result of the text to be predicted.
2. The short text entity emotion analysis method of claim 1, wherein the step of obtaining word vectors, position vectors, distance vectors, emotion vectors, syntax vectors, and lexical vectors corresponding to each word in each training text in a short text training set comprises:
acquiring a short text training set, wherein the short text training set comprises a plurality of training texts and entity words and emotion words corresponding to each training text;
respectively converting words in each training text into word vectors;
respectively converting the positions of words in each training text in the training text into position vectors;
respectively carrying out distance calculation on words and emotion words in each training text to obtain distance vectors of the words in each training text;
respectively carrying out emotion tendency calculation on words in each training text to obtain emotion vectors of the words in each training text;
respectively carrying out syntactic analysis on each training text through a syntactic analysis tool to obtain syntactic vectors of words in each training text;
And respectively carrying out part-of-speech analysis on each training text through a lexical analysis tool to obtain lexical vectors of words in each training text.
3. The emotion analysis method of a short text entity according to claim 2, wherein the step of obtaining a distance vector of a word in each training text by respectively performing distance calculation on the word and the emotion word in each training text comprises:
when the words in the training text are non-entity words, the distance vectors corresponding to the words in the training text are zero vectors;
when the words in the training texts are entity words, searching is carried out in a preset emotion matching dictionary according to the entity words in each training text, and emotion words corresponding to entity word matching in each training text are determined, wherein the preset emotion matching dictionary comprises a plurality of entities and emotion words matched with the entities;
and respectively carrying out distance calculation on the entity words and the emotion words corresponding to the entity word collocations in each training text to obtain distance vectors of the entity words and the emotion words in each training text.
4. The emotion analysis method of short text entity according to claim 2, wherein the step of calculating emotion tendencies of words in each training text to obtain emotion vectors of words in each training text comprises:
When the words in the training text are non-emotion words, the emotion vectors corresponding to the words in the training text are zero vectors;
when the words in the training texts are emotion words, searching is carried out in a preset emotion matching dictionary according to the emotion words in each training text, emotion tendencies corresponding to the emotion words in each training text are determined, and emotion vectors corresponding to the emotion words in each training text are obtained.
5. The emotion analysis method of short text entity according to claim 2, wherein the step of obtaining a syntax vector of a word in each short text by performing syntax analysis on each training text by a syntax analysis tool comprises:
when the words in the training text are non-entity words, the syntax vectors corresponding to the words in the training text are zero vectors;
when the words in the training texts are entity words, searching in a preset emotion matching dictionary according to the entity words in each training text, and determining emotion words corresponding to the entity word matching in each training text;
and carrying out syntactic analysis on the entity words and the emotion words corresponding to the entity word collocations in each training text respectively to obtain syntactic vectors of the entity words and the emotion words in each training text.
6. The emotion analysis method of short text entity of claim 2,
the calculation formula of the fusion word vector corresponding to the word in the training text is as follows:
w_a(Dx,wi)=w_t(Dx,wi)+w_p(Dx,wi)+w_d(Dx,wi)+w_s(Dx,wi)+w_f(Dx,wi)+w_g(Dx,wi)
wherein w_a (Dx, wi) is a fusion word vector corresponding to the i-th word wi in the x-th training text Dx; w_t (Dx, wi) is a word vector corresponding to the i-th word wi in the x-th training text Dx; w_p (Dx, wi) is a position vector corresponding to the i-th word wi in the x-th training text Dx; w_d (Dx, wi) is a distance vector corresponding to the i-th word wi in the x-th training text Dx; w_s (Dx, wi) is the emotion vector corresponding to the i-th word wi in the x-th training text Dx; w_f (Dx, wi) is a syntax vector corresponding to the i-th word wi in the x-th training text Dx; w_g (Dx, wi) is the lexical vector corresponding to the i-th word wi in the x-th training text Dx.
7. The short text entity emotion analysis method of any one of claims 1 to 6, further comprising, after the step of multiplying the correlation coefficient corresponding to each training text by the encoded entity vector to obtain the correlation matrix corresponding to each training text, respectively:
acquiring preset cycle times;
and repeatedly calculating the correlation matrix according to the preset cycle times, and further extracting features to obtain an updated correlation matrix.
8. A short text entity emotion analysis system, comprising:
the first acquisition module is used for acquiring word vectors, position vectors, distance vectors, emotion vectors, syntax vectors and lexical vectors corresponding to each word in each training text in the short text training set; the position vector is used for representing the position of the word in the text, the distance vector is used for representing the distance between the word and the emotion words matched with the entity words in the text, the emotion vector is used for representing the emotion tendency of the word, the syntax vector is used for representing the syntax information between the word and the emotion words matched with the entity words in the text, and the lexical vector is used for representing the part-of-speech information of the word;
the first processing module is used for obtaining a fusion word vector corresponding to each word in each training text according to the word vector, the position vector, the distance vector, the emotion vector, the syntax vector and the lexical vector corresponding to each word in each training text;
the second processing module is used for respectively inputting the fusion word vector of each training text into the TD_LSTM network to obtain an LSTM output vector corresponding to each training text;
the third processing module is used for inputting word vectors corresponding to each entity word into the full-connection layer respectively to obtain coded entity vectors corresponding to each training text;
The fourth processing module is used for respectively carrying out attention calculation on the LSTM output vector corresponding to each training text and the coded entity vector to obtain a correlation coefficient corresponding to each training text;
the fifth processing module is used for multiplying the correlation coefficient corresponding to each training text with the coded entity vector to obtain a correlation matrix corresponding to each training text;
the sixth processing module is used for inputting the correlation matrix corresponding to each training text into the full-connection layer respectively, and obtaining an entity emotion probability value corresponding to each training text through softmax calculation;
the seventh processing module is used for obtaining a loss function according to the entity emotion probability value corresponding to each training text and the entity emotion reality value corresponding to each training text, and carrying out iterative optimization on the loss function to obtain an optimal short text entity emotion model;
the second acquisition module is used for acquiring the text to be predicted;
and the eighth processing module is used for inputting the text to be predicted into the optimal short text entity emotion model to obtain an entity emotion tendency result of the text to be predicted.
9. An electronic device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores a computer program executable by the at least one processor to cause the at least one processor to perform the short text entity emotion analysis method of any of claims 1-7.
10. A computer readable storage medium having stored thereon computer instructions for causing the computer to perform the short text entity emotion analysis method of any of claims 1-7.
CN202110839641.6A 2021-07-23 2021-07-23 Short text entity emotion analysis method, system, electronic equipment and storage medium Active CN113569559B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110839641.6A CN113569559B (en) 2021-07-23 2021-07-23 Short text entity emotion analysis method, system, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110839641.6A CN113569559B (en) 2021-07-23 2021-07-23 Short text entity emotion analysis method, system, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113569559A CN113569559A (en) 2021-10-29
CN113569559B true CN113569559B (en) 2024-02-02

Family

ID=78167028

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110839641.6A Active CN113569559B (en) 2021-07-23 2021-07-23 Short text entity emotion analysis method, system, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113569559B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114153973A (en) * 2021-12-07 2022-03-08 内蒙古工业大学 Mongolian multi-mode emotion analysis method based on T-M BERT pre-training model
CN115544260B (en) * 2022-12-05 2023-04-25 湖南工商大学 Contrast optimization coding and decoding method for text emotion analysis

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109522548A (en) * 2018-10-26 2019-03-26 天津大学 A kind of text emotion analysis method based on two-way interactive neural network
CN110110083A (en) * 2019-04-17 2019-08-09 华东理工大学 A kind of sensibility classification method of text, device, equipment and storage medium
WO2019174422A1 (en) * 2018-03-16 2019-09-19 北京国双科技有限公司 Method for analyzing entity association relationship, and related apparatus
WO2019174423A1 (en) * 2018-03-16 2019-09-19 北京国双科技有限公司 Entity sentiment analysis method and related apparatus
CN111090724A (en) * 2019-11-21 2020-05-01 新华智云科技有限公司 Entity extraction method capable of judging relevance between text content and entity based on deep learning
CN111522936A (en) * 2020-04-24 2020-08-11 上海智臻智能网络科技股份有限公司 Intelligent customer service dialogue reply generation method and device containing emotion and electronic equipment
WO2020238985A1 (en) * 2019-05-31 2020-12-03 中国科学院深圳先进技术研究院 Model training method, dialogue generation method, apparatus and device, and storage medium
CN112100384A (en) * 2020-11-10 2020-12-18 北京智慧星光信息技术有限公司 Data viewpoint extraction method, device, equipment and storage medium
CN112347965A (en) * 2020-11-16 2021-02-09 浙江大学 Video relation detection method and system based on space-time diagram
JP2021033994A (en) * 2019-08-20 2021-03-01 株式会社Nttドコモ Text processing method, apparatus, device and computer readable storage medium
CN113139060A (en) * 2021-05-13 2021-07-20 杭州网易再顾科技有限公司 Text analysis model training and text analysis method, medium, device and equipment

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019174422A1 (en) * 2018-03-16 2019-09-19 北京国双科技有限公司 Method for analyzing entity association relationship, and related apparatus
WO2019174423A1 (en) * 2018-03-16 2019-09-19 北京国双科技有限公司 Entity sentiment analysis method and related apparatus
CN109522548A (en) * 2018-10-26 2019-03-26 天津大学 A kind of text emotion analysis method based on two-way interactive neural network
CN110110083A (en) * 2019-04-17 2019-08-09 华东理工大学 A kind of sensibility classification method of text, device, equipment and storage medium
WO2020238985A1 (en) * 2019-05-31 2020-12-03 中国科学院深圳先进技术研究院 Model training method, dialogue generation method, apparatus and device, and storage medium
JP2021033994A (en) * 2019-08-20 2021-03-01 株式会社Nttドコモ Text processing method, apparatus, device and computer readable storage medium
CN111090724A (en) * 2019-11-21 2020-05-01 新华智云科技有限公司 Entity extraction method capable of judging relevance between text content and entity based on deep learning
CN111522936A (en) * 2020-04-24 2020-08-11 上海智臻智能网络科技股份有限公司 Intelligent customer service dialogue reply generation method and device containing emotion and electronic equipment
CN112100384A (en) * 2020-11-10 2020-12-18 北京智慧星光信息技术有限公司 Data viewpoint extraction method, device, equipment and storage medium
CN112347965A (en) * 2020-11-16 2021-02-09 浙江大学 Video relation detection method and system based on space-time diagram
CN113139060A (en) * 2021-05-13 2021-07-20 杭州网易再顾科技有限公司 Text analysis model training and text analysis method, medium, device and equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于Word2Vec新词识别的评论情感分析***的研究与实现;***;《中国优秀硕士学位论文全文数据库-信息科技辑》(第01期);I138-5111 *

Also Published As

Publication number Publication date
CN113569559A (en) 2021-10-29

Similar Documents

Publication Publication Date Title
US10706084B2 (en) Method and device for parsing question in knowledge base
CN106502985B (en) neural network modeling method and device for generating titles
CN108363790B (en) Method, device, equipment and storage medium for evaluating comments
WO2023065544A1 (en) Intention classification method and apparatus, electronic device, and computer-readable storage medium
CN111859987B (en) Text processing method, training method and device for target task model
CN110737758A (en) Method and apparatus for generating a model
CN112101041B (en) Entity relationship extraction method, device, equipment and medium based on semantic similarity
AU2017408800B2 (en) Method and system of mining information, electronic device and readable storable medium
CN108108426B (en) Understanding method and device for natural language question and electronic equipment
CN111144507B (en) Emotion analysis model pre-training method and device and electronic equipment
WO2021042516A1 (en) Named-entity recognition method and device, and computer readable storage medium
CN113569559B (en) Short text entity emotion analysis method, system, electronic equipment and storage medium
CN112395385B (en) Text generation method and device based on artificial intelligence, computer equipment and medium
CN110413787B (en) Text clustering method, device, terminal and storage medium
WO2020232898A1 (en) Text classification method and apparatus, electronic device and computer non-volatile readable storage medium
CN112101031B (en) Entity identification method, terminal equipment and storage medium
CN113177412A (en) Named entity identification method and system based on bert, electronic equipment and storage medium
CN109522396B (en) Knowledge processing method and system for national defense science and technology field
US20230094730A1 (en) Model training method and method for human-machine interaction
CN113657100A (en) Entity identification method and device, electronic equipment and storage medium
CN117370378A (en) Method, device, equipment and medium for converting natural language into database statement
CN111814476A (en) Method and device for extracting entity relationship
CN116821373A (en) Map-based prompt recommendation method, device, equipment and medium
CN113553411B (en) Query statement generation method and device, electronic equipment and storage medium
CN112989829B (en) Named entity recognition method, device, equipment and storage medium

Legal Events

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