CN110287477B - Entity emotion analysis method and related device - Google Patents

Entity emotion analysis method and related device Download PDF

Info

Publication number
CN110287477B
CN110287477B CN201810217282.9A CN201810217282A CN110287477B CN 110287477 B CN110287477 B CN 110287477B CN 201810217282 A CN201810217282 A CN 201810217282A CN 110287477 B CN110287477 B CN 110287477B
Authority
CN
China
Prior art keywords
vector
text
predicted
speech sequence
participle
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
CN201810217282.9A
Other languages
Chinese (zh)
Other versions
CN110287477A (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 Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum 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 Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201810217282.9A priority Critical patent/CN110287477B/en
Priority to PCT/CN2019/073665 priority patent/WO2019174423A1/en
Publication of CN110287477A publication Critical patent/CN110287477A/en
Application granted granted Critical
Publication of CN110287477B publication Critical patent/CN110287477B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • 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
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Medical Informatics (AREA)
  • Mathematical Physics (AREA)
  • Evolutionary Computation (AREA)
  • Databases & Information Systems (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Machine Translation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses an entity emotion analysis method and a related device, wherein in the entity emotion analysis method, after a part of speech sequence of a text to be predicted is obtained by performing word segmentation processing on the text to be predicted, a vector of each word segmentation in the part of speech sequence of the text to be predicted and a vector of a target entity are obtained, and an entity emotion prediction model predicts the vector of each word segmentation in the part of speech sequence of the text to be predicted and the vector of the target entity, so that a prediction result of emotion tendentiousness of the target entity in the text to be predicted can be obtained. In the process, the text to be predicted is subjected to word segmentation processing to obtain a part-of-speech sequence, and a vector of each word segmentation in the part-of-speech sequence and a vector of a target entity are obtained, and the manual word selection and the word feature extraction are not performed, so that the problem that the accuracy of an emotion tendency result is influenced due to the manual word selection and the provision of the word feature is solved.

Description

Entity emotion analysis method and related device
Technical Field
The invention relates to the technical field of text analysis, in particular to an entity emotion analysis method and a related device.
Background
The text emotion analysis is mainly used for reflecting the emotional tendency of a user about certain events, characters, enterprises, products and the like in social media. Entity sentiment analysis refers to analyzing sentiment tendencies of certain entities in a text, but not tendencies of the whole text, and has the advantage of enabling the analysis granularity of sentiment objects to be clearer.
The existing scheme generally mainly relies on manual feature extraction to perform a traditional machine learning classification algorithm. Specifically, words around the target entity in the text are manually selected, the characteristics of the words are extracted and input into the classifier, and the classifier is used for emotion analysis to obtain the emotion tendentiousness result of the text to the target entity.
The words are manually selected and the characteristics of the words are extracted, so that the characteristic extraction process has strong subjectivity, and the accuracy of the emotion tendency result is influenced.
Disclosure of Invention
In view of the above, the present invention is proposed to provide an entity emotion analyzing method and related apparatus that overcome or at least partially solve the above problems.
An entity emotion analysis method, comprising:
acquiring a text to be predicted;
performing word segmentation processing on the text to be predicted to obtain a part-of-speech sequence of the text to be predicted;
obtaining a vector of each word segmentation in the part of speech sequence of the text to be predicted and a vector of a target entity;
predicting the vector of each participle in the part of speech sequence of the text to be predicted and the vector of the target entity by using an entity emotion prediction model to obtain a prediction result of the emotion tendentiousness of the target entity in the text to be predicted; wherein: the entity emotion prediction model is constructed on the basis of a first principle; the first principle includes: iteratively updating parameters in the neural network algorithm until a prediction result obtained by predicting the feature vector of the training text by using the neural network algorithm after updating the parameters is equal to an artificial labeling result; and obtaining the feature vector of the training text according to the vector of the part of speech sequence of the training text and the vector of the target entity in the part of speech sequence of the training text.
Optionally, the obtaining a vector of each participle in the part of speech sequence of the text to be predicted and a vector of the target entity includes:
respectively obtaining a word vector of each participle in the part of speech sequence of the text to be predicted;
multiplying the word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted;
and taking the vector of the participle corresponding to the target entity in the text to be predicted as the vector of the target entity in the part of speech sequence of the text to be predicted.
Optionally, the method further comprises:
obtaining any one or combination of a part-of-speech vector, a word packet vector and a vector of a relative target entity distance of each participle in the part-of-speech sequence of the text to be predicted;
combining a word vector of each participle in the part-of-speech sequence of the text to be predicted, and any one or combination of the part-of-speech vector, the word packet vector and the vector of the relative target entity distance of each participle in the obtained part-of-speech sequence of the text to be predicted to obtain an initial vector of each participle in the part-of-speech sequence of the text to be predicted;
multiplying the word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain a vector of each participle in the part-of-speech sequence of the text to be predicted, including:
multiplying the initial vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted.
Optionally, if the participles corresponding to the target entity in the text to be predicted include a plurality of participles, taking an average value of vectors of the plurality of participles corresponding to the target entity in the text to be predicted as a vector of the target entity in the part-of-speech sequence of the text to be predicted.
Optionally, the predicting, by using the entity emotion prediction model, the vector of each participle in the part of speech sequence of the text to be predicted and the vector of the target entity to obtain a prediction result of emotion tendentiousness of the target entity in the text to be predicted, includes:
carrying out weighted average processing on the vector of each participle in the part-of-speech sequence of the text to be predicted to obtain a vector weighted by the part-of-speech sequence of the text to be predicted;
multiplying a vector of a target entity in the part of speech sequence of the text to be predicted by a first matrix to obtain a derived vector of the target entity;
obtaining a feature vector according to the vector weighted by the part of speech sequence of the text to be predicted and/or a derivative vector of a target entity in the part of speech sequence of the text to be predicted;
processing the feature vector by adopting a softmax function to obtain a probability output vector, wherein the probability output vector comprises: and the probability values of the target entities in the text to be predicted under the emotion tendencies of the preset categories respectively.
Alternatively,
the construction process of the entity emotion prediction model comprises the following steps:
performing word segmentation processing on a training text to obtain a part-of-speech sequence of the training text;
obtaining a vector of each word segmentation in the part of speech sequence of the training text and a vector of a target entity;
carrying out weighted average processing on the vector of each participle in the part of speech sequence of the training text to obtain a vector weighted by the part of speech sequence of the training text;
multiplying the vector of the target entity in the part of speech sequence of the training text by a first matrix to obtain a derived vector of the target entity in the part of speech sequence of the training text;
obtaining a feature vector according to the vector weighted by the part of speech sequence of the training text and/or a derivative vector of a target entity in the part of speech sequence of the training text;
processing the feature vector by adopting a softmax function to obtain a probability output vector, wherein the probability output vector comprises: probability values of target entities in the training texts under the emotion tendencies of preset categories respectively;
performing cross entropy operation on the probability output vector and the artificial labeling category of the training text to obtain a loss function;
optimizing the loss function, and updating a first parameter according to the optimized loss function until a probability output vector obtained by predicting the training text by using a feature vector obtained by using the updated first parameter is equal to the manual labeling category of the training text; wherein the first parameters comprise the first matrix, the softmax function, and a vector for each participle in the sequence of parts of speech of the training text;
taking the updated second parameter as an entity emotion prediction model; wherein the second parameter comprises: the first matrix and the softmax function.
An entity emotion analyzing apparatus, comprising:
the device comprises an acquisition unit, a prediction unit and a prediction unit, wherein the acquisition unit is used for acquiring a text to be predicted;
the word segmentation unit is used for carrying out word segmentation processing on the text to be predicted to obtain a part-of-speech sequence of the text to be predicted;
the generating unit is used for obtaining a vector of each participle in the part of speech sequence of the text to be predicted and a vector of a target entity;
the prediction unit is used for predicting the vector of each participle in the part of speech sequence of the text to be predicted and the vector of the target entity by using an entity emotion prediction model to obtain a prediction result of the emotion tendentiousness of the target entity in the text to be predicted; the entity emotion prediction model is constructed on the basis of a first principle; the first principle includes: iteratively updating parameters in the neural network algorithm until a prediction result obtained by predicting the feature vector of the training text by using the neural network algorithm after updating the parameters is equal to an artificial labeling result; and obtaining the feature vector of the training text according to the vector of the part of speech sequence of the training text and the vector of the target entity in the part of speech sequence of the training text.
Optionally, the generating unit includes:
the first obtaining unit is used for respectively obtaining a word vector of each participle in the part-of-speech sequence of the text to be predicted;
the second obtaining unit is used for multiplying the word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted;
and the generating subunit is used for taking the vector of the participle corresponding to the target entity in the text to be predicted as the vector of the target entity in the part-of-speech sequence of the text to be predicted.
A storage medium comprising a stored program, wherein when the program runs, a device in which the storage medium is located is controlled to execute the entity emotion analysis method according to any one of the above.
A processor, configured to execute a program, wherein the program executes to perform any one of the entity emotion analysis methods.
By means of the technical scheme, in the entity emotion analysis method and the related device, after word segmentation processing is carried out on a text to be predicted to obtain a part-of-speech sequence of the text to be predicted, vectors of each word segmentation in the part-of-speech sequence of the text to be predicted and vectors of target entities are obtained, an entity emotion prediction model predicts the vectors of each word segmentation in the part-of-speech sequence of the text to be predicted and the vectors of the target entities, and prediction results of emotion tendencies of the target entities in the text to be predicted can be obtained. In the process, the text to be predicted is subjected to word segmentation processing to obtain a part-of-speech sequence, and a vector of each word segmentation in the part-of-speech sequence and a vector of a target entity are obtained, and the manual word selection and the word feature extraction are not performed, so that the problem that the accuracy of an emotion tendency result is influenced due to the manual word selection and the provision of the word feature is solved.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow chart showing a process for constructing an entity emotion prediction model according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a specific implementation manner of step S102 disclosed in the embodiment of the present invention;
FIG. 3 is a flow chart of the entity sentiment analysis method disclosed by the embodiment of the invention;
FIG. 4 is a flowchart illustrating a specific implementation manner of step S303 disclosed in the embodiment of the present invention;
FIG. 5 is a flowchart illustrating a specific implementation manner of step S304 disclosed in the embodiment of the present invention;
FIG. 6 is a schematic structural diagram of an entity emotion analysis device disclosed in the embodiment of the invention;
FIG. 7 is a schematic structural diagram of a generating unit disclosed in the embodiment of the invention;
fig. 8 shows a schematic structural diagram of a prediction unit disclosed in the embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In the embodiment of the application, an entity emotion prediction model is needed to predict the text to be predicted. Therefore, before the entity emotion analysis method disclosed in the embodiment of the present application is executed, the entity emotion prediction model needs to be constructed.
Referring to fig. 1, the process of constructing the entity emotion prediction model includes:
s101, performing word segmentation processing on the training text to obtain a part-of-speech sequence of the training text.
Wherein a training document is prepared, the training document comprising at least one training text. The training text is the evaluation sentence of the user about certain events, people, enterprises, products and the like.
Performing word segmentation on each training text in a training document by adopting open source tool software such as LTP (Language Technology Platform) and acquiring a part-of-speech sequence of a corresponding word segmentation, wherein the part-of-speech sequence comprises a word segmentation sequence and a part-of-speech result; the word segmentation sequence comprises each word segmentation obtained by segmenting the training text; the part-of-speech result includes parts-of-speech of the respective participles. For example: the training text is: the automobile front face is designed with the Weiwu Baqi. After the training text is subjected to word segmentation processing, the obtained word segmentation sequence is [ automobile, front face, design, armed, dominance ], and the part-of-speech result is [ n, n, v, a, n ]; n represents general noun, noun; v represents verbs, verbs; a represents an adjective.
S102, obtaining a vector of each word segmentation in the part of speech sequence of the training text and a vector of the target entity.
Each participle in the part-of-speech sequence of the training text needs to be expressed in a characteristic vector mode. Therefore, for each participle in the part-of-speech sequence of the training text, a vector of the participle needs to be obtained. The training text comprises a target entity, and the part of speech sequence after the word segmentation processing of the training text also comprises the word segmentation corresponding to the target entity. Therefore, the vector of the participle corresponding to the target entity in the part-of-speech sequence of the training text is the vector of the target entity.
Optionally, in an implementation manner of step S102, referring to fig. 2, the step includes:
and S1021, respectively obtaining a word vector of each participle in the part of speech sequence of the training text.
And screening each word segmentation in the part-of-speech sequence of the training text in a word vector model respectively to obtain a word vector of the current word segmentation in the word vector model.
And performing word segmentation on each text sentence in the text library by using open source tool software, and performing word vector training by using a word vector model, namely generating the word vector model. The text base comprises an industry corpus and a general corpus, wherein the general corpus refers to the text base which is personalized out of industry. The word vector model has the function of mapping words into a space with a certain latitude and can represent similarity between words. Meanwhile, the word vector model includes low-frequency long-tail words (the low-frequency long-tail words refer to words with a frequency lower than a certain threshold value in all words) appearing in the corpus, and the words are collectively denoted as UNK (unknown keyword), and the UNK has a unique word vector in the word vector model.
And if a word in the part of speech sequence of the training text has no corresponding word vector in the word vector model, using the UNK word vector as the word vector of the word.
It should be noted that each word in the part-of-speech sequence of the training text, whose part-of-speech differs, also leads to a difference in emotional orientation of the target entity. Thus, a part-of-speech vector for each participle in the sequence of parts-of-speech of the training text may also be obtained.
Specifically, a random vector with a certain number of dimensions on the part of speech, for example, the number of parts of speech is 5 [ a, b, c, d, e ], then a may be represented by a random vector Va, and similarly, b may be represented by a random vector Vb, and the number of dimensions of Va and Vb may be arbitrarily specified. For each word segmentation in the part-of-speech sequence of the training text, a corresponding part-of-speech vector can be obtained according to the part-of-speech.
Similarly, the word packet to which the participle belongs also affects the judgment of the emotional orientation of the target entity, and particularly, a word vector corresponding to a certain participle in the part-of-speech sequence of the training text is not found in the word vector model, and the participle can be comprehensively reflected through the word packet vector of the participle. Therefore, a word package vector for each participle in the part-of-speech sequence of the training text may also be obtained.
Specifically, the relationship between each word in the part-of-speech sequence of the training text and the word package in the industry field is encoded to obtain a word package vector of each word in the part-of-speech sequence of the training text. For example: and judging whether each participle in the part-of-speech sequence of the training text is in an entity word packet or not and whether each participle is in an evaluation word packet or not. And coding the judgment result to obtain a word packet vector of each word in the part of speech sequence of the training text.
The distance of each participle in the part-of-speech sequence of the training text relative to the target entity has different influence on the emotional tendency of the target entity. In general, if the distance of a word segmentation from the target entity is long, the influence of the emotional tendency of the target entity is small. Therefore, a vector of the distance of each participle in the part-of-speech sequence of the training text from the target entity needs to be obtained.
And coding each word segmentation in the part of speech sequence of the training text according to the distance of the word segmentation relative to the target entity to obtain a vector of the distance of each word segmentation relative to the target entity. For example: [ car, front face, design, power, and dominance ], where the target entity is front face design, then the distance between each participle and the target entity is [ -2, -1,0,0,1,2,3], and the distance sequence is encoded, and-2, -1,0, 1,2,3 are encoded into vectors of certain dimensions, respectively, to obtain the vector of the distance of each participle relative to the target entity.
If any one or any combination of the part-of-speech vector, the word packet vector, and the vector relative to the target entity distance of each participle in the part-of-speech sequence of the training text is obtained, the word vector, the part-of-speech vector, the word packet vector, and the vector relative to the target entity distance of each participle in the part-of-speech sequence of the training text are combined to obtain an initial vector of each participle in the part-of-speech sequence of the training text.
And for each participle in the part-of-speech sequence of the training text, respectively splicing and combining a word vector, the part-of-speech vector, a word packet vector and a vector of a distance relative to a target entity to form an initial vector of the participle.
And S1022, multiplying the word vector of each participle in the part of speech sequence of the training text by the attenuation factor to obtain the vector of each participle in the part of speech sequence of the training text.
And calculating the attenuation factor of each word according to the word vector of the distance of each word in the part of speech sequence of the training text relative to the target entity. Specifically, the calculation formula of the attenuation factor e is that e is 1-d/N, where d represents the absolute distance between the current participle and the target entity, and N is the length of the part-of-speech sequence of the training document.
Multiplying the word vector of each word segmentation in the part of speech sequence of the training text by the corresponding attenuation factor to obtain the vector of the word segmentation.
It should be further noted that the word segmentation length of each training text in the training document is counted, and whether an ultralong outlier length text exists in the training document is determined. Specifically, the standard deviation of the mean value of the word segmentation lengths of the training texts is calculated, and the overlength outlier length text is the training text which is beyond a plurality of multiples of the standard deviation of the mean value whether the word segmentation lengths exceed the mean value. The specific multiple requirement can be set according to the actual situation.
And if judging that no ultralong outlier length text exists in the training document, taking the word segmentation length of the training text with the longest word segmentation length in the training document as the length of the part of speech sequence of the training document. And if the training document is judged to have the overlong outlier length text, taking the word segmentation length of the training text with the longest word segmentation length in the remaining training texts except the overlong outlier length text in the training document as the length of the part of speech sequence of the training document. And intercepting the overlong outlier length text in the training document according to the length of the part of speech sequence of the training document. Specifically, the word segmentation length and the target entity in the training text are respectively expanded forwards and backwards until the word segmentation length reaches the length of the part of speech sequence of the training document.
For example: the training documents comprise 10 training texts, the word segmentation length of each training text is different, but the word segmentation length of the longest training text is 50, and then 50 is taken as the length of the part of speech sequence of the training documents. If a training text exists in the training document, and the word segmentation length of the training text is 1000, the training text is an ultralong outlier length text.
It should be further noted that, if the initial vector of each participle in the part-of-speech sequence of the training text is obtained, the manner of obtaining the vector of each participle in the part-of-speech sequence of the training text is as follows: multiplying the initial vector of each participle in the part of speech sequence of the training text by the attenuation factor.
And S1023, taking the vector of the word segmentation corresponding to the target entity in the training text as the vector of the target entity.
It should be noted that, if the participles of the training text corresponding to the target entity include multiple ones, the average value of the vectors of the multiple participles of the training text corresponding to the target entity is used as the vector of the target entity.
S103, carrying out weighted average processing on the vector of each word in the part of speech sequence of the training text to obtain the vector of the training text after the part of speech sequence is weighted.
And combining the vector of the target entity on the vector of each participle in the part-of-speech sequence of the training text to obtain the vector of each participle in the part-of-speech sequence of the training text. And calculating the vector of each participle in the part-of-speech sequence of the training text by using an attribute layer of an HAN (Hierarchical Attention network mechanism model) to obtain the weight of each participle. Specifically, if the word segmentation is far from the target entity, the emotional influence on the target entity is small, and the attention is not needed, the weight is weakened, and otherwise, the weight is strengthened.
And performing weighted average processing on the vector of each word in the part of speech sequence of the training text according to the weight of each word in the part of speech sequence of the training text to obtain the vector weighted by the part of speech sequence of the training text.
And S104, multiplying the vector of the target entity in the part of speech sequence of the training text by the first matrix to obtain a derived vector of the target entity.
And multiplying the vector of the target entity in the part of speech sequence of the training text by the first matrix to obtain a derived vector of the target entity.
It should be further noted that the first matrix is an m × m matrix, and m is a dimension of a vector of the target entity in the part-of-speech sequence of the training text. The specific values of the first matrix are randomly initialized values, and each value can be selected from fractions which are uniformly distributed in an interval of-0.1 to 0.1.
And S105, obtaining a feature vector according to the vector weighted by the part of speech sequence of the training text and/or the derivative vector of the target entity.
The feature vector may be obtained by using a vector obtained by weighting the part-of-speech sequence of the training text as the feature vector, by using a derivative vector of the target entity as the feature vector, and by adding or subtracting the derivative vector of the target entity to or from the vector obtained by weighting the part-of-speech sequence of the training text.
Specifically, if the word segmentation corresponding to the target entity in the training text has emotional tendency, the derived vector of the target entity may be selected as the feature vector. In addition, the feature vector obtained by adding or subtracting the derived vector of the target entity to or from the vector weighted by the part of speech sequence of the training text may be added to the vector weighted by the part of speech sequence of the training text.
Optionally, in another embodiment of the present application, steps S103 to S104 may be repeatedly executed several times, where the number of times to be repeatedly executed may be set according to actual requirements.
Specifically, the feature vector obtained in the last execution of step S104 is used as the vector of the target entity in the next execution of steps S103 and S104, so as to obtain the latest weighted vector of the part-of-speech sequence of the training text and the latest derivative vector of the target entity, and then a new feature vector is obtained according to the latest weighted vector of the part-of-speech sequence of the training text and/or the latest derivative vector of the target entity.
And S106, processing the characteristic vector by adopting a softmax function to obtain a probability output vector.
Wherein the probability output vector comprises probability values for three categories, the three categories comprising positive, medium and negative. Is indicating that the emotion is positive for the target entity for the training text; negative indicates that the emotion of the training text is negative for the target entity; the (1) indicates that the emotion of the training text is neutral to the target entity. The probability value of each category is used for representing the probability that the entity emotion of the target entity of the training text belongs to the corresponding category.
And S107, performing cross entropy operation on the probability output vector and the artificial labeling type of the training text to obtain a loss function.
And for each training text in the training document, manually identifying the emotion of the training text on a target entity, and labeling the emotion of the positive category, the emotion of the negative category and the emotion of the positive category according to the emotion to obtain the manually labeled category of the training text. For example: the automobile front face design Weiwu Baqi training text has the target entity of front face design and the emotion of the front face. Thus, the identification of the manually labeled category of the training text may be [1,0,0 ].
And performing cross entropy operation on the probability output vector and the artificial labeling category of the training text to obtain a loss function, wherein the loss function is used for indicating the difference between the probability output vector and the artificial labeling category of the training text.
And S108, optimizing the loss function, and updating parameters according to the optimized loss function until a probability output vector obtained by predicting the training text by using the feature vector obtained by the updated first parameter is equal to the manual labeling category of the training text.
Wherein the first parameters include the attention layer, the first matrix, a softmax function, and a vector for each participle in the sequence of parts of speech of the training text. Specifically, the obtaining manner of the vector of each word segmentation in the part-of-speech sequence of the training text may be referred to in the embodiment corresponding to fig. 1, and the content of step S102 is not described herein again.
The loss function can be optimized through a random gradient descent method or an Adam optimization algorithm and the like to obtain an optimized loss function, and updated parameters are obtained according to the optimized loss function through layer-by-layer recursion.
It should be noted that, in this step, the equivalent means are: from the perspective of one skilled in the art, the probability output vector may be considered equivalent, and may include non-identical, to the manually labeled category of the training text.
S109, taking the updated second parameter as an entity emotion prediction model; wherein the second parameter comprises: the attention layer, the first matrix, and the softmax function.
Based on the entity emotion prediction model constructed by the method of the embodiment, entity emotion analysis can be performed on the text to be predicted. Specifically, referring to fig. 3, the entity emotion analysis method includes:
s301, obtaining a text to be predicted.
The text to be predicted is an evaluation statement of a user about certain events, persons, enterprises, products and the like. And acquiring the text to be predicted to analyze the emotional tendency of the text about the target entity in the text.
S302, performing word segmentation processing on the text to be predicted to obtain a part-of-speech sequence of the text to be predicted.
And performing word segmentation processing on the text to be predicted by adopting open source tool software, and acquiring a part-of-speech sequence of corresponding words. The specific execution process of this step can be seen in the embodiment corresponding to fig. 1, and the content of step S101 is not described herein again.
S303, obtaining a vector of each participle in the part of speech sequence of the text to be predicted and a vector of the target entity.
Optionally, in an implementation manner of step S303, referring to fig. 4, the step includes:
s3031, respectively obtaining a word vector of each participle in the part of speech sequence of the text to be predicted.
Optionally, before obtaining a word vector of each participle in the part-of-speech sequence of the text to be predicted, a part-of-speech vector, a word packet vector, and a vector of relative target entity distance of each participle in the part-of-speech sequence of the text to be predicted may also be obtained.
The word vectors, the part-of-speech vectors, the word-bag vectors, and the vectors corresponding to the target entity distance of the participle may be obtained in the embodiment corresponding to fig. 1, and the content of step S1021 is shown.
S3032, multiplying the word vector of each participle in the part of speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part of speech sequence of the text to be predicted.
For a specific implementation manner of this step, reference may be made to the content of step S1022 in the embodiment corresponding to fig. 1, which is not described herein again.
S3033, taking the vector of the participle corresponding to the target entity in the text to be predicted as the vector of the target entity.
Optionally, in another embodiment of the present application, if the participle corresponding to the target entity in the text to be predicted includes a plurality of participles, an average value of vectors of the plurality of participles corresponding to the target entity in the text to be predicted is used as the vector of the target entity.
S304, predicting the vector of each participle in the part-of-speech sequence of the text to be predicted and the vector of the target entity by using an entity emotion prediction model to obtain a prediction result of the target entity of the text to be predicted; the entity emotion prediction model is constructed on the basis of a first principle; the first principle includes: iteratively updating parameters in the neural network algorithm until a prediction result obtained by predicting the feature vector of the training text by using the neural network algorithm after updating the parameters is equal to an artificial labeling result; and obtaining the feature vector of the training text according to the vector of the part of speech sequence of the training text and the vector of the target entity in the part of speech sequence of the training text.
In the entity emotion analysis method disclosed in this embodiment, after a part of speech sequence of a text to be predicted is obtained by performing word segmentation processing on the text to be predicted, a vector of each word in the part of speech sequence of the text to be predicted and a vector of a target entity are obtained, and a prediction result of emotion tendentiousness of the target entity in the text to be predicted can be obtained by predicting the vector of each word in the part of speech sequence of the text to be predicted and the vector of the target entity by using an entity emotion prediction model. In the process, the text to be predicted is subjected to word segmentation processing to obtain a part-of-speech sequence, and a vector of each word segmentation in the part-of-speech sequence and a vector of a target entity are obtained, and the manual word selection and the word feature extraction are not performed, so that the problem that the accuracy of an emotion tendency result is influenced due to the manual word selection and the provision of the word feature is solved.
Optionally, in another embodiment of the present application, referring to fig. 5, step S304 includes:
s3041, carrying out weighted average processing on the vector of each participle in the part-of-speech sequence of the text to be predicted to obtain a vector weighted by the part-of-speech sequence of the text to be predicted.
For a specific implementation manner of this step, reference may be made to the content of step S103 in the embodiment corresponding to fig. 1, which is not described herein again.
S3042, multiplying the vector of the target entity in the part of speech sequence of the text to be predicted by the first matrix to obtain a derived vector of the target entity.
The first matrix corresponds to the entity emotion prediction model in step S109 in the embodiment of fig. 1. Moreover, for a specific implementation manner of this step, reference may be made to the content of step S104 in the embodiment corresponding to fig. 1, which is not described herein again.
S3043, obtaining a feature vector according to the vector weighted by the part of speech sequence of the text to be predicted and/or a derivative vector of a target entity in the part of speech sequence of the text to be predicted.
For a specific implementation manner of this step, reference may be made to the content of step S105 in the embodiment corresponding to fig. 1, which is not described herein again.
S3044, processing the feature vector by adopting a softmax function to obtain a probability output vector.
Wherein the softmax function is a softmax function corresponding to the entity emotion prediction model in step S109 in the embodiment of fig. 1. Moreover, for a specific implementation manner of this step, reference may be made to the content of step S106 in the embodiment corresponding to fig. 1, which is not described herein again.
The embodiment of the application also discloses an entity emotion analysis device, and the specific working process of each unit included in the entity emotion analysis device can be referred to the content of the embodiment corresponding to fig. 3. Specifically, referring to fig. 6, the entity emotion analyzing apparatus includes:
an obtaining unit 601, configured to obtain a text to be predicted.
A word segmentation unit 602, configured to perform word segmentation processing on the text to be predicted, so as to obtain a part-of-speech sequence of the text to be predicted.
A generating unit 603, configured to obtain a vector of each participle in the part-of-speech sequence of the text to be predicted and a vector of the target entity.
Optionally, in another embodiment of the present application, the generating unit 603, see fig. 7, includes:
a first obtaining unit 6031, configured to obtain a word vector of each participle in the part of speech sequence of the text to be predicted respectively.
A second obtaining unit 6032, configured to multiply a word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain a vector of each participle in the part-of-speech sequence of the text to be predicted.
A generating sub-unit 6033, configured to use a vector of the participle in the text to be predicted, which corresponds to the target entity, as a vector of the target entity in the part-of-speech sequence of the text to be predicted.
For a specific working process of each unit in the generating unit 603 disclosed in this embodiment, reference may be made to the content of the embodiment corresponding to fig. 4, which is not described herein again.
Optionally, in another embodiment of the present application, if the participle corresponding to the target entity in the text to be predicted includes a plurality of participles, the generating sub-unit 6033 executes, as the vector of the target entity in the part-of-speech sequence of the text to be predicted, to specifically: and taking the average value of the vectors of the multiple participles corresponding to the target entity in the text to be predicted as the vector of the target entity in the part of speech sequence of the text to be predicted.
Optionally, in another embodiment of the present application, the entity emotion analyzing apparatus further includes:
and the third obtaining unit is used for obtaining any one or combination of a part-of-speech vector, a word packet vector and a vector of a relative target entity distance of each participle in the part-of-speech sequence of the text to be predicted.
And the combination unit is used for combining the word vector of each participle in the part-of-speech sequence of the text to be predicted, and any one or combination of the part-of-speech vector, the word packet vector and the vector of the relative target entity distance of each participle in the obtained part-of-speech sequence of the text to be predicted to obtain an initial vector of each participle in the part-of-speech sequence of the text to be predicted.
The second obtaining unit 6032, when performing the multiplication of the word vector of each participle in the part-of-speech sequence of the text to be predicted and the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted, is specifically configured to: multiplying the initial vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted.
The predicting unit 604 is configured to predict, by using an entity emotion prediction model, a vector of each participle in the part-of-speech sequence of the text to be predicted and a vector of a target entity, so as to obtain a prediction result of emotion tendentiousness of the target entity in the text to be predicted; the entity emotion prediction model is constructed on the basis of a first principle; the first principle includes: iteratively updating parameters in the neural network algorithm until a prediction result obtained by predicting the feature vector of the training text by using the neural network algorithm after updating the parameters is equal to an artificial labeling result; and obtaining the feature vector of the training text according to the vector of the part of speech sequence of the training text and the vector of the target entity in the part of speech sequence of the training text.
Optionally, in another embodiment of the present application, the prediction unit 604, as shown in fig. 8, includes:
a first calculating unit 6041, configured to perform weighted average processing on a vector of each participle in the part-of-speech sequence of the text to be predicted, so as to obtain a vector weighted by the part-of-speech sequence of the text to be predicted.
A second calculating unit 6042, configured to multiply a vector of a target entity in the part of speech sequence of the text to be predicted by the first matrix to obtain a derivative vector of the target entity.
A third calculating unit 6043, configured to obtain a feature vector according to the vector weighted by the part of speech sequence of the text to be predicted and/or a derivative vector of the target entity in the part of speech sequence of the text to be predicted.
And a fourth calculating unit 6044, configured to process the feature vector by using a softmax function, so as to obtain a probability output vector.
For a specific working process of each unit in the prediction unit 604 disclosed in this embodiment, reference may be made to the content of the embodiment corresponding to fig. 5, which is not described herein again.
In this embodiment, the text to be predicted is subjected to word segmentation processing by the word segmentation unit to obtain a part-of-speech sequence, and the generating unit obtains a vector of each word segmentation in the part-of-speech sequence and a vector of the target entity, but manual word selection and word feature extraction are not performed, so that the problem that the accuracy of the emotion tendency result is affected due to manual word selection and the provision of word features is solved.
Optionally, in another embodiment of the present application, the entity emotion analysis device may further predict the training text to obtain an entity emotion prediction model.
Specifically, the method comprises the following steps: the word segmentation unit 602 is further configured to perform word segmentation processing on the training text to obtain a part-of-speech sequence of the training text.
The generating unit 603 is further configured to obtain a vector of each participle in the part-of-speech sequence of the training text and a vector of the target entity.
The first calculating unit 6041 is further configured to perform weighted average processing on the vector of each participle in the part-of-speech sequence of the training text to obtain a vector weighted by the part-of-speech sequence of the training text.
The second calculating unit 6042 is further configured to multiply the vector of the target entity in the part-of-speech sequence of the training text with the first matrix to obtain a derivative vector of the target entity in the part-of-speech sequence of the training text.
The third calculating unit 6043 is further configured to obtain a feature vector according to the vector weighted by the part of speech sequence of the training text and/or a derivative vector of the target entity in the part of speech sequence of the training text.
And the fourth calculating unit 6044 is further configured to process the feature vector by using a softmax function to obtain a probability output vector.
Also, the entity emotion analyzing apparatus further includes: and the operation unit is used for performing cross entropy operation on the probability output vector and the artificial labeling type of the training text to obtain a loss function.
An optimization unit for optimizing the loss function.
An updating unit, configured to update the first parameter according to the optimized loss function until a probability output vector obtained by predicting the training text by using a feature vector obtained by using the updated first parameter by the fourth calculating unit 6044 is substantially equal to the artificial labeling category of the training text; wherein the first parameters include the first matrix, the softmax function, and a vector for each participle in the sequence of parts of speech of the training text.
The construction unit is used for taking the updated second parameter as an entity emotion prediction model; wherein the second parameter comprises: the first matrix and the softmax function.
For the specific working process of each unit in the above embodiment, reference may be made to the content of the embodiment corresponding to fig. 1, and details are not described here again.
The entity emotion analysis device comprises a processor and a memory, wherein the acquisition unit, the word segmentation unit, the generation unit, the prediction unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more than one, and the emotion analysis process of the text to be predicted is realized by adjusting the kernel parameters, so that the prediction result of the emotion tendentiousness of the target entity in the text to be predicted is obtained.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
An embodiment of the present invention provides a storage medium on which a program is stored, the program implementing the method for entity emotion analysis when executed by a processor.
The embodiment of the invention provides a processor, which is used for running a program, wherein the method for analyzing entity emotion is executed when the program runs.
The embodiment of the invention provides equipment, and the equipment can be a server, a PC, a PAD, a mobile phone and the like. The device comprises a processor, a memory and a program stored on the memory and capable of running on the processor, and the processor realizes the following steps when executing the program:
an entity emotion analysis method, comprising:
acquiring a text to be predicted;
performing word segmentation processing on the text to be predicted to obtain a part-of-speech sequence of the text to be predicted;
obtaining a vector of each word segmentation in the part of speech sequence of the text to be predicted and a vector of a target entity;
predicting the vector of each participle in the part of speech sequence of the text to be predicted and the vector of the target entity by using an entity emotion prediction model to obtain a prediction result of the emotion tendentiousness of the target entity in the text to be predicted; wherein: the entity emotion prediction model is constructed on the basis of a first principle; the first principle includes: iteratively updating parameters in the neural network algorithm until a prediction result obtained by predicting the feature vector of the training text by using the neural network algorithm after updating the parameters is equal to an artificial labeling result; and obtaining the feature vector of the training text according to the vector of the part of speech sequence of the training text and the vector of the target entity in the part of speech sequence of the training text.
Optionally, the obtaining a vector of each participle in the part of speech sequence of the text to be predicted and a vector of the target entity includes:
respectively obtaining a word vector of each participle in the part of speech sequence of the text to be predicted;
multiplying the word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted;
and taking the vector of the participle corresponding to the target entity in the text to be predicted as the vector of the target entity in the part of speech sequence of the text to be predicted.
Optionally, the entity emotion analysis method further includes:
obtaining any one or combination of a part-of-speech vector, a word packet vector and a vector of a relative target entity distance of each participle in the part-of-speech sequence of the text to be predicted;
combining a word vector of each participle in the part-of-speech sequence of the text to be predicted, and any one or combination of the part-of-speech vector, the word packet vector and the vector of the relative target entity distance of each participle in the obtained part-of-speech sequence of the text to be predicted to obtain an initial vector of each participle in the part-of-speech sequence of the text to be predicted;
multiplying the word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain a vector of each participle in the part-of-speech sequence of the text to be predicted, including:
multiplying the initial vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted.
Optionally, if the participles corresponding to the target entity in the text to be predicted include a plurality of participles, taking an average value of vectors of the plurality of participles corresponding to the target entity in the text to be predicted as a vector of the target entity in the part-of-speech sequence of the text to be predicted.
Optionally, the predicting, by using the entity emotion prediction model, the vector of each participle in the part of speech sequence of the text to be predicted and the vector of the target entity to obtain a prediction result of emotion tendentiousness of the target entity in the text to be predicted, includes:
carrying out weighted average processing on the vector of each participle in the part-of-speech sequence of the text to be predicted to obtain a vector weighted by the part-of-speech sequence of the text to be predicted;
multiplying a vector of a target entity in the part of speech sequence of the text to be predicted by a first matrix to obtain a derived vector of the target entity;
obtaining a feature vector according to the vector weighted by the part of speech sequence of the text to be predicted and/or a derivative vector of a target entity in the part of speech sequence of the text to be predicted;
processing the feature vector by adopting a softmax function to obtain a probability output vector, wherein the probability output vector comprises: and the probability values of the target entities in the text to be predicted under the emotion tendencies of the preset categories respectively.
Optionally, the process of constructing the entity emotion prediction model includes:
performing word segmentation processing on a training text to obtain a part-of-speech sequence of the training text;
obtaining a vector of each word segmentation in the part of speech sequence of the training text and a vector of a target entity;
carrying out weighted average processing on the vector of each participle in the part of speech sequence of the training text to obtain a vector weighted by the part of speech sequence of the training text;
multiplying the vector of the target entity in the part of speech sequence of the training text by a first matrix to obtain a derived vector of the target entity in the part of speech sequence of the training text;
obtaining a feature vector according to the vector weighted by the part of speech sequence of the training text and/or a derivative vector of a target entity in the part of speech sequence of the training text;
processing the feature vector by adopting a softmax function to obtain a probability output vector, wherein the probability output vector comprises: probability values of target entities in the training texts under the emotion tendencies of preset categories respectively;
performing cross entropy operation on the probability output vector and the artificial labeling category of the training text to obtain a loss function;
optimizing the loss function, and updating a first parameter according to the optimized loss function until a probability output vector obtained by predicting the training text by using a feature vector obtained by using the updated first parameter is equal to the manual labeling category of the training text; wherein the first parameters comprise the first matrix, the softmax function, and a vector for each participle in the sequence of parts of speech of the training text;
taking the updated second parameter as an entity emotion prediction model; wherein the second parameter comprises: the first matrix and the softmax function.
The invention also provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device:
an entity emotion analysis method, comprising:
acquiring a text to be predicted;
performing word segmentation processing on the text to be predicted to obtain a part-of-speech sequence of the text to be predicted;
obtaining a vector of each word segmentation in the part of speech sequence of the text to be predicted and a vector of a target entity;
predicting the vector of each participle in the part of speech sequence of the text to be predicted and the vector of the target entity by using an entity emotion prediction model to obtain a prediction result of the emotion tendentiousness of the target entity in the text to be predicted; wherein: the entity emotion prediction model is constructed on the basis of a first principle; the first principle includes: iteratively updating parameters in the neural network algorithm until a prediction result obtained by predicting the feature vector of the training text by using the neural network algorithm after updating the parameters is equal to an artificial labeling result; and obtaining the feature vector of the training text according to the vector of the part of speech sequence of the training text and the vector of the target entity in the part of speech sequence of the training text.
Optionally, the obtaining a vector of each participle in the part of speech sequence of the text to be predicted and a vector of the target entity includes:
respectively obtaining a word vector of each participle in the part of speech sequence of the text to be predicted;
multiplying the word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted;
and taking the vector of the participle corresponding to the target entity in the text to be predicted as the vector of the target entity in the part of speech sequence of the text to be predicted.
Optionally, the entity emotion analysis method further includes:
obtaining any one or combination of a part-of-speech vector, a word packet vector and a vector of a relative target entity distance of each participle in the part-of-speech sequence of the text to be predicted;
combining a word vector of each participle in the part-of-speech sequence of the text to be predicted, and any one or combination of the part-of-speech vector, the word packet vector and the vector of the relative target entity distance of each participle in the obtained part-of-speech sequence of the text to be predicted to obtain an initial vector of each participle in the part-of-speech sequence of the text to be predicted;
multiplying the word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain a vector of each participle in the part-of-speech sequence of the text to be predicted, including:
multiplying the initial vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted.
Optionally, if the participles corresponding to the target entity in the text to be predicted include a plurality of participles, taking an average value of vectors of the plurality of participles corresponding to the target entity in the text to be predicted as a vector of the target entity in the part-of-speech sequence of the text to be predicted.
Optionally, the predicting, by using the entity emotion prediction model, the vector of each participle in the part of speech sequence of the text to be predicted and the vector of the target entity to obtain a prediction result of emotion tendentiousness of the target entity in the text to be predicted, includes:
carrying out weighted average processing on the vector of each participle in the part-of-speech sequence of the text to be predicted to obtain a vector weighted by the part-of-speech sequence of the text to be predicted;
multiplying a vector of a target entity in the part of speech sequence of the text to be predicted by a first matrix to obtain a derived vector of the target entity;
obtaining a feature vector according to the vector weighted by the part of speech sequence of the text to be predicted and/or a derivative vector of a target entity in the part of speech sequence of the text to be predicted;
processing the feature vector by adopting a softmax function to obtain a probability output vector, wherein the probability output vector comprises: and the probability values of the target entities in the text to be predicted under the emotion tendencies of the preset categories respectively.
Optionally, the process of constructing the entity emotion prediction model includes:
performing word segmentation processing on a training text to obtain a part-of-speech sequence of the training text;
obtaining a vector of each word segmentation in the part of speech sequence of the training text and a vector of a target entity;
carrying out weighted average processing on the vector of each participle in the part of speech sequence of the training text to obtain a vector weighted by the part of speech sequence of the training text;
multiplying the vector of the target entity in the part of speech sequence of the training text by a first matrix to obtain a derived vector of the target entity in the part of speech sequence of the training text;
obtaining a feature vector according to the vector weighted by the part of speech sequence of the training text and/or a derivative vector of a target entity in the part of speech sequence of the training text;
processing the feature vector by adopting a softmax function to obtain a probability output vector, wherein the probability output vector comprises: probability values of target entities in the training texts under the emotion tendencies of preset categories respectively;
performing cross entropy operation on the probability output vector and the artificial labeling category of the training text to obtain a loss function;
optimizing the loss function, and updating a first parameter according to the optimized loss function until a probability output vector obtained by predicting the training text by using a feature vector obtained by using the updated first parameter is equal to the manual labeling category of the training text; wherein the first parameters comprise the first matrix, the softmax function, and a vector for each participle in the sequence of parts of speech of the training text;
taking the updated second parameter as an entity emotion prediction model; wherein the second parameter comprises: the first matrix and the softmax function.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (9)

1. An entity emotion analysis method, comprising:
acquiring a text to be predicted;
performing word segmentation processing on the text to be predicted to obtain a part-of-speech sequence of the text to be predicted, wherein the part-of-speech sequence comprises a word segmentation sequence and a part-of-speech result;
obtaining a vector of each participle in the part-of-speech sequence of the text to be predicted and a vector of a target entity, wherein the vector of each participle comprises a part-of-speech vector, a word packet vector and a vector of a distance relative to the target entity, and the word packet vector of each participle is obtained by encoding the affiliated relationship of each participle and an industry field word packet;
predicting the vector of each participle in the part of speech sequence of the text to be predicted and the vector of the target entity by using an entity emotion prediction model to obtain a prediction result of the emotion tendentiousness of the target entity in the text to be predicted; wherein: the entity emotion prediction model is constructed on the basis of a first principle; the first principle includes: iteratively updating parameters in the neural network algorithm until a prediction result obtained by predicting the feature vector of the training text by using the neural network algorithm after updating the parameters is equal to an artificial labeling result; the feature vector of the training text is obtained according to the vector of the part of speech sequence of the training text and the vector of the target entity in the part of speech sequence of the training text;
the construction process of the entity emotion prediction model comprises the following steps:
performing word segmentation processing on a training text to obtain a part-of-speech sequence of the training text;
obtaining a vector of each word segmentation in the part of speech sequence of the training text and a vector of a target entity;
carrying out weighted average processing on the vector of each participle in the part of speech sequence of the training text to obtain a vector weighted by the part of speech sequence of the training text;
multiplying a vector of a target entity in the part-of-speech sequence of the training text by a first matrix to obtain a derivative vector of the target entity in the part-of-speech sequence of the training text, wherein the first matrix is an m x m matrix, m is the dimension of the vector of the target entity in the part-of-speech sequence of the training text, the specific numerical value of the first matrix is a randomly initialized numerical value, and each numerical value selects decimal uniformly distributed in an interval of-0.1;
obtaining a feature vector according to the vector weighted by the part of speech sequence of the training text and/or a derivative vector of a target entity in the part of speech sequence of the training text;
processing the feature vector by adopting a softmax function to obtain a probability output vector, wherein the probability output vector comprises: probability values of target entities in the training texts under the emotion tendencies of preset categories respectively;
performing cross entropy operation on the probability output vector and the artificial labeling category of the training text to obtain a loss function;
optimizing the loss function, and updating the first parameter according to the optimized loss function until a probability output vector obtained by predicting the training text by using a feature vector obtained by using the updated first parameter is equal to the artificial labeling category of the training text; wherein the first parameters comprise the first matrix, the softmax function, and a vector for each participle in the sequence of parts of speech of the training text;
taking the updated second parameter as an entity emotion prediction model; wherein the second parameter comprises: the first matrix and the softmax function.
2. The method of claim 1, wherein the obtaining a vector of each participle in the part-of-speech sequence of the text to be predicted and a vector of a target entity comprises:
respectively obtaining a word vector of each participle in the part of speech sequence of the text to be predicted;
multiplying the word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted;
and taking the vector of the participle corresponding to the target entity in the text to be predicted as the vector of the target entity in the part of speech sequence of the text to be predicted.
3. The method of claim 2, further comprising:
obtaining any one or combination of a part-of-speech vector, a word packet vector and a vector of a relative target entity distance of each participle in the part-of-speech sequence of the text to be predicted;
combining a word vector of each participle in the part-of-speech sequence of the text to be predicted, and any one or combination of the part-of-speech vector, the word packet vector and the vector of the relative target entity distance of each participle in the obtained part-of-speech sequence of the text to be predicted to obtain an initial vector of each participle in the part-of-speech sequence of the text to be predicted;
multiplying the word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain a vector of each participle in the part-of-speech sequence of the text to be predicted, including:
multiplying the initial vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted.
4. The method according to claim 2, wherein if the word segmentation corresponding to the target entity in the text to be predicted includes a plurality of words, an average value of vectors of the plurality of word segmentation corresponding to the target entity in the text to be predicted is used as the vector of the target entity in the part-of-speech sequence of the text to be predicted.
5. The method of claim 1, wherein the predicting the vector of each participle in the part-of-speech sequence of the text to be predicted and the vector of the target entity by using the entity emotion prediction model to obtain a prediction result of the emotion tendentiousness of the target entity in the text to be predicted comprises:
carrying out weighted average processing on the vector of each participle in the part-of-speech sequence of the text to be predicted to obtain a vector weighted by the part-of-speech sequence of the text to be predicted;
multiplying a vector of a target entity in the part of speech sequence of the text to be predicted by a first matrix to obtain a derived vector of the target entity;
obtaining a feature vector according to the vector weighted by the part of speech sequence of the text to be predicted and/or a derivative vector of a target entity in the part of speech sequence of the text to be predicted;
processing the feature vector by adopting a softmax function to obtain a probability output vector, wherein the probability output vector comprises: and the probability values of the target entities in the text to be predicted under the emotion tendencies of the preset categories respectively.
6. An entity emotion analysis apparatus, comprising:
the device comprises an acquisition unit, a prediction unit and a prediction unit, wherein the acquisition unit is used for acquiring a text to be predicted;
the word segmentation unit is used for performing word segmentation processing on the text to be predicted to obtain a part-of-speech sequence of the text to be predicted, wherein the part-of-speech sequence comprises a word segmentation sequence and a part-of-speech result;
the generating unit is used for obtaining a vector of each participle in the part of speech sequence of the text to be predicted and a vector of a target entity, wherein the vector of each participle comprises a part of speech vector, a word packet vector and a vector of a distance relative to the target entity, and the word packet vector of each participle is obtained by encoding the affiliated relationship of each participle and an industry field word packet;
the prediction unit is used for predicting the vector of each participle in the part of speech sequence of the text to be predicted and the vector of the target entity by using an entity emotion prediction model to obtain a prediction result of the emotion tendentiousness of the target entity in the text to be predicted; the entity emotion prediction model is constructed on the basis of a first principle; the first principle includes: iteratively updating parameters in the neural network algorithm until a prediction result obtained by predicting the feature vector of the training text by using the neural network algorithm after updating the parameters is equal to an artificial labeling result; the feature vector of the training text is obtained according to the vector of the part of speech sequence of the training text and the vector of the target entity in the part of speech sequence of the training text, and the construction process of the entity emotion prediction model comprises the following steps: performing word segmentation processing on a training text to obtain a part-of-speech sequence of the training text; obtaining a vector of each word segmentation in the part of speech sequence of the training text and a vector of a target entity; carrying out weighted average processing on the vector of each participle in the part of speech sequence of the training text to obtain a vector weighted by the part of speech sequence of the training text; multiplying a vector of a target entity in the part-of-speech sequence of the training text by a first matrix to obtain a derivative vector of the target entity in the part-of-speech sequence of the training text, wherein the first matrix is an m x m matrix, m is the dimension of the vector of the target entity in the part-of-speech sequence of the training text, the specific numerical value of the first matrix is a randomly initialized numerical value, and each numerical value selects decimal uniformly distributed in an interval of-0.1; obtaining a feature vector according to the vector weighted by the part of speech sequence of the training text and/or a derivative vector of a target entity in the part of speech sequence of the training text; processing the feature vector by adopting a softmax function to obtain a probability output vector, wherein the probability output vector comprises: probability values of target entities in the training texts under the emotion tendencies of preset categories respectively; performing cross entropy operation on the probability output vector and the artificial labeling category of the training text to obtain a loss function; optimizing the loss function, and updating the first parameter according to the optimized loss function until a probability output vector obtained by predicting the training text by using a feature vector obtained by using the updated first parameter is equal to the artificial labeling category of the training text; wherein the first parameters comprise the first matrix, the softmax function, and a vector for each participle in the sequence of parts of speech of the training text; taking the updated second parameter as an entity emotion prediction model; wherein the second parameter comprises: the first matrix and the softmax function.
7. The apparatus of claim 6, wherein the generating unit comprises:
the first obtaining unit is used for respectively obtaining a word vector of each participle in the part-of-speech sequence of the text to be predicted;
the second obtaining unit is used for multiplying the word vector of each participle in the part-of-speech sequence of the text to be predicted by the attenuation factor to obtain the vector of each participle in the part-of-speech sequence of the text to be predicted;
and the generating subunit is used for taking the vector of the participle corresponding to the target entity in the text to be predicted as the vector of the target entity in the part-of-speech sequence of the text to be predicted.
8. A storage medium comprising a stored program, wherein the apparatus on which the storage medium is located is controlled to perform the entity emotion analyzing method according to any one of claims 1 to 5 when the program is executed.
9. A processor, configured to run a program, wherein the program is configured to execute the entity sentiment analysis method of any one of claims 1 to 5 when running.
CN201810217282.9A 2018-03-16 2018-03-16 Entity emotion analysis method and related device Active CN110287477B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201810217282.9A CN110287477B (en) 2018-03-16 2018-03-16 Entity emotion analysis method and related device
PCT/CN2019/073665 WO2019174423A1 (en) 2018-03-16 2019-01-29 Entity sentiment analysis method and related apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810217282.9A CN110287477B (en) 2018-03-16 2018-03-16 Entity emotion analysis method and related device

Publications (2)

Publication Number Publication Date
CN110287477A CN110287477A (en) 2019-09-27
CN110287477B true CN110287477B (en) 2021-05-25

Family

ID=67907347

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810217282.9A Active CN110287477B (en) 2018-03-16 2018-03-16 Entity emotion analysis method and related device

Country Status (2)

Country Link
CN (1) CN110287477B (en)
WO (1) WO2019174423A1 (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112579768A (en) * 2019-09-30 2021-03-30 北京国双科技有限公司 Emotion classification model training method, text emotion classification method and text emotion classification device
US11507989B2 (en) * 2019-10-21 2022-11-22 Salesforce, Inc. Multi-label product categorization
CN110990531B (en) * 2019-11-28 2024-04-02 北京声智科技有限公司 Text emotion recognition method and device
CN111241832B (en) * 2020-01-15 2023-08-15 北京百度网讯科技有限公司 Core entity labeling method and device and electronic equipment
CN111309864B (en) * 2020-02-11 2022-08-26 安徽理工大学 User group emotional tendency migration dynamic analysis method for microblog hot topics
CN113378562B (en) * 2020-03-10 2023-09-19 中国移动通信集团辽宁有限公司 Word segmentation processing method, device, computing equipment and storage medium
CN111538835B (en) * 2020-03-30 2023-05-23 东南大学 Social media emotion classification method and device based on knowledge graph
CN111552810B (en) * 2020-04-24 2024-03-19 深圳数联天下智能科技有限公司 Entity extraction and classification method, entity extraction and classification device, computer equipment and storage medium
CN111324739B (en) * 2020-05-15 2020-08-28 支付宝(杭州)信息技术有限公司 Text emotion analysis method and system
CN112749275B (en) * 2020-05-22 2024-05-14 腾讯科技(深圳)有限公司 Data processing method and device
CN113723089B (en) * 2020-05-25 2023-12-26 阿里巴巴集团控股有限公司 Word segmentation model training method, word segmentation method and data processing method and device
CN111783453B (en) * 2020-07-01 2024-05-21 支付宝(杭州)信息技术有限公司 Text emotion information processing method and device
CN112069324A (en) * 2020-08-27 2020-12-11 北京灵汐科技有限公司 Classified label adding method, device, equipment and storage medium
CN114386411A (en) * 2020-10-16 2022-04-22 北京金山数字娱乐科技有限公司 Relationship extraction method and device
CN113569559B (en) * 2021-07-23 2024-02-02 北京智慧星光信息技术有限公司 Short text entity emotion analysis method, system, electronic equipment and storage medium
CN113849651B (en) * 2021-09-28 2024-04-09 平安科技(深圳)有限公司 Emotion classification method, device, equipment and medium based on document-level emotion tendencies
CN115392260B (en) * 2022-10-31 2023-04-07 暨南大学 Social media tweet emotion analysis method facing specific target

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101593204A (en) * 2009-06-05 2009-12-02 北京大学 A kind of emotion tendency analysis system based on news comment webpage
CN106776581A (en) * 2017-02-21 2017-05-31 浙江工商大学 Subjective texts sentiment analysis method based on deep learning
CN107168945A (en) * 2017-04-13 2017-09-15 广东工业大学 A kind of bidirectional circulating neutral net fine granularity opinion mining method for merging multiple features
US9875244B1 (en) * 2008-11-10 2018-01-23 Google Llc Sentiment-based classification of media content

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104281694A (en) * 2014-10-13 2015-01-14 安徽华贞信息科技有限公司 Analysis system of emotional tendency of text
CN104298665A (en) * 2014-10-16 2015-01-21 苏州大学 Identification method and device of evaluation objects of Chinese texts
KR101727686B1 (en) * 2014-12-23 2017-04-20 고려대학교 산학협력단 Method for extracting semantic entity topic
CN107038154A (en) * 2016-11-25 2017-08-11 阿里巴巴集团控股有限公司 A kind of text emotion recognition methods and device
CN107608956B (en) * 2017-09-05 2021-02-19 广东石油化工学院 Reader emotion distribution prediction algorithm based on CNN-GRNN

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9875244B1 (en) * 2008-11-10 2018-01-23 Google Llc Sentiment-based classification of media content
CN101593204A (en) * 2009-06-05 2009-12-02 北京大学 A kind of emotion tendency analysis system based on news comment webpage
CN106776581A (en) * 2017-02-21 2017-05-31 浙江工商大学 Subjective texts sentiment analysis method based on deep learning
CN107168945A (en) * 2017-04-13 2017-09-15 广东工业大学 A kind of bidirectional circulating neutral net fine granularity opinion mining method for merging multiple features

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《面向产品属性的用户情感模型》;贾闻俊 等;《计算机应用》;20160110;第36卷(第1期);全文 *

Also Published As

Publication number Publication date
WO2019174423A1 (en) 2019-09-19
CN110287477A (en) 2019-09-27

Similar Documents

Publication Publication Date Title
CN110287477B (en) Entity emotion analysis method and related device
CN110276066B (en) Entity association relation analysis method and related device
US20150154305A1 (en) Method of automated discovery of topics relatedness
CN110619044B (en) Emotion analysis method, system, storage medium and equipment
CN107291840B (en) User attribute prediction model construction method and device
CN110162778B (en) Text abstract generation method and device
US10825071B2 (en) Adaptive multi-perceptual similarity detection and resolution
CN107391682B (en) Knowledge verification method, knowledge verification apparatus, and storage medium
US11373041B2 (en) Text classification using models with complementary granularity and accuracy
CN111950295A (en) Method and system for training natural language processing model
CN110019784B (en) Text classification method and device
CN114995903B (en) Class label identification method and device based on pre-training language model
CN109597982B (en) Abstract text recognition method and device
US8744986B2 (en) Effort estimation using text analysis
CN110990523A (en) Legal document determining method and system
Pascual et al. Prosodic break prediction with RNNs
CN112597310A (en) Domain and intention hierarchical joint classification method, device, equipment and storage medium
US20210294978A1 (en) Word Attribution Prediction from Subject Data
JP2014232145A (en) Pause application model selection apparatus, pause application device, methods thereof, and program
KR102441442B1 (en) Method and apparatus for learning graph convolutional network
CN108205523B (en) Method and device for training dense word vectors by using corpus
US11734602B2 (en) Methods and systems for automated feature generation utilizing formula semantification
CN113554184A (en) Model training method and device, electronic equipment and storage medium
CN109146395B (en) Data processing method, device and equipment
CN110019831B (en) Product attribute analysis method and device

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