Text sentiment analysis method, electronic device and storage medium

By conducting semantic analysis and dependent syntax analysis on the input text, and weighted calculations combined with vocabulary feature vectors and dependent syntax information, the problem of low accuracy of text sentiment analysis in the existing technology is solved, and more efficient sentiment analysis results are achieved.

CN113434682BActive Publication Date: 2024-11-08PING AN TECH (SHENZHEN) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110744167.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-30
Publication Date
2024-11-08
Estimated Expiration
2041-06-30

AI Technical Summary

Technical Problem

In text sentiment analysis, the existing deep learning models are uniformly modeled on all vocabulary dependencies, resulting in low accuracy in sentiment analysis, making it difficult to effectively extract streamlined information from massive data, especially the tendency analysis of stock review opinions.

Method used

By conducting semantic analysis and dependent syntax analysis of the input text, vocabulary feature vectors and dependent syntax information are obtained, and weighted calculations are performed to integrate the dependencies between vocabulary to improve the accuracy of emotional classification.

Benefits of technology

It improves the accuracy of text sentiment analysis, can more effectively identify noise in syntactic information, and enhances the ability to identify text emotional tendencies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113434682B_ABST
    Figure CN113434682B_ABST
Patent Text Reader

Abstract

The present invention discloses a text sentiment analysis method, an electronic device and a storage medium, and belongs to the technical field of natural language processing. The method comprises: obtaining an input text, wherein the input text comprises a plurality of first words. Performing semantic analysis on the input text to obtain a plurality of vocabulary feature vectors, and performing dependency syntactic analysis on the input text to obtain dependency syntactic information corresponding to each first word. Performing weighted calculation based on the plurality of vocabulary feature vectors and the dependency syntactic information corresponding to each first word to obtain a plurality of target feature vectors. Performing sentiment classification based on the plurality of target feature vectors to obtain a sentiment analysis result corresponding to the input text. The technical solution of the present invention can realize the fusion of dependency relationships between words in the input text, and can weight the noise in the syntactic information by using syntactic information to identify the noise, which is conducive to improving the accuracy of text sentiment analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a text sentiment analysis method, an electronic device and a storage medium. Background Art

[0002] In securities trading, investors will seek to maximize investment benefits based on the information they possess. Therefore, the more information investors have and the more accurate it is, the higher the expected return will be. Some domestic portals publish a large amount of stock review information, research reports, and forum posts every day. Faced with the massive amount of data on the Internet, investors urgently need an effective tool to automatically extract concise and clear information from the massive amount of data, especially the tendency analysis of stock review opinions, so as to predict the market fluctuation trend by sensing investor sentiment.

[0003] In the existing method, the sentiment analysis of the input text is mainly performed using a trained deep learning model to obtain the sentiment tendency of the input text. However, the existing deep learning model models all word dependencies in the text in the same way, which easily leads to low accuracy of text sentiment analysis. Summary of the invention

[0004] The present invention provides a text sentiment analysis method, an electronic device and a storage medium, the main purpose of which is to improve the accuracy of text sentiment analysis.

[0005] To achieve the above-mentioned purpose, an embodiment of the present invention provides a text sentiment analysis method, which includes the following steps: obtaining an input text, wherein the input text includes multiple first words; performing semantic analysis on the input text to obtain multiple vocabulary feature vectors, and performing dependency syntactic analysis on the input text to obtain dependency syntactic information corresponding to each of the first words; performing weighted calculation based on the multiple vocabulary feature vectors and the dependency syntactic information corresponding to each of the first words to obtain multiple target feature vectors; performing sentiment classification based on the multiple target feature vectors to obtain a sentiment analysis result corresponding to the input text.

[0006] To achieve the above-mentioned purpose, an embodiment of the present invention further proposes an electronic device, which includes an acquisition module, a first analysis module, a second analysis module, a calculation module and a third analysis module, wherein: the acquisition module is used to acquire an input text, and the input text includes multiple first words. The first analysis module is used to perform semantic analysis on the input text to obtain multiple vocabulary feature vectors. The second analysis module is used to perform dependency syntactic analysis on the input text to obtain dependency syntactic information corresponding to each of the first words. The calculation module is used to perform weighted calculation based on the multiple vocabulary feature vectors and the dependency syntactic information corresponding to each of the first words to obtain multiple target feature vectors. The third analysis module is used to perform sentiment classification based on the multiple target feature vectors to obtain a sentiment analysis result corresponding to the input text.

[0007] To achieve the above-mentioned purpose, an embodiment of the present invention further proposes an electronic device, which includes a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory, and the program implements the steps of the aforementioned method when executed by the processor.

[0008] To achieve the above objectives, the present invention provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the aforementioned method.

[0009] The text sentiment analysis method, electronic device and storage medium proposed in the present invention not only perform semantic analysis on the input text to obtain multiple vocabulary feature vectors, but also perform dependency syntactic analysis on the input text to obtain dependency syntactic information corresponding to each vocabulary in the input text. Since the dependency syntactic information is used to represent the dependency syntactic relationship between vocabulary, the contribution of the dependency syntactic relationship between each vocabulary to the vocabulary feature vector analysis can be weighted and calculated to obtain multiple target feature vectors for sentiment classification. Therefore, the final sentiment analysis result can integrate the dependency relationship between vocabulary in the input text, and by adopting syntactic information to weight and identify the noise in the syntactic information, it is beneficial to improve the accuracy of text sentiment analysis. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] Figure 1 It is a structural block diagram of an electronic device applied in an embodiment of the present invention.

[0011] Figure 2 It is a flowchart of the text sentiment analysis method provided in Example 1 of the present invention.

[0012] Figure 3 It is a flowchart of the text sentiment analysis method provided in the second embodiment of the present invention.

[0013] Figure 4 Schematic diagram of an application of a text sentiment analysis method in an embodiment of the present invention.

[0014] Figure 5 This Figure 3 The specific flow chart of step S360 in the text sentiment analysis method is shown.

[0015] Figure 6 It is a structural block diagram of another electronic device applied in the embodiment of the present invention. DETAILED DESCRIPTION

[0016] 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.

[0017] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present invention, and have no special meanings. Therefore, "module", "component" or "unit" can be used in a mixed manner.

[0018] The present invention provides a text sentiment analysis method, which is applied to an electronic device. Figure 1 As shown, Figure 1 It is a structural block diagram of an electronic device applied in an embodiment of the present invention.

[0019] In this embodiment, the electronic device may be a terminal device with computing functions, such as a server, a smart phone, a tablet computer, a portable computer, or a desktop computer.

[0020] The electronic device includes a memory 11 , a processor 12 , a network interface 13 and a data bus 14 .

[0021] The memory 11 includes at least one type of readable storage medium, and at least one type of readable storage medium may be a non-volatile storage medium such as a flash memory, a hard disk, a multimedia card, a card-type memory, etc. In some embodiments, the readable storage medium may be an internal storage unit of the electronic device, such as a hard disk of the electronic device. In other embodiments, the readable storage medium may also be an external memory of the electronic device, such as a plug-in hard disk equipped on the electronic device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc.

[0022] In this embodiment, the readable storage medium of the memory 11 is generally used to store the text sentiment analysis program 10 installed in the electronic device, various sample sets, and pre-trained feature word extraction models, semantic analysis models, dependency syntax parsing models, predictors, sentiment classifiers, and encoders, etc. The memory 11 can also be used to temporarily store data that has been output or is to be output.

[0023] In some embodiments, the processor 12 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes stored in the memory 11 or process data, such as executing a text sentiment analysis program.

[0024] The network interface 13 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), and is generally used to establish a communication connection between the electronic device and other electronic devices.

[0025] The data bus 14 is used to realize the connection and communication between these components.

[0026] Figure 1 Only an electronic device having components 11 - 14 is shown, but it should be understood that implementing all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.

[0027] Optionally, the electronic device may also include a user interface, which may include an input unit such as a keyboard, a voice input device such as a microphone and other devices with voice recognition function, a voice output device such as a speaker, headphones, etc. Optionally, the user interface may also include a standard wired interface or a wireless interface.

[0028] Optionally, the electronic device may further include a display, which may also be referred to as a display screen or a display unit. In some embodiments, it may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an organic light-emitting diode (OLED) touch device. The display is used to display information processed in the electronic device and to display a visual user interface.

[0029] Optionally, the electronic device further includes a touch sensor. The area provided by the touch sensor for the user to perform a touch operation is called a touch control area. In addition, the touch sensor described here may be a resistive touch sensor, a capacitive touch sensor, etc. Moreover, the touch sensor includes not only a contact touch sensor, but also a proximity touch sensor, etc. In addition, the touch sensor may be a single sensor or a plurality of sensors arranged in an array, for example.

[0030] In addition, the area of ​​the display of the electronic device can be the same as or different from the area of ​​the touch sensor. Optionally, the display and the touch sensor are stacked to form a touch display screen. The device detects touch operations triggered by the user based on the touch display screen.

[0031] The following is a detailed description of a text sentiment analysis method disclosed in an embodiment of the present invention.

[0032] Embodiment 1

[0033] like Figure 2 As shown, Figure 2 This is a flowchart of the text sentiment analysis method provided by the first embodiment of the present invention. Figure 1 In the device embodiment shown, the processor 12 implements the following steps when executing the text sentiment analysis program 10 stored in the memory 11:

[0034] Step S210: obtaining input text, where the input text includes a plurality of first words.

[0035] In this embodiment, the input text may be a sentence to be analyzed, or the input text may be a sentence and a specified feature word, and the type of the input text is not limited. Specifically, the feature word may be an aspect feature word in a sentence, which is suitable for aspect-level text sentiment analysis. For example, in the sentence "This device is fully functional but has a short battery life", the aspect feature word may be "function" or "battery life". If the aspect feature word is "function", the sentence sentiment is positive, and if the aspect feature word is "battery life", the sentence sentiment is negative, thereby inferring the sentiment tendency of the sentence in a certain aspect feature.

[0036] Optionally, the input text can be obtained based on the text to be analyzed. The text to be analyzed can be text data obtained from the Internet using a search engine or crawler software, or text data obtained from a local document, or text data entered in a functional module (such as an input text box) of a user interface. If the input text also includes feature words, in some embodiments, the trained feature word extraction model can be directly used to extract feature words from the text to be analyzed. For example, the feature word extraction model can be trained based on a natural language processing data set with part-of-speech tagging, such as the Stanford core data set; in other embodiments, the feature words input by the user through a touch display or input unit can be obtained, and the voice data input by the user through a voice input device can also be obtained, and then the feature words can be identified from the voice data based on voice recognition technology, so that the user can specify the aspect features for analysis according to their own needs.

[0037] Step S220: Perform semantic analysis on the input text to obtain multiple vocabulary feature vectors.

[0038] In this embodiment, a plurality of vocabulary feature vectors correspond to the vocabulary contained in the input text one by one. Optionally, a pre-trained semantic analysis model can be used to perform semantic analysis on the input text, and the training step of the semantic analysis model includes: preparing a first training set including a certain number of text samples, and adding the embedding vectors of each vocabulary in the text sample to the corresponding first verification set, and the embedding vector can be a fixed-length vector representation obtained by converting the vocabulary in combination with the contextual semantics of the vocabulary in the text. The neural network is trained using the first training set to obtain the feature vectors output by the neural network for each vocabulary, and the accuracy of the feature vectors of the corresponding vocabulary is verified using the first verification set. If the accuracy is greater than or equal to the preset accuracy, the training ends. If the accuracy is less than the preset accuracy, the number of samples is continued to be increased and the training step is re-executed. Among them, the neural network can adopt a convolutional neural network (CNN), a recurrent neural network (RNN), a long short term memory network (LSTM) or a gate recurrent unit (GRU) network, which is not specifically limited.

[0039] Step S230: performing dependency syntactic analysis on the input text to obtain dependency syntactic information corresponding to each first word.

[0040] In this embodiment, the dependency syntactic information is used to represent the dependency relationship between each first word and other words in the input text, and one dependency relationship connects two words, namely the core word and the dependent word. The dependency relationship can be subdivided into different types, indicating the specific syntactic relationship between the two words, and the dependency relationship type can include but is not limited to the subject-predicate relationship, the verb-object relationship, the indirect object relationship, the prepositioned object, the auxiliary modifier, the attributive-predicate relationship, the adverbial-predicate structure, the verb-complement structure, the parallel relationship, the core structure, the independent structure and the preposition-object relationship.

[0041] Optionally, the dependency syntactic analysis of the input text can be performed specifically by using rule-based methods (such as CYK's dynamic programming algorithm, constraint satisfaction-based methods, and deterministic analysis strategies, etc.), statistical methods (such as generative dependency analysis methods, discriminant dependency analysis methods, and deterministic dependency analysis methods, etc.), or deep learning-based methods (such as using existing syntactic analysis tools such as Biaffine syntactic parser and HanLP), etc.

[0042] Step S240: performing weighted calculation according to the plurality of vocabulary feature vectors and the dependency syntactic information corresponding to each first vocabulary word to obtain a plurality of target feature vectors.

[0043] Step S250: Perform sentiment classification based on multiple target feature vectors to obtain a sentiment analysis result corresponding to the input text.

[0044] Optionally, step S250 may specifically include: inputting multiple target feature vectors into a predetermined sentiment classifier, obtaining the probability of identifying each sentiment type from the input text, and taking the sentiment type with the highest probability as the sentiment analysis result corresponding to the input text. The sentiment types may include but are not limited to positive, negative, and neutral.

[0045] Specifically, the training step of the sentiment classifier includes: sentiment classification of each text sample in the above-mentioned first training set to obtain the sentiment label of each text sample. The feature vectors obtained after the above-mentioned semantic analysis, dependency syntactic analysis and weighted calculation of each text sample in the first training set are taken as the second training set, and the sentiment label of each text sample is used as the second verification set. The sentiment classifier is trained using the second training set, and the output result of the sentiment classifier is verified for accuracy using the second verification set. If the accuracy is greater than or equal to the first accuracy, the training ends, or, if the accuracy is less than the first accuracy, the number of text samples is increased and the above-mentioned training steps are re-executed.

[0046] For example, suppose that after inputting multiple target feature vectors into a predetermined sentiment classifier, the probability of identifying each sentiment type (value range: 0-1) is different, for example, positive: 0.5, negative: 0.4, neutral: 0.1. It can be seen that the probability of identifying "positive" from the input text is the highest, and the sentiment analysis result corresponding to the input text is determined to be "positive".

[0047] More specifically, the sentiment classifier may include a dense layer, which may be used to perform full connection calculation and softmax calculation on the feature vector to obtain the probability of each sentiment type, and the calculation formula is as follows:

[0048]

[0049] Where T is the set of emotion types, |T| is used to represent the total number of dimensions corresponding to the emotion type set. For example, if the emotion type set includes positive, negative, and neutral, |T| = 3; W is the weight matrix, and b is the bias value. Both W and b are trainable emotion classifier parameters and are used to align the dimensions of u with the output space. Each dimension of u corresponds to an emotion type, and u t represents the value corresponding to the tth dimension in u, s t is the softmax calculation result corresponding to the tth dimension. Further, take y = argmax (s t ), the sentiment type with the highest probability can be taken as the sentiment analysis result y.

[0050] It can be understood that the parameters that need to be preset, such as the preset accuracy and the first accuracy mentioned in the above embodiments, can be adjusted accordingly according to user needs.

[0051] It can be seen that by implementing the above method embodiment, the contribution of the lexical feature vector analysis to the dependency syntactic relationship between each word is weighted and calculated to obtain multiple target feature vectors for sentiment classification. Therefore, the final sentiment analysis result can integrate the dependency relationship between words in the input text, and by using syntactic information to weight the noise in the syntactic information, it is beneficial to improve the accuracy of text sentiment analysis.

[0052] Embodiment 2

[0053] like Figure 3 As shown, Figure 3 This is a flow chart of the text sentiment analysis method provided by the second embodiment of the present invention. Figure 1 In the electronic device embodiment shown, the processor 12 implements the following steps when executing the text sentiment analysis program 10 stored in the memory 11:

[0054] Step S310: Acquire input text, the input text includes a plurality of first words; and execute steps S320 to S330 and steps S340 to S350 respectively.

[0055] Step S320: construct a processing sequence according to the input text.

[0056] In this embodiment, the processing sequence includes the text initial symbol and the above-mentioned multiple first words. Specifically, the input text can be first tokenized to obtain multiple first words, and then combined with the text initial symbol to form a processing sequence with the multiple first words. Among them, the word tokenization algorithm can adopt a conditional random field (CRF) word segmentation algorithm or a word segmentation algorithm based on a hidden Markov model (HMM), etc., and there is no limitation on this. In one implementation method, if the input text includes a sentence X, after word segmentation, X = {x1, x2, ..., x n}, then sentence X includes n first words, where n is a positive integer. The processing sequence may be {[CLS], X, [SEP]}, where [CLS] is a text initialization symbol used to identify the beginning of a sentence. Correspondingly, the processing sequence may also include a text end symbol [SEP] used to identify the end of a sentence. In another implementation, if the input text includes sentence X and aspect feature word A, after word segmentation, A = {a1, a2, ..., a m}, A is a substring of X, and m is a positive integer, then the processing sequence can be {[CLS], X, [SEP], A, [SEP]}.

[0057] Step S330: semantically analyze the processing sequence to obtain vocabulary feature vectors corresponding to each of the plurality of first words and a hidden feature vector corresponding to the text initial symbol; and execute step S360.

[0058] In this embodiment, specifically, the BERT model can be used to construct a processing sequence for the input text and perform semantic analysis on the processing sequence, then BERT(X,A)=[h0,H X ,H X ], where h0 is the hidden feature vector of the initial character [CLS], H X and H A are the word embedding matrices of sentence X and aspect feature word A respectively. For example, see Figure 4 , Figure 4 Schematic diagram of an application of a text sentiment analysis method in an embodiment of the present invention. Figure 4 As shown in the figure, the input text includes the sentence "Total environment is fantastic although bar service is poor" and the aspect feature word "bar service", and the constructed processing sequence is {[CLS], Total, environment, is, fantastic, although, bar, service, is, poor, [SEP], bar, service, [SEP]}. After the processing sequence is input into the BERT model, the hidden feature vector h0 of the text initial symbol and the lexical feature vectors (i.e., word embedding matrices) h1 to h11 of the 11 first words are obtained.

[0059] Step S340: performing dependency syntactic analysis on the input text to obtain dependency syntactic information corresponding to each first word.

[0060] In this embodiment, the dependency syntactic information corresponding to the first vocabulary can be at least one mapping relationship object corresponding to the first vocabulary, and the mapping relationship object includes a first object and a second object, and the first object and the second object correspond one to one. The first object is used to represent the dependency relationship information corresponding to the first vocabulary, and the second object is used to represent the relationship type information corresponding to the dependency relationship information. The mapping relationship object can be a key-value pair, a row list, a two-dimensional array or a tuple, etc., which is not specifically limited. The following description is taken as an example of a key-value pair, in which case the first object is the key and the second object is the value.

[0061] Optionally, step S340 may specifically be: performing dependency syntactic analysis on the input text, constructing a dependency syntactic tree, the dependency syntactic tree being used to represent the dependency relationship corresponding to each first word and the dependency relationship type corresponding to the dependency relationship. Based on this, for each first word: according to the dependency relationship corresponding to the first word in the dependency syntactic tree, a second word indicated by the dependency relationship is obtained; according to the second word, a first object corresponding to the first word is constructed; according to the dependency relationship type corresponding to the dependency relationship, a second object corresponding to the first object is constructed; according to the first object and the second object, a mapping relationship object corresponding to the first word is constructed.

[0062] Still Figure 4 Take the following example to illustrate this. Figure 4 As shown in the figure, the sentence "Total environment is fantastic although bar service is poor" is parsed and a dependency syntax tree is constructed. In the dependency syntax tree, the dependency relationship between words is represented by directed arcs, also known as dependency arcs. Taking the word "service" as an example, the two dependency arcs related to the word "service" are connected to the word "bar" and the word "poor" respectively. Therefore, the word "service" has a dependency relationship with the word "bar", and the corresponding dependency type is compound, that is, a compound word; the word "service" has a dependency relationship with the word "poor", and the corresponding dependency type is nsubj, that is, a noun subject. Therefore, two mapping relationship objects corresponding to the word "service" can be constructed, such as the key-value pairs (bar, bar_compound) and (poor, poor_nsubj).

[0063] It can be seen that based on the structure of the mapping relationship object, the dependency syntactic information of the vocabulary is stored in the first object and the second object respectively. It does not need to rely on the model embedding matrix. It can be addressed through the first object and the dependency relationship type can be read using the second object. It has better flexibility and is suitable for encoding prior knowledge.

[0064] Alternatively, a pre-determined dependency syntax parsing model may be used to construct a dependency syntax tree, and the dependency syntax parsing model may be a second-order dependency syntax parsing model, such as a second-order Sibling model or a second-order Grand-Child model, etc., without specific limitation. Since the first-order syntax knowledge fails to provide sufficient and useful context information, and the third-order syntax knowledge often considers too much vocabulary in the sentence, resulting in the introduction of irrelevant context information, the two-order syntax knowledge used in the present invention can achieve a better dependency relationship analysis effect.

[0065] Step S350: For the dependency syntactic information corresponding to each first word, encode the first object corresponding to the dependency syntactic information to obtain a first vector, and encode the second object corresponding to the dependency syntactic information to obtain a second vector; execute step S360.

[0066] In this embodiment, the first vector is used to represent the vector features of the first object, and the second vector is used to represent the vector features of the second object. Specifically, the first object and the second object can be encoded using a predetermined encoder, and the encoder can be a word2vec model, which is not limited. It can be seen that this can combine the context information between words for encoding, and embed the high-dimensional word vector into a low-dimensional space, which is convenient for analyzing vocabulary relationships, faster, and more versatile.

[0067] Step S360: performing weighted addition on the plurality of vocabulary feature vectors and the first vector and the second vector corresponding to each first vocabulary word to obtain a plurality of target feature vectors.

[0068] Optionally, see Figure 5 , Figure 5 This Figure 3 The specific flow chart of step S360 in the text sentiment analysis method is shown.

[0069] like Figure 5 As shown, step S360 may specifically include the following steps S361-S363:

[0070] Step S361: for each vocabulary feature vector, determine the target vocabulary corresponding to the vocabulary feature vector.

[0071] Step S362: performing weight assignment according to the vocabulary feature vector and each first vector corresponding to the target vocabulary, and obtaining weight information of each second vector corresponding to the target vocabulary.

[0072] Further optionally, step S362 may specifically be:

[0073] The vocabulary feature vector and each first vector corresponding to the target vocabulary are input into a predetermined predictor to obtain the correlation probability between the vocabulary feature vector and each first vector corresponding to the target vocabulary, which are used as weighted information of the second vector corresponding to the first vector. The predictor can be obtained by training the feature vector sample set using a classification algorithm, and the classification algorithm can be a naive Bayes algorithm, a decision tree algorithm, or a neural network algorithm, etc., which is not limited. Optionally, the classification algorithm can be specifically:

[0074]

[0075] Among them, p i,jis the weighted information of the jth second vector corresponding to the target word i, is the jth first vector corresponding to the target word i, q is the number of mapping objects corresponding to the target word i, and h i is the vocabulary feature vector corresponding to the target vocabulary i.

[0076] Step S363: using the weight information of each second vector corresponding to the target vocabulary, perform weighted sum calculation on each second vector corresponding to the target vocabulary to obtain a target feature vector.

[0077] Specifically, the formula for weighted sum calculation can satisfy:

[0078]

[0079] Among them, i is the target feature vector corresponding to the target word i, is the jth second vector corresponding to the target word i.

[0080] For example, Figure 4 For example, the word "service" corresponds to two mapping relationship objects, namely the key-value pairs (bar, bar_compound) and (poor, poor_nsubj). Assuming that the vocabulary feature vector corresponding to the word "service" is h7, according to the two sets of key-value pairs (bar, bar_compound) and (poor, poor_nsubj), the first first vector can be obtained respectively through step S350 The first second vector The second first vector and the second second vector Furthermore, through step S362, the weighted information of the first second vector is obtained as follows:

[0081] Used to represent the relative probability of the words "bar" and "service";

[0082] And, the weighted information of the second vector is:

[0083] Used to represent the relative probability of the words "poor" and "service".

[0084] Based on this, the target feature vector corresponding to the word "service"

[0085] It can be seen that according to the contribution of the dependency relationship between each word to the word feature vector analysis, different dependency types are weighted calculation to obtain multiple target feature vectors for sentiment classification. Therefore, the final sentiment analysis result can simultaneously integrate the dependency relationship between words in the input text and the specific dependency type, which can further improve the accuracy of text sentiment analysis.

[0086] Alternatively, the above steps S350, S360 and S361 to S363 can all be implemented by a key-value memory network (KVMN) model, thereby implementing a non-graph structure based on the KVMN model to simultaneously model the dependency relationship and dependency relationship type between words. That is, for example, Figure 4 As shown, by inputting the vocabulary feature vectors h1 to h11 of the 11 first words and the key-value pairs corresponding to each first word into the KVMN model, 11 target feature vectors o1 to o11 output by the KVMN model can be obtained.

[0087] Step S370: averaging multiple target feature vectors to obtain a first feature vector.

[0088] Step S380: concatenate the first feature vector and the hidden feature vector to obtain a second feature vector.

[0089] Specifically, step S370 and step S380 may satisfy the following formula:

[0090]

[0091] Where r is the second feature vector, h0 is the hidden feature vector, l is the number of vocabulary feature vectors, o i is the target feature vector corresponding to the i-th vocabulary feature vector, Used to represent the concatenation of vectors.

[0092] Still Figure 4 For example, Figure 4 As shown, after the KVMN model outputs 11 target feature vectors o1 to o11, the 11 target feature vectors o1 to o11 are averaged, and the result of the average calculation is concatenated with the hidden feature vector h0, and finally sent to the sentiment classifier 40, and the output of the sentiment classifier 40 is "Negative", thereby completing the text sentiment analysis process.

[0093] It can be seen that the use of text initialization symbols can play a role in identifying sentence analysis tasks and ensure the integrity of sentences in the process of text sentiment analysis.

[0094] Step S390: Perform sentiment classification based on the second feature vector to obtain a sentiment analysis result corresponding to the input text.

[0095] Optionally, step S390 may specifically be: inputting the second feature vector into a predetermined sentiment classifier to obtain the probability of identifying each sentiment type from the input text, and taking the sentiment type with the highest probability as the sentiment analysis result corresponding to the input text.

[0096] It can be understood that the specific implementation of steps S310, S330 and S390 in this embodiment can also refer to the description of steps S210, S220 and S250 in the above embodiment 1, and will not be repeated here.

[0097] It can be seen that by implementing the above method embodiment, according to the contribution of the dependency relationship between each word to the word feature vector analysis, weighted calculation is performed on different dependency relationship types to obtain multiple target feature vectors for sentiment classification, and at the same time, the dependency relationship between words in the input text and the specific dependency relationship type are integrated, which can further improve the accuracy of text sentiment analysis. In addition, the text initial symbol is used to identify the sentence analysis task to ensure the sentence integrity in the text sentiment analysis process.

[0098] The embodiment of the present invention also provides an electronic device. Figure 6 , Figure 6 is a structural block diagram of another electronic device used in an embodiment of the present invention. Figure 6 As shown, the electronic device 600 includes:

[0099] The acquisition module 610 is used to acquire an input text, where the input text includes a plurality of first words.

[0100] The first analysis module 620 is used to perform semantic analysis on the input text to obtain a plurality of vocabulary feature vectors.

[0101] The second analysis module 630 is used to perform dependency syntactic analysis on the input text to obtain dependency syntactic information corresponding to each first word.

[0102] The calculation module 640 is used to perform weighted calculation according to the multiple vocabulary feature vectors and the dependency syntactic information corresponding to each first vocabulary to obtain multiple target feature vectors.

[0103] The third analysis module 650 is used to perform sentiment classification based on multiple target feature vectors to obtain a sentiment analysis result corresponding to the input text.

[0104] It should be noted that the specific implementation process of this embodiment can refer to the specific implementation process described in the above method embodiment, and will not be repeated here.

[0105] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0106] In hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0107] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the present invention is not limited thereby. Any modification, equivalent substitution and improvement made by those skilled in the art without departing from the scope and essence of the present invention shall be within the scope of the present invention.

Claims

1. A text sentiment analysis method, characterized in that: The method comprises: Obtaining an input text, wherein the input text includes a plurality of first words; constructing a processing sequence according to the input text, the processing sequence comprising a text initialization symbol and a plurality of the first words; Performing semantic analysis on the processing sequence to obtain vocabulary feature vectors corresponding to each of the plurality of first words and a hidden feature vector corresponding to the text initial symbol; Performing dependency syntactic analysis on the input text to obtain dependency syntactic information corresponding to each of the first words; Performing weighted calculation according to the plurality of vocabulary feature vectors and the dependency syntactic information corresponding to each of the first words to obtain a plurality of target feature vectors; Calculate the average of the plurality of target feature vectors to obtain a first feature vector; Concatenate the first feature vector and the hidden feature vector to obtain a second feature vector; Perform sentiment classification based on the second feature vector to obtain a sentiment analysis result corresponding to the input text; The dependency syntactic information is at least one mapping relationship object, the mapping relationship object includes a first object and a second object, the first object is used to represent the dependency relationship information corresponding to the first vocabulary, and the second object is used to represent the relationship type information corresponding to the dependency relationship information, and the dependency syntactic analysis of the input text to obtain the dependency syntactic information corresponding to each of the first vocabulary includes: Performing dependency syntactic analysis on the input text to construct a dependency syntactic tree, wherein the dependency syntactic tree is used to represent dependency relationships corresponding to each of the first words and dependency relationship types corresponding to the dependency relationships; For each of the first words, according to the dependency relationship corresponding to the first word in the dependency syntax tree, obtain a second word indicated by the dependency relationship; constructing the first object corresponding to the first vocabulary according to the second vocabulary; Constructing the second object corresponding to the first object according to the dependency relationship type corresponding to the dependency relationship; The mapping relationship object corresponding to the first vocabulary is constructed according to the first object and the second object.

2. The method according to claim 1, characterized in that The step of performing weighted calculation according to the plurality of vocabulary feature vectors and the dependency syntactic information corresponding to each of the first vocabulary words to obtain a plurality of target feature vectors includes: For each dependency syntactic information corresponding to the first vocabulary, encoding the first object corresponding to the dependency syntactic information to obtain a first vector; For each dependency syntactic information corresponding to the first vocabulary, encode the second object corresponding to the dependency syntactic information to obtain a second vector; wherein the first vector is used to represent the vector feature of the first object, and the second vector is used to represent the vector feature of the second object; A plurality of target feature vectors are obtained by performing weighted addition on the plurality of vocabulary feature vectors and the first vector and the second vector corresponding to each of the first words.

3. The method according to claim 2, characterized in that The step of performing weighted addition on the plurality of vocabulary feature vectors and the first vector and the second vector corresponding to each of the first words to obtain a plurality of target feature vectors includes: For each of the vocabulary feature vectors, determining a target vocabulary corresponding to the vocabulary feature vector; For each of the vocabulary feature vectors, weight allocation is performed according to the vocabulary feature vector and the first vector corresponding to the target vocabulary to obtain weight information of the second vector corresponding to the target vocabulary; For each of the vocabulary feature vectors, the weighted information of the second vector corresponding to the target vocabulary is used to perform a weighted sum calculation on the second vector corresponding to the target vocabulary to obtain a target feature vector.

4. The method according to claim 3, characterized in that The step of performing weight distribution according to the vocabulary feature vector and the first vector corresponding to the target vocabulary to obtain weight information of each second vector corresponding to the target vocabulary includes: The vocabulary feature vector and the first vector corresponding to the target vocabulary are input into a predetermined predictor to obtain the correlation probabilities between the vocabulary feature vector and the first vector corresponding to the target vocabulary, which are used as weighting information of the second vector corresponding to the first vector.

5. The method according to any one of claims 1 to 4, characterized in that: The performing sentiment classification based on the second feature vector to obtain a sentiment analysis result corresponding to the input text includes: The second feature vector is input into a predetermined sentiment classifier to obtain the probability of identifying each sentiment type from the input text, and the sentiment type with the highest probability is taken as the sentiment analysis result corresponding to the input text.

6. An electronic device, characterized in that: The device comprises: An acquisition module, used for acquiring an input text, wherein the input text includes a plurality of first words; A first analysis module is used to: construct a processing sequence according to the input text, the processing sequence including a text initial symbol and a plurality of the first words; perform semantic analysis on the processing sequence to obtain a vocabulary feature vector corresponding to each of the plurality of the first words and a hidden feature vector corresponding to the text initial symbol; A second analysis module, configured to perform dependency syntactic analysis on the input text to obtain dependency syntactic information corresponding to each of the first words; A calculation module, configured to perform weighted calculation according to the plurality of vocabulary feature vectors and the dependency syntactic information corresponding to each of the first words, to obtain a plurality of target feature vectors; The third analysis module is used to: average the plurality of target feature vectors to obtain a first feature vector; concatenate the first feature vector and the hidden feature vector to obtain a second feature vector; and perform sentiment classification based on the second feature vector to obtain a sentiment analysis result corresponding to the input text; The dependency syntactic information is at least one mapping relationship object, the mapping relationship object includes a first object and a second object, the first object is used to represent the dependency relationship information corresponding to the first vocabulary, the second object is used to represent the relationship type information corresponding to the dependency relationship information, and the second analysis module is used to perform dependency syntactic analysis on the input text to obtain the dependency syntactic information corresponding to each of the first vocabulary, including: Performing dependency syntactic analysis on the input text to construct a dependency syntactic tree, wherein the dependency syntactic tree is used to represent dependency relationships corresponding to each of the first words and dependency relationship types corresponding to the dependency relationships; For each of the first words, according to the dependency relationship corresponding to the first word in the dependency syntax tree, obtain a second word indicated by the dependency relationship; constructing the first object corresponding to the first vocabulary according to the second vocabulary; Constructing the second object corresponding to the first object according to the dependency relationship type corresponding to the dependency relationship; The mapping relationship object corresponding to the first vocabulary is constructed according to the first object and the second object.

7. An electronic device, characterized in that: The device includes a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory. When the program is executed by the processor, the steps of the text sentiment analysis method according to any one of claims 1 to 5 are realized.

8. A storage medium for computer-readable storage, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the text sentiment analysis method described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Interactive attention emotion analysis method based on dependency syntax

    CN109582764A

  • Microblog sentiment analysis method combining ontology and syntactic dependency

    CN110020436A

  • Text emotion reason identification method based on D-LSTM

    CN110162636A

  • Online comment automatic reply method based on deep semantic matching

    CN111797898A