WO2020258502A1 - 文本分析方法、装置、计算机装置及存储介质 - Google Patents

文本分析方法、装置、计算机装置及存储介质 Download PDF

Info

Publication number
WO2020258502A1
WO2020258502A1 PCT/CN2019/103413 CN2019103413W WO2020258502A1 WO 2020258502 A1 WO2020258502 A1 WO 2020258502A1 CN 2019103413 W CN2019103413 W CN 2019103413W WO 2020258502 A1 WO2020258502 A1 WO 2020258502A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
feature vector
word
analyzed
recognized
Prior art date
Application number
PCT/CN2019/103413
Other languages
English (en)
French (fr)
Inventor
金戈
徐亮
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020258502A1 publication Critical patent/WO2020258502A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks

Definitions

  • This application relates to the technical field of natural language processing, in particular to a text analysis method, device, computer device and storage medium.
  • text analysis methods for text sentiment classification gradually use deep learning methods, including CNN (Convolutional Neural Network), RNN (Recurrent Neural Networks, Recurrent Neural Network) and LSTM (Long Short-term Memory Recurrent).
  • CNN Convolutional Neural Network
  • RNN Recurrent Neural Networks, Recurrent Neural Network
  • LSTM Long Short-term Memory Recurrent
  • CNN-based algorithms can effectively classify text, the problem of text sentiment classification is not a simple text classification problem.
  • RNN has important applications in text analysis because it contains the timing relationship of the input information. Using RNN for text analysis is better than traditional machine learning-based text sentiment classification methods. Use RNN for document-level sentiment classification, and apply the pooling layer to automatically determine important words in text classification. However, it cannot be ignored that RNN itself has certain defects. When there are too many cycles, problems such as long-term dependence and gradient explosion will occur.
  • LSTM uses memory units in the chain structure of neural network modules to control the interaction of information, thereby avoiding the shortcomings of RNN.
  • Algorithms based on the LSTM network can store important information in the text by selectively saving and forgetting information, thereby completing text analysis.
  • the existing text analysis method based on the LSTM network has a long operation process, low operation efficiency, and low accuracy of text sentiment classification.
  • the first aspect of the present application provides a text analysis method, the method includes:
  • the weight-adjusted feature vector is input into the fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized.
  • the converting each word of the text to be analyzed into a word vector includes:
  • the word2vec tool is used to convert each word of the text to be analyzed into a word vector.
  • the segmentation of the text to be recognized includes:
  • the obtaining the text to be analyzed includes:
  • the emotion recognition model further includes a first hidden layer and a second hidden layer
  • the calculating the weight of the feature vector includes:
  • the intermediate value is input to the second hidden layer, and output through an output function to obtain the weight.
  • the inputting the weight-adjusted feature vector into the fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized includes:
  • the joint feature vector is output through an output function to obtain the emotion category of the text to be recognized.
  • the method further includes:
  • the word corresponding to the target feature vector in the text to be recognized is used as a text summary of the text to be recognized.
  • a second aspect of the present application provides a text analysis device, the device includes:
  • the acquisition module is used to acquire the text to be analyzed
  • a conversion module for converting each word of the text to be analyzed into a word vector
  • the feature extraction module is used to input the word vector into the two-way long and short-term memory recurrent neural network in the emotion recognition model to obtain the feature vector of each word of the text to be analyzed;
  • the first calculation module is used to calculate the weight of the feature vector
  • the second calculation module is configured to multiply the feature vector and the corresponding weight to obtain the feature vector after weight adjustment
  • the recognition module is configured to input the weight-adjusted feature vector into the fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized.
  • the converting each word of the text to be analyzed into a word vector includes:
  • the word2vec tool is used to convert each word of the text to be analyzed into a word vector.
  • the segmentation of the text to be recognized includes:
  • the obtaining the text to be analyzed includes:
  • the emotion recognition model further includes a first hidden layer and a second hidden layer
  • the calculating the weight of the feature vector includes:
  • the intermediate value is input to the second hidden layer, and output through an output function to obtain the weight.
  • the inputting the weight-adjusted feature vector into the fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized includes:
  • the joint feature vector is output through an output function to obtain the emotion category of the text to be recognized.
  • the device further includes:
  • the abstract acquisition module is configured to determine a target feature vector whose weight is greater than or equal to a preset value in the feature vector, and use the word corresponding to the target feature vector in the text to be recognized as a text summary of the text to be recognized.
  • a third aspect of the present application provides a computer device that includes a processor, and the processor is configured to implement the text analysis method when executing computer-readable instructions stored in a memory.
  • a fourth aspect of the present application provides a non-volatile readable storage medium having computer readable instructions stored thereon, and the computer readable instructions implement the text analysis method when executed by a processor.
  • This application obtains the text to be analyzed; converts each word of the text to be analyzed into a word vector; inputs the word vector into the two-way long and short-term memory recurrent neural network in the emotion recognition model to obtain the information of each word in the text to be analyzed Feature vector; calculate the weight of the feature vector; multiply the feature vector with the corresponding weight to obtain a feature vector after weight adjustment; input the feature vector after weight adjustment into the emotion recognition model
  • the fully connected layer in obtain the emotion category of the text to be recognized.
  • Fig. 1 is a flowchart of a text analysis method provided by an embodiment of the present application.
  • Figure 2 is a structural diagram of a text analysis device provided by an embodiment of the present application.
  • Fig. 3 is a schematic diagram of a computer device provided by an embodiment of the present application.
  • the text analysis method of the present application is applied in one or more computer devices.
  • the computer device is a device that can automatically perform numerical calculation and/or information processing in accordance with pre-set or stored instructions.
  • Its hardware includes, but is not limited to, a microprocessor and an application specific integrated circuit (ASIC) , Field-Programmable Gate Array (FPGA), Digital Processor (Digital Signal Processor, DSP), embedded equipment, etc.
  • ASIC application specific integrated circuit
  • FPGA Field-Programmable Gate Array
  • DSP Digital Processor
  • embedded equipment etc.
  • the computer device may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the computer device can interact with the user through a keyboard, a mouse, a remote control, a touch panel, or a voice control device.
  • FIG. 1 is a flowchart of a text analysis method provided in Embodiment 1 of the present application.
  • the text analysis method is applied to a computer device.
  • the text analysis method of this application analyzes the text to be analyzed and determines the sentiment category of the text to be analyzed.
  • the text analysis method can improve the efficiency and accuracy of text emotion classification.
  • the text analysis method includes:
  • Step 101 Obtain the text to be analyzed.
  • User input data can be received, and the text to be analyzed can be obtained according to the user input data.
  • the user input data may be text, voice or image.
  • the text input by the user may be received, and the text input by the user may be used as the text to be analyzed.
  • the voice input by the user may be accepted, and the voice may be recognized to obtain the text to be analyzed.
  • the user's voice can be collected through the microphone of the service self-service machine, and the service application can be obtained according to the collected voice.
  • Various speech recognition technologies can be used, such as Dynamic Time Warping (DTW), Hidden Markov Model (HMM), Vector Quantization (VQ), Artificial Neural Network (Artificial Neural Network, ANN) and other technologies to recognize the voice.
  • a text image input by a user may be received, and the text image may be recognized to obtain the text to be analyzed.
  • the text image can be sequentially subjected to clustering analysis, grayscale, image filtering, binarization, and tilt correction processing, and the processed text image is image segmented to obtain multiple character images, and the character images are recognized to obtain The text to be analyzed.
  • the cluster analysis processing can use the K-means algorithm to perform color clustering.
  • Binarization can firstly process the image with local threshold method, and then apply dynamic threshold method to each part processed by local threshold method.
  • Image segmentation of the processed image may include: segmenting the processed image based on region, segmenting each region based on region segmentation based on edge detection, and performing character segmentation on the segmented image based on edge detection. .
  • the text to be analyzed can be obtained from a predetermined data source.
  • user comments are obtained from social platforms (such as online forums, Weibo, etc.), and the user comments are used as the text to be analyzed.
  • a product review is obtained from a shopping platform (such as Taobao, Jingdong, etc.), and the product review is used as the text to be analyzed.
  • the text to be recognized may be Chinese text.
  • the text to be recognized may also be text in other languages.
  • the text to be analyzed may include one sentence or multiple sentences. If the text to be analyzed includes multiple sentences, each sentence can be analyzed separately to obtain the sentiment category of each sentence.
  • Step 102 Convert each word of the text to be analyzed into a word vector.
  • the word vector means that each word is represented as a multi-dimensional vector containing semantic information.
  • the text to be analyzed may include n different words, and one-hot vectors of n dimensions are used to represent the words in the text to be analyzed (that is, each word in the text to be analyzed corresponds to the one-hot vector One dimension, the first word corresponds to the first dimension in the one-hot vector, the second word corresponds to the second dimension in the one-hot vector, and so on), where n is a positive integer, and n can be 5000.
  • the value of the third dimension is 1, and the value of other dimensions is 0.
  • the dimension of the word vector can be 300 dimensions, and the vectorization processing can use fewer dimensions
  • the vector of carries the information of the text to be analyzed.
  • the word2vec tool can be used to convert each word of the text to be analyzed into a word vector.
  • the Skip-gram model in the word2vec tool can be used to train each word represented by a one-hot vector in the text to be analyzed to obtain a word vector dictionary, where each word corresponds to a word vector.
  • the word2vec tool is the valley lyrics vector tool.
  • the converting each word of the text to be analyzed into a word vector includes:
  • the word2vec tool is used to convert each word of the text to be analyzed into a word vector.
  • the text to be recognized is a Chinese text
  • the Chinese text is segmented to obtain each word of the Chinese text
  • the word2vec tool is used to convert each word of the text to be analyzed represented by one-hot vector into words vector.
  • the stuttering word segmentation can be used to segment the text to be recognized.
  • Stuttering word segmentation belongs to probabilistic language model word segmentation. Its task is to find a segmentation scheme S among all the results obtained by full segmentation, so that P(S) is the largest, where P(S) represents the probability of segmentation scheme S.
  • the stammering word segmentation is an existing technology, and will not be repeated here.
  • the text to be recognized may be segmented by using specific characters, and segmentation is performed at positions before and/or after the specific character in the text to be recognized, to obtain a segmentation result of the text to be recognized.
  • a preset verb such as go, in
  • segmentation is performed at the position before and/or after the preset verb in the text to be recognized, to obtain the to-be-recognized text
  • the word segmentation result of the text can be used to segment the text to be recognized, and segmentation is performed at the position before and/or after the preset verb in the text to be recognized, to obtain the to-be-recognized text.
  • a dictionary library can be used to segment the text to be recognized.
  • the dictionary library includes multiple proper nouns, and the proper nouns are no longer segmented as a single word.
  • the converting each word of the text to be analyzed into a word vector includes:
  • the specified characters may include auxiliary words, such as modal auxiliary words (?, ne, ah, bar, etc.), tense auxiliary words (zh, le, pass, etc.), and structural particles (de, di, de, etc.).
  • the designated characters may include English characters, numbers, symbols, prepositions, conjunctions, etc.
  • a stop word database can be established, and the stop word database includes the specified characters (ie stop words) to be removed.
  • Step 103 Input the word vector into the two-way Long Short-term Memory Recurrent Neural Network (LSTM) in the emotion recognition model to obtain the feature vector of each word of the text to be analyzed.
  • LSTM Long Short-term Memory Recurrent Neural Network
  • the two-way LSTM is used to construct features for input data (ie, the word vector).
  • the bidirectional LSTM includes a forward LSTM and a backward LSTM.
  • the word vector is input into the forward LSTM and the backward LSTM respectively to obtain the feature vector.
  • the feature vector includes a forward feature vector and a backward feature vector.
  • the forward feature vector is obtained from the forward LSTM, and the backward feature vector is obtained from the backward LSTM.
  • the forward LSTM and the backward LSTM may both include two LSTM unit layers.
  • the first LSTM unit layer constructs features on input data to obtain hidden layer units, and the second layer LSTM unit layer performs processing on the hidden layer units. combination.
  • the first LSTM unit layer is used to extract local features
  • the second LSTM unit layer is used to combine local features to obtain global features.
  • Each LSTM cell layer includes a forget gate, an input gate, and an output gate, and the forget gate, input gate, and output gate control the memory state of the LSTM cell layer.
  • the dimension of the feature vector is equal to the number of word vectors.
  • LSTM is a time recurrent neural network. Compared with the traditional Recurrent Neural Network (RNN), LSTM stores information by constructing some gates on the LSTM unit layer, so the gradient will not disappear quickly during the model training process.
  • RNN Recurrent Neural Network
  • Step 104 Calculate the weight of the feature vector.
  • the weight of the feature vector indicates the importance of the word corresponding to the feature vector to the emotion classification of the text to be recognized. The higher the weight, the stronger the classification ability.
  • the feature vector includes a forward feature vector and a backward feature vector.
  • Calculating the weight of the feature vector means calculating the forward weight of the forward feature vector and the backward feature vector of the backward feature vector. To weight.
  • the weight of each feature vector can be calculated through an attention mechanism.
  • the emotion recognition model further includes a first hidden layer and a second hidden layer
  • the calculating the weight of the feature vector includes:
  • the intermediate value is input to the second hidden layer, and output through an output function to obtain the weight.
  • the feature vectors obtained by the bidirectional long-short-term memory recurrent neural network have different importance to the emotion classification of the text to be recognized.
  • the first hidden layer and the second hidden layer are added to the emotion recognition model .
  • For calculating the importance of the feature vector to the emotion classification of the text to be recognized that is, calculating the weight of the feature vector
  • adding the weight to the process of emotion classification of the text to be recognized It is beneficial to improve the accuracy of emotion classification for the text to be recognized.
  • the activation function can adopt a tanh function, and the activation function can activate a non-linear relationship in the neural network model (that is, the feature vector input to the first hidden layer and the intermediate value output from the first hidden layer are non-linear Relationship), the eigenvector obtains the intermediate value after passing the activation function.
  • the intermediate value is passed to the second hidden layer, and the weight of the feature vector is output after passing the output function, and the output function may adopt a softmax function.
  • the vector output by the output function is attention.
  • the foregoing method for calculating the weight of the feature vector has a simple operation process, can quickly obtain the weight of the feature vector, and improves the operation efficiency of the emotion recognition model.
  • cross entropy can be used as a loss function.
  • the two-way LSTM, the first hidden layer, and the second hidden layer can be uniformly trained, which can shorten the training time and quickly obtain an emotion recognition model with an attention mechanism.
  • Step 105 Multiply the feature vector with the corresponding weight to obtain the feature vector after weight adjustment.
  • Multiply each feature vector with the corresponding weight to obtain the feature vector after weight adjustment that is, multiply the forward feature vector and the forward weight to obtain the forward feature vector after weight adjustment, Multiply the backward feature vector and the backward weight to obtain the backward feature vector after the weight adjustment.
  • Step 106 Input the weight-adjusted feature vector into the fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized.
  • inputting the weight-adjusted feature vector into a fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized includes:
  • the joint feature vector is output through an output function to obtain the emotion category of the text to be recognized.
  • the fully connected layer can integrate the local information of the weight-adjusted feature vector to obtain a joint feature vector.
  • the joint feature vector may be output through a softmax function (that is, an output function) to obtain the emotion category of the text to be recognized.
  • the emotional category of the text to be recognized may include positive text and negative text.
  • the sentiment categories output include positive reviews and negative reviews.
  • the emotion category of the text to be recognized may include positive text, negative text, and neutral text.
  • the sentiment categories output include positive comments, negative comments, and neutral comments.
  • the text analysis method of the first embodiment obtains the text to be analyzed; converts each word of the text to be analyzed into a word vector; inputs the word vector into the two-way long and short-term memory recurrent neural network in the emotion recognition model to obtain the to be analyzed
  • the feature vector of each word of the text calculate the weight of the feature vector; multiply the feature vector with the corresponding weight to obtain the feature vector after weight adjustment; input the feature vector after weight adjustment
  • the fully connected layer in the emotion recognition model obtains the emotion category of the text to be recognized.
  • the text analysis method of the first embodiment uses a two-way LSTM and adds an attention mechanism, which can quickly classify text, improve the accuracy of classification, and realize fast and accurate text sentiment classification.
  • the method further includes:
  • the word corresponding to the target feature vector in the text to be recognized is used as a text summary of the text to be recognized.
  • the text analysis method of this application combines text sentiment classification and text summary extraction, and does not need to use two independent models to train and process separately, and text sentiment classification and text summary extraction share the same underlying emotion recognition model, and the encoded part is bidirectional LSTM is updated at the same time, so it has a mutual promotion effect, which has a certain improvement on the performance of the model, and improves the efficiency of text analysis.
  • Fig. 2 is a structural diagram of a text analysis device provided in the second embodiment of the present application.
  • the text analysis device 20 is applied to a computer device.
  • the text analysis of this device analyzes the text to be analyzed, and determines the sentiment category of the text to be analyzed.
  • the text analysis device 20 can improve the efficiency and accuracy of text emotion classification.
  • the text analysis device 20 may include an acquisition module 201, a conversion module 202, a feature extraction module 203, a first calculation module 204, a second calculation module 205, and an identification module 206.
  • the obtaining module 201 is used to obtain the text to be analyzed.
  • User input data can be received, and the text to be analyzed can be obtained according to the user input data.
  • the user input data may be text, voice or image.
  • the text input by the user may be received, and the text input by the user may be used as the text to be analyzed.
  • the voice input by the user may be accepted, and the voice may be recognized to obtain the text to be analyzed.
  • the user's voice can be collected through the microphone of the service self-service machine, and the service application can be obtained according to the collected voice.
  • Various speech recognition technologies can be used, such as Dynamic Time Warping (DTW), Hidden Markov Model (HMM), Vector Quantization (VQ), Artificial Neural Network (Artificial Neural Network, ANN) and other technologies to recognize the voice.
  • a text image input by a user may be received, and the text image may be recognized to obtain the text to be analyzed.
  • the text image can be sequentially subjected to clustering analysis, grayscale, image filtering, binarization, and tilt correction processing, and the processed text image is image segmented to obtain multiple character images, and the character images are recognized to obtain The text to be analyzed.
  • the cluster analysis processing can use the K-means algorithm to perform color clustering.
  • Binarization can firstly process the image with local threshold method, and then apply dynamic threshold method to each part processed by local threshold method.
  • Image segmentation of the processed image may include: segmenting the processed image based on region, segmenting each region based on region segmentation based on edge detection, and performing character segmentation on the segmented image based on edge detection. .
  • the text to be analyzed can be obtained from a predetermined data source.
  • user comments are obtained from social platforms (such as online forums, Weibo, etc.), and the user comments are used as the text to be analyzed.
  • a product review is obtained from a shopping platform (such as Taobao, Jingdong, etc.), and the product review is used as the text to be analyzed.
  • the text to be recognized may be Chinese text.
  • the text to be recognized may also be text in other languages.
  • the text to be analyzed may include one sentence or multiple sentences. If the text to be analyzed includes multiple sentences, each sentence can be analyzed separately to obtain the sentiment category of each sentence.
  • the conversion module 202 is configured to convert each word of the text to be analyzed into a word vector.
  • the word vector means that each word is represented as a multi-dimensional vector containing semantic information.
  • the text to be analyzed may include n different words, and one-hot vectors of n dimensions are used to represent the words in the text to be analyzed (that is, each word in the text to be analyzed corresponds to the one-hot vector One dimension, the first word corresponds to the first dimension in the one-hot vector, the second word corresponds to the second dimension in the one-hot vector, and so on), where n is a positive integer, and n can be 5000.
  • the value of the third dimension is 1, and the value of other dimensions is 0.
  • the dimension of the word vector can be 300 dimensions, and the vectorization processing can use fewer dimensions
  • the vector of carries the information of the text to be analyzed.
  • the word2vec tool can be used to convert each word of the text to be analyzed into a word vector.
  • the Skip-gram model in the word2vec tool can be used to train each word represented by a one-hot vector in the text to be analyzed to obtain a word vector dictionary, where each word corresponds to a word vector.
  • the word2vec tool is the valley lyrics vector tool.
  • the converting each word of the text to be analyzed into a word vector includes:
  • the text to be recognized is a Chinese text
  • the Chinese text is segmented to obtain each word of the Chinese text
  • the word2vec tool is used to convert each word of the text to be analyzed into a word vector.
  • the stuttering word segmentation can be used to segment the text to be recognized.
  • Stuttering word segmentation belongs to probabilistic language model word segmentation. Its task is to find a segmentation scheme S among all the results obtained by full segmentation, so that P(S) is the largest, where P(S) represents the probability of segmentation scheme S.
  • the stammering word segmentation is an existing technology, and will not be repeated here.
  • the text to be recognized may be segmented by using specific characters, and segmentation is performed at positions before and/or after the specific character in the text to be recognized, to obtain a segmentation result of the text to be recognized.
  • a preset verb such as go, in
  • segmentation is performed at the position before and/or after the preset verb in the text to be recognized, to obtain the to-be-recognized text
  • the word segmentation result of the text can be used to segment the text to be recognized, and segmentation is performed at the position before and/or after the preset verb in the text to be recognized, to obtain the to-be-recognized text.
  • a dictionary library can be used to segment the text to be recognized.
  • the dictionary library includes multiple proper nouns, and the proper nouns are no longer segmented as a single word.
  • the converting each word of the text to be analyzed into a word vector includes:
  • the specified characters may include auxiliary words, such as modal auxiliary words (?, ne, ah, bar, etc.), tense auxiliary words (zh, le, pass, etc.), and structural particles (de, di, de, etc.).
  • the designated characters may include English characters, numbers, symbols, prepositions, conjunctions, etc.
  • a stop word database can be established, and the stop word database includes the specified characters (ie stop words) to be removed.
  • the feature extraction module 203 is configured to input the word vector into the bidirectional long-short-term Memory Recurrent Neural Network (LSTM) in the emotion recognition model to obtain the feature vector of each word of the text to be analyzed .
  • LSTM Long-short-term Memory Recurrent Neural Network
  • the two-way LSTM is used to construct features for input data (ie, the word vector).
  • the word vector is input into the forward LSTM and the backward LSTM respectively to obtain the feature vector.
  • the feature vector includes a forward feature vector and a backward feature vector.
  • the forward feature vector is obtained from the forward LSTM
  • the backward feature vector is obtained from the backward LSTM.
  • the forward LSTM and the backward LSTM may both include two LSTM unit layers.
  • the first LSTM unit layer constructs features on input data to obtain hidden layer units
  • the second layer LSTM unit layer performs processing on the hidden layer units. combination.
  • the first LSTM unit layer is used to extract local features
  • the second LSTM unit layer is used to combine local features to obtain global features.
  • Each LSTM cell layer includes a forget gate, an input gate, and an output gate, and the forget gate, input gate, and output gate control the memory state of the LSTM cell layer.
  • the dimension of the feature vector is equal to the number of word vectors.
  • LSTM is a time recurrent neural network model. Compared with the traditional Recurrent Neural Network (RNN) model, LSTM stores information by constructing some gates in the LSTM unit layer, so the gradient will not disappear quickly during the model training process.
  • RNN Recurrent Neural Network
  • the first calculation module 204 is used to calculate the weight of the feature vector.
  • the weight of the feature vector indicates the importance of the word corresponding to the feature vector to the emotion classification of the text to be recognized. The higher the weight, the stronger the classification ability.
  • the feature vector includes a forward feature vector and a backward feature vector.
  • Calculating the weight of the feature vector means calculating the forward weight of the forward feature vector and the backward feature vector of the backward feature vector. To weight.
  • the weight of each feature vector can be calculated through an attention mechanism.
  • the emotion recognition model further includes a first hidden layer and a second hidden layer, and calculating the weight of the feature vector includes:
  • the intermediate value is input to the second hidden layer, and output through an output function to obtain the weight.
  • the feature vectors obtained by the two-way long and short-term memory recurrent neural network are of different importance to the emotion classification of the text to be recognized.
  • This embodiment adds the first hidden layer and the second hidden layer to calculate the The importance of the feature vector to the sentiment classification of the text to be recognized (that is, calculating the weight of the feature vector), and adding the weight to the process of sentiment classification of the text to be identified is beneficial to improve the Recognize the accuracy of text for sentiment classification.
  • the activation function can adopt a tanh function, and the activation function can activate a non-linear relationship in the neural network model (that is, the feature vector input to the first hidden layer and the intermediate value output from the first hidden layer are non-linear Relationship), the eigenvector obtains the intermediate value after passing the activation function.
  • the intermediate value is passed to the second hidden layer, and the weight of the feature vector is output after passing the output function, and the output function may adopt a softmax function.
  • the vector output by the output function is attention.
  • the foregoing method for calculating the weight of the feature vector has a simple operation process, can quickly obtain the weight of the feature vector, and improves the operation efficiency of the emotion recognition model.
  • cross entropy can be used as a loss function.
  • the two-way LSTM, the first hidden layer, and the second hidden layer can be uniformly trained, which can shorten the training time and quickly obtain an emotion recognition model with an attention mechanism.
  • the second calculation module 205 is configured to multiply the feature vector and the corresponding weight to obtain the feature vector after the weight adjustment.
  • Multiply each feature vector with the corresponding weight to obtain the feature vector after weight adjustment that is, multiply the forward feature vector and the forward weight to obtain the forward feature vector after weight adjustment, Multiply the backward feature vector and the backward weight to obtain the backward feature vector after the weight adjustment.
  • the recognition module 206 is configured to input the weight-adjusted feature vector into the fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized.
  • inputting the weight-adjusted feature vector into a fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized includes:
  • the joint feature vector is output through an output function to obtain the emotion category of the text to be recognized.
  • the fully connected layer can integrate the local information of the weight-adjusted feature vector to obtain a joint feature vector.
  • the joint feature vector may be output through a softmax function (that is, an output function) to obtain the emotion category of the text to be recognized.
  • the emotional category of the text to be recognized may include positive text and negative text.
  • the sentiment categories output include positive reviews and negative reviews.
  • the emotion category of the text to be recognized may include positive text, negative text, and neutral text.
  • the sentiment categories output include positive comments, negative comments, and neutral comments.
  • This embodiment provides a text analysis device 20.
  • the text analysis is to analyze the text to be analyzed and determine the sentiment category of the text to be analyzed.
  • the text analysis device 20 obtains the text to be analyzed; converts each word of the text to be analyzed into a word vector; inputs the word vector into the bidirectional long and short-term memory recurrent neural network in the emotion recognition model to obtain the text to be analyzed Calculate the weight of the feature vector; Multiply the feature vector with the corresponding weight to obtain the feature vector after weight adjustment; Input the feature vector after weight adjustment into the
  • the fully connected layer in the emotion recognition model is used to obtain the emotion category of the text to be recognized.
  • a two-way LSTM is used and an attention mechanism is added, which can quickly classify text, improve the accuracy of classification, and realize fast and accurate text emotion classification.
  • the text analysis device 20 may further include: a summary acquisition module, configured to determine a target feature vector whose weight is greater than or equal to a preset value in the feature vector, and compare the The word corresponding to the target feature vector is used as the text summary of the text to be recognized.
  • a summary acquisition module configured to determine a target feature vector whose weight is greater than or equal to a preset value in the feature vector, and compare the The word corresponding to the target feature vector is used as the text summary of the text to be recognized.
  • the text analysis device 20 combines text sentiment classification and text summarization extraction, and does not need to use two independent models for training and processing separately, and text sentiment classification and text summarization extraction share the same bottom layer of the emotion recognition model, and the encoded part is bidirectional LSTM It is updated at the same time, so it has a mutual promotion effect, has a certain improvement on the performance of the model, and improves the efficiency of text analysis.
  • This embodiment provides a non-volatile readable storage medium having computer readable instructions stored on the non-volatile readable storage medium, and when the computer readable instructions are executed by a processor, the text analysis method in the above embodiment Steps, such as steps 101-106 shown in Figure 1:
  • Step 101 Obtain the text to be analyzed
  • Step 102 Convert each word of the text to be analyzed into a word vector
  • Step 103 Input the word vector into the two-way long and short-term memory recurrent neural network in the emotion recognition model to obtain the feature vector of each word of the text to be analyzed;
  • Step 104 Calculate the weight of the feature vector
  • Step 105 Multiply the feature vector by the corresponding weight to obtain the feature vector after weight adjustment
  • Step 106 Input the weight-adjusted feature vector into the fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized.
  • the obtaining module 201 is used to obtain the text to be analyzed
  • the conversion module 202 is configured to convert each word of the text to be analyzed into a word vector
  • the feature extraction module 203 is configured to input the word vector into the two-way long and short-term memory recurrent neural network in the emotion recognition model to obtain the feature vector of each word of the text to be analyzed;
  • the first calculation module 204 is configured to calculate the weight of the feature vector
  • the second calculation module 205 is configured to multiply the feature vector and the corresponding weight to obtain the feature vector after weight adjustment;
  • the recognition module 206 is configured to input the weight-adjusted feature vector into the fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized.
  • FIG. 3 is a schematic diagram of a computer device provided in Embodiment 4 of this application.
  • the computer device 30 includes a memory 301, a processor 302, and computer-readable instructions 303 stored in the memory 301 and running on the processor 302, such as a text analysis program.
  • the processor 302 executes the computer-readable instruction 303, the steps in the embodiment of the text analysis method described above are implemented, for example, steps 101-106 shown in FIG. 1:
  • Step 101 Obtain the text to be analyzed
  • Step 102 Convert each word of the text to be analyzed into a word vector
  • Step 103 Input the word vector into the two-way long and short-term memory recurrent neural network in the emotion recognition model to obtain the feature vector of each word of the text to be analyzed;
  • Step 104 Calculate the weight of the feature vector
  • Step 105 Multiply the feature vector by the corresponding weight to obtain the feature vector after weight adjustment
  • Step 106 Input the weight-adjusted feature vector into the fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized.
  • the obtaining module 201 is used to obtain the text to be analyzed
  • the conversion module 202 is configured to convert each word of the text to be analyzed into a word vector
  • the feature extraction module 203 is configured to input the word vector into the two-way long and short-term memory recurrent neural network in the emotion recognition model to obtain the feature vector of each word of the text to be analyzed;
  • the first calculation module 204 is configured to calculate the weight of the feature vector
  • the second calculation module 205 is configured to multiply the feature vector and the corresponding weight to obtain the feature vector after weight adjustment;
  • the recognition module 206 is configured to input the weight-adjusted feature vector into the fully connected layer in the emotion recognition model to obtain the emotion category of the text to be recognized.
  • the computer-readable instruction 303 may be divided into one or more modules, and the one or more modules are stored in the memory 301 and executed by the processor 302 to complete the method .
  • the one or more modules may be a series of computer-readable instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer-readable instructions 303 in the computer device 30.
  • the computer-readable instruction 303 can be divided into the acquisition module 201, the conversion module 202, the feature extraction module 203, the first calculation module 204, the second calculation module 205, and the recognition module 206 in FIG. 2.
  • the specific functions of each module See example two.
  • the computer device 30 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the schematic diagram 3 is only an example of the computer device 30 and does not constitute a limitation on the computer device 30. It may include more or less components than those shown in the figure, or combine certain components, or be different.
  • the computer device 30 may also include input and output devices, network access devices, buses, etc.
  • the so-called processor 302 may be a central processing unit (Central Processing Unit, CPU), other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor can be a microprocessor or the processor 302 can also be any conventional processor, etc.
  • the processor 302 is the control center of the computer device 30 and connects the entire computer device 30 with various interfaces and lines. Various parts.
  • the memory 301 may be used to store the computer-readable instructions 303, and the processor 302 executes or executes the computer-readable instructions or modules stored in the memory 301, and calls data stored in the memory 301 to implement Various functions of the computer device 30.
  • the memory 301 may mainly include a program storage area and a data storage area.
  • the program storage area may store an operating system, an application program required by at least one function (such as a sound playback function, an image playback function, etc.), etc.; Data (such as audio data, etc.) created according to the use of the computer device 30 and the like are stored.
  • the memory 301 may include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a Secure Digital (SD) card, a flash memory card (Flash Card), At least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
  • non-volatile memory such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a Secure Digital (SD) card, a flash memory card (Flash Card), At least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
  • the integrated module of the computer device 30 is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a non-volatile readable storage medium.
  • this application implements all or part of the processes in the above-mentioned embodiments and methods, and can also be completed by instructing relevant hardware through a computer program.
  • the computer program can be stored in a non-volatile readable storage medium.
  • the computer program includes computer-readable instruction codes, and the computer-readable instruction codes may be in the form of source code, object code, executable file, or some intermediate forms.
  • the non-volatile readable medium may include: any entity or device capable of carrying the computer readable instruction code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), and software distribution media.
  • modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module.
  • the above-mentioned integrated modules can be implemented in the form of hardware, or in the form of hardware plus software functional modules.
  • the above-mentioned integrated module implemented in the form of a software function module can be stored in a non-volatile readable storage medium, and includes several instructions to enable a computer device (may be a personal computer, a server, or a network device, etc.) Or a processor (processor) executes some steps of the method described in each embodiment of the present application.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Molecular Biology (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Machine Translation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种文本分析方法、装置、计算机装置及存储介质,属于人工智能技术领域。所述文本分析方法包括:获取待分析文本(101);将所述待分析文本的各个词语转换为词向量(102);将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量(103);计算所述特征向量的权重(104);将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量(105);将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别(106)。该方法提高了文本感情分类的效率和准确性。

Description

文本分析方法、装置、计算机装置及存储介质
本申请要求于2019年06月25日提交中国专利局,申请号为201910555929.3发明名称为“文本分析方法、装置、计算机装置及计算机存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及自然语言处理技术领域,具体涉及一种文本分析方法、装置、计算机装置及存储介质。
背景技术
目前,用于文本情感分类的文本分析方法逐渐使用深度学习方法,其中以CNN(Convolutional Neural Network,卷积神经网络)、RNN(Recurrent Neural Networks,递归神经网络)和LSTM(Long Short-term Memory Recurrent Neural Network,长短时记忆递归神经网络)为代表的深度学习方法取得较好的结果。
基于CNN的算法虽然可以有效地进行文本分类,但文本情感分类问题并非单纯的文本分类问题。
RNN因包含输入信息的时序关系而在文本分析中有重要应用,利用RNN进行文本分析,比基于传统机器学习的文本情感分类方法的效果更好。使用RNN进行文档级情感分类,应用池化层自动判断在文本分类中重要的词语。但不可忽略的是RNN自身具有一定的缺陷,当循环轮次过多时,会产生长期依赖和梯度爆炸等问题。
针对RNN的不足,其变体LSTM在神经网络模块的链式结构中采用记忆单元来控制信息的交互,从而避免了RNN的缺陷。基于LSTM网络的算法可以通过有选择的保存和遗忘信息来存储文本中重要的信息,从而完成文本分析。然而,现有的基于LSTM网络的文本分析方法运算过程较长,运算效率不高,并且文本情感分类的准确性不高。
发明内容
鉴于以上内容,有必要提出一种文本分析方法、装置、计算机装置及存储介质,其可以提高文本感情分类的效率和准确性。
本申请的第一方面提供一种文本分析方法,所述方法包括:
获取待分析文本;
将所述待分析文本的各个词语转换为词向量;
将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得 到所述待分析文本的各个词语的特征向量;
计算所述特征向量的权重;
将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;
将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
另一种可能的实现方式中,所述将所述待分析文本的各个词语转换为词向量包括:
对所述待识别文本进行分词,得到所述待识别文本的各个词语;
用word2vec工具将所述待分析文本的各个词语转换为词向量。
另一种可能的实现方式中,所述对所述待识别文本进行分词包括:
利用结巴分词对所述待识别文本进行分词;或者
利用特定字符对所述待识别文本进行分词;或者
利用词典库对所述待识别文本进行分词。
另一种可能的实现方式中,所述获取待分析文本包括:
接收用户输入的文字,将所述用户输入的文字作为所述待分析文本;或者
接受用户输入的语音,对所述语音进行识别,得到所述待分析文本;或者
接收用户输入的文本图像,从所述文本图像进行识别,得到所述待分析文本;或者
从预定数据源获取所述待分析文本。
另一种可能的实现方式中,所述情感识别模型还包括第一隐层和第二隐层,所述计算所述特征向量的权重包括:
将所述特征向量输入所述第一隐层,并通过激活函数激活,得到中间值;
将所述中间值输入所述第二隐层,并通过输出函数输出,得到所述权重。
另一种可能的实现方式中,所述将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别包括:
将所述经过权重调整后的特征向量输入所述全连接层,得到联合特征向量;
将所述联合特征向量通过输出函数输出,得到所述待识别文本的情感类别。
另一种可能的实现方式中,所述方法还包括:
确定所述特征向量中权重大于或等于预设值的目标特征向量;
将所述待识别文本中所述目标特征向量对应的词语作为所述待识别文本的文本摘要。
本申请的第二方面提供一种文本分析装置,所述装置包括:
获取模块,用于获取待分析文本;
转换模块,用于将所述待分析文本的各个词语转换为词向量;
特征提取模块,用于将所述词向量输入情感识别模型中的双向长短时记忆 递归神经网络,得到所述待分析文本的各个词语的特征向量;
第一计算模块,用于计算所述特征向量的权重;
第二计算模块,用于将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;
识别模块,用于将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
另一种可能的实现方式中,所述将所述待分析文本的各个词语转换为词向量包括:
对所述待识别文本进行分词,得到所述待识别文本的各个词语;
用word2vec工具将所述待分析文本的各个词语转换为词向量。
另一种可能的实现方式中,所述对所述待识别文本进行分词包括:
利用结巴分词对所述待识别文本进行分词;或者
利用特定字符对所述待识别文本进行分词;或者
利用词典库对所述待识别文本进行分词.
另一种可能的实现方式中,所述获取待分析文本包括:
接收用户输入的文字,将所述用户输入的文字作为所述待分析文本;或者
接受用户输入的语音,对所述语音进行识别,得到所述待分析文本;或者
接收用户输入的文本图像,从所述文本图像进行识别,得到所述待分析文本;或者
从预定数据源获取所述待分析文本。
另一种可能的实现方式中,所述情感识别模型还包括第一隐层和第二隐层,所述计算所述特征向量的权重包括:
将所述特征向量输入所述第一隐层,并通过激活函数激活,得到中间值;
将所述中间值输入所述第二隐层,并通过输出函数输出,得到所述权重。
另一种可能的实现方式中,所述将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别包括:
将所述经过权重调整后的特征向量输入所述全连接层,得到联合特征向量;
将所述联合特征向量通过输出函数输出,得到所述待识别文本的情感类别。
另一种可能的实现方式中,所述装置还包括:
摘要获取模块,用于确定所述特征向量中权重大于或等于预设值的目标特征向量,将所述待识别文本中所述目标特征向量对应的词语作为所述待识别文本的文本摘要。
本申请的第三方面提供一种计算机装置,所述计算机装置包括处理器,所述处理器用于执行存储器中存储的计算机可读指令时实现所述文本分析方法。
本申请的第四方面提供一种非易失性可读存储介质,其上存储有计算机 可读指令,所述计算机可读指令被处理器执行时实现所述文本分析方法。
本申请获取待分析文本;将所述待分析文本的各个词语转换为词向量;将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;计算所述特征向量的权重;将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。本申请提高了文本感情分类的效率和准确性。
附图说明
图1是本申请实施例提供的文本分析方法的流程图。
图2是本申请实施例提供的文本分析装置的结构图。
图3是本申请实施例提供的计算机装置的示意图。
具体实施方式
为了能够更清楚地理解本申请的上述目的、特征和优点,下面结合附图和具体实施例对本申请进行详细描述。需要说明的是,在不冲突的情况下,本申请的实施例及实施例中的特征可以相互组合。
在下面的描述中阐述了很多具体细节以便于充分理解本申请,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中在本申请的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本申请。
优选地,本申请的文本分析方法应用在一个或者多个计算机装置中。所述计算机装置是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程门阵列(Field-Programmable Gate Array,FPGA)、数字处理器(Digital Signal Processor,DSP)、嵌入式设备等。
所述计算机装置可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述计算机装置可以与用户通过键盘、鼠标、遥控器、触摸板或声控设备等方式进行人机交互。
实施例一
图1是本申请实施例一提供的文本分析方法的流程图。所述文本分析方法应用于计算机装置。
本申请文本分析方法对待分析文本进行分析,确定所述待分析文本的情感类别。所述文本分析方法可以提高文本感情分类的效率和准确性。
如图1所示,所述文本分析方法包括:
步骤101,获取待分析文本。
可以接收用户输入数据,根据所述用户输入数据获取所述待分析文本。所述用户输入数据可以是文字、语音或图像。
例如,可以接收用户输入的文字,将所述用户输入的文字作为所述待分析文本。
又如,可以接受用户输入的语音,对所述语音进行识别,得到所述待分析文本。可以通过所述业务自助机的麦克风采集所述用户的语音,根据采集的语音进获得所述业务申请。可以采用各种语音识别技术,例如动态时间规整(Dynamic Time Warping,DTW)、隐马尔可夫模型(Hidden Markov Model,HMM)、矢量量化(Vector Quantization,VQ)、人工神经网络(Artificial Neural Network,ANN)等技术对所述语音进行识别。
再如,可以接收用户输入的文本图像,对所述文本图像进行识别,得到所述待分析文本。可以对文本图像依次进行聚类分析、灰度化、图像滤波、二值化、倾斜校正处理,对处理后的文本图像进行图像分割,得到多个字符图像,对所述字符图像进行识别,得到所述待分析文本。其中,聚类分析处理可以采用K-means算法进行颜色聚类。二值化处理可以先对图像进行局部阈值法处理,再对局部阈值法处理后的每一部分进行动态阈值法处理。对处理后的图像进行图像分割可以包括:对处理后的图像进行基于区域的分割,对基于区域分割后的每一区域进行基于边缘检测的分割,对基于边缘检测的分割后的图像进行字符分割。
或者,可以从预定数据源获取所述待分析文本。例如,从社交平台(例如网络论坛、微博等)获取用户评论,将所述用户评论作为所述待分析文本。又如,从购物平台(例如淘宝、京东等)获取商品评论,将所述商品评论作为所述待分析文本。
所述待识别文本可以是中文文本。所述待识别文本也可以是其他语言文本。
所述待分析文本可以包括一句话,也可以包括多句话。若所述待分析文本包括多句话,可以分别对每句话进行分析,得到每句话的情感类别。
步骤102,将所述待分析文本的各个词语转换为词向量。
词向量指的是每个词语被表征为一个包含语义信息的多维度的向量。所述待分析文本可以包括n个不同的词语,用n个维度的one-hot向量表示所述待分析文本中的词语(即所述待分析文本中的每个词语对应于one-hot向量的一个维度,第一个词语对应one-hot向量中的第一个维度,第二个词语对应one-hot向量中的第二个维度,依次类推),其中n为正整数,n可以为5000。例如,所述待分析文本中的第三个词语对应的one-hot向量中,第三个维度的值为1,其他维度的值为0。对用one-hot向量表示的所述待分析文本的各个词语进行向量化处理,得到每个词语的词向量,词向量的维度可以为300个维度,通过所述向量化处理可以用较少维度的向量承载所述待分析文本的信息。
可以利用word2vec工具将所述待分析文本的各个词语转换为词向量。 例如,可以利用所述word2vec工具中的Skip-gram模型对所述待分析文本中的用one-hot向量表示的每个词语进行训练,得到词向量字典,其中每个词语对应一个词向量。所述word2vec工具为谷歌词向量工具。
可选的,所述将所述待分析文本的各个词语转换为词向量包括:
对所述待识别文本进行分词,得到所述待识别文本的各个词语;
用word2vec工具将所述待分析文本的各个词语转换为词向量。
例如,所述待识别文本为中文文本,对所述中文文本进行分词,得到所述中文文本的各个词语;用word2vec工具将用one-hot向量表示的所述待分析文本的各个词语转换为词向量。
可以利用结巴分词对所述待识别文本进行分词。结巴分词属于概率语言模型分词,其任务是在全切分所得的所有结果中求某个切分方案S,使得P(S)最大,其中,P(S)表示切分方案S的概率。结巴分词为现有技术,此处不再赘述。
可以利用特定字符对所述待识别文本进行分词,在所述待识别文本中所述特定字符的前和/或后的位置上进行切分,得到所述待识别文本的分词结果。例如,可以使用预设动词(如去、在)对所述待识别文本进行分词,在所述待识别文本中预设动词的前和/或后的位置上进行切分,得到所述待识别文本的分词结果。
可以利用词典库对所述待识别文本进行分词。词典库包括多个专有名词,将专有名词作为单个词语不再进行切分。
可选的,所述将所述待分析文本的各个词语转换为词向量包括:
去除所述待识别文本中的指定字符;对去除指定字符的所述待识别文本进行分词,得到去除指定字符的所述待识别文本的各个词语;用word2vec工具将所述待分析文本的各个词语转换为词向量。
所述指定字符可以包括助词,例如语气助词(吗、呢、啊、吧等)、时态助词(着、了、过等)、结构助词(的、地、得等)。所述指定字符可以包括英文字符、数字、符号、介词、连词等。可以建立停词库,停词库中包括需去除的指定字符(即停用词)。
步骤103,将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络(Long Short-term Memory Recurrent Neural Network,LSTM),得到所述待分析文本的各个词语的特征向量。
所述双向LSTM用于对输入数据(即所述词向量)构造特征。所述双向LSTM包括前向LSTM和后向LSTM。将所述词向量分别输入所述前向LSTM和所述后向LSTM,得到所述特征向量。所述特征向量包括前向特征向量和后向特征向量,由所述前向LSTM得到所述前向特征向量,由所述后向LSTM得到所述后向特征向量。所述前向LSTM和所述后向LSTM可以都包括两层LSTM单元层,第一层LSTM单元层对输入数据构造特征,得到隐藏层单元,第二层LSTM单元层对所述隐藏层单元进行组合。所述第一层LSTM单元层用于提取局部特征,所述第二层LSTM单元层用于结合局部特征得到全局特征。每个LSTM单元层包括遗忘门、输入门、输出门,所述遗忘门、输入门、 输出门控制所述LSTM单元层的记忆状态。
所述特征向量的维度等于所述词向量的个数。
LSTM是一种时间递归神经网络。相对于传统的循环神经网络(Recurrent Neural Network,RNN),LSTM通过在LSTM单元层构建一些门来存储信息,因此其在模型训练的过程中,梯度不会很快消失。
步骤104,计算所述特征向量的权重。
特征向量的权重表示特征向量对应的词语对所述待识别文本情感分类的重要程度。权重较高,则分类能力越强。
如前所述,所述特征向量包括前向特征向量和后向特征向量,计算所述特征向量的权重也就是分别计算所述前向特征向量的前向权重和所述后向特征向量的后向权重。
在本实施例中,可以通过注意力(attention)机制计算每个特征向量的权重。
可选的,所述情感识别模型还包括第一隐层和第二隐层,所述计算所述特征向量的权重包括:
将所述特征向量输入所述第一隐层,并通过激活函数激活,得到中间值;
将所述中间值输入所述第二隐层,并通过输出函数输出,得到所述权重。
由双向长短时记忆递归神经网络得到的所述特征向量对所述待识别文本的情感分类的重要程度不同,本实施例在情感识别模型中加入所述第一隐层和所述第二隐层,用于计算所述特征向量对所述待识别文本的情感分类的重要程度(即计算所述特征向量的权重),将所述权重加入到所述待识别文本的情感分类的过程中,有利于提升对所述待识别文本进行情感分类的准确性。
所述激活函数可以采用tanh函数,激活函数可以在神经网络模型中激活非线性关系(即让输入所述第一隐层的特征向量与所述第一隐层输出的所述中间值具有非线性关系),所述特征向量通过所述激活函数后得到所述中间值。所述中间值被传递给第二隐层,通过所述输出函数后输出所述特征向量的权重,所述输出函数可以采用softmax函数。
所述输出函数输出的向量即为注意力。
上述计算特征向量的权重的方法运算过程简单,能够快速得到特征向量的权重,提高了情感识别模型的运算效率。
在对所述情感识别模型进行训练时,可以使用交叉熵作为损失函数。可以对双向LSTM、第一隐层、第二隐层统一进行训练,可以缩短训练时间,快速获得具有注意力机制的情感识别模型。
步骤105,将所述特征向量与对应的权重相乘,得到经过权重调整后的特征向量。
将每个特征向量与对应的权重相乘,得到经过权重调整后的特征向量,也就是将所述前向特征向量和所述前向权重相乘,得到经过权重调整后的前向特征向量,将所述后向特征向量和所述后向权重相乘,得到经过权重调整后的后向特征向量。
步骤106,将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
可选的,将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别包括:
将所述经过权重调整后的特征向量输入所述全连接层,得到联合特征向量;
将所述联合特征向量通过输出函数输出,得到所述待识别文本的情感类别。
全连接层可以整合所述经过权重调整后的特征向量的局部信息,得到联合特征向量。所述联合特征向量可以通过softmax函数(即输出函数)进行输出,得到所述待识别文本的情感类别。
在本实施例中,所述待识别文本的情感类别可以包括正面文本、负面文本。例如,若本方法用于对用户评论进行分析,输出的情感类别包括正面评论和负面评论。
在另一实施例中,所述待识别文本的情感类别可以包括正面文本、负面文本、中性文本。例如,若本方法用于对用户评论进行分析,输出的情感类别包括正面评论、负面评论和中性评论。
实施例一的文本分析方法获取待分析文本;将所述待分析文本的各个词语转换为词向量;将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;计算所述特征向量的权重;将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。实施例一的文本分析方法使用双向LSTM并加入了注意力机制,能够快速地对文本进行分类,并且提高了分类的准确性,实现了快速准确的文本情感分类。
作为一种可选的实施方式,所述方法还包括:
确定所述特征向量中权重大于或等于预设值的目标特征向量;
将所述待识别文本中所述目标特征向量对应的词语作为所述待识别文本的文本摘要。
本申请文本分析方法将文本情感分类和文本摘要提取结合在一起,不需要采用两个独立模型分别训练处理,并且文本情感分类和文本摘要提取共享情感识别模型的同一底层,且编码的部分被双向LSTM同时更新,因此有了相互促进的作用,对于模型的性能有一定的提升,提高了文本分析的效率。
实施例二
图2是本申请实施例二提供的文本分析装置的结构图。所述文本分析装置20应用于计算机装置。本装置的文本分析对待分析文本进行分析,确定所述待分析文本的情感类别。所述文本分析装置20可以提高文本感情分类的效率和准确性。如图2所示,所述文本分析装置20可以包括获取模块201、转换模块202、特征提取模块203、第一计算模块204、第二计算模块205、 识别模块206。
获取模块201,用于获取待分析文本。
可以接收用户输入数据,根据所述用户输入数据获取所述待分析文本。所述用户输入数据可以是文字、语音或图像。
例如,可以接收用户输入的文字,将所述用户输入的文字作为所述待分析文本。
又如,可以接受用户输入的语音,对所述语音进行识别,得到所述待分析文本。可以通过所述业务自助机的麦克风采集所述用户的语音,根据采集的语音进获得所述业务申请。可以采用各种语音识别技术,例如动态时间规整(Dynamic Time Warping,DTW)、隐马尔可夫模型(Hidden Markov Model,HMM)、矢量量化(Vector Quantization,VQ)、人工神经网络(Artificial Neural Network,ANN)等技术对所述语音进行识别。
再如,可以接收用户输入的文本图像,对所述文本图像进行识别,得到所述待分析文本。可以对文本图像依次进行聚类分析、灰度化、图像滤波、二值化、倾斜校正处理,对处理后的文本图像进行图像分割,得到多个字符图像,对所述字符图像进行识别,得到所述待分析文本。其中,聚类分析处理可以采用K-means算法进行颜色聚类。二值化处理可以先对图像进行局部阈值法处理,再对局部阈值法处理后的每一部分进行动态阈值法处理。对处理后的图像进行图像分割可以包括:对处理后的图像进行基于区域的分割,对基于区域分割后的每一区域进行基于边缘检测的分割,对基于边缘检测的分割后的图像进行字符分割。
或者,可以从预定数据源获取所述待分析文本。例如,从社交平台(例如网络论坛、微博等)获取用户评论,将所述用户评论作为所述待分析文本。又如,从购物平台(例如淘宝、京东等)获取商品评论,将所述商品评论作为所述待分析文本。
所述待识别文本可以是中文文本。所述待识别文本也可以是其他语言文本。
所述待分析文本可以包括一句话,也可以包括多句话。若所述待分析文本包括多句话,可以分别对每句话进行分析,得到每句话的情感类别。
转换模块202,用于将所述待分析文本的各个词语转换为词向量。
词向量指的是每个词语被表征为一个包含语义信息的多维度的向量。所述待分析文本可以包括n个不同的词语,用n个维度的one-hot向量表示所述待分析文本中的词语(即所述待分析文本中的每个词语对应于one-hot向量的一个维度,第一个词语对应one-hot向量中的第一个维度,第二个词语对应one-hot向量中的第二个维度,依次类推),其中n为正整数,n可以为5000。例如,所述待分析文本中的第三个词语对应的one-hot向量中,第三个维度的值为1,其他维度的值为0。对用one-hot向量表示的所述待分析文本的各个词语进行向量化处理,得到每个词语的词向量,词向量的维度可以为300个维度,通过所述向量化处理可以用较少维度的向量承载所述待分析文本的信息。
可以利用word2vec工具将所述待分析文本的各个词语转换为词向量。例如,可以利用所述word2vec工具中的Skip-gram模型对所述待分析文本中的用one-hot向量表示的每个词语进行训练,得到词向量字典,其中每个词语对应一个词向量。所述word2vec工具为谷歌词向量工具。
可选的,所述将所述待分析文本的各个词语转换为词向量包括:
对所述待识别文本进行分词,得到所述待识别文本的各个词语;用word2vec工具将所述待分析文本的各个词语转换为词向量。
例如,所述待识别文本为中文文本,对所述中文文本进行分词,得到所述中文文本的各个词语;用word2vec工具将所述待分析文本的各个词语转换为词向量。
可以利用结巴分词对所述待识别文本进行分词。结巴分词属于概率语言模型分词,其任务是在全切分所得的所有结果中求某个切分方案S,使得P(S)最大,其中,P(S)表示切分方案S的概率。结巴分词为现有技术,此处不再赘述。
可以利用特定字符对所述待识别文本进行分词,在所述待识别文本中所述特定字符的前和/或后的位置上进行切分,得到所述待识别文本的分词结果。例如,可以使用预设动词(如去、在)对所述待识别文本进行分词,在所述待识别文本中预设动词的前和/或后的位置上进行切分,得到所述待识别文本的分词结果。
可以利用词典库对所述待识别文本进行分词。词典库包括多个专有名词,将专有名词作为单个词语不再进行切分。
可选的,所述将所述待分析文本的各个词语转换为词向量包括:
去除所述待识别文本中的指定字符;对去除指定字符的所述待识别文本进行分词,得到去除指定字符的所述待识别文本的各个词语;用word2vec工具将所述待分析文本的各个词语转换为词向量。
所述指定字符可以包括助词,例如语气助词(吗、呢、啊、吧等)、时态助词(着、了、过等)、结构助词(的、地、得等)。所述指定字符可以包括英文字符、数字、符号、介词、连词等。可以建立停词库,停词库中包括需去除的指定字符(即停用词)。
特征提取模块203,用于将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络(Long Short-term Memory Recurrent Neural Network,LSTM),得到所述待分析文本的各个词语的特征向量。
所述双向LSTM用于对输入数据(即所述词向量)构造特征。所述双向LSTM前向LSTM和后向LSTM。将所述词向量分别输入所述前向LSTM和所述后向LSTM,得到所述特征向量。所述特征向量包括前向特征向量和后向特征向量,由所述前向LSTM得到所述前向特征向量,由所述后向LSTM得到所述后向特征向量。所述前向LSTM和所述后向LSTM可以都包括两层LSTM单元层,第一层LSTM单元层对输入数据构造特征,得到隐藏层单元,第二层LSTM单元层对所述隐藏层单元进行组合。所述第一层LSTM单元层用于提取局部特征,所述第二层LSTM单元层用于结合局部特征得到全局特 征。每个LSTM单元层包括遗忘门、输入门、输出门,所述遗忘门、输入门、输出门控制所述LSTM单元层的记忆状态。
所述特征向量的维度等于所述词向量的个数。
LSTM是一种时间递归神经网络模型。相对于传统的循环神经网络(Recurrent Neural Network,RNN)模型,LSTM通过在LSTM单元层构建一些门来存储信息,因此其在模型训练的过程中,梯度不会很快消失。
第一计算模块204,用于计算所述特征向量的权重。
特征向量的权重表示特征向量对应的词语对所述待识别文本情感分类的重要程度。权重较高,则分类能力越强。
如前所述,所述特征向量包括前向特征向量和后向特征向量,计算所述特征向量的权重也就是分别计算所述前向特征向量的前向权重和所述后向特征向量的后向权重。
在本实施例中,可以通过注意力(attention)机制计算每个特征向量的权重。
可选的,所述情感识别模型还包括第一隐层和第二隐层,计算所述特征向量的权重包括:
将所述特征向量输入所述第一隐层,并通过激活函数激活,得到中间值;
将所述中间值输入所述第二隐层,并通过输出函数输出,得到所述权重。
由双向长短时记忆递归神经网络得到的所述特征向量对所述待识别文本的情感分类的重要程度不同,本实施例加入所第一隐层和所述第二隐层,用于计算所述特征向量对所述待识别文本的情感分类的重要程度(即计算所述特征向量的权重),将所述权重加入到所述待识别文本的情感分类的过程中,有利于提升对所述待识别文本进行情感分类的准确性。
所述激活函数可以采用tanh函数,激活函数可以在神经网络模型中激活非线性关系(即让输入所述第一隐层的特征向量与所述第一隐层输出的所述中间值具有非线性关系),所述特征向量通过所述激活函数后得到所述中间值。所述中间值被传递给第二隐层,通过所述输出函数后输出所述特征向量的权重,所述输出函数可以采用softmax函数。
所述输出函数输出的向量即为注意力。
上述计算特征向量的权重的方法运算过程简单,能够快速得到特征向量的权重,提高了情感识别模型的运算效率。
在对所述情感识别模型进行训练时,可以使用交叉熵作为损失函数。可以对双向LSTM、第一隐层、第二隐层统一进行训练,可以缩短训练时间,快速获得具有注意力机制的情感识别模型。
第二计算模块205,用于将所述特征向量与对应的权重相乘,得到经过权重调整后的特征向量。
将每个特征向量与对应的权重相乘,得到经过权重调整后的特征向量,也就是将所述前向特征向量和所述前向权重相乘,得到经过权重调整后的前向特征向量,将所述后向特征向量和所述后向权重相乘,得到经过权重调整后的后向特征向量。
识别模块206,用于将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
可选的,将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别包括:
将所述经过权重调整后的特征向量输入所述全连接层,得到联合特征向量;
将所述联合特征向量通过输出函数输出,得到所述待识别文本的情感类别。
全连接层可以整合所述经过权重调整后的特征向量的局部信息,得到联合特征向量。所述联合特征向量可以通过softmax函数(即输出函数)进行输出,得到所述待识别文本的情感类别。
在本实施例中,所述待识别文本的情感类别可以包括正面文本、负面文本。例如,若本方法用于对用户评论进行分析,输出的情感类别包括正面评论和负面评论。
在另一实施例中,所述待识别文本的情感类别可以包括正面文本、负面文本、中性文本。例如,若本方法用于对用户评论进行分析,输出的情感类别包括正面评论、负面评论和中性评论。
本实施例提供了一种文本分析装置20。所述文本分析是对待分析文本进行分析,确定所述待分析文本的情感类别。所述文本分析装置20获取待分析文本;将所述待分析文本的各个词语转换为词向量;将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;计算所述特征向量的权重;将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。本实施例使用双向LSTM并加入了注意力机制,能够快速地对文本进行分类,并且提高了分类的准确性,实现了快速准确的文本情感分类。
在另一实施例中,所述文本分析装置20还可以包括:摘要获取模块,用于确定所述特征向量中权重大于或等于预设值的目标特征向量,将所述待识别文本中所述目标特征向量对应的词语作为所述待识别文本的文本摘要。
文本分析装置20将文本情感分类和文本摘要提取结合在一起,不需要采用两个独立模型分别训练处理,并且文本情感分类和文本摘要提取共享情感识别模型的同一底层,且编码的部分被双向LSTM同时更新,因此有了相互促进的作用,对于模型的性能有一定的提升,提高了文本分析的效率。
实施例三
本实施例提供一种非易失性可读存储介质,该非易失性可读存储介质上存储有计算机可读指令,该计算机可读指令被处理器执行时实现上述文本分析方法实施例中的步骤,例如图1所示的步骤101-106:
步骤101,获取待分析文本;
步骤102,将所述待分析文本的各个词语转换为词向量;
步骤103,将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;
步骤104,计算所述特征向量的权重;
步骤105,将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;
步骤106,将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
或者,该计算机可读指令被处理器执行时实现上述装置实施例中各模块的功能,例如图2中的模块201-206:
获取模块201,用于获取待分析文本;
转换模块202,用于将所述待分析文本的各个词语转换为词向量;
特征提取模块203,用于将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;
第一计算模块204,用于计算所述特征向量的权重;
第二计算模块205,用于将所述特征向量与对应的权重相乘,得到经过权重调整后的特征向量;
识别模块206,用于将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
实施例四
图3为本申请实施例四提供的计算机装置的示意图。所述计算机装置30包括存储器301、处理器302以及存储在所述存储器301中并可在所述处理器302上运行的计算机可读指令303,例如文本分析程序。所述处理器302执行所述计算机可读指令303时实现上述文本分析方法实施例中的步骤,例如图1所示的步骤101-106:
步骤101,获取待分析文本;
步骤102,将所述待分析文本的各个词语转换为词向量;
步骤103,将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;
步骤104,计算所述特征向量的权重;
步骤105,将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;
步骤106,将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
或者,该计算机可读指令被处理器执行时实现上述装置实施例中各模块的功能,例如图2中的模块201-206:
获取模块201,用于获取待分析文本;
转换模块202,用于将所述待分析文本的各个词语转换为词向量;
特征提取模块203,用于将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;
第一计算模块204,用于计算所述特征向量的权重;
第二计算模块205,用于将所述特征向量与对应的权重相乘,得到经过权重调整后的特征向量;
识别模块206,用于将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
示例性的,所述计算机可读指令303可以被分割成一个或多个模块,所述一个或者多个模块被存储在所述存储器301中,并由所述处理器302执行,以完成本方法。所述一个或多个模块可以是能够完成特定功能的一系列计算机可读指令段,该指令段用于描述所述计算机可读指令303在所述计算机装置30中的执行过程。例如,所述计算机可读指令303可以被分割成图2中的获取模块201、转换模块202、特征提取模块203、第一计算模块204、第二计算模块205、识别模块206,各模块具体功能参见实施例二。
所述计算机装置30可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。本领域技术人员可以理解,所述示意图3仅仅是计算机装置30的示例,并不构成对计算机装置30的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述计算机装置30还可以包括输入输出设备、网络接入设备、总线等。
所称处理器302可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器302也可以是任何常规的处理器等,所述处理器302是所述计算机装置30的控制中心,利用各种接口和线路连接整个计算机装置30的各个部分。
所述存储器301可用于存储所述计算机可读指令303,所述处理器302通过运行或执行存储在所述存储器301内的计算机可读指令或模块,以及调用存储在存储器301内的数据,实现所述计算机装置30的各种功能。所述存储器301可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据计算机装置30的使用所创建的数据(比如音频数据等)等。此外,存储器301可以包括非易失性存储器,例如硬盘、内存、插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)、至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。
所述计算机装置30集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个非易失性可读存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机可读指令代码,所述计算 机可读指令代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述非易失性可读介质可以包括:能够携带所述计算机可读指令代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、以及软件分发介质等。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。
上述以软件功能模块的形式实现的集成的模块,可以存储在一个非易失性可读存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本申请各个实施例所述方法的部分步骤。
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其他的具体形式实现本申请。因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本申请内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。此外,显然“包括”一词不排除其他模块或步骤,单数不排除复数。系统权利要求中陈述的多个模块或装置也可以由一个模块或装置通过软件或者硬件来实现。第一,第二等词语用来表示名称,而并不表示任何特定的顺序。
最后应说明的是,以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。

Claims (20)

  1. 一种文本分析方法,其特征在于,所述方法包括:
    获取待分析文本;
    将所述待分析文本的各个词语转换为词向量;
    将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;
    计算所述特征向量的权重;
    将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;
    将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
  2. 如权利要求1所述的方法,其特征在于,所述将所述待分析文本的各个词语转换为词向量包括:
    对所述待识别文本进行分词,得到所述待识别文本的各个词语;
    用word2vec工具将所述待分析文本的各个词语转换为词向量。
  3. 如权利要求2所述的方法,其特征在于,所述对所述待识别文本进行分词包括:
    利用结巴分词对所述待识别文本进行分词;或者
    利用特定字符对所述待识别文本进行分词;或者
    利用词典库对所述待识别文本进行分词。
  4. 如权利要求1所述的方法,其特征在于,所述获取待分析文本包括:
    接收用户输入的文字,将所述用户输入的文字作为所述待分析文本;或者
    接受用户输入的语音,对所述语音进行识别,得到所述待分析文本;或者
    接收用户输入的文本图像,从所述文本图像进行识别,得到所述待分析文本;或者
    从预定数据源获取所述待分析文本。
  5. 如权利要求1所述的方法,其特征在于,所述情感识别模型还包括第一隐层和第二隐层,所述计算所述特征向量的权重包括:
    将所述特征向量输入所述第一隐层,并通过激活函数激活,得到中间值;
    将所述中间值输入所述第二隐层,并通过输出函数输出,得到所述权重。
  6. 如权利要求1所述的方法,其特征在于,所述将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别包括:
    将所述经过权重调整后的特征向量输入所述全连接层,得到联合特征向量;
    将所述联合特征向量通过输出函数输出,得到所述待识别文本的情感类别。
  7. 如权利要求1-6中任一项所述的方法,其特征在于,所述方法还包括:
    确定所述特征向量中权重大于或等于预设值的目标特征向量;
    将所述待识别文本中所述目标特征向量对应的词语作为所述待识别文本的文本摘要。
  8. 一种文本分析装置,其特征在于,所述装置包括:
    获取模块,用于获取待分析文本;
    转换模块,用于将所述待分析文本的各个词语转换为词向量;
    特征提取模块,用于将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;
    第一计算模块,用于计算所述特征向量的权重;
    第二计算模块,用于将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;
    识别模块,用于将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
  9. 一种计算机装置,其特征在于,所述计算机装置包括处理器和存储器,所述存储器用于存储计算机可读指令,所述处理器用于执行所述计算机可读指令以实现以下步骤:
    获取待分析文本;
    将所述待分析文本的各个词语转换为词向量;
    将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;
    计算所述特征向量的权重;
    将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;
    将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
  10. 如权利要求9所述的计算机装置,其特征在于,所述处理器执行所述计算机可读指令以实现所述将所述待分析文本的各个词语转换为词向量时,包括以下步骤:
    对所述待识别文本进行分词,得到所述待识别文本的各个词语;
    用word2vec工具将所述待分析文本的各个词语转换为词向量。
  11. 如权利要求10所述的计算机装置,其特征在于,所述处理器执行所述计算机可读指令以实现所述对所述待识别文本进行分词时,包括以下步骤:
    利用结巴分词对所述待识别文本进行分词;或者
    利用特定字符对所述待识别文本进行分词;或者
    利用词典库对所述待识别文本进行分词。
  12. 如权利要求9所述的计算机装置,其特征在于,所述处理器执行所述计算机可读指令以实现所述获取待分析文本,包括以下步骤:
    接收用户输入的文字,将所述用户输入的文字作为所述待分析文本;或者
    接受用户输入的语音,对所述语音进行识别,得到所述待分析文本;或者
    接收用户输入的文本图像,从所述文本图像进行识别,得到所述待分析文本;或者
    从预定数据源获取所述待分析文本。
  13. 如权利要求9所述的计算机装置,其特征在于,所述处理器执行所述计算机可读指令以实现所述将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别,包括以下步骤:
    将所述经过权重调整后的特征向量输入所述全连接层,得到联合特征向量;
    将所述联合特征向量通过输出函数输出,得到所述待识别文本的情感类别。
  14. 如权利要求9-13中任一项所述的计算机装置,其特征在于,所述处理器还用于执行所述计算机可读指令以实现以下步骤:
    确定所述特征向量中权重大于或等于预设值的目标特征向量;
    将所述待识别文本中所述目标特征向量对应的词语作为所述待识别文本的文本摘要。
  15. 一种非易失性可读存储介质,所述非易失性可读存储介质上存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现以下步骤:
    获取待分析文本;
    将所述待分析文本的各个词语转换为词向量;
    将所述词向量输入情感识别模型中的双向长短时记忆递归神经网络,得到所述待分析文本的各个词语的特征向量;
    计算所述特征向量的权重;
    将所述特征向量与对应的所述权重相乘,得到经过权重调整后的特征向量;
    将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别。
  16. 如权利要求15所述的存储介质,其特征在于,所述计算机可读指令被处理器执行以实现所述将所述待分析文本的各个词语转换为词向量时,包括以下步骤:
    对所述待识别文本进行分词,得到所述待识别文本的各个词语;
    用word2vec工具将所述待分析文本的各个词语转换为词向量。
  17. 如权利要求16所述的存储介质,其特征在于,所述计算机可读指令被处理器执行以实现所述对所述待识别文本进行分词时,包括以下步骤:
    利用结巴分词对所述待识别文本进行分词;或者
    利用特定字符对所述待识别文本进行分词;或者
    利用词典库对所述待识别文本进行分词。
  18. 如权利要求15所述的存储介质,其特征在于,所述计算机可读指令被处理器执行以实现所述获取待分析文本,包括以下步骤:
    接收用户输入的文字,将所述用户输入的文字作为所述待分析文本;或者
    接受用户输入的语音,对所述语音进行识别,得到所述待分析文本;或者
    接收用户输入的文本图像,从所述文本图像进行识别,得到所述待分析文本;或者
    从预定数据源获取所述待分析文本。
  19. 如权利要求15所述的存储介质,其特征在于,所述计算机可读指令被处理器执行以实现所述将所述经过权重调整后的特征向量输入所述情感识别模型中的全连接层,得到所述待识别文本的情感类别,包括以下步骤:
    将所述经过权重调整后的特征向量输入所述全连接层,得到联合特征向量;
    将所述联合特征向量通过输出函数输出,得到所述待识别文本的情感类别。
  20. 如权利要求15-19中任一项所述的存储介质,其特征在于,所述计算机可读指令被处理器时还用于实现以下步骤:
    确定所述特征向量中权重大于或等于预设值的目标特征向量;
    将所述待识别文本中所述目标特征向量对应的词语作为所述待识别文本的文本摘要。
PCT/CN2019/103413 2019-06-25 2019-08-29 文本分析方法、装置、计算机装置及存储介质 WO2020258502A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910555929.3A CN110427610A (zh) 2019-06-25 2019-06-25 文本分析方法、装置、计算机装置及计算机存储介质
CN201910555929.3 2019-06-25

Publications (1)

Publication Number Publication Date
WO2020258502A1 true WO2020258502A1 (zh) 2020-12-30

Family

ID=68408651

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/103413 WO2020258502A1 (zh) 2019-06-25 2019-08-29 文本分析方法、装置、计算机装置及存储介质

Country Status (2)

Country Link
CN (1) CN110427610A (zh)
WO (1) WO2020258502A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112818681A (zh) * 2020-12-31 2021-05-18 北京知因智慧科技有限公司 文本情感分析方法、系统及电子设备
CN113571050A (zh) * 2021-07-28 2021-10-29 复旦大学 一种基于Attention与Bi-LSTM的语音抑郁状态识别方法
CN113688247A (zh) * 2021-09-29 2021-11-23 有米科技股份有限公司 基于文本的行业识别模型的确定方法及装置
CN114817526A (zh) * 2022-02-21 2022-07-29 华院计算技术(上海)股份有限公司 文本分类方法及装置、存储介质、终端
CN115292620A (zh) * 2022-08-09 2022-11-04 腾讯科技(深圳)有限公司 地域信息识别方法、装置、电子设备和存储介质

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110990531B (zh) * 2019-11-28 2024-04-02 北京声智科技有限公司 一种文本情感识别方法及装置
CN111241820A (zh) * 2020-01-14 2020-06-05 平安科技(深圳)有限公司 不良用语识别方法、装置、电子装置及存储介质
CN111291187B (zh) * 2020-01-22 2023-08-08 北京芯盾时代科技有限公司 一种情感分析方法、装置、电子设备及存储介质
CN111524534B (zh) * 2020-03-20 2021-04-09 北京捷通华声科技股份有限公司 一种语音分析方法、系统、设备及存储介质
CN113626672A (zh) * 2021-02-26 2021-11-09 新大陆数字技术股份有限公司 基于rcnn网络的舆情分析方法及系统
CN113515591B (zh) * 2021-04-22 2024-03-15 平安科技(深圳)有限公司 文本不良信息识别方法、装置、电子设备及存储介质
CN112989054B (zh) * 2021-04-26 2021-07-30 腾讯科技(深圳)有限公司 一种文本处理方法和装置
CN113283232A (zh) * 2021-05-31 2021-08-20 支付宝(杭州)信息技术有限公司 自动解析文本中隐私信息的方法和装置
CN113705692B (zh) * 2021-08-30 2023-11-21 平安科技(深圳)有限公司 基于人工智能的情感分类方法、装置、电子设备及介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109492157A (zh) * 2018-10-24 2019-03-19 华侨大学 基于rnn、注意力机制的新闻推荐方法及主题表征方法
CN109726391A (zh) * 2018-12-11 2019-05-07 中科恒运股份有限公司 对文本进行情感分类的方法、装置及终端
CN109739960A (zh) * 2018-12-11 2019-05-10 中科恒运股份有限公司 文本的情感分析方法、情感分析装置及终端
CN109857860A (zh) * 2019-01-04 2019-06-07 平安科技(深圳)有限公司 文本分类方法、装置、计算机设备及存储介质

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108052505A (zh) * 2017-12-26 2018-05-18 上海智臻智能网络科技股份有限公司 文本情感分析方法及装置、存储介质、终端
CN109697285B (zh) * 2018-12-13 2022-06-21 中南大学 增强语义表示的层次BiLSTM中文电子病历疾病编码标注方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109492157A (zh) * 2018-10-24 2019-03-19 华侨大学 基于rnn、注意力机制的新闻推荐方法及主题表征方法
CN109726391A (zh) * 2018-12-11 2019-05-07 中科恒运股份有限公司 对文本进行情感分类的方法、装置及终端
CN109739960A (zh) * 2018-12-11 2019-05-10 中科恒运股份有限公司 文本的情感分析方法、情感分析装置及终端
CN109857860A (zh) * 2019-01-04 2019-06-07 平安科技(深圳)有限公司 文本分类方法、装置、计算机设备及存储介质

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
CHENG LU: "Research on the Attention Mechanism-Based Bidirectional LSTM Model for the Sentiment Classification of Chinese Product Reviews", SOFTWARE ENGINEER, CN, vol. 20, no. 11, 5 November 2017 (2017-11-05), CN, XP055771605, ISSN: 2096-1472, DOI: 10.19644/j.cnki.issn2096-1472.2017.11.002 *
YEQUAN WANG, HUANG MINLIE, ZHU XIAOYAN, ZHAO LI: "Attention-based LSTM for Aspect-level Sentiment Classification", PROCEEDINGS OF THE 2016 CONFERENCE ON EMPIRICAL METHODS IN NATURAL LANGUAGE PROCESSING, EMPL2016, ASSOCIATION FOR COMPUTATIONAL LINGUISTICS, AUSTIN, TEXAS, USA, 5 November 2016 (2016-11-05), Austin, Texas, USA, pages 606 - 615, XP055527207, DOI: 10.18653/v1/D16-1058 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112818681A (zh) * 2020-12-31 2021-05-18 北京知因智慧科技有限公司 文本情感分析方法、系统及电子设备
CN112818681B (zh) * 2020-12-31 2023-11-10 北京知因智慧科技有限公司 文本情感分析方法、系统及电子设备
CN113571050A (zh) * 2021-07-28 2021-10-29 复旦大学 一种基于Attention与Bi-LSTM的语音抑郁状态识别方法
CN113688247A (zh) * 2021-09-29 2021-11-23 有米科技股份有限公司 基于文本的行业识别模型的确定方法及装置
CN114817526A (zh) * 2022-02-21 2022-07-29 华院计算技术(上海)股份有限公司 文本分类方法及装置、存储介质、终端
CN114817526B (zh) * 2022-02-21 2024-03-29 华院计算技术(上海)股份有限公司 文本分类方法及装置、存储介质、终端
CN115292620A (zh) * 2022-08-09 2022-11-04 腾讯科技(深圳)有限公司 地域信息识别方法、装置、电子设备和存储介质

Also Published As

Publication number Publication date
CN110427610A (zh) 2019-11-08

Similar Documents

Publication Publication Date Title
WO2020258502A1 (zh) 文本分析方法、装置、计算机装置及存储介质
CN109241524B (zh) 语义解析方法及装置、计算机可读存储介质、电子设备
US20210201143A1 (en) Computing device and method of classifying category of data
JP5901001B1 (ja) 音響言語モデルトレーニングのための方法およびデバイス
CN107729313B (zh) 基于深度神经网络的多音字读音的判别方法和装置
JP6909832B2 (ja) オーディオにおける重要語句を認識するための方法、装置、機器及び媒体
WO2021000497A1 (zh) 检索方法、装置、计算机设备和存储介质
WO2020168752A1 (zh) 一种基于对偶学习的语音识别与语音合成方法及装置
CN110415679B (zh) 语音纠错方法、装置、设备和存储介质
CN110083832B (zh) 文章转载关系的识别方法、装置、设备及可读存储介质
CN111177186B (zh) 基于问题检索的单句意图识别方法、装置和系统
WO2021204017A1 (zh) 文本意图识别方法、装置以及相关设备
CN111310441A (zh) 基于bert的语音识别后文本修正方法、装置、终端及介质
CN111209363B (zh) 语料数据处理方法、装置、服务器和存储介质
CN110209802B (zh) 一种提取摘要文本的方法及装置
CN110309504B (zh) 基于分词的文本处理方法、装置、设备及存储介质
WO2023134402A1 (zh) 一种基于孪生卷积神经网络的书法字识别方法
Li et al. Combining CNN and BLSTM to Extract Textual and Acoustic Features for Recognizing Stances in Mandarin Ideological Debate Competition.
CN113326702A (zh) 语义识别方法、装置、电子设备及存储介质
WO2022095370A1 (zh) 一种文本匹配方法、装置、终端设备和存储介质
CN114925693B (zh) 一种基于多模型融合的多元关系抽取方法和抽取系统
CN116561592A (zh) 文本情感识别模型的训练方法和文本情感识别方法及装置
CN111368066B (zh) 获取对话摘要的方法、装置和计算机可读存储介质
EP4060526A1 (en) Text processing method and device
WO2021147404A1 (zh) 依存关系分类方法及相关设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19934698

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19934698

Country of ref document: EP

Kind code of ref document: A1