Emotional Intelligence Classification Method, Device, Electronic Device and Medium for Review Texts
By performing fine-grained analysis and word vector processing on the comment text, combined with attention mechanism and multi-layer perceptron, the problem of inaccurate emotional classification in the existing technology is solved, and higher accuracy and fine-grained expression are achieved.
Patent Information
- Application Number
- CN202210961855.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-11
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2042-08-11
AI Technical Summary
The prior art cannot display the specific emotional direction in the text from a more fine-grained perspective in the emotion classification of text comments, resulting in inaccurate emotional classification.
By obtaining comment text, analyzing the evaluation object categories and extracting comment dimension information, using word segmentation tools for word segmentation processing, and converting comment dimension information and text word segmentation into dimension word vectors and text word vectors. Then, the attention score of the text word vector is calculated using the attention mechanism and fused with the text word vector. Then, the vector intraproduct matrix of the text fusion word vector and the dimension word vector is calculated, the vector weight is marked, and the refusion and pooling is performed. Finally, the multi-layer perceptron is used to calculate the text emotional category probability.
It improves the accuracy of emotional classification of comment texts and can express comment texts more granularly, thus providing more accurate references for user decisions.
Smart Images

Figure CN115309864B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent decision-making, and particularly to an emotional intelligent classification method, device, electronic device and medium for review texts. Background Art
[0002] With the development of network technology, more and more Internet users share experiences and post comments on various websites. These review texts express the opinions and emotions of the reviewers and contain huge commercial value. Various shopping websites, forums, blogs, and microblogs, etc., provide a broad platform for Internet users to express opinions and exchange information. People gradually get used to sharing experiences and posting comments on various websites and directly expressing their positive or negative, supportive or opposing emotions, such as posting book reviews, movie reviews, evaluations of a certain hotel, or usage experiences of a certain mobile phone, etc. Users are also accustomed to obtaining information from various reviews on the Internet to find reference opinions for their certain decisions.
[0003] Currently, the industry often conducts emotional classification of text reviews at the text level or sentence level. The text level is to calculate the overall emotional category for the entire text review, and the sentence level means classifying the emotional category for each sentence in the entire text review. However, the text emotional classification achieved through the text level or sentence level cannot show the specific emotional direction in the text from a finer-grained perspective. For example, a sentence may contain multiple dimensions, and each dimension has its own emotional category. If classified from the text level or sentence level, it is impossible to accurately determine the emotional category of the text review, resulting in inaccurate text emotional classification. Summary of the Invention
[0004] The present invention provides an emotional intelligent classification method, device, electronic device and medium for review texts, and its main purpose is to improve the accuracy of emotional classification of review texts.
[0005] To achieve the above purpose, an emotional intelligent classification method for review texts provided by the present invention includes:
[0006] Obtain a review text, analyze the evaluation object category of the review text, and extract the comment dimension information corresponding to the evaluation object category;
[0007] Use a word segmentation tool to perform word segmentation processing on the review text to obtain text word segments;
[0008] Convert the comment dimension information and the text word segments into dimension word vectors and text word vectors respectively;
[0009] Calculate the attention score of the text word vector using the attention mechanism in the trained text sentiment classification model, and fuse the attention score with the text word vector to obtain a text fusion word vector;
[0010] Use the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fusion word vector and the dimension word vector, and mark the vector weights of each inner product vector in the vector inner product matrix;
[0011] Re-fuse the vector weights with the text fusion word vector to obtain a target fusion word vector, and perform pooling processing on the target fusion word vector using the pooling layer in the trained text sentiment classification model to obtain a pooled fusion word vector;
[0012] Calculate the text sentiment category probability of the pooled fusion word vector using the multi-layer perceptron in the trained text sentiment classification model, and determine the sentiment category of the review text using the output layer in the trained text sentiment classification model according to the text sentiment category probability.
[0013] Optionally, the analyzing the evaluation object category of the review text includes:
[0014] Extract the original feature words of the review text;
[0015] Extract the feature object words from the original feature words, and convert the feature object words into feature category words;
[0016] Screen out the classification feature words that meet the preset conditions from the original feature words;
[0017] Determine the evaluation object category of the review text according to the feature category words and the classification feature words.
[0018] Optionally, the calculating the attention score of the text word vector using the attention mechanism in the trained text sentiment classification model includes:
[0019] Create a dimension vector corresponding to the text word vector using the vector matrix in the attention mechanism;
[0020] Calculate the vector weights of the dimension vector using the dot product function in the attention mechanism, and use the vector weights as the attention score of the text word vector.
[0021] Optionally, the fusing the attention score with the text word vector to obtain a text fusion word vector includes:
[0022] Normalize the attention score using a preset normalization function to obtain a weight coefficient, and create a numerical vector corresponding to the text word vector;
[0023] Multiply the weight coefficient by the numerical vector to obtain a text fusion word vector.
[0024] Optionally, the preset normalization function includes:
[0025]
[0026] where y k represents the weight coefficient, and a k represents the attention score of the k-th text word vector, and a i represents the attention score of the i-th text word vector, n represents the number of attention scores, and e represents an irrational number.
[0027] Optionally, using the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fusion word vector and the dimension word vector includes:
[0028] Create a text fusion matrix of the text fusion word vector by using the vector matrix conversion method in the conversion layer, and create a dimension word matrix of the dimension word vector by using the vector matrix conversion method;
[0029] Perform an inner product calculation on the text fusion matrix and the dimension word matrix by using the inner product function in the conversion layer to obtain the vector inner product matrix.
[0030] Optionally, according to the text category probability, using the output layer in the trained text sentiment classification model to determine the text sentiment category of the review text includes:
[0031] According to the text category probability, use the feedforward neural network in the output layer to determine the text category of the review text, and based on the text category, use a preset sentiment label threshold mapping relation table to determine the text sentiment category of the review text.
[0032] To solve the above problems, the present invention also provides an emotional intelligent classification device for review text, and the device includes:
[0033] A category recognition module, configured to obtain a review text, analyze the evaluation object category of the review text, and extract review dimension information corresponding to the evaluation object category;
[0034] A text word segmentation module, configured to perform word segmentation processing on the review text by using a word segmentation tool to obtain text word segmentation;
[0035] A word vector conversion module, configured to convert the review dimension information and the text word segmentation into dimension word vectors and text word vectors respectively;
[0036] A word vector fusion module, configured to calculate the attention scores of the text word vectors by using the attention mechanism in the trained text sentiment classification model, and fuse the attention scores with the text word vectors to obtain text fusion word vectors;
[0037] A vector inner product module, configured to calculate the vector inner product matrix of the text fusion word vectors and the dimension word vectors by using the conversion layer in the trained text sentiment classification model, and mark the vector weights of each inner product vector in the vector inner product matrix;
[0038] A pooling processing module, configured to re-fuse the vector weights with the text fusion word vectors to obtain target fusion word vectors, and perform pooling processing on the target fusion word vectors by using the pooling layer in the trained text sentiment classification model to obtain pooled fusion word vectors;
[0039] A sentiment category discrimination module, configured to calculate the text sentiment category probabilities of the pooled fusion word vectors by using the multi-layer perceptron in the trained text sentiment classification model, and determine the sentiment category of the review text by using the output layer in the trained text sentiment classification model according to the text sentiment category probabilities.
[0040] To solve the above problems, the present invention also provides an electronic device, which includes:
[0041] At least one processor; and,
[0042] A memory communicatively connected to the at least one processor; wherein,
[0043] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to implement the above-mentioned sentiment intelligent classification method for review texts.
[0044] To solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored, and the at least one computer program is executed by a processor in an electronic device to implement the above-mentioned sentiment intelligent classification method for review texts.
[0045] It can be seen that in the embodiments of the present invention, by identifying the evaluation object category of the obtained review text, an operation object is provided for the subsequent method implementation, and according to the review dimension information corresponding to the evaluation object category, review data of the review object category is obtained from multiple dimension directions, ensuring the fine-grained information splitting of the review text corresponding to the evaluation object category in the subsequent process. Using a word segmentation tool to perform word segmentation processing on the review text to obtain text word segments, and respectively converting the review dimension information and the text word segments into dimension word vectors and text word vectors is a preprocessing of the review text to provide input for the subsequent text sentiment classification model for further processing as a guarantee; secondly, in the embodiments of the present invention, the attention mechanism in the trained text sentiment classification model is used to calculate the attention scores of the text word vectors, which can be used to describe the attention degrees of each text word segment in the review text. The attention scores are fused with the text word vectors to generate a text fusion word vector that more truly reflects the actual application scenario, which can provide input support for the conversion layer in the subsequent text sentiment classification model. Using the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fusion word vector and the dimension word vector can provide support for obtaining the weight coefficients of the text fusion word vector in terms of dimension words in the subsequent process, and then generating a target fusion word vector. Marking the vector weights of each inner product vector in the vector inner product matrix can determine the weight of the text fusion word vector in terms of dimension words, for making an association between the review text and the dimension aspect in the subsequent process to more fully express the review text, with a view to making a more fine-grained review of the review text; further, in the embodiments of the present invention, the vector weights are re-fused with the text fusion word vector to obtain a target fusion word vector, which can obtain a more fine-grained expression of the review text and improve the accuracy of subsequent text sentiment classification. Using the pooling layer in the trained text sentiment classification model to perform pooling processing on the target fusion word vector to obtain a pooled fusion word vector can be used as the input of the activation function of the multi-layer perceptron in the subsequent text sentiment classification model for further processing. Using the multi-layer perceptron in the trained text sentiment classification model to calculate the text category probability of the pooled fusion word vector, and according to the text category probability, using the output layer in the trained text sentiment classification model to determine the text sentiment category of the review text can realize a fine-grained evaluation of the review text, improve the accuracy of subsequent text sentiment classification, and provide a more accurate reference opinion for user decision-making. Therefore, a method, device, electronic device and storage medium for emotional intelligent classification of review text proposed in the embodiments of the present invention can improve the accuracy of review text sentiment classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 FIG. is a schematic flow chart of a method for emotional intelligent classification of review text provided by an embodiment of the present invention;
[0047] Figure 2 Schematic diagram of modules of an emotional intelligence classification device for review texts provided by an embodiment of the present invention;
[0048] Figure 3 Internal structure schematic diagram of an electronic device for implementing an emotional intelligence classification method for review texts provided by an embodiment of the present invention;
[0049] The realization, functional features and advantages of the present invention will be further described in conjunction with embodiments with reference to the accompanying drawings. Detailed implementation manners
[0050] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0051] An embodiment of the present invention provides an emotional intelligence classification method for review texts. The execution subject of the emotional intelligence classification method for review texts includes, but is not limited to, at least one of electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided by this embodiment of the present invention. In other words, the emotional intelligence classification method for review texts can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes, but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms.
[0052] Refer to Figure 1 As shown, it is a flowchart of an emotional intelligence classification method for review texts provided by an embodiment of the present invention. In the embodiment of the present invention, the emotional intelligence classification method for review texts includes the following steps S1 to S7:
[0053] S1. Obtain a review text, analyze the evaluation object category of the review text, and extract the comment dimension information corresponding to the evaluation object category;
[0054] In the embodiment of the present invention, the operation object for subsequent method implementation is provided by obtaining the review text. Among them, the review text refers to the manifestation form of the written language to be evaluated, such as sentences, paragraphs, and texts, etc.
[0055] Further, in an alternative embodiment of the present invention, the review text can be obtained through web crawling technology. The web crawling technology refers to a web crawler, which is a program or script that automatically fetches information on the World Wide Web according to certain rules.
[0056] In an embodiment of the present invention, analyzing the evaluation object category of the review text can provide a basis for determining the dimensional information of the review text subsequently. The evaluation object category refers to the category to which the object or the attribute of the object targeted by the review text belongs.
[0057] Further, in an alternative embodiment of the present invention, analyzing the evaluation object category of the review text includes: extracting the original feature words of the review text; extracting the feature object words from the original feature words, and converting the feature object words into feature category words; screening out the classification feature words that meet the preset conditions from the original feature words; combining the feature category words and the classification feature words to determine the evaluation object category of the review text.
[0058] The original feature words refer to the feature words initially extracted from the text. The feature object words refer to the nouns representing objects in the original feature words. The classification feature words are used to describe words with classification information attributes, such as dish names, delicious, environment, quiet, price, expensive, etc.
[0059] Further, in an alternative embodiment of the present invention, the original feature words of the review text can be implemented through a preset text analysis algorithm. The preset text analysis algorithm includes Information Gain (IG), Chi-Square (chi-square) algorithm, which is used for the representation of the text and the selection of its feature terms, and quantifies the feature words extracted from the text to represent the text information. The feature category words of the review text can be implemented through a preset mapping conversion method. The preset mapping conversion method includes an object word-category word mapping relationship, which is a method used to describe the corresponding relationship of the mutual transformation between the elements of two sets. For example, object words such as price, environment, location, and service in the review text are mapped to the category word service industry. The classification feature words of the review text can be implemented through a preset corpus word category mapping relationship. For example, expensive or cheap is mapped to the price category, far or near is mapped to the distance category, and price and distance are mapped to the service industry category, etc. The corpus refers to a large-scale electronic text library that has been scientifically sampled and processed, and stores language materials that have actually appeared in the actual use of the language.
[0060] Further, in an alternative embodiment of the present invention, the evaluation object category of the review text is obtained by semantic overlapping of the feature category words and the classification feature words.
[0061] In the embodiments of the present invention, by extracting the comment dimension information corresponding to the evaluation object category, comment data of the comment object category can be obtained from multiple dimensional directions, ensuring the fine-grained information splitting of the comment text corresponding to the evaluation object category. Among them, the comment dimension information refers to the relative or parallel information description associated with the object category at a certain level. For example, the comment dimension information of the evaluation text about a restaurant is dishes, price, environment, location, service, etc.
[0062] It should be understood that in the implementation of the present invention, the extraction of the comment dimension information corresponding to the evaluation object category includes: matching the evaluation object category with the dimension categories in the pre-constructed category-dimension relationship table, and taking the evaluation dimensions corresponding to the successfully matched dimension categories as the comment dimension information corresponding to the evaluation object category.
[0063] Among them, the pre-constructed category-dimension relationship table refers to a data table obtained by mapping the relationship between historical object categories and historical evaluation dimensions. The historical object categories and historical evaluation dimensions can be collected through big data technology, and the historical object categories and historical evaluation dimensions can be mapped through a relationship mapping algorithm, and the relationship mapping algorithm can be compiled through the Python language.
[0064] Furthermore, in an optional embodiment of the present invention, the matching between the evaluation object category and the dimension categories in the pre-constructed category-dimension relationship table can be achieved through a matching algorithm, such as a cosine similarity matching algorithm.
[0065] S2. Use a word segmentation tool to perform word segmentation on the comment text to obtain text word segmentation;
[0066] In the embodiments of the present invention, using the word segmentation tool to perform word segmentation on the comment text to obtain text word segmentation is a preprocessing of the comment text, providing guarantee for further operations to obtain the word vectors of the comment text.
[0067] Among them, the word segmentation tool is a tool that recombines a continuous sequence of characters into a sequence of words according to certain specifications, such as word segmentation tools like jieba, ltp, and ir. The text word segmentation refers to splitting a sequence of Chinese characters into individual words. For example, the text word segmentation of "This restaurant is delicious but too expensive" is "This restaurant is delicious but too expensive".
[0068] S3. Convert the comment dimension information and the text word segmentation into dimension word vectors and text word vectors respectively;
[0069] In an embodiment of the present invention, by respectively converting the comment dimension information and the text word segmentation into a dimension word vector and a text word vector as the input of a subsequent text sentiment classification model, a basis is provided for further processing. Wherein, the text word vector refers to a vector that maps words or phrases in a natural language vocabulary to a real number space. Conceptually, it involves a mathematical embedding from the one-dimensional space of each word to a multi-dimensional continuous vector space. The comment dimension information refers to information and its formal content that is "related" to a thing and is conducive to better understanding the thing. For example, "dishes", "price", and "service" are the comment dimension information of a "restaurant".
[0070] Further, in an alternative embodiment of the present invention, the step of respectively converting the comment dimension information and the text word segmentation into a dimension word vector and a text word vector can be achieved by using a pre-trained vector conversion model to calculate the word vectors of the comment dimension information and the text word segmentation, such as vector conversion models like Skip-gram, CBOW, LBL, NNLM, C&W, and Glove.
[0071] S4. Use the attention mechanism in the trained text sentiment classification model to calculate the attention scores of the text word vectors, and fuse the attention scores with the text word vectors to obtain text fusion word vectors;
[0072] In an embodiment of the present invention, by using the attention mechanism in the trained text sentiment classification model to calculate the attention scores of the text word vectors, it can be used to describe the attention degrees of each text word segmentation in the comment text, providing support for generating the text fusion word vectors that more truly reflect the actual application scenario subsequently. Wherein, the text sentiment classification model refers to a formal expression obtained by abstracting and training the features and rules of text for classification, such as text sentiment classification models like support vector machine (SVM) and K-nearest neighbor (KNN) model. The attention mechanism originates from the study of human vision. In cognitive science, due to the bottleneck of information processing, humans will selectively focus on a part of all information while ignoring other visible information, and the above mechanism is usually referred to as the attention mechanism.
[0073] Further, in an alternative embodiment of the present invention, the step of using the attention mechanism in the trained text sentiment classification model to calculate the attention scores of the text word vectors includes: creating a dimension vector corresponding to the text word vector by using the vector matrix in the attention mechanism; calculating the vector weights of the dimension vector by using the dot product function in the attention mechanism, and taking the vector weights as the attention scores of the text word vectors.
[0074] Among them, the dot product function refers to a binary operation that accepts two vectors on the real number R and returns a real-valued scalar, which is realized by multiplying the corresponding components of two vectors of the same dimension and then summing them up.
[0075] In the embodiment of the present invention, by fusing the attention score with the text word vector, the obtained text fusion word vector can provide input support for the conversion layer in the subsequent text sentiment classification model.
[0076] Further, in an alternative embodiment of the present invention, the fusing the attention score with the text word vector to obtain a text fusion word vector includes: normalizing the attention score by using a preset normalization function to obtain a weight coefficient, and creating a numerical vector corresponding to the text word vector; multiplying the weight coefficient by the numerical vector to obtain a text fusion word vector.
[0077] Among them, the weight coefficient refers to the degree of importance of a certain text word vector item in the text word vector system, which can be used to show the degree of importance of several text word vectors in the total amount of text word vectors, and different proportional coefficients are given respectively.
[0078] Further, in an alternative embodiment of the present invention, the preset normalization function includes:
[0079]
[0080] Among them, y k represents the weight coefficient, a k represents the attention score of the k-th text word vector, a i represents the attention score of the i-th text word vector, n represents the number of attention scores, and e represents an infinite non-recurring decimal.
[0081] Further, in an alternative embodiment of the present invention, the numerical vector corresponding to the text word vector is created in the same principle as the above query vector and identification vector, and will not be further described here.
[0082] S5. Use the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fusion word vector and the dimension word vector, and mark the vector weight of each inner product vector in the vector inner product matrix;
[0083] In the embodiments of the present invention, by using the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fusion word vector and the dimension word vector, it can provide support for obtaining the weight coefficient of the text fusion word vector in terms of dimension words, so as to generate the target fusion word vector subsequently. Among them, the conversion layer is optionally a processing layer that further extracts features from the output of the SA layer by using the FFN layer of the transformer model.
[0084] Further, in the embodiments of the present invention, the method of using the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fusion word vector and the dimension word vector includes: creating a text fusion matrix of the text fusion word vector by using the vector matrix conversion method in the conversion layer, and creating a dimension word matrix of the dimension word vector by using the vector matrix conversion method; performing an inner product calculation on the text fusion matrix and the dimension word matrix by using the inner product function in the conversion layer to obtain the vector inner product matrix.
[0085] Among them, the vector matrix conversion method refers to a method of converting a group of vectors into a matrix, which can be realized by arranging the vectors in sequence as a row or a column of the matrix according to the same rule.
[0086] In the embodiments of the present invention, by marking the vector weights of each inner product vector in the vector inner product matrix, the weight of the text fusion word vector in terms of dimension words can be determined, so as to make an association between the review text and the dimension aspect subsequently to more fully express the review text, in order to make a more fine-grained review of the review text.
[0087] Further, in an optional embodiment of the present invention, the marking of the vector weights of each inner product vector in the vector inner product matrix can be realized by determining the position of the matrix element corresponding to each inner product vector in the vector inner product matrix according to the matrix multiplication principle.
[0088] S6. Re-fuse the vector weights with the text fusion word vector to obtain a target fusion word vector, and perform pooling processing on the target fusion word vector by using the pooling layer in the trained text sentiment classification model to obtain a pooled fusion word vector;
[0089] In the embodiments of the present invention, by re-fusing the vector weights with the text fusion word vector to obtain a target fusion word vector, a more fine-grained expression of the review text can be obtained, and the accuracy of subsequent text sentiment classification can be improved.
[0090] Further, in an optional embodiment of the present invention, the re - fusion of the vector weight and the text fusion word vector to obtain the target fusion word vector can be achieved by performing a dot - product calculation on the vector weight and the text fusion word vector.
[0091] In the embodiment of the present invention, through the pooling layer in the trained text sentiment classification model to perform pooling processing on the target fusion word vector, the obtained pooled fusion word vector can be used as the input of the activation function of the multi - layer perceptron in the subsequent text sentiment classification model for further processing. Among them, the pooling layer reduces the calculation amount and prevents overfitting by partitioning and sampling the data and downsampling a large matrix into a small matrix. The pooling processing is a series of operations performed on the input data by the pooling layer, including max - pooling, average - pooling, random - pooling, median - pooling, and combined - pooling and other pooling processes.
[0092] S7. Use the multi - layer perceptron in the trained text sentiment classification model to calculate the text category probability of the pooled fusion word vector. According to the text category probability, use the output layer in the trained text sentiment classification model to determine the text sentiment category of the review text.
[0093] In the embodiment of the present invention, calculating the text category probability of the pooled fusion word vector through the multi - layer perceptron in the trained text sentiment classification model can provide a guarantee for subsequently determining the text sentiment category of the review text. Among them, the multi - layer perceptron is a neural network composed of fully - connected layers with at least one hidden layer, and the output of each hidden layer is transformed through an activation function. The activation function refers to a non - linear function operating on the neurons in the hidden layer of an artificial neural network, responsible for mapping the input of the neuron to the output, such as activation functions like the sigmoid function, ReLU function, tanh function, etc.
[0094] Further, in an optional embodiment of the present invention, the following formula is used to calculate the text category probability of the pooled fusion word vector:
[0095]
[0096] Among them, x is the neuron input in the artificial neural network, f(x) is the neuron output obtained by mapping the neuron input x through a function, and R represents the real number field.
[0097] In the embodiment of the present invention, determining the text sentiment category of the review text according to the text category probability and using the output layer in the trained text sentiment classification model can realize a fine - grained evaluation of the review text and provide more accurate reference opinions for user decision - making.
[0098] Further, in an optional embodiment of the present invention, determining the text sentiment category of the review text according to the text category probability by using the output layer in the trained text sentiment classification model includes: determining the text category of the review text by using the feedforward neural network in the output layer according to the text category probability, and determining the text sentiment category of the review text based on the text category by using a preset sentiment label threshold mapping relationship table.
[0099] Among them, the preset sentiment label threshold mapping relationship table can be constructed according to the business scenario. For example, if the sentiment labels are set to four categories: positive, neutral, negative, and irrelevant, then the sentiment label threshold mapping relationship table can be as follows:
[0100] f:A→B,f 1 :A 1 →B 1 ,f 2 :A 2 →B 2 ,f 3 :A 3 →B 3 ,f 4 :A 4 →B 4 ;
[0101] Among them, A = {A 1, A 2, A 3 ,A 4}, B = {B 1, B 2, B 3 ,B 4}, A 2 = {x i ≥T h ,0.5≤nin<0.75, A3 = xi≥Th, 0.25≤nin<0.5, A4 = xi≥Th, 0≤nin<0.25, x = x1,x2,x3…,xn, 0≤x i≤ 1,i = 1,2,3…,n; B 1 = {positive}, B 2 = {neutral}, B 3 = {negative}, B 4 = {irrelevant}.
[0102] Among them, f represents the sentiment label threshold mapping relationship table, x represents the text dimension probability of the text vector of the review text to be evaluated (which is a probability vector), x i represents the text dimension probability component corresponding to the i-th review dimension, T h is the label threshold, and optionally T h= 0.5, and it can also be set according to the actual application scenario. n is the dimension of the text vector of the paper to be evaluated, and n i represents the number of vector components in the text vector of the paper to be evaluated corresponding to the i-th comment dimension that satisfy the threshold condition.
[0103] It can be seen that in the embodiment of the present invention, by identifying the evaluation object category of the obtained review text, an operation object is provided for the subsequent method implementation, and according to the review dimension information corresponding to the evaluation object category, review data of the review object category is obtained from multiple dimension directions to ensure the fine-grained information splitting of the review text corresponding to the evaluation object category in the subsequent process. Using a word segmentation tool to perform word segmentation on the review text to obtain text word segments, and respectively converting the review dimension information and the text word segments into dimension word vectors and text word vectors is a preprocessing of the review text to provide input for the subsequent text sentiment classification model for further processing as a guarantee; secondly, in the embodiment of the present invention, the attention mechanism in the trained text sentiment classification model is used to calculate the attention scores of the text word vectors, which can be used to describe the attention degrees of each text word segment in the review text. Fusing the attention scores with the text word vectors to generate a text fusion word vector that more truly reflects the actual application scenario can provide input support for the conversion layer in the subsequent text sentiment classification model. Using the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fusion word vector and the dimension word vector can provide support for obtaining the weight coefficients of the text fusion word vector in terms of dimension words in the subsequent process, so as to generate a target fusion word vector in the subsequent process. Marking the vector weights of each inner product vector in the vector inner product matrix can determine the weights of the text fusion word vector in terms of dimension words, so as to make an association between the review text and the dimension aspect in the subsequent process to more fully express the review text, in order to perform a more fine-grained review of the review text; further, in the embodiment of the present invention, re-fusing the vector weights with the text fusion word vector to obtain a target fusion word vector can obtain a more fine-grained expression of the review text, improving the accuracy of subsequent text sentiment classification. Using the pooling layer in the trained text sentiment classification model to perform pooling processing on the target fusion word vector to obtain a pooled fusion word vector can be used as the input of the activation function of the multi-layer perceptron in the subsequent text sentiment classification model for further processing. Using the multi-layer perceptron in the trained text sentiment classification model to calculate the text category probability of the pooled fusion word vector, and according to the text category probability, using the output layer in the trained text sentiment classification model to determine the text sentiment category of the review text can realize a fine-grained evaluation of the review text, improving the accuracy of subsequent text sentiment classification and providing more accurate reference opinions for user decision-making. Therefore, a method, device, electronic device and storage medium for emotional intelligent classification of review text proposed in the embodiment of the present invention can improve the accuracy of review text sentiment classification.
[0104] As Figure 2 shown, it is a functional module diagram of the emotional intelligent classification device for review text of the present invention.
[0105] The emotional intelligence classification device 100 for review texts according to the present invention can be installed in an electronic device. According to the functions achieved, the emotional intelligence classification device for review texts may include a category recognition module 101, a text word segmentation module 102, a word vector conversion module 103, a word vector fusion module 104, a vector inner product module 105, a pooling processing module 106, and an emotional category discrimination module 107. The modules in the present invention can also be referred to as units, which refer to a series of computer program segments that can be executed by the processor of an electronic device and can complete fixed functions, and are stored in the memory of the electronic device.
[0106] In this embodiment, the functions of each module / unit are as follows:
[0107] The category recognition module 101 is used to obtain a review text, analyze the evaluation object category of the review text, and extract the comment dimension information corresponding to the evaluation object category;
[0108] The text word segmentation module 102 is used to perform word segmentation processing on the review text by using a word segmentation tool to obtain text word segmentation;
[0109] The word vector conversion module 103 is used to convert the comment dimension information and the text word segmentation into dimension word vectors and text word vectors respectively;
[0110] The word vector fusion module 104 is used to calculate the attention scores of the text word vectors by using the attention mechanism in the trained text emotion classification model, and fuse the attention scores with the text word vectors to obtain text fusion word vectors;
[0111] The vector inner product module 105 is used to calculate the vector inner product matrix of the text fusion word vectors and the dimension word vectors by using the conversion layer in the trained text emotion classification model, and mark the vector weights of each inner product vector in the vector inner product matrix;
[0112] The pooling processing module 106 is used to re-fuse the vector weights with the text fusion word vectors to obtain target fusion word vectors, and perform pooling processing on the target fusion word vectors by using the pooling layer in the trained text emotion classification model to obtain pooled fusion word vectors;
[0113] The emotional category discrimination module 107 is used to calculate the text emotion category probability of the pooled fusion word vectors by using the multi-layer perceptron in the trained text emotion classification model, and determine the emotional category of the review text by using the output layer in the trained text emotion classification model according to the text emotion category probability.
[0114] Specifically, when the modules in the sentiment intelligent classification device 100 of the review text in the embodiments of the present invention are used, they adopt the same technical means as the Figure 1 sentiment intelligent classification method of the review text described therein, and can produce the same technical effects, which will not be elaborated here.
[0115] As Figure 3 shown, it is a schematic structural diagram of an electronic device 1 for implementing the sentiment intelligent classification method of review text of the present invention.
[0116] The electronic device 1 may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and may further include a computer program stored in the memory 11 and executable on the processor 10, such as a sentiment intelligent classification program for review text.
[0117] Among them, the processor 10 may be composed of integrated circuits in some embodiments. For example, it may be composed of a single packaged integrated circuit, or may be composed of multiple integrated circuits with the same or different functions, including a combination of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control core (Control Unit) of the electronic device 1, connecting various components of the entire electronic device 1 through various interfaces and lines, and by running or executing programs or modules stored in the memory 11 (such as executing the sentiment intelligent classification program for review text, etc.), and calling the data stored in the memory 11, to perform various functions of the electronic device 1 and process data.
[0118] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disks, multimedia cards, card-type memories (such as SD or DX memories, etc.), magnetic memories, magnetic disks, optical disks, etc. The memory 11 may be an internal storage unit of the electronic device 1 in some embodiments, such as the mobile hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 1. Further, the memory 11 may include both an internal storage unit and an external storage device of the electronic device 1. The memory 11 can not only be used to store application software installed in the electronic device 1 and various types of data, such as the code of the sentiment intelligent classification program for review text, etc., but also be used to temporarily store data that has been output or will be output.
[0119] The communication bus 12 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. This bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable connection communication between the memory 11 and at least one processor 10, etc.
[0120] The communication interface 13 is used for communication between the above-mentioned electronic device 1 and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), and is generally used to establish a communication connection between this electronic device 1 and other electronic devices 1. The user interface may be a display, an input unit (such as a keyboard), and optionally, the user interface may also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch liquid crystal display, and an OLED (Organic Light-Emitting Diode) toucher, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, and is used to display the information processed in the electronic device 1 and to display a visual user interface.
[0121] Figure 3 Only the electronic device 1 with components is shown. Those skilled in the art can understand that Figure 3 the shown structure does not constitute a limitation on the electronic device 1, and it may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0122] For example, although not shown, the electronic device 1 may further include a power source (such as a battery) for powering each component. Preferably, the power source can be logically connected to the at least one processor 10 through a power management device, so as to implement functions such as charge management, discharge management, and power consumption management through the power management device. The power source may also include any components such as one or more DC or AC power sources, a recharge device, a power failure detection circuit, a power converter or an inverter, and a power status indicator. The electronic device 1 may also include various sensors, a Bluetooth module, a Wi-Fi module, etc., which will not be elaborated here.
[0123] It should be understood that the above embodiments are only for illustration purposes and are not limited by this structure within the scope of the patent invention.
[0124] The sentiment intelligent classification program of the review text stored in the memory 11 in the electronic device 1 is a combination of multiple computer programs. When running in the processor 10, it can achieve the following:
[0125] Obtain the review text, analyze the evaluation object category of the review text, and extract the comment dimension information corresponding to the evaluation object category;
[0126] Use a word segmentation tool to perform word segmentation on the review text to obtain text word segments;
[0127] Convert the comment dimension information and the text word segments into dimension word vectors and text word vectors respectively;
[0128] Use the attention mechanism in the trained text sentiment classification model to calculate the attention scores of the text word vectors, and fuse the attention scores with the text word vectors to obtain text fused word vectors;
[0129] Use the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fused word vectors and the dimension word vectors, and mark the vector weights of each inner product vector in the vector inner product matrix;
[0130] Re-fuse the vector weights with the text fused word vectors to obtain target fused word vectors, and use the pooling layer in the trained text sentiment classification model to perform pooling processing on the target fused word vectors to obtain pooled fused word vectors;
[0131] Use the multi-layer perceptron in the trained text sentiment classification model to calculate the text sentiment category probability of the pooled fused word vectors, and use the output layer in the trained text sentiment classification model to determine the sentiment category of the review text according to the text sentiment category probability.
[0132] Specifically, for the specific implementation method of the above computer program by the processor 10, reference can be made to Figure 1 the description of the relevant steps in the corresponding embodiment, which will not be elaborated here.
[0133] Furthermore, if the modules / units integrated in the electronic device 1 are implemented in the form of software function units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory).
[0134] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor of the electronic device 1, can implement:
[0135] Obtain a review text, analyze the evaluation object category of the review text, and extract the review dimension information corresponding to the evaluation object category;
[0136] Use a word segmentation tool to perform word segmentation on the review text to obtain text word segmentation;
[0137] Convert the review dimension information and the text word segmentation into dimension word vectors and text word vectors respectively;
[0138] Use the attention mechanism in the trained text sentiment classification model to calculate the attention scores of the text word vectors, and fuse the attention scores with the text word vectors to obtain text fusion word vectors;
[0139] Use the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fusion word vectors and the dimension word vectors, and mark the vector weights of each inner product vector in the vector inner product matrix;
[0140] Re-fuse the vector weights with the text fusion word vectors to obtain target fusion word vectors, and use the pooling layer in the trained text sentiment classification model to perform pooling processing on the target fusion word vectors to obtain pooled fusion word vectors;
[0141] Use the multi-layer perceptron in the trained text sentiment classification model to calculate the text sentiment category probability of the pooled fusion word vectors, and determine the sentiment category of the review text according to the text sentiment category probability using the output layer in the trained text sentiment classification model.
[0142] In several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0143] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0144] In addition, in each embodiment of the present invention, each functional module can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware, or in the form of a combination of hardware and software functional modules.
[0145] For those skilled in the art, it is obvious that the present invention is not limited to the details of the above-described exemplary embodiments, and without departing from the spirit or basic characteristics of the present invention, the present invention can be implemented in other specific forms.
[0146] Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting. The scope of the present invention is defined by the appended claims rather than the above description. Therefore, all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be included in the present invention. Any reference signs in the claims should not be construed as limiting the claims involved.
[0147] The embodiments of the present invention can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is a theory, method, technology and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0148] In addition, obviously, the word "including" does not exclude other units or steps, and the singular does not exclude the plural. The multiple units or devices stated in the system claims can also be implemented by one unit or device through software or hardware. Words such as "second" are used to denote names and do not denote any particular order.
[0149] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for sentiment intelligent classification of review texts, characterized in that, the method includes: Obtain a review text, analyze the evaluation object category of the review text, and extract the comment dimension information corresponding to the evaluation object category; Use a preset word segmentation tool to perform word segmentation on the review text to obtain text word segmentation; Convert the comment dimension information and the text word segmentation into dimension word vectors and text word vectors respectively; Use the attention mechanism in the trained text sentiment classification model to calculate the attention scores of the text word vectors, and fuse the attention scores with the text word vectors to obtain text fusion word vectors; Use the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fusion word vectors and the dimension word vectors, and mark the vector weights of each inner product vector in the vector inner product matrix; Re-fuse the vector weights with the text fusion word vectors to obtain target fusion word vectors, and use the pooling layer in the trained text sentiment classification model to perform pooling processing on the target fusion word vectors to obtain pooled fusion word vectors; Use the multi-layer perceptron in the trained text sentiment classification model to calculate the text category probability of the pooled fusion word vectors, and use the output layer in the trained text sentiment classification model to determine the text sentiment category of the review text according to the text category probability; wherein, the analysis of the evaluation object category of the review text includes: extracting the original feature words of the review text; extracting the feature object words from the original feature words, and converting the feature object words into feature category words; screening out the classification feature words that meet the preset conditions from the original feature words; determining the evaluation object category of the review text according to the feature category words and the classification feature words; The use of the attention mechanism in the trained text sentiment classification model to calculate the attention scores of the text word vectors includes: creating a dimension vector corresponding to the text word vectors using the vector matrix in the attention mechanism; calculating the vector weights of the dimension vectors using the dot product function in the attention mechanism, and using the vector weights as the attention scores of the text word vectors.
2. The method for sentiment intelligent classification of review texts according to claim 1, characterized in that, the fusion of the attention scores with the text word vectors to obtain text fusion word vectors includes: Normalize the attention scores using a preset normalization function to obtain weight coefficients, and create a numerical vector corresponding to the text word vectors; Multiply the weight coefficients by the numerical vectors to obtain text fusion word vectors.
3. The method for sentiment intelligent classification of review texts according to claim 2, characterized in that, the preset normalization function includes: Among them, represents the weight coefficient, represents the attention score of the th text word vector, represents the attention score of the th text word vector, represents the number of attention scores, represents an irrational number.
4. The method for sentiment intelligent classification of review texts according to claim 1, characterized in that, the use of the conversion layer in the trained text sentiment classification model to calculate the vector inner product matrix of the text fusion word vectors and the dimension word vectors includes: Create a text fusion matrix for the text fusion word vectors using the vector matrix conversion method in the conversion layer, and create a dimensional word matrix for the dimensional word vectors using the vector matrix conversion method; Perform an inner product calculation on the text fusion matrix and the dimensional word matrix using the inner product function in the conversion layer to obtain the vector inner product matrix.
5. The method for sentiment intelligent classification of review texts according to claim 1, characterized in that determining the text sentiment category of the review text according to the text category probability using the output layer in the trained text sentiment classification model includes: Determining the text category of the review text according to the text category probability using the feedforward neural network in the output layer; Based on the text category, determine the text sentiment category of the review text using a preset sentiment label threshold mapping relationship table.
6. A sentiment intelligent classification device for review texts, used to implement the method for sentiment intelligent classification of review texts according to any one of claims 1 to 5, characterized in that the device includes: A category recognition module, used to obtain a review text, analyze the evaluation object category of the review text, and extract the review dimension information corresponding to the evaluation object category; A text word segmentation module, used to perform word segmentation processing on the review text using a word segmentation tool to obtain text word segmentation; A word vector conversion module, used to convert the review dimension information and the text word segmentation into dimensional word vectors and text word vectors respectively; A word vector fusion module, used to calculate the attention score of the text word vectors using the attention mechanism in the trained text sentiment classification model, and fuse the attention score with the text word vectors to obtain text fusion word vectors; A vector inner product module, used to calculate the vector inner product matrix of the text fusion word vectors and the dimensional word vectors using the conversion layer in the trained text sentiment classification model, and mark the vector weights of each inner product vector in the vector inner product matrix; A pooling processing module, used to re-fuse the vector weights with the text fusion word vectors to obtain target fusion word vectors, and perform pooling processing on the target fusion word vectors using the pooling layer in the trained text sentiment classification model to obtain pooled fusion word vectors; A sentiment category discrimination module, used to calculate the text category probability of the pooled fusion word vectors using the multi-layer perceptron in the trained text sentiment classification model, and determine the text sentiment category of the review text according to the text category probability using the output layer in the trained text sentiment classification model.
7. An electronic device, characterized in that the electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for sentiment intelligent classification of review texts according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, Characterized in that, when the computer program is executed by a processor, it implements the method for sentiment intelligent classification of review texts as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Short text object sentiment classification method based on multilevel interactive attention mechanism
CN113268592A
Fine-grained sentiment analysis method and device
CN114065755A