Text sentiment analysis method, apparatus, medium, and program
By performing word segmentation and grammatical feature analysis on the text, combined with a Bayesian model, the problem of low accuracy in text sentiment analysis was solved, achieving more accurate and comprehensive sentiment category analysis.
Patent Information
- Application Number
- CN202111220753.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-20
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2041-10-20
AI Technical Summary
The accuracy of text-based sentiment analysis in existing technologies is relatively low, which affects the reliability of text-based sentiment analysis results.
By segmenting the text to be analyzed, the feature words in the segmented sequence and their contextual grammatical relationships are determined. Combining grammatical features and sequence features, a Bayesian model is used to determine the sentiment category of the text.
It improves the accuracy of text sentiment analysis, enabling more precise and comprehensive sentiment category analysis.
Smart Images

Figure CN115994215B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and more specifically, to a text sentiment analysis method, apparatus, medium, and program. Background Technology
[0002] Text sentiment analysis has been widely applied in many fields, such as news recommendation and social media platforms. For example, in e-commerce shopping recommendation scenarios, the positive and negative reviews of product text comments can guide shoppers to better filter products according to their own needs, improving the shopping experience and efficiency.
[0003] Sentiment analysis of text can determine the category of emotion expressed by the text. If the accuracy of sentiment analysis results is low, it will affect the reliability of related analyses based on these results. Therefore, how to accurately analyze the category of emotion expressed by text is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0004] In view of this, in order to solve the above problems, the present invention provides a text sentiment analysis method, apparatus, medium and program to improve the accuracy of determining the sentiment category of text.
[0005] To achieve the above objectives, this application provides a text sentiment analysis method, including:
[0006] The text to be analyzed is segmented into words to obtain a segmented word sequence, which includes multiple words in the text that have a sequential order.
[0007] Determine at least one feature word in the word segmentation sequence and the feature word category of the feature word, wherein the feature word belongs to the plurality of word segments;
[0008] Determine the contextual grammatical relationships of each feature word in the segmented sequence;
[0009] Based on the contextual grammatical relationships and feature word categories of each feature word in the segmented sequence, the grammatical features of the segmented sequence are determined;
[0010] By combining the vectors of each feature word in the segmented sequence, the sequence features of the segmented sequence are determined;
[0011] Based on the grammatical and sequence features of the word segmentation sequence, as well as the grammatical and sequence features of the training text sets under different sentiment categories, the sentiment category to which the text belongs is determined using a Bayesian model.
[0012] In one possible implementation, determining the contextual grammatical relationship of each feature word in the word segmentation sequence includes one or more of the following:
[0013] Determine the semantic dependency relationships between each word in the word segmentation sequence, wherein the semantic dependency relationships include the semantic dependency relationships between the contexts of each feature word in the word segmentation sequence;
[0014] Determine the syntactic dependency relations between each word in the word segmentation sequence, wherein the syntactic dependency relations include the syntactic dependency relations between the contexts of each feature word in the word segmentation sequence;
[0015] Determine the part-of-speech information of each word in the word segmentation sequence.
[0016] In another possible implementation, after determining at least one feature word in the word segmentation sequence and the feature word category of the feature word, the method further includes:
[0017] In the word segmentation sequence, category labels corresponding to the feature word categories of the feature words are marked for the feature words, resulting in a feature word labeling sequence with feature word category labels;
[0018] Determining the semantic dependency relationships between the segments in the segmentation sequence includes:
[0019] Determine the semantic dependency relationships between each word segment in the feature word annotation sequence, and construct a semantic dependency relationship sequence that retains the annotated feature word category labels and the semantic dependency relationships;
[0020] Determining the syntactic dependency relationships between the segments in the segmentation sequence includes:
[0021] Determine the syntactic dependency relationships between each word segment in the feature word annotation sequence, and construct a syntactic dependency relationship sequence that retains the annotated feature word category labels and the syntactic dependency relationships;
[0022] Determining the part-of-speech information of each word in the word segmentation sequence includes:
[0023] Part-of-speech tagging is performed on each word segment in the feature word tagging sequence to obtain a part-of-speech tagging sequence with feature word category labels;
[0024] The step of determining the grammatical features of the word segmentation sequence based on the contextual grammatical relationships and feature word categories of each feature word in the segmentation sequence includes:
[0025] Based on at least one of the semantic dependency relation sequence, the syntactic dependency relation sequence, and the part-of-speech tagging sequence, the grammatical features in the word segmentation sequence are determined.
[0026] In another possible implementation, determining the grammatical features in the word segmentation sequence based on at least one of the semantic dependency relation sequence, the syntactic dependency relation sequence, and the part-of-speech tagging sequence includes:
[0027] By combining semantic dependency sequence samples from multiple training text samples in the training text library, at least one semantically frequent sequence that belongs to the subsequence of the semantic dependency sequence and meets the mining conditions is determined. The mining conditions include: conforming to the frequent sequence mining rules, including at least one feature word category label, and not belonging to the subsequence of other mined frequent sequences; the training text library includes training text sets under different sentiment categories.
[0028] By combining syntactic dependency sequence samples from multiple training texts in the training text library, at least one syntactically frequent sequence that belongs to the subsequence of the syntactic dependency sequence and satisfies the mining conditions is identified.
[0029] By combining part-of-speech tagging sequence samples from multiple training texts in the training text library, at least one frequent part-of-speech sequence that belongs to the subsequence of the part-of-speech tagging sequence and satisfies the mining conditions is determined.
[0030] Based on the encoding of at least one of the at least one semantically frequent sequence, the at least one syntactically frequent sequence, and the at least one part-of-speech frequent sequence, the encoding features of the word segmentation sequence are determined, and the encoding features are determined as the syntactic features of the word segmentation sequence.
[0031] Furthermore, this application also provides a text sentiment analysis device, comprising:
[0032] The word segmentation processing unit is used to segment the text to be analyzed to obtain a word segmentation sequence of the text, which includes multiple words in the text that have a sequential order.
[0033] A feature word determination unit is used to determine at least one feature word in the word segmentation sequence and the feature word category of the feature word, wherein the feature word belongs to the plurality of word segments;
[0034] A grammar determination unit is used to determine the contextual grammatical relationships of each feature word in the word segmentation sequence;
[0035] The first feature determination unit is used to determine the grammatical features of the word segmentation sequence based on the contextual grammatical relationship and feature word category of each feature word in the word segmentation sequence;
[0036] The second feature determination unit is used to determine the sequence features of the word segmentation sequence by combining the vectors of each feature word in the word segmentation sequence;
[0037] The category determination unit is used to determine the sentiment category to which the text belongs based on the grammatical and sequence features of the word segmentation sequence, as well as the grammatical and sequence features of the training text sets under different sentiment categories, using a Bayesian model.
[0038] In another aspect, this application also provides a computer device, including: a processor and a memory, wherein the processor and the memory are connected via a communication bus;
[0039] The processor is used to call and execute the program stored in the memory;
[0040] The memory is used to store a program that implements the text sentiment analysis method described in any of the above descriptions.
[0041] In another aspect, this application also provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded and executed by a processor to implement the text sentiment analysis method as described in any of the above claims.
[0042] In another aspect, this application also provides a computer program product, including a computer program / instructions, characterized in that, when the computer program / instructions are executed by a processor, they implement the steps of the text sentiment analysis method as described in any of the above.
[0043] As can be seen from the above, after identifying the feature words contained in the word segmentation sequence of the text, this application not only combines the vectors of each feature word in the word segmentation sequence to determine the sequence features of the word segmentation sequence, but also combines the contextual grammatical relationships of each feature word in the word segmentation sequence to determine the grammatical features of the word segmentation sequence. This achieves a more accurate and comprehensive mining of the features in the text used to express emotion. On this basis, by combining the sequence features and grammatical features of the text, as well as the multi-dimensional features of the training text set under different emotion categories, and using a Bayesian model to determine the emotion category to which the text belongs, a more refined and comprehensive emotion category analysis is achieved, thereby improving the accuracy of determining the emotion category of the text. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0045] Figure 1 A schematic diagram illustrating an application scenario to which the text sentiment analysis method provided in this application embodiment is applicable;
[0046] Figure 2 A flowchart illustrating the text sentiment analysis method provided in this application embodiment;
[0047] Figure 3 A flowchart illustrating the process of determining the sequence features of a word segmentation sequence, as provided in an embodiment of this application.
[0048] Figure 4 Another flowchart illustrating the text sentiment analysis method provided in this application embodiment;
[0049] Figure 5 This is a schematic diagram illustrating the semantic dependency relationship of the annotated word segmentation sequence in an embodiment of this application;
[0050] Figure 6 This is a schematic diagram illustrating the syntactic dependency relations of the annotated word segmentation sequence in an embodiment of this application;
[0051] Figure 7 A schematic diagram showing the correspondence between part-of-speech names, part-of-speech tags, and part-of-speech codes in this application is provided.
[0052] Figure 8 This application illustrates the correspondence between the type names and relation identifiers of various dependency relations in syntactic dependency relations, as well as their dictionary codes.
[0053] Figure 9 This illustration shows another flowchart of the text sentiment analysis method provided in the embodiments of this application;
[0054] Figure 10 This illustration shows a schematic diagram of the composition structure of a text sentiment analysis device provided in an embodiment of this application;
[0055] Figure 11 A schematic diagram of the composition structure of a computer device provided in an embodiment of this application is shown. Detailed Implementation
[0056] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0057] This application relates to technologies such as artificial intelligence. Artificial intelligence is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly include computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0058] This application relates to at least the natural language processing technology in artificial intelligence.
[0059] Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language people use in daily life—and thus it has a close relationship with linguistic research. NLP techniques typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.
[0060] The text sentiment analysis in this application is based on natural language processing. Text sentiment analysis can be applied to a variety of application scenarios.
[0061] To better understand the technical solutions provided in the embodiments of this application, a brief description of an application scenario to which the technical solutions provided in the embodiments of this application are applicable is provided below. It should be noted that the application scenario described below is for illustrative purposes only and not for limitation. In specific implementations, the technical solutions provided in the embodiments of this application can be flexibly applied according to actual needs.
[0062] like Figure 1 This illustrates an application scenario of the text sentiment analysis method provided in this application embodiment. Figure 1 As can be seen, this application scenario may include: data processing device 101 and application server 102.
[0063] This data processing device can obtain the text to be analyzed and analyze the sentiment category expressed in the text.
[0064] The application server can perform information recommendation and other related processing based on the sentiment category of the text determined by the data processing device.
[0065] The data processing device can be on the same system platform as the application server, or it can be a computer device independent of the system platform to which the application server belongs; there are no restrictions on this.
[0066] The text processed by the data processing device can come from a large amount of text obtained from the application server, or it can be collected through other data collection platforms.
[0067] For example, in one possible scenario, the application server could be the e-commerce server of an e-commerce shopping platform. In this case, the e-commerce server can send the product review texts obtained from the e-commerce shopping platform to the data processing device, and based on the ratings of each product review text determined by the data processing device, guide shoppers to filter according to their own needs, thereby improving the shopping experience and efficiency.
[0068] For example, in another possible scenario, the application server can be a news server, and the text analyzed by the data processing device can be news review text. Accordingly, the news server can combine the preferences for different news expressed in the news review text to make reasonable news recommendations.
[0069] Of course, text sentiment analysis technology can also be applied to many other application scenarios such as online social platforms and public opinion trend prediction. Depending on the application scenario, the application server can also be different, and there are no restrictions on this.
[0070] The text sentiment analysis in this application can be any form of sentiment analysis, such as fine-grained sentiment analysis, also known as attribute-level sentiment analysis, which mines the sentiment attributes of the evaluation object at a more specific dimension, so the analysis results are more meaningful and valuable.
[0071] The following section provides a detailed explanation of the text sentiment analysis method used in this application, using the flowchart as an example.
[0072] like Figure 2 This illustration shows a flowchart of a text sentiment analysis method provided in an embodiment of this application. This embodiment can be applied to a data processing device, and the method of this embodiment may include:
[0073] S201, perform word segmentation on the text to be analyzed to obtain the word segmentation sequence of the text.
[0074] In this process, word segmentation of the text yields multiple word segments in a sequential order, and these sequential word segments together form the word segmentation sequence.
[0075] It is understandable that there are many possibilities for word segmentation of text, and this application does not impose any restrictions on this.
[0076] The word segmentation sequence includes multiple words in the text that have a sequential order.
[0077] S202, determine at least one feature word in the word segmentation sequence and the feature word category of the feature word.
[0078] In this context, a feature word is one of multiple word segments in the word segmentation sequence. In other words, it is necessary to determine which word segments belong to the feature word category.
[0079] Feature words are words that are related to the emotional expression of a text.
[0080] There are several possible ways to determine the feature words among multiple segmented words in a word segmentation sequence. For example, in one possible implementation, segmented words belonging to a feature word library can be identified and designated as feature words. This feature word library may include multiple pre-determined words related to sentiment expression.
[0081] Of course, this is just one example. The implementation of determining feature words from multiple word segments through other methods is also applicable to this embodiment, and there is no limitation on it.
[0082] The category of a feature word is called a feature word class. Feature word classes can be used to characterize the role of a feature word in emotional expression. For example, feature words can be divided into domain attribute words, emotion words, degree adverbs, and negation words.
[0083] There are several possible ways to determine the category of a feature word.
[0084] For example, the feature lexicon can include feature words of different categories. In this case, if a segment in the word segmentation sequence belongs to a feature word of a certain category in the feature lexicon, that segment is identified as a feature word, and that category is the category of the feature word. The feature words of different categories in the feature lexicon can come from sentiment dictionaries, degree adverb dictionaries, negation word dictionaries, and attribute word sets determined based on domain and scenario from different websites or platforms, etc., without any restrictions.
[0085] For example, the category of feature words can also be determined through category classification models or semantic analysis, and this application does not impose any restrictions on this.
[0086] S203, determine the contextual grammatical relationships of each feature word in the word segmentation sequence.
[0087] The contextual grammatical relationship of feature segmentation refers to the grammatical relationship between feature segmentation and its context in the segmentation sequence. For example, the combination relationship between feature segmentation and its context, the part of speech of feature words and their context, and the order of feature segmentation and its context, etc., can reflect any grammatical relationship information related to feature segmentation and its context.
[0088] To facilitate understanding, the following examples illustrate several possible cases for determining contextual syntactic relationships:
[0089] In one possible scenario, the semantic dependencies between the segments in the segmentation sequence can be determined. Since the feature segments belong to the segments in the segmentation sequence, the semantic dependencies between the segments in the segmentation sequence must include the semantic dependencies between the contexts of the feature words.
[0090] Determining the semantic dependencies of each word in a word segmentation sequence can be achieved through semantic dependency parsing (SDP). SDP analyzes the semantic relationships between various linguistic units of a sentence and presents these relationships as dependency structures. SDP can simultaneously describe the structure and semantic information of a word segmentation sequence, thus bypassing the surface structure of the word segmentation sequence (sentence) to directly obtain the essence of deep semantic expression.
[0091] In another possible scenario, the syntactic dependencies between the segments in the segmentation sequence can be determined. Since the feature words belong to the segmentation sequence, this syntactic dependency includes the syntactic dependencies between the contexts of the feature words in the segmentation sequence.
[0092] Syntactic dependency relations can be obtained by performing dependency parsing on word segmentation sequences. Dependency parsing can identify grammatical components such as subject-verb-object and attributive-adverbial-complement in a sentence (the word segmentation sequence in this application) and analyze the relationships between these components, thereby describing the dependency relations between the words in the sentence.
[0093] In another possible scenario, the part-of-speech information of each word in the word segmentation sequence can be determined. Of course, the part-of-speech information of each word in the word segmentation sequence must include the part-of-speech information of each feature word.
[0094] Among them, part of speech is the result of classifying words based on their grammatical function and meaning. Part of speech refers to the grammatical features of a class of words. For example, the part of speech of words can be divided into: noun, verb, adjective, etc. For example, the part of speech of the word "banana" is a noun, the part of speech of "jump" is a verb, and the part of speech of "small" is an adjective.
[0095] In this application, any part-of-speech tagging method can be used to determine the part of speech of the words, and this application does not impose any restrictions on it.
[0096] It is understandable that the above examples illustrate several contextual grammatical relationships. In actual applications, there may be other possibilities for the grammatical relationships between the contexts of a word, and no restrictions are imposed on this.
[0097] It should be noted that in practical applications, determining the contextual grammatical relations of feature words can simultaneously include multiple grammatical relations. For example, this application can include some or all of the above-mentioned possible contextual grammatical relations. For instance, it can simultaneously determine the part-of-speech information, grammatical dependency relations, and syntactic dependency relations of each word in the word segmentation sequence.
[0098] S204. Based on the contextual grammatical relationships and feature word categories of each feature word in the segmented sequence, determine the grammatical features of the segmented sequence.
[0099] Among them, the grammatical features of the word segmentation sequence, which are the grammatical features of the text to be analyzed, refer to the feature representation that can reflect the contextual grammatical relationships and the feature word categories of each feature word in the word segmentation sequence.
[0100] For ease of differentiation, the features of the word segmentation sequence determined based on contextual grammatical relationships and feature word categories are called grammatical features.
[0101] There are many possible ways to construct grammatical features that represent contextual grammatical relationships and feature word categories, and there are no restrictions on this.
[0102] To make it easier to understand, let's take one possible scenario as an example:
[0103] For example, the grammatical relationships of each feature word in the segmented sequence can be combined with the feature word category to perform feature encoding, thereby obtaining the grammatical relationships of the segmented sequence. For instance, different grammatical relationships can correspond to different encoding rules, and different feature word categories also correspond to different encodings. Based on this, the encoding features corresponding to the grammatical relationships of each feature word and the encodings corresponding to the feature word categories of each feature word can be combined to obtain the grammatical features of the segmented sequence.
[0104] It should be noted that when there are multiple contextual grammatical relationships corresponding to each feature word in a word segmentation sequence, these contextual grammatical relationships and the feature word categories of each feature word can be combined simultaneously to determine the grammatical feature. For example, vector transformation or feature encoding can be performed by combining the grammatical dependency relationships, syntactic dependency relationships, part-of-speech information, and feature word categories of each feature word in the word segmentation sequence to ultimately obtain the grammatical feature.
[0105] S205, combine the vectors of each feature word in the word segmentation sequence to determine the sequence features of the word segmentation sequence.
[0106] The sequence features of a word segmentation sequence refer to the features used to characterize each feature word that constitutes the word segmentation sequence.
[0107] For example, the vectors of each feature word in the word segmentation sequence can be concatenated to obtain the sequence features of the word segmentation sequence; or, the features of each word in the word segmentation sequence can be directly combined to obtain the sequence features of the word segmentation sequence.
[0108] The vector representation of each word or feature word in the word segmentation sequence can be determined in various ways, and this application does not impose any restrictions on this.
[0109] S206. Based on the grammatical and sequence features of the word segmentation sequence, as well as the grammatical and sequence features of the training text sets under different sentiment categories, a Bayesian model is used to determine the sentiment category to which the text belongs.
[0110] The emotional categories that the text may possess can be set as needed. For example, emotional categories can be divided into positive or negative emotions. Or, emotional categories can be divided into happiness, anger, and peace, etc.
[0111] Understandably, the classification principle based on the Bayesian model is to calculate the posterior probability of an object using the Bayesian formula based on the object's prior probability, which is the probability that the object belongs to a certain class. The class with the highest posterior probability is then selected as the class to which the object belongs.
[0112] Based on this, this application pre-constructs training text sets corresponding to different sentiment categories. Each sentiment category's training text set can include multiple training texts belonging to that sentiment category; that is, each training text in the training text set is labeled with its corresponding sentiment category. The grammatical features and sequence features corresponding to the training text sets for each sentiment category are already determined.
[0113] The grammatical features corresponding to the training text set can include the grammatical features of each training text in that set. Similarly, the sequence features corresponding to the training text set can include the sequence features of each training text in that set. The method for determining the grammatical and sequence features of the training text is similar to the process for determining the grammatical and sequence features of the text to be analyzed, and will not be elaborated further here.
[0114] Based on the above, using a Bayesian model, we can determine the probability that the grammatical and sequence features of a text belong to the grammatical and sequence features of the training text set under each sentiment category. In other words, we can determine the probability that a text belongs to different sentiment categories, and finally determine the sentiment category with the highest probability as the sentiment category expressed by the text.
[0115] In one possible implementation, combining the classification principle of Bayesian models, this application can also determine the sentiment category of a text by using the mutual information between the grammatical features and sequence features of the word segmentation sequence and the grammatical features and sequence features of the training text sets for each sentiment category.
[0116] Specifically, for each sentiment category, the first mutual information between the grammatical features of the segmented sequence and the grammatical features of each training text in the training text set under that sentiment category can be calculated, as well as the second mutual information between the sequence features of the segmented sequence and the sequence features of each training text in the training text set under that sentiment category.
[0117] Based on this, for each sentiment category, the sum of the corresponding first mutual information and second mutual information is determined as the correlation value between the segmented sequence and that sentiment category. Accordingly, sentiment categories whose correlation value with the segmented sequence exceeds a set threshold can be identified as the sentiment category to which the segmented sequence belongs.
[0118] The following section explains the principle behind this application's ability to determine the sentiment category of text based on mutual information, using Bayes' theorem.
[0119] For a given input feature Q, P(Q) is the probability of the input feature Q. The input feature Q consists of n features. In this application, the input feature is a feature set consisting of syntactic feature q1 and sequence feature q2. Therefore, the value of n is actually 2. Accordingly, P(Q) is the probability that the text to be analyzed contains the input feature Q, that is, the probability that the text contains syntactic feature q1 and sequence feature q2. Combining the classification principle of the Bayesian model, the sentiment category A is predicted, and a conditional probability P(A|Q) is constructed to maximize this conditional probability. That is, among all sentiment categories A, the sentiment category that maximizes P(A|Q) is found. This conditional probability P(A|Q) represents the probability that sentiment category A occurs given the input feature Q.
[0120] The Bayesian formula can be found in Formula 1 below:
[0121]
[0122] In this application, the predicted sentiment category A includes multiple sentiment categories a. The probability of a certain sentiment category needs to be returned as the output, i.e., P(A) = P(a). When predicting a fixed sentiment category a, P(a) is a constant value. Therefore, when analyzing how to maximize P(A|Q), only the remaining part of Equation 1 needs to be analyzed.
[0123] Based on the composition of the input features, we can derive the following formula:
[0124]
[0125] Due to the various input features q i The elements are mutually independent, and i is a natural number from 1 to n. P(Q|A) can be expressed as the following formula:
[0126]
[0127] Formula 4 can be derived from Formula 3:
[0128]
[0129] Taking the logarithm of both sides of Formula 4 above, we get Formula 5 as follows:
[0130]
[0131] Formula 5 is actually the formula for calculating mutual information. Based on Formula 5, the Bayesian model can be simplified to the mutual information I(a,q) between features. i (This is an estimate.)
[0132] in,
[0133] Here, sentiment category 'a' is actually represented by the grammatical and sequence features of each training text under that sentiment category. Therefore, based on Formula 6, for the text to be analyzed, we only need to calculate the first mutual information between the grammatical features of the text and the grammatical features of each training text under sentiment category 'a', and calculate the second mutual information between the sequence features of the text and the sequence features of each training text under sentiment category 'a'. If the sum of the first and second mutual information exceeds a set threshold, then the sentiment category corresponding to the corresponding P(A|Q) is determined as the sentiment category to which the text belongs.
[0134] As can be seen from the above, after identifying the feature words contained in the word segmentation sequence of the text, this application not only combines the vectors of each feature word in the word segmentation sequence to determine the sequence features of the word segmentation sequence, but also combines the contextual grammatical relationships of each feature word in the word segmentation sequence to determine the grammatical features of the word segmentation sequence. This achieves a more accurate and comprehensive mining of the features in the text used to express emotion. On this basis, by combining the sequence features and grammatical features of the text, as well as the multi-dimensional features of the training text set under different emotion categories, and using a Bayesian model to determine the emotion category to which the text belongs, a more refined and comprehensive emotion category analysis is achieved, thereby improving the accuracy of determining the emotion category of the text.
[0135] It is understandable that there may be multiple ways to determine the sequence features of the word segmentation sequence in this application.
[0136] In order to more comprehensively and reliably reflect the features of feature words in the word segmentation sequence, the method for constructing the feature vectors of feature words in this application not only directly maps the vectors of feature words by using traditional vector mapping methods such as word2vec, but the feature vectors of feature words can also include one or several features such as the character vectors of each character in each feature word, the position of the feature word, and the word features of other words adjacent to the feature word. The following is an introduction by cases.
[0137] In the first possible implementation, for each character in the word segmentation sequence, it can be converted into an initial character vector of each character. For example, based on a vector library such as word2vec, the character vector of the character is mapped, and the obtained at this time is the initial character vector of the character. Similarly, it is also necessary to determine the word vector of each word in the word segmentation sequence. For example, word2vec can be used to determine the word vector. For example, for the character "位", the character vector of "位" is equal to the vector formed by splicing the initial character vector converted from the character "位" and the word vector of the word "位置" where "位" is located.
[0138] On this basis, for each character in the word segmentation sequence, the initial vector of the character and the word vectors of each word where the character is located are spliced into the character vector of the character. On this basis, considering that each feature word in the word segmentation sequence contains each character in the word segmentation sequence, after determining the character vectors of each character based on the above method, the character vectors of each character in the word segmentation sequence can be spliced into a vector representing the sequence features of the word segmentation sequence.
[0139] In the second possible implementation, the word vectors of each feature word in the word segmentation sequence can be determined. The word vectors of feature words can be determined according to the traditional word vector conversion method, or can be obtained by synthesizing the character vectors of each character in the feature word, and the character vectors of each character in the feature word can be obtained by using the first possible implementation. On this basis, the word vectors of each feature word can be combined to obtain the sequence features including the word vectors of each feature word.
[0140] In the third possible implementation, this application can also combine the positions of each character in the word segmentation sequence to determine the position encoding of each character. On this basis, this application can combine the word vector of the feature word and the position encoding of each character included in the feature word to construct the encoding vector of the word segmentation sequence and obtain the sequence features of the word segmentation sequence. Among them, there are also multiple ways to combine the position of the character in the word segmentation sequence to determine the position feature of the character. In the subsequent Figure 3 The embodiment will illustrate in combination with one case and will not be elaborated here.
[0141] In the fourth possible implementation, this application determines the word features and word position features of a set number of words before and after each feature word in the word segmentation sequence. Based on this, the sequence features of the word segmentation sequence are constructed by combining the word features and word position features of the set number of words before and after each feature word.
[0142] Understandably, in practical applications, in order to more comprehensively reflect the feature words contained in the segmented sequence and the contextual features of those feature words, this application can also combine the above implementation methods to comprehensively determine the sequence features of the segmented sequence. For example... Figure 3 The diagram illustrates a flowchart of one implementation of determining sequence features of a word segmentation sequence according to this application. The process of this embodiment may include:
[0143] S301, for each character in the word segmentation sequence, determine the initial character vector of the character and the initial word segmentation vector of the word to which the character belongs, and concatenate the initial character vector and the initial word segmentation vector into the character vector of the character.
[0144] As mentioned earlier, the initial character vector is the vector representation of the character converted according to the traditional character or word vector conversion method.
[0145] Here, the word segment to which a character belongs refers to the word segment containing that character, and the initial word segment vector of that word segment can also be the word vector converted using the traditional word vector conversion method.
[0146] S302: For each word segment in the word segmentation sequence, construct a word-character hybrid vector based on the character vectors of each character contained in the word segmentation.
[0147] It is understandable that the character vector of each character in the word segmentation is the character vector constructed using step S301. Based on this, this application can concatenate the character vectors of each character in the word segmentation to form the vector of the word segmentation. For ease of distinction, the constructed word segmentation vector is called the word-character hybrid vector.
[0148] S303: For each word in the word segmentation sequence, determine the position encoding vector of the word segmentation position according to the position of the word segmentation in the word segmentation sequence.
[0149] The position of a word segment in a word segmentation sequence can be determined by the order of the words in the word segmentation sequence, and then the order position is mapped to a position vector.
[0150] For example, according to the order of the segments in the segmentation sequence, each segment is identified and numbered. The identifier number of each segment can be mapped to a position vector of a set dimension (e.g., 200) using Formula 7 or Formula 8. Specifically, for the j-th segment in the segmentation sequence, j is a natural number from 1 to N, and N is the total number of segments in the segmentation sequence; if j is even, then Formula 7 can be used to map the segment's identifier code w to PE. 2j (w), if j is odd, then use formula eight to map the identifier encoding w of the segmentation to PE. 2j+1 (w):
[0151] PE 2j (w)=sin(w / 10000 2j / 200 (Formula 7);
[0152] PE 2j+1 (w)=cos(w / 10000 2j / 200 (Formula 8);
[0153] Of course, this is just one example of how to convert a position into a positional encoding vector. In practical applications, the position of a word segment can be encoded in other ways depending on its position in the word segmentation sequence, and there are no restrictions on this.
[0154] S304, determine at least one adjacent word in the word segmentation sequence that is adjacent to the feature word, and determine the context feature vector of the feature word in the word segmentation sequence based on the position encoding vector and word-word mixing vector of each of the at least one adjacent word.
[0155] In this application, a set number of segments preceding and following a feature word in the segmentation sequence can be identified as adjacent segments of that feature word, as needed. For ease of distinction, the segments adjacent to the feature word are referred to as adjacent segments of the feature word. For example, the two nearest segments preceding the feature word can be identified as the two adjacent segments preceding the feature word, and the two nearest segments following the feature word can be identified as the two adjacent segments following the feature word.
[0156] It is understandable that, since each feature word in the word segmentation sequence may be adjacent or not adjacent, this application can identify each adjacent word in the word segmentation sequence that is adjacent to any feature word but does not belong to the feature word.
[0157] It is understandable that, since the word-word mixing vector and position encoding vector of each word have been constructed in the previous steps S301 to S303, the word-word mixing vector and position encoding vector of each adjacent word can be obtained after determining each adjacent word.
[0158] The word-word mixing vector and positional encoding vector of each adjacent word segment reflect the contextual features of each feature word in the word segmentation sequence. For example, the word-word mixing vector and positional encoding vector of each adjacent word segment can be combined into a single vector, which represents the contextual features of the feature word in the word segmentation sequence.
[0159] For example, the text "This hotel's rooms are spacious and bright" can be segmented into the word sequence: "This hotel's rooms are spacious and bright." The feature words identified from the word segmentation sequence are "rooms," "very," and "spacious." Based on this, the two segmented words before and after the feature words are selected as window words, i.e., adjacent segmented words. Therefore, adjacent segmented words can include "hotel," "of," "very," and "bright."
[0160] Based on this, the word-word mixture vector and positional encoding vector of each adjacent word segment constitute the contextual feature of the feature word in the segmentation sequence. For example, the contextual feature of the adjacent word "hotel" is the feature vector obtained by concatenating the word-word mixture vector of "hotel" and the positional encoding vector of "hotel". The same applies to other adjacent words; the contextual features corresponding to these adjacent words constitute the overall contextual feature of all feature words in the segmentation sequence.
[0161] S305. Combining the context features of the feature words in the word segmentation sequence, as well as the word-word mixing vector and position encoding vector of each feature word, the sequence feature vector of the word segmentation sequence is determined.
[0162] It is understandable that, since feature words can also be segmented, the word-word mixture vector and position feature vector of each feature word can be obtained from the results determined in the previous steps S302 and S303.
[0163] In this embodiment, the sequence features of the word segmentation sequence can be represented by a sequence feature vector. Since the sequence feature vector reflects not only the word-word mixing features and positional features of the feature words themselves, but also the context features in which the feature words are located, this sequence feature vector can more comprehensively and precisely reflect the features of each feature word and its context in the word segmentation sequence, thereby facilitating a more accurate subsequent mining of the sentiment classification of the text corresponding to the word segmentation sequence.
[0164] It is understandable that the contextual grammatical relationships of each feature word in the segmentation sequence can have multiple possibilities in this application. In order to directly reflect the position of the feature word and its corresponding contextual grammatical relationship within the various contextual grammatical relationships in the segmentation sequence, this application constructs a corresponding grammatical annotation sequence for each contextual grammatical relationship, and annotates the category labels of the feature words in the segmentation sequence within the grammatical annotation sequence. For example... Figure 4This illustrates a flowchart of yet another embodiment of a text sentiment analysis method according to this application. The method of this embodiment may include:
[0165] S401, perform word segmentation on the text to be analyzed to obtain the word segmentation sequence of the text.
[0166] S402, determine at least one feature word in the word segmentation sequence and the feature word category of the feature word.
[0167] The above two steps can be referred to in the relevant descriptions of the previous embodiments, and will not be repeated here.
[0168] S403, in the word segmentation sequence, label the feature words with category labels corresponding to the feature word categories of the feature words, and obtain the feature word labeling sequence with feature word category labels.
[0169] Among them, the category label of the feature word category is a label used to characterize the feature word category. Therefore, the category labels of different feature word categories are also different.
[0170] For example, feature word categories can include attribute words, sentiment words, degree adverbs, and negation words. Correspondingly, the category label for attribute words can be "#", the category label for sentiment words can be "*", the category label for degree adverbs can be "&", and the category label for negation words can be "!".
[0171] For example, suppose the text is "The service attitude is quite good, I will come again next time". The word segmentation result is "The service attitude is quite good, I will come again next time". Here, the four words "The service attitude is quite good" are feature words, while "service" and "attitude" are attribute words and need to be labeled with the category label #; "quite" is an adverb of degree and needs to be labeled with &; and "good" is a sentiment word and needs to be labeled with *.
[0172] Based on this, after labeling the text sequence with category tags for the feature words, the following feature word labeling sequence can be obtained:
[0173] The service was quite good; I'll come again next time.
[0174] S404, determine the semantic dependency relationship between each segment in the feature word annotation sequence, and construct a semantic dependency relationship sequence that retains the annotated feature word category labels and the semantic dependency relationship between each segment.
[0175] Understandably, since the feature word annotation sequence is essentially still a sequence composed of multiple word segments, semantic dependency analysis can be used to determine the semantic dependency relationships in the feature word annotation sequence.
[0176] It is understandable that after the semantic dependency relationship of the segmented sequence is obtained, it can be converted into a sequence representing the semantic dependency relationship based on the semantic dependency relationship of the segmented sequence. In this application, in order to reflect the position and category of the feature words contained in the segmented sequence, it is necessary to retain the feature word category label of each word.
[0177] For example, we can first use semantic dependency analysis to label the semantic dependency relationships between each word in the feature word labeling sequence, then delete each word in the feature word labeling sequence, and only retain the labeled feature word category labels and the semantic dependency relationships between each word to obtain a sequence, which is the dependency relationship sequence.
[0178] For example, taking the feature word-labeled sequence "#service#attitude&quite*good, will come again next time" as an example, semantic dependency analysis can be used to identify the semantic dependency relationships between the various word segments in this sequence. Specifically, as shown... Figure 5 As shown.
[0179] exist Figure 5 In Chinese, dependency relationships are represented by symbols on the lines connecting word segments. For example, Root is a root node that indicates the beginning of a text segment. FEAT represents a descriptive role, EXP represents a party relationship, and so on. Other semantic dependency relationship symbols, such as mDEPD and eSUCC, are used to represent different semantic relationships. The specifics can be determined based on the semantic dependency relationships and their symbolic correspondences, which will not be elaborated here.
[0180] Combination Figure 5 The semantic dependencies are marked, and according to the annotation principle of front to back and far to near, while retaining the annotated feature word categories, the following are deleted. Figure 5 Each word is segmented, and the semantic dependencies of each segment are preserved. Ultimately, the feature word annotation sequence can be converted into a semantic dependency sequence carrying the annotated feature word categories.
[0181] Root#FEAT#EXP&mDEPD*eSUCC mPUNC TIME mDEPD mDEPD.
[0182] S405, determine the syntactic dependency relationships between each segment in the feature word annotation sequence, and construct a syntactic dependency relationship sequence that retains the labeled feature word category labels and the syntactic dependency relationships between each segment.
[0183] The process of constructing a syntactic dependency relation sequence is similar to that of constructing a grammatical dependency relation sequence. However, it requires analyzing the syntactic dependency relations between each word in the feature word labeling sequence based on the syntactic dependency analysis method. Then, while retaining the category labels of each feature word, each word in the feature word labeling sequence is deleted, and the syntactic dependency relations of each determined word are used to form a sequence to obtain the syntactic dependency relation sequence.
[0184] For example, taking the text "The composer of the song is Zhang San" as an example, the word segmentation sequence of this text is "The composer of the song is Zhang San". Assuming that the feature words in the word segmentation sequence are "composer" and "Zhang San", and assuming that "composer" is a sentiment word and "Zhang San" is an attribute word, then the word segmentation sequence after labeling the category tags of the feature words, i.e. the feature word labeling sequence, is "The composer of the song is #Zhang San".
[0185] Then, by using syntactic dependency parsing to perform dependency annotation on the feature word tagging sequence, we can obtain the following: Figure 6 The diagram shows the dependency relationships.
[0186] like Figure 6 As shown, the syntactic relationship between "song" and "composition" is ATT, where ATT indicates a noun-head relationship, while the syntactic relationship between "song" and "of" is RAD, where RAD indicates a right-attachment relationship. Figure 6 The meanings of the other syntactic relation symbols marked in the table can be found in Table 4 below, and will not be repeated here.
[0187] Following the labeling principle of front to back and far to near, ATT relationships are further back than RAD relationships and are placed first. At the same time, combined with... Figure 6 While retaining the category labels of the marked feature words, the entire syntactic relation sequence is transformed into: HED ATTRAD*SBV VOB#.
[0188] Similarly, for the feature word annotation sequence mentioned earlier: "#service#attitude&quite*good, will come again next time", the converted syntactic dependency relation sequence can be: HED#ATT#SBV&ADV*COO WP ADV ADV ADV.
[0189] S406, perform part-of-speech tagging on each word in the feature word tagging sequence to obtain a part-of-speech tagging sequence with feature word category labels.
[0190] Part-of-speech tagging (POS) refers to labeling the part of speech of each word in the text. Different parts of speech correspond to different tag labels. For example, nouns can be uniformly tagged as "n", adjectives as "a", conjunctions as "c", and adverbs as "vd", etc. For details on the POS tags for each part of speech, please refer to [link to relevant documentation]. Figure 7The part-of-speech codes corresponding to each part-of-speech name in the Chinese part-of-speech coding table will not be repeated here.
[0191] As shown in Table 1, the correspondence between different texts and the results of word segmentation and part-of-speech tagging in the text is presented in Table 1.
[0192] Table 1
[0193]
[0194]
[0195] The part-of-speech tagging results in Table 1 retain each word in the word segmentation sequence.
[0196] It is understandable that the part-of-speech tagging sequence is a sequence composed of the part-of-speech tagging results of each word in the text. Therefore, after tagging each word in the segmentation sequence with its part of speech, removing each word will result in the part-of-speech tagging sequence corresponding to the segmentation sequence.
[0197] In this application, part-of-speech tagging is performed on the feature word tagging sequence. In order to retain the position and category of the feature words in the word segmentation sequence, the feature word category label of each feature word can be retained. The part-of-speech tagging sequence with feature word category label is formed by combining the tagging position of the feature word category label and the part-of-speech tagging structure of each word segmentation.
[0198] For example, for each text in Table 1, the part-of-speech tagging sequence carrying the feature word category labels can be constructed as shown in Table 2 below, while retaining the feature word category labels.
[0199] Table 2
[0200] Part-of-speech tagging sequence # / n# / n& / d* / a / wp / n / d / v / v / v / v / n / wp# / n# / n / a& / d* / a # / n# / n / d& / d* / a / u / wp / v / v / m
[0201] In Table 2, the three rows of part-of-speech tagging sequences correspond to the part-of-speech tagging sequences for the three texts in Table 1. As can be seen from Table 2, the part-of-speech tagging sequences in this application not only include the part-of-speech tags of each word in the word segmentation sequence, but also retain the category labels of the feature words in the word segmentation sequence, and the position of the category labels of the feature words in the part-of-speech tagging sequence is consistent with the position of the feature words in the word segmentation sequence.
[0202] S407, Based on at least one of semantic dependency relation sequence, syntactic dependency relation sequence and part-of-speech tagging sequence, determine the grammatical features in the word segmentation sequence.
[0203] It is understood that the contextual grammatical relations of feature words in the word segmentation sequence may include one or more of the following: grammatical dependency relations, syntactic dependency relations, and part-of-speech information. Therefore, in this application, one or more of the above steps S404 to S406 may be performed as needed.
[0204] It is understandable that the various sequences representing contextual grammatical relationships not only contain information about the position and category of feature words in the word segmentation sequence, but also the contextual grammatical relationships between feature words and other words in the word segmentation sequence. Based on this, this application can more comprehensively and precisely reflect the grammatical relationships between feature words and their context by combining any one or more of these sequences to determine the grammatical features of the word segmentation sequence.
[0205] There are several possible ways to determine grammatical features.
[0206] In one possible implementation, for any of these syntactic relation sequences, the feature code corresponding to the sequence can be determined first, and then one or more feature codes from these sequences can be combined to obtain the syntactic feature.
[0207] For example, for a part-of-speech tagging sequence with feature word category labels, considering that the part-of-speech tagging sequence reflects the context of the feature words, the part-of-speech codes of the part-of-speech tags can be combined sequentially according to the order of the part-of-speech tags in the part-of-speech tagging sequence to splice out the part-of-speech sequence code of the part-of-speech tagging sequence.
[0208] For example, it can be combined Figure 7 Determine the part-of-speech code corresponding to the part of speech of each word in the part-of-speech tagging sequence. For example... Figure 7 It shows different parts of speech names and part-of-speech tags ( Figure 7 The table shows the correspondence between part-of-speech tagging symbols and their corresponding part-of-speech codes. The tagging symbols represent identifiers for each part of speech, while the part-of-speech codes are 6-bit binary numbers representing each part of speech in a pre-constructed part-of-speech dictionary. Based on this, the part-of-speech codes corresponding to each tagging symbol in the tagging sequence are queried sequentially.
[0209] For example, if the part-of-speech tagging sequence contains the tagged parts of speech: / n, / d, / a, then combined with Figure 7 The segmentation code for the part-of-speech tag “n” is “010011”, “d” is “001000”, and “a” is “000010”. Based on this, the segmentation codes for these three tags are concatenated in the order they appear to be in the segmentation sequence.
[0210] As an alternative approach, in order to further reflect the characteristics of each feature word in the part-of-speech tagging sequence, this application may also determine the label code of each feature word category label and the part-of-speech code of each feature word category label in sequence according to the sequential relationship between the feature category labels and part-of-speech tags of each feature word in the part-of-speech tagging sequence, and then concatenate and combine them in sequence to obtain the part-of-speech sequence code of the part-of-speech tagging sequence.
[0211] For example, assuming the part-of-speech tagging sequence is "# / n / d* / a", then the part-of-speech sequence code of this part-of-speech tagging sequence is formed by concatenating the tag code of "#", the part-of-speech code of "n" is "010011", the part-of-speech code of "d" is "001000", the tag code of "*", and the part-of-speech code of "a" is "000010".
[0212] For example, for a syntactic dependency relation sequence, the process of determining the syntactic sequence code of the syntactic dependency relation sequence is similar to the process of determining the part-of-speech sequence code corresponding to the part-of-speech tagging sequence. For example, the relation codes corresponding to each syntactic dependency relation in the syntactic dependency relation sequence are determined in sequence and then concatenated in order to obtain the syntactic sequence code corresponding to the syntactic dependency relation sequence.
[0213] For example, see Figure 8 It illustrates the correspondence between syntactic dependency relations, relation markers, and syntactic relation codes.
[0214] Depend on Figure 8 The text shows the names of various syntactic dependency relations, namely... Figure 8 The relation name in the table, and each syntactic dependency relation corresponds to a relation tagger that marks that syntactic dependency relation and the corresponding syntactic relation code. For example... Figure 8 The subject-predicate syntactic relation is marked with "SBV", and the corresponding syntactic relation code is a four-bit binary code "0001".
[0215] Of course, as an alternative approach, one can determine the label code of the feature word category label and the relation code of the relation in the syntactic dependency relation sequence according to the order of the feature word category label and the relation code of the relation, and then concatenate the label codes and relation codes in order to obtain the syntactic sequence code corresponding to the syntactic dependency relation sequence.
[0216] The same applies to semantic dependency sequences. By combining the relation codes of each semantic relation, the semantic sequence code of the semantic dependency sequence is obtained.
[0217] Optionally, the label encoding of each feature word's category label and the relation encoding of each semantic relationship can be combined to obtain the semantic sequence encoding of the semantic dependency relationship sequence.
[0218] Correspondingly, one or more of semantic sequence encoding, syntactic sequence encoding, and part-of-speech sequence encoding can be concatenated to obtain the concatenated grammatical features.
[0219] In another possible implementation, for any one of the semantic dependency relation sequence, syntactic dependency relation sequence, and part-of-speech tagging sequence, in order to mine deeper grammatical relation patterns and obtain more important features in the sequence that are more prominent for sentiment analysis, this application can also mine frequent sequence patterns of such sequences in multiple text training data and the text to be analyzed, so as to finally obtain the frequent sequences corresponding to such sequences, and determine semantic features based on the frequent sequences contained in such sequences of the text.
[0220] For example, for a semantic dependency sequence, the semantic dependency sequence samples of multiple training texts in the training text library can be combined to determine at least one semantically frequent sequence that belongs to the subsequence of the semantic dependency sequence and meets the mining conditions.
[0221] The training text library may include training text sets under different sentiment categories, and each training text set includes multiple training texts. In this application, for each training text, the semantic dependency sequence of the training text is pre-determined. The process of determining and constructing the semantic dependency sequence of the training text is similar to the process of determining the semantic dependency sequence of the text mentioned above, and will not be repeated here. For ease of distinction, the semantic dependency sequence of the training samples is referred to as the semantic dependency sequence sample.
[0222] The mining conditions include: conforming to the frequent sequence mining rules, including at least one feature word category label, and not belonging to a subsequence of other mined frequent sequences.
[0223] In other words, this application needs to mine multiple candidate frequent sequences from multiple training texts and multiple semantic dependency relation sequences corresponding to the text to be analyzed, including feature category labels and semantic dependency relation sequences belonging to the text to be segmented, according to the frequent sequence mining rules, and determine the candidate frequent sequences of subsequences that do not belong to other candidate frequent sequences from the multiple candidate frequent sequences, and determine the candidate frequent sequences as semantic frequent sequences that meet the mining conditions.
[0224] For example, regarding syntactic dependency relation sequences, we can combine syntactic dependency relation sequence samples from multiple training texts in the training text library to determine at least one frequently occurring syntactic sequence that belongs to the subsequence of the syntactic dependency relation sequence corresponding to the text to be segmented and meets the mining conditions.
[0225] The mining conditions are the same here. Therefore, the mined syntactic frequent sequences are also at least one frequent sequence that has at least one feature category label, belongs to the semantic dependency relation sequence of the text to be analyzed, and does not belong to at least one other frequent sequence mined from the semantic dependency relation sequence. This at least one frequent sequence is called a syntactic frequent sequence.
[0226] The method for determining the syntactic dependency sequence of the training text can be found in the previous introduction. For ease of distinction, the syntactic dependency sequence of the training text is referred to as the syntactic dependency sequence sample.
[0227] For example, by combining part-of-speech tagging sequence samples from multiple training texts in the training text library, at least one frequent part-of-speech sequence that belongs to the subsequence of the part-of-speech tagging sequence corresponding to the text to be analyzed and meets the mining conditions is identified. In this application, the frequent sequence that conforms to the frequent sequence mining rules mined from the part-of-speech tagging sequence corresponding to the text to be analyzed is called a frequent part-of-speech sequence. This frequent part-of-speech sequence does not belong to the subsequence of other frequent sequences mined from the part-of-speech tagging sequence of the text.
[0228] Accordingly, the encoding features of the word segmentation sequence can be determined based on the encoding of at least one of the at least semantically frequent sequences, the at least one syntactically frequent sequences, and the at least one part-of-speech frequent sequences, and these encoding features can be identified as the grammatical features of the word segmentation sequence. For example, the grammatical features of the word segmentation sequence can be obtained by separately determining the sequence encodings of the semantically frequent sequences, the syntactically frequent sequences, and the part-of-speech frequent sequences, concatenating or combining the sequence encodings into a post-feature encoding.
[0229] The sequence encoding method for transforming semantically frequent sequences can be similar to the encoding method for determining semantic dependency relation sequences. Similarly, the sequence encoding process for determining syntactically frequent sequences is similar to the sequence encoding process for determining syntactic dependency relation sequences, and the sequence encoding process for determining part-of-speech frequent sequences is similar to the sequence encoding process for determining part-of-speech relation sequences. These will not be elaborated further here.
[0230] It is understandable that, considering that the process of mining frequent sequences has already been carried out in conjunction with the position of feature word category labels, when determining the sequence encoding of semantically frequent sequences, it is only necessary to concatenate the relation encoding of semantic dependencies in the semantically frequent sequences. The same applies to syntactic and part-of-speech frequent sequences, which will not be elaborated further.
[0231] S408, combine the vectors of each feature word in the word segmentation sequence to determine the sequence features of the word segmentation sequence.
[0232] S409. Based on the grammatical and sequence features of the word segmentation sequence, as well as the grammatical and sequence features of the training text sets under different sentiment categories, a Bayesian model is used to determine the sentiment category to which the text belongs.
[0233] Steps S408 and S409 can be found in the relevant descriptions of the previous embodiments, and will not be repeated here.
[0234] For ease of understanding Figure 4 The following example illustrates how the contextual grammatical relationship of feature words in a word segmentation sequence includes the part-of-speech tagging sequence of the word segmentation sequence, and how frequent sequence mining is combined to determine grammatical features.
[0235] like Figure 9 The diagram illustrates a flowchart of a sentiment analysis method according to this application in an application scenario. The method in this embodiment may include:
[0236] S901, the text to be analyzed is segmented into words to obtain the word segmentation sequence of the text.
[0237] S902, determine at least one feature word in the word segmentation sequence and the feature word category of the feature word.
[0238] The above two steps can be referred to in the relevant descriptions of the previous embodiments, and will not be repeated here.
[0239] S903, in the word segmentation sequence, label the feature words with category labels corresponding to the feature word categories of the feature words, and obtain the feature word labeling sequence with feature word category labels.
[0240] S904, perform part-of-speech tagging on each word segment in the feature word tagging sequence to obtain a part-of-speech tagging sequence with feature word category labels.
[0241] The steps S901 to S904 above can be found in the relevant descriptions of the previous embodiments, and will not be repeated here.
[0242] S905, combining part-of-speech tagging sequence samples from multiple training texts in the training text library, determine at least one frequent part-of-speech sequence that belongs to the subsequence of the part-of-speech tagging sequence corresponding to the text to be analyzed and satisfies the mining conditions.
[0243] The mining condition is as follows: it must conform to the frequent sequence mining rules, include at least one feature word category label, and not belong to a subsequence of other frequently mined sequences. In other words, in this application, it is only necessary to obtain frequent sequences that belong to the part-of-speech tagging sequence and include feature word category labels, and these frequent sequences cannot be subsequences of other frequent sequences mined from the part-of-speech tagging sequence.
[0244] It is understandable that by limiting frequent part-of-speech sequences to subsequences that do not belong to other frequent sequences mined from the part-of-speech labeled sequence samples, it is possible to mine frequent part-of-speech sequences that have a high frequency of occurrence and contain rich part-of-speech information.
[0245] It is understood that various algorithms can be used for frequent sequence mining in this application without restriction.
[0246] To facilitate understanding, the following example illustrates how to use the prefixspan algorithm to mine frequent parts of speech belonging to part-of-speech tagging sequences:
[0247] Before mining frequent sequences, a minimum support needs to be set. The calculation method for the minimum support min_sup can be found in Formula 9 below:
[0248] min_sup = t × s (Formula 9);
[0249] Where t represents the total number of part-of-speech tagging sequences to be mined, and in this application, it represents the total number of part-of-speech tagging sequence samples from multiple training texts and the total number of part-of-speech tagging sequences from the text to be analyzed. s represents the minimum support rate, which can be adjusted according to the number of part-of-speech tagging sequence samples.
[0250] The implementation principle of the prefixspan algorithm for mining frequent sequences involves the following steps:
[0251] Step 1: Find the prefix sums and corresponding projection datasets with a unit length of 1;
[0252] Step 2: Count the frequency of prefixes of length 1 and add prefixes with support higher than the minimum support to the dataset to obtain frequent item set sequence patterns;
[0253] Step 3: Recursively mine all prefixes of length m that meet the minimum support requirement, specifically including the following sub-steps:
[0254] Sub-step 31: Mine the projected dataset of the prefix. If the projected data is an empty set, return the recursion.
[0255] Sub-step 32: Calculate the minimum support of each item in the corresponding projected dataset, merge the items that meet the support requirements with the current prefix to obtain a new prefix, and recursively return if the support requirements are not met.
[0256] Sub-step 33: Let m = m + 1, where the prefixes are the new prefixes after merging individual items. Recursively execute step 3 until the number of m can no longer be increased based on the part-of-speech tagging sequence. Finally, return all frequent sequence patterns.
[0257] In this application, each element in the prefix is a label for a word segmentation transformation in a word segmentation sequence. If the word segment is a feature word, the label for the word segment includes the feature word category label and the part-of-speech tag for the word segment; if the word segment is not a feature word, the label for the word segment is only the part-of-speech tag for the word segment.
[0258] The following description, based on the principle of the Prefixspan algorithm, uses the example of mining frequent part-of-speech sequences from the part-of-speech tagging sequences corresponding to the three texts in Table 2:
[0259] Assuming the minimum support threshold is set to 0.5, then with 3 part-of-speech tagging sequences, the minimum support threshold should be 2.
[0260] Based on this, we first counted the number of occurrences of each part-of-speech element in each part-of-speech tagging sequence in Table 2. A part-of-speech element is a tagging of one part of speech. The counted number of occurrences of each part-of-speech element is shown in Table 3.
[0261] Table 3
[0262] Part-of-speech sequence elements Number of samples / n 3 / v 3 / d 3 / a 3 / wp 3 / u 1 / m 1
[0263] Filter out part-of-speech elements that do not meet the preset support threshold. That is, the part-of-speech element must appear in at least 2 samples in the 3 part-of-speech tagging sequences in Table 2 to meet the support threshold. Based on this, the filtered part-of-speech tagging sequences can be seen in Table 4:
[0264] Table 4
[0265] Single-item support threshold filtering results # / n # / n& / d* / a / wp / n / d / v / v / v / v / n / wp# / n# / n / a& / d* / a # / n# / n / d& / d* / a / wp / v / v
[0266] Mining is based on sequence pattern algorithms. In each iteration, only prefixes containing feature word category labels are retained. For example, to mine fine-grained sentiment, sequence samples with category identifiers * and # in the context are required.
[0267] Accordingly, a prefix and its corresponding suffix are constructed for each part-of-speech element that meets the support rate threshold. The results are shown in Table 5.
[0268] Table 5
[0269]
[0270]
[0271] Taking a prefix " / n" as an example, we can continue to mine the binomial prefixes and corresponding suffixes that meet the minimum support threshold. The binomial prefixes and corresponding suffixes shown in Table 6 below can be obtained.
[0272] Table 6
[0273]
[0274] Taking the binary prefix "# / n# / n" as an example, by continuing to mine the three-term prefixes and corresponding suffixes that meet the minimum support threshold, we can find the three-term prefixes and corresponding suffixes as shown in Table 7.
[0275] Table 7
[0276]
[0277] Taking the three prefixes "# / n# / n& / d" in Table 7 as an example, we can continue to mine the four prefixes and corresponding suffixes that meet the minimum support threshold. The mining results are shown in Table 8.
[0278] Table 8
[0279]
[0280] Based on Table 8, we further explored the five prefixes and corresponding suffixes that satisfy the minimum support threshold, as shown in Table 9:
[0281] Table 9
[0282]
[0283] Based on Table 9, we further explored the six prefixes and corresponding suffixes that satisfy the minimum support threshold, as shown in Table 10:
[0284] Table 10
[0285]
[0286] Based on Table 10, further mining of the seven prefixes and corresponding suffixes that satisfy the minimum support threshold yields the results shown in Table 11:
[0287] Table 11
[0288] Seven prefixes Corresponding suffix # / n# / n& / d* / a / wp / v / v
[0289] After the above iterations are completed, this application will determine the inclusion relationship of the frequent sequences of various lengths mined and will also perform sub-pattern filtering.
[0290] Specifically, if all itemsets of a frequent sequence A can be found in itemsets of a frequent sequence B, then A is a subsequence of B, and correspondingly, B is a supersequence of A. For each frequently mined sequence, since the supersequence itself contains more reference information—that is, it includes contextual auxiliary words and other information not included in the subsequence—this application can retain only the frequently mined sequences that can serve as supersequences as the part-of-speech frequent sequences mined in this application, and delete other frequently mined sequences.
[0291] For example, taking the supersequence "# / n# / n& / d* / a / wp / v / v" and the subsequence "# / n# / n& / d* / a / wp / v" as an example, the supersequence also contains " / v" in addition to the subsequence. Therefore, the supersequence is retained, and the subsequence pattern is deleted. The final results of the mined frequent part-of-speech sequences are shown in Table 12 below:
[0292] Table 12
[0293] The final mined part-of-speech frequent sequences # / n # / n& / d* / a / wp / v / v
[0294] It is understandable that Table 12 is an example of one case, showing that only one frequent part-of-speech sequence was finally mined. However, in actual applications, there may be multiple frequent part-of-speech sequences that meet the mining conditions.
[0295] S906, according to the part-of-speech coding of different parts of speech, encode at least one frequently occurring part-of-speech sequence mined, and combine the codes of the at least one frequently occurring part-of-speech sequence into the grammatical features in the word segmentation sequence.
[0296] For example, for each frequent part-of-speech sequence, the part-of-speech code corresponding to each part-of-speech tag in the frequent part-of-speech sequence can be retrieved sequentially. By concatenating the part-of-speech codes of each part-of-speech tag, the sequence code of the frequent part-of-speech sequence can be obtained. Based on this, the grammatical features of the word segmentation sequence can be obtained by combining the sequence codes of each frequent part-of-speech sequence.
[0297] This step can be found in the previous introduction to encoding based on part-of-speech tagging sequences, and will not be repeated here.
[0298] S907, combining the vectors of each feature word in the word segmentation sequence, determines the sequence features of the word segmentation sequence.
[0299] S908, for each sentiment category, calculate the first mutual information between the grammatical features of the word segmentation sequence and the grammatical features of each training text in the training text set under the sentiment category, and the second mutual information between the sequence features of the word segmentation sequence and the sequence features of each training text in the training text set under the sentiment category, and determine the sum of the first mutual information and the second mutual information as the correlation value between the word segmentation sequence and the sentiment category.
[0300] S909, the sentiment category to which the word segmentation sequence belongs is determined if the correlation value with the word segmentation sequence exceeds a set threshold.
[0301] It is understood that the embodiments of this application are for the purpose of illustration, and only the contextual grammatical relationship of the feature words in the word segmentation sequence includes the part-of-speech tagging sequence with feature word category labels corresponding to the word segmentation sequence as an example. However, the case where the contextual grammatical features include one or both of the aforementioned semantic dependency relation sequence and syntactic dependency relation sequence is also applicable to this embodiment.
[0302] This application combines frequent sequence mining to extract sentiment-related elements from word segmentation sequences, enhancing the generalization performance of extracted evaluation elements. It can flexibly mine the attribute features of feature words in word segmentation sequences and is not affected by long-distance dependencies. It integrates the advantages of frequent sequence mining, ensures the flexibility of rules, and solves the problem that traditional rules relying on manual formulation are not universal.
[0303] Corresponding to the text sentiment analysis method of this application, this application also provides a text sentiment analysis device.
[0304] like Figure 10 The diagram illustrates a structural composition of a text sentiment analysis device provided in this embodiment. The device in this embodiment may include:
[0305] The word segmentation processing unit 1001 is used to perform word segmentation processing on the text to be analyzed, and obtain the word segmentation sequence of the text. The word segmentation sequence includes multiple words in the text that have a sequential order.
[0306] The feature word determination unit 1002 is used to determine at least one feature word in the word segmentation sequence and the feature word category of the feature word, wherein the feature word belongs to the plurality of word segments;
[0307] The grammar determination unit 1003 is used to determine the contextual grammatical relationships of each feature word in the word segmentation sequence;
[0308] The first feature determination unit 1004 is used to determine the grammatical features of the word segmentation sequence based on the contextual grammatical relationship and feature word category of each feature word in the word segmentation sequence.
[0309] The second feature determination unit 1005 is used to determine the sequence features of the word segmentation sequence by combining the vectors of each feature word in the word segmentation sequence.
[0310] The category determination unit 1006 is used to determine the sentiment category to which the text belongs based on the grammatical and sequence features of the word segmentation sequence, as well as the grammatical and sequence features of the training text sets under different sentiment categories, using a Bayesian model.
[0311] In one possible implementation, the syntactic determination unit includes one or more of the following:
[0312] A semantic dependency determination unit is used to determine the semantic dependency relationship between each word in the word segmentation sequence, including the semantic dependency relationship between the contexts of each feature word in the word segmentation sequence;
[0313] The syntactic dependency determination unit is used to determine the syntactic dependency relations between each word in the word segmentation sequence. The syntactic dependency relations include the syntactic dependency relations between the contexts of each feature word in the word segmentation sequence.
[0314] Part-of-speech (POS) determination unit is used to determine the part-of-speech information of each word in the word segmentation sequence.
[0315] In one alternative embodiment, the apparatus further includes: a feature word labeling unit, configured to, after the feature word determination unit determines at least one feature word and the feature word category of each feature word in the word segmentation sequence, label the feature word in the word segmentation sequence with a category label corresponding to the feature word category of the feature word, thereby obtaining a feature word labeling sequence labeled with feature word category labels;
[0316] Specifically, the semantic dependency determination unit is used to determine the semantic dependency relationship between each word segment in the feature word annotation sequence and to construct a semantic dependency relationship sequence that retains the labeled feature word category labels and the semantic dependency relationship.
[0317] Specifically, this syntactic dependency determination unit is used to determine the syntactic dependency relationship between each word segment in the feature word annotation sequence, and to construct a syntactic dependency relationship sequence that retains the labeled feature word category labels and the syntactic dependency relationship;
[0318] Specifically, the part-of-speech tagging unit is used to perform part-of-speech tagging on each word in the feature word tagging sequence to obtain a part-of-speech tagging sequence with feature word category labels;
[0319] Accordingly, the first feature determination unit is specifically used to determine the grammatical features in the word segmentation sequence based on at least one of the semantic dependency relation sequence, the syntactic dependency relation sequence, and the part-of-speech tagging sequence.
[0320] In another alternative embodiment, the first feature determining unit may include:
[0321] The first sequence mining unit is used to combine semantic dependency sequence samples of multiple training text samples in the training text library to determine at least one semantically frequent sequence that belongs to the subsequence of the semantic dependency sequence and meets the mining conditions. The mining conditions include: conforming to the frequent sequence mining rules, including at least one feature word category label, and not belonging to the subsequence of other mined frequent sequences; the training text library includes training text sets under different sentiment categories.
[0322] The second sequence mining unit is used to combine syntactic dependency sequence samples from multiple training texts in the training text library to determine at least one syntactically frequent sequence that belongs to the subsequence of the syntactic dependency sequence and satisfies the mining condition.
[0323] The third sequence mining unit is used to combine part-of-speech tagging sequence samples from multiple training texts in the training text library to determine at least one frequent part-of-speech sequence that belongs to the subsequence of the part-of-speech tagging sequence and satisfies the mining condition.
[0324] The feature encoding unit is used to determine the encoding features of the word segmentation sequence based on the encoding of at least one of the at least one semantically frequent sequence, the at least one syntactically frequent sequence, and the at least one part-of-speech frequent sequence, and to determine the encoding features as the syntactic features of the word segmentation sequence.
[0325] In another possible implementation, the second feature determining unit includes:
[0326] The character vector determination unit is used to determine the initial character vector of each character in the word segmentation sequence and the initial word segmentation vector of the word to which the character belongs, and to concatenate the initial character vector and the initial word segmentation vector to form the character vector of the character.
[0327] The hybrid vector determination unit is used to construct a word-word hybrid vector for each word in the word segmentation sequence based on the word vectors of each character contained in the word segmentation.
[0328] The position encoding unit is used to determine the position encoding vector of each word in the word segmentation sequence according to the position of the word in the word segmentation sequence.
[0329] The association feature determination unit is used to determine at least one adjacent word in the word segmentation sequence that is adjacent to the feature word, and to determine the context feature vector of the feature word in the word segmentation sequence based on the position encoding vector and word-word mixing vector of each of the at least one adjacent word.
[0330] The sequence feature determination unit is used to combine the context feature vectors of the feature words in the segmented sequence, as well as the word-word mixing vectors and position encoding vectors of each feature word, to determine the sequence feature vector of the segmented sequence.
[0331] In another possible implementation, the category determination unit includes:
[0332] The mutual information calculation subunit is used to calculate, for each sentiment category, the first mutual information between the grammatical features of the word segmentation sequence and the grammatical features of each training text in the training text set under the sentiment category, and the second mutual information between the sequence features of the word segmentation sequence and the sequence features of each training text in the training text set under the sentiment category, and to determine the sum of the first mutual information and the second mutual information as the correlation value between the word segmentation sequence and the sentiment category.
[0333] The category determination subunit is used to determine the sentiment category to which the word segmentation sequence belongs if the correlation value with the word segmentation sequence exceeds a set threshold.
[0334] like Figure 11 The diagram shown is a structural diagram of one implementation of a computer device provided in this application. The mobile terminal may include:
[0335] Memory 1101 is used to store programs;
[0336] The processor 1102 is used to call and execute a program stored in memory, specifically for executing the text sentiment analysis method provided in any of the preceding embodiments.
[0337] Processor 1102 may be a central processing unit (CPU) or an application-specific integrated circuit (ASIC).
[0338] The computer device may also include a communication interface 1103 and a communication bus 1104, wherein the memory 1101, the processor 1102 and the communication interface 1103 communicate with each other through the communication bus 1104.
[0339] This application also provides a readable storage medium storing a computer program, which is loaded and executed by a processor to implement the steps of the above-described text sentiment analysis method. The specific implementation process can be referred to the description of the corresponding part of the above embodiments, and will not be repeated in this embodiment.
[0340] In another aspect, a computer program product includes a computer program / instructions, characterized in that, when the computer program / instructions are executed by a processor, they implement the steps of the text sentiment analysis method as described in any of the above embodiments.
[0341] For example, the computer program / instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations of the above-described text sentiment analysis method or text sentiment analysis device. The specific implementation process can be referred to the description of the corresponding embodiments above, and will not be repeated here.
[0342] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. Furthermore, the features described in the various embodiments of this specification can be substituted or combined with each other, enabling those skilled in the art to implement or use this application. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0343] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that elements inherent to a process, method, article, or apparatus that comprises a list of elements, or elements inherent to such processes, methods, articles, or apparatus, are also included. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0344] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A text sentiment analysis method, characterized in that, include: The text to be analyzed is segmented into words to obtain a segmented word sequence, which includes multiple words in the text that have a sequential order. Determine at least one feature word in the word segmentation sequence and the feature word category of the feature word, wherein the feature word belongs to the plurality of word segments; Determine the contextual grammatical relationships of each feature word in the segmented sequence; Based on the contextual grammatical relationships and feature word categories of each feature word in the segmented sequence, the grammatical features of the segmented sequence are determined; By combining the vectors of each feature word in the segmented sequence, the sequence features of the segmented sequence are determined; Based on the grammatical and sequence features of the word segmentation sequence, as well as the grammatical and sequence features of the training text sets under different sentiment categories, the sentiment category to which the text belongs is determined using a Bayesian model.
2. The method according to claim 1, characterized in that, Determining the contextual grammatical relationship of each feature word in the word segmentation sequence includes one or more of the following: Determine the semantic dependency relationships between each word in the word segmentation sequence, wherein the semantic dependency relationships include the semantic dependency relationships between the contexts of each feature word in the word segmentation sequence; Determine the syntactic dependency relations between each word in the word segmentation sequence, wherein the syntactic dependency relations include the syntactic dependency relations between the contexts of each feature word in the word segmentation sequence; Determine the part-of-speech information of each word in the word segmentation sequence.
3. The method according to claim 2, characterized in that, After determining at least one feature word in the word segmentation sequence and the feature word category of the feature word, the method further includes: In the word segmentation sequence, category labels corresponding to the feature word categories of the feature words are marked for the feature words, resulting in a feature word labeling sequence with feature word category labels; Determining the semantic dependency relationships between the segments in the segmentation sequence includes: Determine the semantic dependency relationships between each word segment in the feature word annotation sequence, and construct a semantic dependency relationship sequence that retains the annotated feature word category labels and the semantic dependency relationships; Determining the syntactic dependency relationships between the segments in the segmentation sequence includes: Determine the syntactic dependency relationships between each word segment in the feature word annotation sequence, and construct a syntactic dependency relationship sequence that retains the annotated feature word category labels and the syntactic dependency relationships; Determining the part-of-speech information of each word in the word segmentation sequence includes: Part-of-speech tagging is performed on each word segment in the feature word tagging sequence to obtain a part-of-speech tagging sequence with feature word category labels; The step of determining the grammatical features of the word segmentation sequence based on the contextual grammatical relationships and feature word categories of each feature word in the segmentation sequence includes: Based on at least one of the semantic dependency relation sequence, the syntactic dependency relation sequence, and the part-of-speech tagging sequence, the grammatical features in the word segmentation sequence are determined.
4. The method according to claim 3, characterized in that, The step of determining the grammatical features in the word segmentation sequence based on at least one of the semantic dependency relation sequence, the syntactic dependency relation sequence, and the part-of-speech tagging sequence includes: By combining semantic dependency sequence samples from multiple training text samples in the training text library, at least one semantically frequent sequence that belongs to the subsequence of the semantic dependency sequence and meets the mining conditions is determined. The mining conditions include: conforming to the frequent sequence mining rules, including at least one feature word category label, and not belonging to the subsequence of other mined frequent sequences; the training text library includes training text sets under different sentiment categories. By combining syntactic dependency sequence samples from multiple training texts in the training text library, at least one syntactically frequent sequence that belongs to the subsequence of the syntactic dependency sequence and satisfies the mining conditions is identified. By combining part-of-speech tagging sequence samples from multiple training texts in the training text library, at least one frequent part-of-speech sequence that belongs to the subsequence of the part-of-speech tagging sequence and satisfies the mining conditions is determined. Based on the encoding of at least one of the at least one semantically frequent sequence, the at least one syntactically frequent sequence, and the at least one part-of-speech frequent sequence, the encoding features of the word segmentation sequence are determined, and the encoding features are determined as the syntactic features of the word segmentation sequence.
5. The method according to claim 1, characterized in that, The step of determining the sequence features of the word segmentation sequence by combining the vectors of each feature word in the word segmentation sequence includes: For each character in the word segmentation sequence, determine the initial character vector of the character and the initial word segmentation vector of the word to which the character belongs, and concatenate the initial character vector and the initial word segmentation vector to form the character vector of the character; For each word in the word segmentation sequence, a word-character hybrid vector is constructed based on the character vectors of each character contained in the word segmentation. For each word in the word segmentation sequence, determine the position encoding vector of the word's location according to its position in the word segmentation sequence; Determine at least one adjacent word in the word segmentation sequence that is adjacent to the feature word, and determine the context feature vector of the feature word in the word segmentation sequence based on the position encoding vector and word-word mixing vector of each of the at least one adjacent word; By combining the context feature vectors of the feature words in the segmented sequence, as well as the word-word hybrid vectors and positional encoding vectors of each feature word, the sequence feature vector of the segmented sequence is determined.
6. The method according to claim 1, characterized in that, The step of determining the sentiment category of the text using a Bayesian model, based on the grammatical and sequence features of the word segmentation sequence and the grammatical and sequence features of the training text sets under different sentiment categories, includes: For each sentiment category, calculate the first mutual information between the grammatical features of the word segmentation sequence and the grammatical features of each training text in the training text set under the sentiment category, and the second mutual information between the sequence features of the word segmentation sequence and the sequence features of each training text in the training text set under the sentiment category. The sum of the first mutual information and the second mutual information is determined as the correlation value between the word segmentation sequence and the sentiment category. The sentiment category to which the word segmentation sequence belongs is determined if the correlation value with the word segmentation sequence exceeds a set threshold.
7. A text sentiment analysis device, characterized in that, include: The word segmentation processing unit is used to segment the text to be analyzed to obtain a word segmentation sequence of the text, which includes multiple words in the text that have a sequential order. A feature word determination unit is used to determine at least one feature word in the word segmentation sequence and the feature word category of the feature word, wherein the feature word belongs to the plurality of word segments; A grammar determination unit is used to determine the contextual grammatical relationships of each feature word in the word segmentation sequence; The first feature determination unit is used to determine the grammatical features of the word segmentation sequence based on the contextual grammatical relationship and feature word category of each feature word in the word segmentation sequence; The second feature determination unit is used to determine the sequence features of the word segmentation sequence by combining the vectors of each feature word in the word segmentation sequence; The category determination unit is used to determine the sentiment category to which the text belongs based on the grammatical and sequence features of the word segmentation sequence, as well as the grammatical and sequence features of the training text sets under different sentiment categories, using a Bayesian model.
8. A computer device, characterized in that, include: A processor and a memory, which are connected via a communication bus; The processor is used to call and execute the program stored in the memory; The memory is used to store a program for implementing the text sentiment analysis method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, It stores a computer program, which is loaded and executed by a processor to implement the text sentiment analysis method as described in any one of claims 1-6.
10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the steps of the text sentiment analysis method according to any one of claims 1-6.
Citation Information
Patent Citations
Classification method and related device
CN111177371A
Text processing method and device, storage medium and electronic equipment
CN113268984A