CN110807314A - Text emotion analysis model training method, device and equipment and readable storage medium - Google Patents
Text emotion analysis model training method, device and equipment and readable storage medium Download PDFInfo
- Publication number
- CN110807314A CN110807314A CN201910884618.1A CN201910884618A CN110807314A CN 110807314 A CN110807314 A CN 110807314A CN 201910884618 A CN201910884618 A CN 201910884618A CN 110807314 A CN110807314 A CN 110807314A
- Authority
- CN
- China
- Prior art keywords
- text
- text sample
- word
- emotion
- analysis model
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/241—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
- G06F18/2411—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on the proximity to a decision surface, e.g. support vector machines
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
Abstract
The application relates to the technical field of artificial intelligence and discloses a text emotion analysis model training method, device and equipment and a readable storage medium. The method comprises the following steps: acquiring a text sample to be trained; performing word segmentation processing on a text sample by a preset word segmentation method, and dividing the text sample into a plurality of different words; respectively coding a plurality of different words based on a preset coding method to obtain word vectors; inputting the word vectors into a preset deep neural network, and performing dimensionality reduction on the word vectors based on the embedded layer; calculating the word vector after dimensionality reduction based on a hidden layer in the deep neural network to obtain corresponding characteristics; classifying the characteristics corresponding to the text samples through a multi-classification SVM (support vector machine) to determine the emotion classification; and determining a difference value between the emotion type and the correct emotion type based on the loss function, and judging that the text emotion analysis model is trained when the difference value meets a preset condition. By the aid of the method and the device, the accuracy of text emotion analysis is improved.
Description
Technical Field
The application relates to the technical field of artificial intelligence, in particular to a text emotion analysis model training method, device and equipment and a readable storage medium.
Background
In the prior art, a deep neural network is generally used for processing the text emotion analysis problem, and the deep neural network can capture long-range context information and has strong feature extraction capability. However, the deep neural network has only one output, so that only two-classification emotion analysis can be completed by means of the deep neural network. Therefore, the accuracy of the existing text emotion analysis method is low.
Disclosure of Invention
The application mainly aims to provide a text emotion analysis model training method, a text emotion analysis model training device, text emotion analysis equipment and a readable storage medium, and aims to solve the technical problem that an existing text emotion analysis method is low in accuracy.
In order to achieve the above object, the present application provides a text emotion analysis model training method, which includes the following steps:
acquiring a text sample to be trained, wherein the text sample is provided with marking information, and the marking information is a correct emotion type contained in the text sample;
performing word segmentation processing on the text sample through a preset word segmentation method, and dividing the text sample into a plurality of different words;
respectively coding the different words based on a preset coding method to obtain word vectors corresponding to the text samples;
inputting the word vector into a preset deep neural network, and performing dimensionality reduction on the word vector based on an embedded layer in the preset deep neural network to obtain a dimensionality-reduced word vector;
calculating the word vector after the dimensionality reduction based on a hidden layer in the preset deep neural network to obtain the characteristics corresponding to the text sample;
classifying the characteristics corresponding to the text samples through a multi-classification SVM (support vector machine) to determine the emotion types corresponding to the text samples;
and determining a difference value between the emotion type and the correct emotion type based on a loss function, and judging that the text emotion analysis model is trained completely when the difference value meets a preset condition.
Optionally, the word segmentation processing on the text sample by a preset word segmentation method, and the dividing the text sample into a plurality of different words includes:
calculating binary conditional probability corresponding to each word contained in the text sample based on a standard corpus, wherein any two words W in the standard corpus1And W2Is represented as:
wherein, freq (W)1,W2) Represents W1And W2Number of adjacent occurrences together in the standard corpus, freq (W)1) And freq (W)2) Respectively represent W1And W2Statistics of occurrences in the standard corpus;
determining the joint distribution probability of each word in the text sample based on the binary conditional probability, determining the maximum joint distribution probability from the joint distribution probabilities, and determining the word segmentation method corresponding to the maximum joint distribution probability as the optimal word segmentation method corresponding to the text sample;
dividing the text sample into a number of different words based on the optimal word segmentation method.
Optionally, the calculating the reduced-dimension word vector based on a hidden layer in the preset deep neural network to obtain the feature corresponding to the text sample includes:
taking the reduced-dimension word vector corresponding to the L-1 section of text sample as the feature of the 1 section of text sample, acquiring a weight matrix of an L-1 layer hidden layer in the preset deep neural network, and calculating the weight matrix of the L-1 layer and the feature of the 1 section of text sample based on a nonlinear activation function to obtain the feature of the L section of text sample, wherein the formula for calculating based on the nonlinear activation function is as follows:
wherein, XiA word vector h obtained after the word segmentation and coding processing is carried out on the ith segment of text samplei 1Extracting the characteristics of the 1 st text sample for the preset deep neural network, wherein sigma is a nonlinear activation function, WL-1Is a weight matrix of an L-1 hidden layer in the preset deep neural network, hi LAnd extracting characteristics of the L-th section of text sample for the preset deep neural network.
Optionally, the classifying the features corresponding to the text samples by the multi-classification SVM support vector machine, and determining the emotion categories corresponding to the text samples includes:
randomly initializing k weight vectors Wy, and for the ith text sample, the decision of the multi-classification SVM support vector machine is as follows:
k is the emotion category number in a preset data set of the multi-classification SVM support vector machine;
will be provided withThe emotion category corresponding to the maximum product of the text sample is determined as the emotion category corresponding to the text sample.
In addition, in order to achieve the above object, the present application further provides a text emotion analysis model training apparatus, including:
the system comprises an acquisition module, a training module and a training module, wherein the acquisition module is used for acquiring a text sample to be trained, the text sample is provided with marking information, and the marking information is a correct emotion type contained in the text sample;
the word segmentation module is used for carrying out word segmentation processing on the text sample through a preset word segmentation method and dividing the text sample into a plurality of different words;
the encoding module is used for respectively encoding the plurality of different words based on a preset encoding method to obtain word vectors corresponding to the text samples;
the dimensionality reduction module is used for inputting the word vector into a preset deep neural network and carrying out dimensionality reduction on the word vector based on an embedded layer in the preset deep neural network to obtain a dimensionality reduced word vector;
the feature module is used for calculating the reduced-dimension word vector based on a hidden layer in the preset deep neural network to obtain features corresponding to the text sample;
the classification module is used for classifying the characteristics corresponding to the text samples through a multi-classification SVM (support vector machine) to determine the emotion types corresponding to the text samples;
and the completion module is used for determining a difference value between the emotion type and the correct emotion type based on a loss function, and judging that the text emotion analysis model training is completed when the difference value meets a preset condition.
Optionally, the word segmentation module includes:
a probability calculating unit, configured to calculate a binary conditional probability corresponding to each word included in the text sample based on a standard corpus, where any two words W in the standard corpus1And W2Is represented as:
wherein, freq (W)1,W2) Represents W1And W2Number of adjacent occurrences together in the standard corpus, freq (W)1) And freq (W)2) Respectively represent W1And W2Statistics of occurrences in the standard corpus;
the optimal word segmentation unit is used for determining the joint distribution probability of each word in the text sample based on the binary conditional probability, determining the maximum joint distribution probability from the joint distribution probabilities, and determining the word segmentation method corresponding to the maximum joint distribution probability as the optimal word segmentation method corresponding to the text sample;
and the text dividing unit is used for dividing the text sample into a plurality of different words based on the optimal word segmentation method.
Optionally, the feature module comprises:
the feature calculation unit is configured to take the reduced-dimension word vector corresponding to the L-1 th text sample as a feature of the 1 st text sample, obtain a weight matrix of an L-1 th hidden layer in the preset deep neural network, and calculate the weight matrix of the L-1 th layer and the feature of the 1 st text sample based on a nonlinear activation function to obtain a feature of the L-1 th text sample, where a formula calculated based on the nonlinear activation function is as follows:
wherein, XiA word vector h obtained after the word segmentation and coding processing is carried out on the ith segment of text samplei 1Extracting the characteristics of the 1 st text sample for the preset deep neural network, wherein sigma is a nonlinear activation function, WL-1To said presetH weight matrix of L-1 hidden layer in deep neural networki LAnd extracting characteristics of the L-th section of text sample for the preset deep neural network.
Optionally, the classification module comprises:
a class calculation unit for randomly initializing k weight vectors WyFor the ith text sample, the decision of the multi-classification SVM support vector machine is:
k is the emotion category number in a preset data set of the multi-classification SVM support vector machine;
a category determination unit for determining a category of the image dataThe emotion category corresponding to the maximum product of the text sample is determined as the emotion category corresponding to the text sample.
In addition, to achieve the above object, the present application also provides a text emotion analysis model training device, which includes an input/output unit, a memory and a processor, wherein the memory stores computer readable instructions, and the computer readable instructions, when executed by the processor, enable the processor to implement the steps of the text emotion analysis model training method as described above.
In addition, to achieve the above object, the present application further provides a readable storage medium, on which a text emotion analysis model training program is stored, and when the text emotion analysis model training program is executed by a processor, the steps of the text emotion analysis model training method are implemented.
The text emotion analysis model training method comprises the steps of firstly, obtaining a text sample to be trained with label information, wherein the label information is a correct emotion type contained in the text sample, and performing word segmentation processing on the text sample to obtain a plurality of different words; respectively coding a plurality of different words to obtain word vectors corresponding to the text samples, inputting the word vectors into a preset deep neural network, and performing dimension reduction processing on the word vectors based on an embedded layer in the preset deep neural network; further, calculating the word vectors subjected to the dimensionality reduction based on a hidden layer in a preset deep neural network to obtain the characteristics corresponding to the text sample; and finally, classifying the calculated features through a multi-classification SVM support vector machine so as to determine the emotion types corresponding to the text samples, determining the difference values of the emotion types and the correct emotion types based on a loss function in the text emotion analysis model training process, and judging that the text emotion analysis model training is finished when the difference values meet preset conditions. According to the text emotion analysis model training method, the emotion characteristics in the text sample are extracted through the deep neural network, then the extracted characteristics are subjected to multi-classification through the multi-classification SVM (support vector machine), and the effect of improving the classification accuracy is achieved.
Drawings
FIG. 1 is a schematic structural diagram of a text emotion analysis model training device for a hardware operating environment according to an embodiment of the present application;
FIG. 2 is a schematic flowchart of an embodiment of a text emotion analysis model training method according to the present application;
FIG. 3 is a functional block diagram of an embodiment of a text emotion analysis model training apparatus according to the present application;
FIG. 4 is a functional unit diagram of a word segmentation module in an embodiment of the text emotion analysis model training apparatus of the present application;
FIG. 5 is a functional block diagram of a feature module in an embodiment of a text emotion analysis model training apparatus according to the present application;
FIG. 6 is a functional unit diagram of a classification module in an embodiment of a text emotion analysis model training apparatus according to the present application.
The implementation, functional features and advantages of the objectives of the present application will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
As shown in fig. 1, fig. 1 is a schematic structural diagram of a text emotion analysis model training device in a hardware operating environment according to an embodiment of the present application.
The text emotion analysis model training device in the embodiment of the application can be a terminal device with data processing capability, such as a portable computer and a server.
As shown in fig. 1, the text emotion analysis model training apparatus may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, a communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001 described previously.
Those skilled in the art will appreciate that the configuration of the text emotion analysis model training apparatus illustrated in FIG. 1 does not constitute a limitation of the text emotion analysis model training apparatus, and may include more or fewer components than illustrated, or some components in combination, or a different arrangement of components.
As shown in FIG. 1, memory 1005, which is one type of computer storage medium, may include an operating system, a network communication module, a user interface module, and a text emotion analysis model training program.
In the text emotion analysis model training apparatus shown in fig. 1, the network interface 1004 is mainly used for connecting to a background server and communicating with the background server; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and processor 1001 may be configured to invoke the text emotion analysis model training program stored in memory 1005 and perform the operations of the following embodiments of the text emotion analysis model training method.
Referring to fig. 2, fig. 2 is a schematic flowchart of an embodiment of a text emotion analysis model training method according to the present application, in which the text emotion analysis model training method includes:
and step S10, acquiring a text sample to be trained, wherein the text sample is provided with marking information, and the marking information is the correct emotion type contained in the text sample.
In this embodiment, first, a text sample to be trained is obtained, so as to train a preset text emotion analysis model based on the text sample. Specifically, the text sample to be trained has label information, wherein the label information is mainly emotion category information included in the text sample, and in the embodiment, the emotion category information includes but is not limited to optimistic, pessimistic, angry, surprise, and the like.
And step S20, performing word segmentation processing on the text sample by a preset word segmentation method, and dividing the text sample into a plurality of different words.
Further, the text sample to be trained is preprocessed, and the preprocessing process mainly includes word segmentation of the text sample. Modern segmentation is based on statistical segmentation, and statistical sample content comes from some standard corpora, through which binary conditional probabilities among all words can be approximately calculated. The method comprises the steps of calculating binary conditional probabilities corresponding to all words contained in a text sample based on a standard corpus, determining the joint distribution probability of the text sample according to the binary conditional probabilities, and determining a word segmentation method corresponding to the maximum joint distribution probability as an optimal word segmentation method corresponding to the text sample so as to divide the text sample into a plurality of different words through the optimal word segmentation method.
And step S30, respectively coding a plurality of different words based on a preset coding method to obtain word vectors corresponding to the text samples.
Further, after the text sample is segmented, a plurality of words obtained by segmenting are respectively encoded, in this embodiment, one-hot encoding is mainly adopted. The one-hot coding aims to convert the category variables into a form which is easy to utilize by a machine learning algorithm, namely, the one-hot coding converts discrete variables obtained by segmenting text samples into continuous variables. And (3) carrying out binary operation on each word contained in the text sample by using one-hot coding, so that the reasonability of distance calculation between variables is improved. It can be understood that, in this embodiment, the word vector corresponding to each word is obtained by encoding each word obtained after the word segmentation processing of the text sample.
And step S40, inputting the word vectors into a preset deep neural network, and performing dimension reduction processing on the word vectors based on an embedded layer in the preset deep neural network to obtain the word vectors after dimension reduction.
And further, inputting the word vector obtained by encoding into a deep neural network, and processing the word vector obtained by encoding based on the deep neural network so as to extract the characteristics of the text sample. In this embodiment, since the word vectors obtained by using one-hot encoding are high in dimensionality and sparse, the input word vectors are first subjected to dimensionality reduction by an embedding layer in a deep neural network.
Specifically, the dimension reduction process is as follows: firstly, the weight matrix W stored in the embedding layer is obtained, because the embedding layer in the deep neural network is a special full connection in nature, only the vectors input to the deep neural network are all 0 or 1, and therefore, the dimension of the input word vector can be reduced by multiplying the input word vector by the weight matrix W.
And step S50, calculating the word vectors after the dimensionality reduction based on a hidden layer in a preset deep neural network to obtain the characteristics corresponding to the text sample.
And further, calculating the word vectors subjected to the dimension reduction through a hidden layer in the deep neural network, so as to extract the features of the word vectors subjected to the dimension reduction, wherein the extracted features are the features corresponding to the text samples.
Specifically, the process of feature extraction is as follows:
randomly inputting word vectors obtained after word segmentation and coding of the L-1 section of text samples into a deep neural network, performing dimensionality reduction on the input word vectors through a weight matrix W of an embedded layer, and taking the word vectors obtained after dimensionality reduction as the features of the 1 st text sample extracted by the deep neural network; further, a weight matrix of an L-1 hidden layer in a preset deep neural network is obtained, the weight matrix of the L-1 and the characteristics of the 1 st text sample are calculated based on a nonlinear activation function, and the characteristics of the L-1 th text sample are obtained, wherein a formula for calculating based on the nonlinear activation function is as follows:
wherein, XiA word vector h obtained after the word segmentation and coding processing is carried out on the ith segment of text samplei 1Extracting the characteristics of the 1 st text sample for the preset deep neural network, wherein sigma is a nonlinear activation function, WL-1Is a weight matrix of an L-1 hidden layer in a preset deep neural network, hi LAnd extracting characteristics of the L-th section of text sample for the preset deep neural network.
And step S60, classifying the characteristics corresponding to the text samples through a multi-classification SVM support vector machine, and determining the emotion types corresponding to the text samples.
After the feature extraction of the text sample to be trained is completed, the extracted features are further classified based on a multi-classification SVM (support vector machine), so that the emotion category of the text sample is determined.
Specifically, the emotion types in the preset data set of the multi-classification SVM support vector machine are assumed to be K, and are marked as y belonging to {1, …, K }; at the same time, k weight vectors W are randomly initializedyFor the ith text sample, the decision of the multi-classification SVM is as follows:
namely, in k emotion types, the preset text emotion analysis model is distinguishedThe category information corresponding to the maximum product of the above is the emotion category corresponding to the text sample.
And step S70, determining the difference value between the emotion type and the correct emotion type based on the loss function, and judging that the text emotion analysis model training is finished when the difference value meets the preset condition.
In this embodiment, whether the text emotion analysis model is trained is determined through a loss function, where the loss function is defined as follows:
wherein, yiIn this embodiment, because the text sample to be trained has the correct emotion category label information, the loss function requires that the scores of all the wrong categories are smaller than the score of the correct category. Meanwhile, in the present embodiment, a degree of difference Δ (y, j) between emotion categories is defined, the degree of difference Δ (y, y) between emotion categories of the same kind is 0, and the difference between emotion categories of different kinds may be set to 1 or may be set to different values. The penalty function requires that the separation between the score of the wrong category and the score of the correct category is greater than the difference Δ (y) between the twoi,y)。
In this embodiment, a text sample to be trained with label information is obtained, the label information is a correct emotion type contained in the text sample, and the text sample is subjected to word segmentation to obtain a plurality of different words; respectively coding a plurality of different words to obtain word vectors corresponding to the text samples, inputting the word vectors into a preset deep neural network, and performing dimension reduction processing on the word vectors based on an embedded layer in the preset deep neural network; further, calculating the word vectors subjected to the dimensionality reduction based on a hidden layer in a preset deep neural network to obtain the characteristics corresponding to the text sample; and finally, classifying the calculated features through a multi-classification SVM support vector machine so as to determine the emotion types corresponding to the text samples, determining the difference values of the emotion types and the correct emotion types based on a loss function in the text emotion analysis model training process, and judging that the text emotion analysis model training is finished when the difference values meet preset conditions. According to the text emotion analysis model training method, the emotion characteristics in the text sample are extracted through the deep neural network, then the extracted characteristics are subjected to multi-classification through the multi-classification SVM (support vector machine), and the effect of improving the classification accuracy is achieved.
Further, the step S20 includes:
step S21, calculating the binary conditional probability corresponding to each word contained in the text sample based on the standard corpus, wherein any two words W in the standard corpus1And W2Is represented as:
wherein, freq (W)1,W2) Represents W1And W2Number of adjacent occurrences together in the standard corpus, freq (W)1) And freq (W)2) Respectively represent W1And W2Statistics of occurrences in the standard corpus;
step S22, determining the joint distribution probability of each word in the text sample based on the binary conditional probability, determining the maximum joint distribution probability from the joint distribution probabilities, and determining the word segmentation method corresponding to the maximum joint distribution probability as the optimal word segmentation method corresponding to the text sample;
step S23, the text sample is divided into several different words based on the optimal word segmentation method.
In this embodiment, a binary conditional probability corresponding to each word included in a text sample is calculated through a standard corpus, a joint distribution probability of the text sample is determined through the binary conditional probability, and a word segmentation method corresponding to the maximum joint distribution probability is determined as an optimal word segmentation method corresponding to the text sample.
In particular, for any two words W1And W2Their binary conditional probability distribution can be approximated as:
wherein, freq (W)1,W2) Represents W1And W2Number of occurrences of neighbors together in the standard corpus, freq (W)1) And freq (W)2) Then respectively represent W1And W2Statistical number of occurrences in the standard corpus.
And calculating the binary conditional probability corresponding to each word contained in the text sample through the binary conditional probability distribution formula, determining the joint distribution probability of each word in the text sample according to the binary conditional probability, and finding the word segmentation method corresponding to the maximum joint distribution probability, namely the optimal word segmentation method corresponding to the text sample. The text sample is subjected to word segmentation processing through an optimal word segmentation method, and the text sample can be divided into a plurality of different words.
Further, after step S70, the method further includes:
in this embodiment, after the training of the preset text emotion analysis model is completed, when a text emotion analysis instruction is received, the preset text emotion analysis model is obtained first, and text emotion analysis is performed on a text to be analyzed by using the preset text emotion analysis model, so as to output emotion category information included in the text to be analyzed.
Specifically, firstly, preprocessing an input text to be analyzed, namely segmenting words of the text to be analyzed; further, a plurality of words obtained by word segmentation are coded based on a one-hot coding method to obtain corresponding word vectors; inputting the word vector obtained by coding into a deep neural network so as to extract the characteristics of the text sample through the deep neural network; and finally, carrying out emotion category classification on the extracted features based on a multi-classification SVM support vector machine, and finally outputting emotion category information corresponding to the text to be analyzed.
Referring to fig. 3, fig. 3 is a functional module schematic diagram of an embodiment of the text emotion analysis model training apparatus of the present application.
In this embodiment, the text emotion analysis model training apparatus includes:
the obtaining module 10 is configured to obtain a text sample to be trained, where the text sample has label information, and the label information is a correct emotion category included in the text sample;
the word segmentation module 20 is configured to perform word segmentation processing on the text sample by using a preset word segmentation method, and divide the text sample into a plurality of different words;
the encoding module 30 is configured to perform encoding processing on the plurality of different words based on a preset encoding method, so as to obtain word vectors corresponding to the text samples;
the dimension reduction module 40 is configured to input the word vector into a preset deep neural network, and perform dimension reduction processing on the word vector based on an embedded layer in the preset deep neural network to obtain a word vector after dimension reduction;
a feature module 50, configured to calculate the reduced-dimension word vector based on a hidden layer in the preset deep neural network, so as to obtain a feature corresponding to the text sample;
a classification module 60, configured to classify, by using a multi-classification SVM support vector machine, features corresponding to the text sample, and determine an emotion category corresponding to the text sample;
a completion module 70, configured to determine a difference value between the emotion category and the correct emotion category based on a loss function, and when the difference value meets a preset condition, determine that the text emotion analysis model training is completed.
Further, referring to fig. 4, the word segmentation module 20 includes:
a probability calculating unit 201, configured to calculate a binary conditional probability corresponding to each word included in the text sample based on a standard corpus, where any two words W in the standard corpus1And W2Is represented as:
wherein, freq (W)1,W2) Represents W1And W2Number of adjacent occurrences together in the standard corpus, freq (W)1) And freq (W)2) Respectively represent W1And W2Statistics of occurrences in the standard corpus;
an optimal word segmentation unit 202, configured to determine joint distribution probabilities of words in the text sample based on the binary conditional probabilities, determine a maximum joint distribution probability from the joint distribution probabilities, and determine a word segmentation method corresponding to the maximum joint distribution probability as an optimal word segmentation method corresponding to the text sample;
a text dividing unit 203 for dividing the text sample into a plurality of different words based on the optimal word segmentation method
Further, referring to fig. 5, the feature module 50 includes:
a feature calculating unit 501, configured to take the reduced-dimension word vector corresponding to the L-1 th text sample as a feature of the 1 st text sample, obtain a weight matrix of an L-1 th hidden layer in the preset deep neural network, and calculate the weight matrix of the L-1 th layer and the feature of the 1 st text sample based on a nonlinear activation function to obtain a feature of the L-1 th text sample, where a formula calculated based on the nonlinear activation function is as follows:
wherein, XiA word vector h obtained after the word segmentation and coding processing is carried out on the ith segment of text samplei 1Extracting the characteristics of the 1 st text sample for the preset deep neural network, wherein sigma is a nonlinear activation function, WL-1Is a weight matrix of an L-1 hidden layer in the preset deep neural network, hi LAnd extracting characteristics of the L-th section of text sample for the preset deep neural network.
Further, referring to fig. 6, the classification module 60 includes:
a class calculation unit 601 for randomly initializing k weight vectors WyFor the ith text sample, the decision of the multi-classification SVM support vector machine is:
k is the emotion category number in a preset data set of the multi-classification SVM support vector machine;
a category determination unit 602 for determining a category of the imageThe emotion category corresponding to the maximum product of the text sample is determined as the emotion category corresponding to the text sample.
The specific embodiment of the text emotion analysis model training device of the present application is basically the same as each embodiment of the text emotion analysis model training method described above, and details thereof are not repeated herein.
In addition, an embodiment of the present application further provides a readable storage medium, where a text emotion analysis model training program is stored on the readable storage medium, and when executed by a processor, the text emotion analysis model training program implements the steps of the text emotion analysis model training method as described above.
The specific embodiment of the readable storage medium of the present application is substantially the same as the embodiments of the text emotion analysis model training method, and details are not repeated herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system 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 system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are included in the scope of the present application.
Claims (10)
1. A text emotion analysis model training method is characterized by comprising the following steps:
acquiring a text sample to be trained, wherein the text sample is provided with marking information, and the marking information is a correct emotion type contained in the text sample;
performing word segmentation processing on the text sample through a preset word segmentation method, and dividing the text sample into a plurality of different words;
respectively coding the different words based on a preset coding method to obtain word vectors corresponding to the text samples;
inputting the word vector into a preset deep neural network, and performing dimensionality reduction on the word vector based on an embedded layer in the preset deep neural network to obtain a dimensionality-reduced word vector;
calculating the word vector after the dimensionality reduction based on a hidden layer in the preset deep neural network to obtain the characteristics corresponding to the text sample;
classifying the characteristics corresponding to the text samples through a multi-classification SVM (support vector machine) to determine the emotion types corresponding to the text samples;
and determining a difference value between the emotion type and the correct emotion type based on a loss function, and judging that the text emotion analysis model is trained completely when the difference value meets a preset condition.
2. The method for training the text emotion analysis model of claim 1, wherein the segmenting the text sample by a preset segmentation method, and the dividing the text sample into a plurality of different words comprises:
calculating two corresponding to each word contained in the text sample based on a standard corpusMeta conditional probability, where any two words W in the standard corpus1And W2Is represented as:
wherein, freq (W)1,W2) Represents W1And W2Number of adjacent occurrences together in the standard corpus, freq (W)1) And freq (W)2) Respectively represent W1And W2Statistics of occurrences in the standard corpus;
determining the joint distribution probability of each word in the text sample based on the binary conditional probability, determining the maximum joint distribution probability from the joint distribution probabilities, and determining the word segmentation method corresponding to the maximum joint distribution probability as the optimal word segmentation method corresponding to the text sample;
dividing the text sample into a number of different words based on the optimal word segmentation method.
3. The method for training the text emotion analysis model according to claim 1, wherein the calculating the reduced-dimension word vector based on the hidden layer in the preset deep neural network to obtain the features corresponding to the text sample comprises:
taking the reduced-dimension word vector corresponding to the L-1 section of text sample as the feature of the 1 section of text sample, acquiring a weight matrix of an L-1 layer hidden layer in the preset deep neural network, and calculating the weight matrix of the L-1 layer and the feature of the 1 section of text sample based on a nonlinear activation function to obtain the feature of the L section of text sample, wherein the formula for calculating based on the nonlinear activation function is as follows:
wherein, XiA word vector h obtained after the word segmentation and coding processing is carried out on the ith segment of text samplei 1Extracting the characteristics of the 1 st text sample for the preset deep neural network, wherein sigma is a nonlinear activation function, WL-1Is a weight matrix of an L-1 hidden layer in the preset deep neural network, hi LAnd extracting characteristics of the L-th section of text sample for the preset deep neural network.
4. The method for training the text emotion analysis model of claim 3, wherein the classifying the features corresponding to the text samples through a multi-classification SVM support vector machine, and the determining the emotion classification corresponding to the text samples comprises:
randomly initializing k weight vectors WyFor the ith text sample, the decision of the multi-classification SVM support vector machine is:
k is the emotion category number in a preset data set of the multi-classification SVM support vector machine;
5. A text emotion analysis model training device, comprising:
the system comprises an acquisition module, a training module and a training module, wherein the acquisition module is used for acquiring a text sample to be trained, the text sample is provided with marking information, and the marking information is a correct emotion type contained in the text sample;
the word segmentation module is used for carrying out word segmentation processing on the text sample through a preset word segmentation method and dividing the text sample into a plurality of different words;
the encoding module is used for respectively encoding the plurality of different words based on a preset encoding method to obtain word vectors corresponding to the text samples;
the dimensionality reduction module is used for inputting the word vector into a preset deep neural network and carrying out dimensionality reduction on the word vector based on an embedded layer in the preset deep neural network to obtain a dimensionality reduced word vector;
the feature module is used for calculating the reduced-dimension word vector based on a hidden layer in the preset deep neural network to obtain features corresponding to the text sample;
the classification module is used for classifying the characteristics corresponding to the text samples through a multi-classification SVM (support vector machine) to determine the emotion types corresponding to the text samples;
and the completion module is used for determining the difference value between the emotion type and the correct emotion type based on a loss function, and judging that the text emotion analysis model training is completed when the difference value meets a preset condition.
6. The apparatus for training text emotion analysis model as claimed in claim 5, wherein the word segmentation module comprises:
a probability calculating unit, configured to calculate a binary conditional probability corresponding to each word included in the text sample based on a standard corpus, where any two words W in the standard corpus1And W2Is represented as:
wherein, freq (W)1,W2) Represents W1And W2Number of adjacent occurrences together in the standard corpus, freq (W)1) And freq (W)2) Respectively represent W1And W2Statistics of occurrences in the standard corpus;
the optimal word segmentation unit is used for determining the joint distribution probability of each word in the text sample based on the binary conditional probability, determining the maximum joint distribution probability from the joint distribution probabilities, and determining the word segmentation method corresponding to the maximum joint distribution probability as the optimal word segmentation method corresponding to the text sample;
and the text dividing unit is used for dividing the text sample into a plurality of different words based on the optimal word segmentation method.
7. The apparatus for training a text emotion analysis model as claimed in claim 5, wherein the feature module comprises:
the feature calculation unit is configured to take the reduced-dimension word vector corresponding to the L-1 th text sample as a feature of the 1 st text sample, obtain a weight matrix of an L-1 th hidden layer in the preset deep neural network, and calculate the weight matrix of the L-1 th layer and the feature of the 1 st text sample based on a nonlinear activation function to obtain a feature of the L-1 th text sample, where a formula calculated based on the nonlinear activation function is as follows:
wherein, XiA word vector h obtained after the word segmentation and coding processing is carried out on the ith segment of text samplei 1Extracting the characteristics of the 1 st text sample for the preset deep neural network, wherein sigma is a nonlinear activation functionNumber, WL-1Is a weight matrix of an L-1 hidden layer in the preset deep neural network, hi LAnd extracting characteristics of the L-th section of text sample for the preset deep neural network.
8. The apparatus for training text emotion analysis model of claim 7, wherein the classification module comprises:
a class calculation unit for randomly initializing k weight vectors WyFor the ith text sample, the decision of the multi-classification SVM support vector machine is:
k is the emotion category number in a preset data set of the multi-classification SVM support vector machine;
9. A text emotion analysis model training apparatus, characterized in that the text emotion analysis model training apparatus comprises an input-output unit, a memory and a processor, the memory having stored therein computer readable instructions which, when executed by the processor, cause the processor to carry out the steps of the text emotion analysis model training method according to any one of claims 1 to 4.
10. A readable storage medium, wherein the readable storage medium stores thereon a text emotion analysis model training program, and the text emotion analysis model training program, when executed by a processor, implements the steps of the text emotion analysis model training method according to any one of claims 1 to 4.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910884618.1A CN110807314A (en) | 2019-09-19 | 2019-09-19 | Text emotion analysis model training method, device and equipment and readable storage medium |
PCT/CN2019/118268 WO2021051598A1 (en) | 2019-09-19 | 2019-11-14 | Text sentiment analysis model training method, apparatus and device, and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910884618.1A CN110807314A (en) | 2019-09-19 | 2019-09-19 | Text emotion analysis model training method, device and equipment and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110807314A true CN110807314A (en) | 2020-02-18 |
Family
ID=69487688
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910884618.1A Pending CN110807314A (en) | 2019-09-19 | 2019-09-19 | Text emotion analysis model training method, device and equipment and readable storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN110807314A (en) |
WO (1) | WO2021051598A1 (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110990837A (en) * | 2020-02-29 | 2020-04-10 | 网御安全技术(深圳)有限公司 | System call behavior sequence dimension reduction method, system, equipment and storage medium |
CN111339305A (en) * | 2020-03-20 | 2020-06-26 | 北京中科模识科技有限公司 | Text classification method and device, electronic equipment and storage medium |
CN112084316A (en) * | 2020-09-09 | 2020-12-15 | 浙江连信科技有限公司 | Training method and device of emotion recognition model |
CN112612878A (en) * | 2020-12-17 | 2021-04-06 | 大唐融合通信股份有限公司 | Customer service information providing method, electronic equipment and device |
CN113283232A (en) * | 2021-05-31 | 2021-08-20 | 支付宝(杭州)信息技术有限公司 | Method and device for automatically analyzing private information in text |
CN113626587A (en) * | 2020-05-08 | 2021-11-09 | 武汉金山办公软件有限公司 | Text type identification method and device, electronic equipment and medium |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113657446A (en) * | 2021-07-13 | 2021-11-16 | 广东外语外贸大学 | Processing method, system and storage medium of multi-label emotion classification model |
CN113656548B (en) * | 2021-08-18 | 2023-08-04 | 福州大学 | Text classification model interpretation method and system based on data envelope analysis |
CN115203412B (en) * | 2022-07-06 | 2024-02-20 | 腾讯科技(深圳)有限公司 | Emotion viewpoint information analysis method and device, storage medium and electronic equipment |
CN116522932B (en) * | 2023-06-26 | 2023-09-19 | 云目未来科技(湖南)有限公司 | Text analysis method and system |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105868178A (en) * | 2016-03-28 | 2016-08-17 | 浙江大学 | Multi-document automatic abstract generation method based on phrase subject modeling |
CN106844424A (en) * | 2016-12-09 | 2017-06-13 | 宁波大学 | A kind of file classification method based on LDA |
CN109857864A (en) * | 2019-01-07 | 2019-06-07 | 平安科技(深圳)有限公司 | Text sentiment classification method, device, computer equipment and storage medium |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP3347833A1 (en) * | 2015-09-08 | 2018-07-18 | Iacus, Stefano, Maria | Isa: a fast, scalable and accurate algorithm for supervised opinion analysis |
CN107391483A (en) * | 2017-07-13 | 2017-11-24 | 武汉大学 | A kind of comment on commodity data sensibility classification method based on convolutional neural networks |
CN108108355A (en) * | 2017-12-25 | 2018-06-01 | 北京牡丹电子集团有限责任公司数字电视技术中心 | Text emotion analysis method and system based on deep learning |
CN109284376A (en) * | 2018-09-10 | 2019-01-29 | 成都信息工程大学 | Cross-cutting news data sentiment analysis method based on domain-adaptive |
CN110209824B (en) * | 2019-06-13 | 2021-06-22 | 中国科学院自动化研究所 | Text emotion analysis method, system and device based on combined model |
-
2019
- 2019-09-19 CN CN201910884618.1A patent/CN110807314A/en active Pending
- 2019-11-14 WO PCT/CN2019/118268 patent/WO2021051598A1/en active Application Filing
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105868178A (en) * | 2016-03-28 | 2016-08-17 | 浙江大学 | Multi-document automatic abstract generation method based on phrase subject modeling |
CN106844424A (en) * | 2016-12-09 | 2017-06-13 | 宁波大学 | A kind of file classification method based on LDA |
CN109857864A (en) * | 2019-01-07 | 2019-06-07 | 平安科技(深圳)有限公司 | Text sentiment classification method, device, computer equipment and storage medium |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110990837A (en) * | 2020-02-29 | 2020-04-10 | 网御安全技术(深圳)有限公司 | System call behavior sequence dimension reduction method, system, equipment and storage medium |
CN110990837B (en) * | 2020-02-29 | 2023-03-24 | 网御安全技术(深圳)有限公司 | System call behavior sequence dimension reduction method, system, equipment and storage medium |
CN111339305A (en) * | 2020-03-20 | 2020-06-26 | 北京中科模识科技有限公司 | Text classification method and device, electronic equipment and storage medium |
CN111339305B (en) * | 2020-03-20 | 2023-04-14 | 北京中科模识科技有限公司 | Text classification method and device, electronic equipment and storage medium |
CN113626587A (en) * | 2020-05-08 | 2021-11-09 | 武汉金山办公软件有限公司 | Text type identification method and device, electronic equipment and medium |
CN113626587B (en) * | 2020-05-08 | 2024-03-29 | 武汉金山办公软件有限公司 | Text category identification method and device, electronic equipment and medium |
CN112084316A (en) * | 2020-09-09 | 2020-12-15 | 浙江连信科技有限公司 | Training method and device of emotion recognition model |
CN112612878A (en) * | 2020-12-17 | 2021-04-06 | 大唐融合通信股份有限公司 | Customer service information providing method, electronic equipment and device |
CN113283232A (en) * | 2021-05-31 | 2021-08-20 | 支付宝(杭州)信息技术有限公司 | Method and device for automatically analyzing private information in text |
Also Published As
Publication number | Publication date |
---|---|
WO2021051598A1 (en) | 2021-03-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110807314A (en) | Text emotion analysis model training method, device and equipment and readable storage medium | |
CN109271521B (en) | Text classification method and device | |
CN110990543A (en) | Intelligent conversation generation method and device, computer equipment and computer storage medium | |
CN106951832B (en) | Verification method and device based on handwritten character recognition | |
CN110555372A (en) | Data entry method, device, equipment and storage medium | |
CN108038208B (en) | Training method and device of context information recognition model and storage medium | |
CN109685065B (en) | Layout analysis method and system for automatically classifying test paper contents | |
CN110705233B (en) | Note generation method and device based on character recognition technology and computer equipment | |
CN111858843B (en) | Text classification method and device | |
CN113254654B (en) | Model training method, text recognition method, device, equipment and medium | |
CN112036168B (en) | Event main body recognition model optimization method, device, equipment and readable storage medium | |
CN110288085B (en) | Data processing method, device and system and storage medium | |
CN110287311A (en) | File classification method and device, storage medium, computer equipment | |
US8463054B2 (en) | Hierarchical OCR using decision tree and nonparametric classifier | |
CN112836509A (en) | Expert system knowledge base construction method and system | |
CN111931809A (en) | Data processing method and device, storage medium and electronic equipment | |
CN117197904A (en) | Training method of human face living body detection model, human face living body detection method and human face living body detection device | |
CN111680669A (en) | Test question segmentation method and system and readable storage medium | |
CN115357699A (en) | Text extraction method, device, equipment and storage medium | |
CN111488501A (en) | E-commerce statistical system based on cloud platform | |
CN110750984B (en) | Command line character string processing method, terminal, device and readable storage medium | |
CN113128284A (en) | Multi-mode emotion recognition method and device | |
CN111859957B (en) | Emotion reason clause label extraction method, device, equipment and storage medium | |
CN114638229A (en) | Entity identification method, device, medium and equipment of record data | |
CN113469237A (en) | User intention identification method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |