Sentiment analysis method, electronic device and computer readable storage medium

By segmenting text and connecting it with context, and combining it with a multi-layer self-attention mechanism model for analysis, the problem of ignoring text context in existing technologies is solved, improving the accuracy of sentiment and personality analysis, and is particularly suitable for processing long texts.

CN114912459BActive Publication Date: 2024-12-03AEROSPACE INFORMATION RES INST CAS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210494236.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-07
Publication Date
2024-12-03
Estimated Expiration
2042-05-07

AI Technical Summary

Technical Problem

Existing technologies ignore the contextual relationships between texts when analyzing individual texts, leading to reduced accuracy and reliability in sentiment classification and Big Five personality analysis.

Method used

By segmenting text data into multiple text fragments and connecting each fragment with the preceding and following texts to form a text sequence for feature extraction and classification, a multi-layer self-attention mechanism model is used for sentiment and personality analysis, providing multi-layer textual context information.

Benefits of technology

It improves the accuracy of sentiment analysis and Big Five personality analysis, especially in handling long texts, enhancing the understanding of textual context and the accuracy of personality judgment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114912459B_ABST
    Figure CN114912459B_ABST
Patent Text Reader

Abstract

The present invention discloses a sentiment analysis method, comprising: segmenting original text data to generate N text clauses, where N is a positive integer greater than or equal to 1; splicing each text clause with the preceding clause and the following clause adjacent to the text clause to generate N text sequences, where each text sequence includes the preceding clause, the text clause to be analyzed, and the following clause; extracting features from the vector matrix of the text sequence to obtain a feature matrix of the text clause to be analyzed; classifying the feature matrix to obtain a sentiment classification result of the text clause to be analyzed; and determining the sentiment analysis result of the original text data according to the N classification results. The present invention also discloses an electronic device, a storage medium, and a computer program product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Sentiment Analysis refers to the process of analyzing, processing and extracting emotionally charged subjective texts using natural language processing and text mining techniques. In recent years, sentiment analysis has flourished, and its research has covered many fields such as natural language processing, information retrieval, information extraction, machine learning, ontology, and text mining, and has continued to develop into one of the hot issues in the field of natural language processing and text mining.

[0003] Sentiment classification is an important branch of text sentiment analysis, also known as sentiment tendency analysis. It specifically refers to identifying the sentiment tendency of subjective text in a given text, that is, whether the tendency is positive or negative, or commendatory or derogatory. However, the vast amount of text on the Internet is not all subjective text, but also full of objective text without tendency. Objective text refers to the objective description of things, without emotional color and emotional tendency. Subjective text carries the author's thoughts or opinions on specific things, and carries the author's emotional tendencies such as dislike and preference. The object of sentiment classification is subjective text with emotional tendency, so sentiment classification needs to screen subjective and objective texts first to improve the speed and accuracy of sentiment classification. At present, the research ideas for sentiment tendency analysis of subjective text are mainly divided into semantic sentiment dictionary and deep learning methods.

[0004] Current research on Big Five sentiment analysis only considers this task as a classification task, that is, only analyzing the personality probability of the corresponding character from the text. Existing technology only analyzes a single text separately, which reduces the persuasiveness of the model results. Summary of the invention

[0005] In order to solve at least some of the above and other technical problems in the prior art, according to an embodiment of one aspect of the present invention, a sentiment analysis method is provided, comprising:

[0006] The original text data is segmented to generate N text clauses, where N is a positive integer greater than or equal to 1;

[0007] Splicing each of the text clauses with the preceding clause and the following clause adjacent to the text clause to generate N text sequences, each of the text sequences including the preceding clause, the text clause to be analyzed, and the following clause;

[0008] Performing feature extraction on the vector matrix of the text sequence to obtain a feature matrix of the text clause to be analyzed;

[0009] Classifying the feature matrix to obtain a sentiment classification result of the text clause to be analyzed;

[0010] Determine a sentiment analysis result of the original text data according to the N classification results.

[0011] In some embodiments of the present invention, segmenting the original text data to generate N text clauses includes:

[0012] Perform a Chinese character quantity query on the text clause, and filter out the text clause when the proportion of Chinese characters in the text clause is less than a preset value;

[0013] The original text data is re-segmented and a new text clause is generated.

[0014] In some embodiments of the present invention, segmenting the original text data includes:

[0015] The text data is segmented according to the punctuation marks of the text data.

[0016] In some embodiments of the present invention, extracting features from the vector matrix includes:

[0017] Performing feature analysis on the vector matrix using a feature analysis model to obtain a feature matrix of the text sequence;

[0018] The feature matrices of the preceding clause and the following clause in the feature matrix are filtered out, and only the feature matrix of the text clause to be analyzed is retained.

[0019] In some embodiments of the present invention, classifying the feature matrix includes:

[0020] A sentiment classification model is used to perform sentiment analysis on the feature matrix to obtain a classification result of the text clause to be analyzed.

[0021] In some embodiments of the present invention, the sentiment classification model is composed of multiple autoregressive self-attention mechanism models, and the output classification results contain five categories, including: openness, conscientiousness, extraversion, agreeableness and neuroticism.

[0022] In some embodiments of the present invention, determining the sentiment analysis result of the original text data according to the N classification results includes:

[0023] By performing sentiment polarity analysis on the classification results, sentiment polarity data of the classification results are obtained, wherein the sentiment polarity data includes three categories: positive, neutral and negative;

[0024] Filtering out data that is neutral in the sentiment polarity data;

[0025] The data that is positive and negative in all the sentiment polarity data are integrated to obtain the sentiment analysis result of the text data.

[0026] According to an embodiment of one aspect of the present invention, there is provided an electronic device, including:

[0027] one or more processors; and

[0028] a memory for storing one or more programs,

[0029] When the one or more programs are executed by the one or more processors, the one or more processors implement the above method.

[0030] According to an embodiment of one aspect of the present invention, a computer-readable storage medium is provided, on which executable instructions are stored, and when the instructions are executed by a processor, the processor implements the above method.

[0031] According to an embodiment of one aspect of the present invention, there is provided a computer program product, comprising a computer program, wherein the computer program implements the above method when executed by a processor.

[0032] Through the above sentiment analysis method, the original text data is segmented to obtain text clauses, and each text clause is spliced ​​with the previous clause and the following clause to generate a text sequence. Compared with performing sentiment analysis on each text clause separately, sentiment analysis on the text sequence can better connect with the context, obtain more accurate processing results, and obtain better technical effects. In addition, data analysis by segmenting clauses can also more conveniently process some longer input texts, such as paragraph-level texts. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 A schematic diagram of a process flow of a sentiment analysis method according to an embodiment of the present invention is shown;

[0034] Figure 2 A schematic diagram of a sentiment analysis process according to an embodiment of the present invention is shown;

[0035] Figure 3 Schematically shows a sentiment classification model architecture diagram according to an embodiment of the present invention;

[0036] Figure 4The structure diagram of the sentiment classification model according to an embodiment of the present invention is schematically shown. DETAILED DESCRIPTION

[0037] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.

[0038] But it should be understood that these descriptions are exemplary only, and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, the description of known techniques is omitted to avoid unnecessary confusion of concepts of the present invention.

[0039] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The term "comprising" used herein indicates the existence of features, steps, operations, but does not exclude the existence or addition of one or more other features.

[0040] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0041] In the technical solution of the present invention, the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information involved comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.

[0042] In the technical solution of the present invention, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.

[0043] Personality analysis, as an important aspect of character portrait analysis, is an indispensable task of natural language processing. In the massive data on the Internet, compared with the static task information of a certain person such as age, name, credit attributes, etc., which is easy to obtain, dynamic attributes such as character are often difficult to obtain directly, and natural language processing technology needs to be applied to analyze the character. Traditional Big Five personality analysis usually adopts the method of psychological scales and tests in the form of online or offline questionnaires. The present invention focuses on analysis from published speeches, and realizes fast and efficient auxiliary analysis of personality in the form of active cognitive acquisition.

[0044] The Big Five personality is a model used to describe the overall personality of a natural person. From Allport's pioneering work, to Cattell's proposal of 16 root traits, to the discovery of the Big Five personality, a basic assumption has always been throughout, namely the lexical hypothesis: important aspects of human life will be given words to describe them. Not only that, if something is really important and ubiquitous, it will be given more words to describe it in all languages. Therefore, discovering personality traits from words has become an important way to study personality. Allport took the lead in starting this arduous work. He asked his assistant to accurately count how many words there were in the English dictionary to describe personality differences. The result was 17,953. Then he selected 4,500 from them, but this was obviously still too many. Later, Cattell selected 35 words that he thought were particularly important from these 4,500 words, and conducted factor analysis on them, including 5 major dimensions: openness, conscientiousness, extroversion, agreeableness, emotionality, and 30 small dimensions. The specific manifestations of each personality are as follows:

[0045] Openness: adventurousness, artistic interests, emotionality, imagination, curiosity, and challenge to authority;

[0046] Conscientiousness: achievement-seeking, cautious, responsible, organized, self-disciplined, and competent;

[0047] Extraversion: activity, assertiveness, positive emotions, excitement seeking, enthusiasm, sociability;

[0048] Agreeableness: altruism, obedience, humility, sincerity, sympathy, trust;

[0049] Emotional levels: irritable, anxious, depressed, self-indulgent, self-conscious, fragile.

[0050] The five-factor model of personality has shown wide application value in clinical psychology, health psychology, developmental psychology, occupation, management and industrial psychology. For example, research has found that extroversion, neuroticism, and agreeableness are all related to mental health; extroversion and openness are two important related factors in occupational psychology and industrial psychology; and responsibility is closely related to personnel selection. If these five factors are divided according to high and low scores, multiple distinct personality traits will be formed. John studied the relationship between the Big Five personality and adolescent psychological development and found that adolescents with high openness and high responsibility have excellent academic performance, while adolescents with low responsibility and low agreeableness have more illegal behaviors. Adolescents with high tendency, low agreeableness and low responsibility often have behavioral problems that conflict with the outside world; adolescents with high neuroticism and low responsibility often show problems caused by inner conflicts. Today, the Big Five personality has become the "universal currency in personality psychology." It is the most active personality research topic since the 1990s and is currently one of the most ideal descriptions of people's basic traits.

[0051] It has always been generally believed that when people express themselves through language and text, they will carry some of their own personality traits, which is particularly prominent in diaries or open source speeches. This means that narrative texts such as argumentative essays and expository essays are not prominent. Therefore, with the development of artificial intelligence in natural language, a method of using algorithmic models to reflect the personality of people in speech has been put on the research topic. These existing Big Five personality analysis methods classify this task five times, which not only ignores the potential connection between different personalities, but also only analyzes the personality probability of the corresponding person from the text and lacks the corresponding evidence to support the analysis results. This greatly reduces the persuasiveness of the model results and brings inconvenience to the application of the analysis method.

[0052] Based on this, the present invention proposes a fine-grained Big Five personality sentiment analysis algorithm based on deep learning. It is based on the content of the network as a prediction, manually annotates the personality sentiment polarity and personality tracing reason reflected in each sentence, and constructs a classification model for analyzing five personalities and corresponding evidence from a large amount of text. Specifically, the model consists of a BERT encoder, a contextual Attention module, and five personality decoding classifiers. The corresponding text and its context are represented by a vector rich in semantic information through the BERT encoder, and the semantic connection between the clause and the context is constructed in the contextual Attention module, and finally the classification result of each clause is generated in the five personality decoding classifiers, and the classification result of the clause is used as the basis for the tracing evidence of each personality. The experimental results show that the Big Five personality sentiment analysis model implemented by this technology can give the Big Five personality analysis results of each character and provide tracing evidence based on multiple chapter-level document inputs of multiple target characters.

[0053] There are many sub-fields in text sentiment analysis tasks. According to the granularity of the analysis, it can be subdivided into word or phrase level, sentence level and paragraph level; according to the processed text category, it can also be subdivided into product review sentiment analysis and news review sentiment analysis; according to the research task, it can be subdivided into sub-tasks such as sentiment classification and sentiment extraction.

[0054] In the process of implementing the present disclosure, it is found that the text reflecting personality is often at the chapter level, which places higher requirements on the context information of the model.

[0055] An embodiment of the present invention provides a sentiment analysis method. Figure 1 The flowchart of the sentiment analysis method according to an embodiment of the present invention is schematically shown.

[0056] like Figure 1 As shown, the method includes operations S101 to S105.

[0057] In operation S101, the original text data is segmented to generate N text clauses, where N is a positive integer greater than or equal to 1.

[0058] According to some embodiments of the present invention, the original text data may be chapter-level text data.

[0059] In some embodiments of the present invention, the original text data P is generated by acquiring comment information on the Internet using a crawler algorithm, and the original text data is divided into several clauses according to punctuation marks:

[0060] P={S1,S2,…S i …,S n}; (one)

[0061] Among them, S i represents the i-th clause generated by segmenting the original text data P, and n represents the number of clauses generated by the original text data.

[0062] In operation S102, each text clause is concatenated with the preceding clause and the following clause adjacent to the text clause to generate N text sequences, each of which includes a preceding clause, a text clause to be analyzed, and a following clause.

[0063] In some embodiments of the present invention, after obtaining the clause segmentation results of the original text data, each clause is concatenated with a clause above and a clause below to construct context information, and a new text sequence is generated in the form of "[SEP] previous clause [CLS] clause to be analyzed [SEP] following clause [SEP]". i , the corresponding generated text sequence is as follows:

[0064] S′i =([SEP],S i-1 ,[CLS],S i ,[SEP],S i+1 ,[SEP]); (ii)

[0065] Among them, S′ i Indicates the text sequence to be analyzed, [SEP] indicates the separator, [CLS] indicates the classification marker, S i-1 Indicates the above clause, S i+1 Indicates the following clause.

[0066] In operation S103, feature extraction is performed on the vector matrix of the text sequence to obtain a feature matrix of the text clause to be analyzed.

[0067] In some embodiments of the present invention, the text sequence to be analyzed is processed by using the BERT model, converted from character form to vectorized form, and a vector matrix is ​​generated, which is expressed as follows:

[0068] T i =TokenConvert(S′ i ); (three)

[0069] Among them, T i is the vector matrix of the text clause to be analyzed, T i ∈R n×d , R represents the matrix, n is T i The sequence length is , and d is the feature dimension.

[0070] In some embodiments of the present invention, multiple autoregressive Transformer models are used to extract features from the vector matrix to obtain a feature matrix of the text clause to be analyzed, which is expressed as follows:

[0071]

[0072]

[0073] in, is the feature matrix of the text sequence to be analyzed, and m is the level of the Transformer model.

[0074] In some embodiments of the present invention, from the feature matrix of the text sequence to be analyzed Filter out the feature matrix of the previous clause and the following clause, and only keep the feature matrix corresponding to the [CLS] position of the text clause to be analyzed

[0075] In operation S104, the feature matrix is ​​classified to obtain a sentiment classification result of the text clause to be analyzed.

[0076] In some embodiments of the present invention, the feature matrix is ​​classified by using a trainable classifier, and the formula is expressed as:

[0077]

[0078] Among them, W i c is the trainable classifier weight matrix, W i c ∈R d×3 , including three sentiment polarities: positive, neutral and negative, V i c is the sentiment classification result of the text clause to be analyzed, V i c ∈R 1×3 , c indicates that the emotion classification results contain five categories, including: openness, conscientiousness, extraversion, agreeableness and neuroticism.

[0079] In operation S105 , a sentiment analysis result of the original text data is determined according to the N classification results.

[0080] In some embodiments of the present invention, the sentiment classification results of all text clauses to be analyzed with neutral sentiment polarity are filtered out, and only the sentiment classification results with positive or negative sentiment polarity are retained, and the remaining sentiment classification results are combined to obtain the sentiment analysis result of the original text data.

[0081] Through the above-mentioned sentiment analysis method, the original text data is segmented to obtain text clauses, and each text clause is spliced ​​with the previous clause and the following clause to generate a text sequence. Compared with performing sentiment analysis on each text clause separately, sentiment analysis on the text sequence can better connect with the context, obtain more accurate processing results, and achieve better technical effects. In addition, data analysis by segmenting clauses can also more conveniently process some longer input texts, such as paragraph-level texts, and model the semantic connection between clauses and their contexts in the model, thereby enhancing the accuracy of personality judgment.

[0082] Figure 2 The following is a schematic diagram of a sentiment analysis process according to an embodiment of the present invention.

[0083] In some other embodiments of the present invention, the sentiment analysis process is as follows: Figure 2 As shown, taking a piece of data crawled by a crawler as an example, the uncleaned data P is as follows:

[0084] "Earlier, several staff members in #a certain district requested the Housing Department to conduct a comprehensive inspection of the sewage drains in public housing estates in the district to ensure that the drains in public housing estates will not become a channel for the spread of the virus. The relevant inspection work has been carried out in a certain estate today, starting from a certain building. Engineering staff will go to the residents' homes and ask them to let them enter the houses to inspect the drains. Mr. XX reminds everyone that before allowing personnel to enter the houses, their identities must be confirmed and their work permits checked. If there is any doubt, you can call the Housing Department to confirm their identities. Residents who missed the engineering staff's visit can take the initiative to contact the Housing Department to make an appointment for inspection. #a certain district #a certain estate #dedicated to the residents #inspecting the drains".

[0085] In some other embodiments of the present invention, since the input text is too long, in order to facilitate calculation, the present invention divides the text with a period ".", and the clauses {S1, S2, ..., S n The segmentation results are as follows:

[0086] "Earlier, several staff members in a certain district requested the Housing Department to conduct a comprehensive inspection of the sewage drains in public housing estates in the district to ensure that the drains in public housing estates will not become a channel for the spread of the virus."

[0087] "Relevant inspection work has been carried out in a certain estate today, starting with a certain building. Engineering personnel will go to the residents' homes and ask them to let them enter the houses to inspect the channels."

[0088] "Mr. So-and-so would like to remind everyone that before letting people into your house, you must confirm their identity and check their work ID. If you are in doubt, you can call the Housing Department to confirm their identity."

[0089] "Residents who missed the engineering staff's visit can take the initiative to contact the Housing Department for scheduled inspections."

[0090] ·"#a certain district #a certain village #dedicated to serving the villagers #inspection channels".

[0091] In other embodiments of the present invention, by checking the segmented data text, clauses with less than 40% Chinese characters and topic texts with "#" are filtered out.

[0092] In some other embodiments of the present invention, a context clause is added to each segmented clause, and symbols are used to mark the clauses. i “Mr. So-and-so reminds everyone that before letting people into the house, you must confirm their identity and check their work permit. If you have any doubts, you can call the Housing Department to confirm their identity.”, Spliced ​​text sequence S′ i as follows:

[0093] [SEP]Related inspections have been carried out in a certain estate today, starting from a certain building. Engineering personnel will go to residents’ homes and ask them to let them in to check the channels. [CLS]Someone reminds everyone that before letting personnel in, they must confirm their identities and check their work permits. If in doubt, you can call the Housing Department to confirm their identities. [SEP]Residents who missed the engineering personnel’s visit can take the initiative to contact the Housing Department to schedule an inspection. [SEP]

[0094] In some other embodiments of the present invention, the text sequence is converted into a vector matrix T according to the vocabulary of "bert-base-chinese" i , as shown below:

[0095] T i =[102,4685,1068,3466,3389,2339,868,8024,791,1921,2347,5307,1762,2506,6004,6931,1079,2458,2245,8024,4507,7032,3727,3517,2458,1993,976,6629,8024,2339,4923,782,144 7,833,677,7305,6206,3724,2233,3696,6375,800,812,1057,2238,3466,3389,3940,6887,511,101,4119,1528,2990,2990,1920,2157,8024,6375,782,1447,1057,2238,1184,8024,2553,7 557,4802,6371,800,812,4638,6716,819,8024,3466,3389,800,812,4638,2339,868,6395,8024,1963,3300,2577,4542,8024,1377,809,5636,4510,2791,2238,5392,8024,4802,6371,800 ,812,4638,6716,819,511,102,7231,6814,749,2339,4923,782,1447,677,7305,4638,2233,3696,8024,1377,809,712,1220,5468,5317,2791,2238,5392,5276,3309,3466,3389,511,102].

[0096] In some other embodiments of the present invention, the vector matrix T i Input to the BERT model vector matrix Ti Perform feature extraction to obtain the feature matrix H i , as shown below:

[0097]

[0098] Figure 3 The following schematically shows the architecture diagram of a sentiment classification model according to an embodiment of the present invention.

[0099] In some other embodiments of the present invention, the sentiment classification model architecture is as follows: Figure 3 As shown, from the feature matrix H i Take out the vector matrix corresponding to the [CLS] position and input it into the classifier to obtain the classification result of the text to be analyzed:

[0100] V i 0 =(0.952,0.045,0.008);

[0101] V i 1 =(0.052,0.983,0.026);

[0102] V i 2 =(0.782,0.133,0.255);

[0103] V i 3 =(0.665,0.238,0.022);

[0104] V i 4 =(0.973,0.445,0.308);

[0105] Among them, in (x, y, z), x means that the clause to be analyzed does not have this personality tendency, y means that the clause to be analyzed shows the positive tendency of personality, and z means that the clause to be analyzed shows the negative tendency of personality.

[0106] In other embodiments of the present invention, V i 0 Indicates openness, V i 1 Indicates Conscientiousness, V i 2 V stands for Extraversion. i 3 V stands for Agreeableness. i 4Indicates neuroticism.

[0107] In some other embodiments of the present invention, only V i 1 The y in the test is 0.983, which is greater than x and z, indicating a responsible personality. It is worth noting that the above scores have not been normalized, and their sum is not 1.

[0108] In other embodiments of the present invention, the classification result only represents the classification result of the clause to be analyzed, and the analysis result of the entire chapter is a combination of the analysis results of all clauses. If a certain personality is not judged in all clauses, then all emotional polarities of the personality are 0.

[0109] In other embodiments of the present invention, the sentiment analysis results of the original text data are obtained by synthesizing the classification results of all clauses:

[0110] {'DCSeanMockoffice,Chessa Village Service Association-XXX Staff Office':

[0111] {'Openness':

[0112] 'Reason':{'Positive':[],'Negative':[]},

[0113] 'Polarity':{'Neural':0,'Positive':0,'Negative':0}},

[0114] 'Conscientiousness':

[0115] 'Reason':{'Positive':['Earlier, several staff members in #a certain district requested the Housing Department to conduct a comprehensive inspection of the sewage drains in the public housing estates in the district to ensure that the drains in public housing estates will not become a channel for the spread of the virus. ','The relevant inspection work has been carried out in a certain estate today, starting from a certain building. The engineering staff will go to the residents and ask them to let them enter the house to inspect the drains. ','Residents who missed the engineering staff's visit can take the initiative to contact the Housing Department to make an appointment for inspection. ','#a certain district#a certain estate#full heart for the residents#inspect the drains'],'Negative':[]},

[0116] 'Polarity': {'Neural': 0.009109260758365111, 'Positive':0.9882133357602432, 'Negative':0.00267740348139168}},

[0117] 'Extraversion':{

[0118] 'Reason':{'Positive':[],'Negative':[]},

[0119] 'Polarity':{'Neural':0,'Positive':0,'Negative':0}},

[0120] 'Agreeableness':

[0121] 'Reason':{'Positive':['XXX would like to remind everyone that before letting people into the house, you must confirm their identity and check their work permit. If you have any doubts, you can call the Housing Department to confirm their identity. '],'Negative':[]},

[0122] 'Polarity': {'Neural': 0.00044732769189374084, 'Positive':0.9995195513316687,'Negative':3.31209764375339e-05}},

[0123] 'Neuroticism':

[0124] 'Reason':{'Positive':[],'Negative':[]},

[0125] 'Polarity':{'Neural':0,'Positive':0,'Negative':0}}}}.

[0126] In other embodiments of the present invention, in the sentiment analysis results of the original text data, for the target "DC Sean Mock Office, Chessa Village Service Association - XX Personnel Office", the original text data only shows positive Conscientiousness personality and positive Agreeableness personality.

[0127] In some embodiments of the present invention, segmenting the original text data to generate N text clauses includes: performing a Chinese character number query on the text clause, filtering out the text clause when the proportion of Chinese characters in the text clause is less than a preset value; and re-segmenting the original text data and generating new text clauses. Usually, when the number of Chinese characters in a text clause is less than 40%, the text clause is filtered out, and the original text data is re-segmented until the number of Chinese characters reaches more than 40%.

[0128] In some embodiments of the present invention, segmenting the original text data includes segmenting the text data according to punctuation marks of the text data, generally by period, or by comma, semicolon, or other symbols.

[0129] In some embodiments of the present invention, feature extraction of a vector matrix includes: using a feature analysis model to perform feature analysis on the vector matrix to obtain a feature matrix of a text sequence; filtering out the feature matrices of the preceding clause and the following clause in the feature matrix, and retaining only the feature matrix of the text clause to be analyzed. During feature extraction, the context clause can modify the features of the clause to be analyzed to achieve a better feature extraction effect, and after the extraction is completed, the feature matrix of the context clause is filtered out to ensure that the feature matrix data of the clause to be analyzed is not contaminated.

[0130] In some embodiments of the present invention, classifying the feature matrix includes: using a sentiment classification model to perform sentiment analysis on the feature matrix to obtain a classification result of the text clause to be analyzed. The sentiment classification model is composed of multiple autoregressive Transformer models, and the multiple Transformer models are stacked together to process the input feature matrix.

[0131] In some embodiments of the present invention, the number of Transformers is 12, a 12-head attention mechanism is used, and the hidden layer dimension is 768.

[0132] In some embodiments of the present invention, the maximum output sequence length of the sentiment classification model is 256, and the excess will be split and discarded.

[0133] In some embodiments of the present invention, the sentiment classification model is optimized using the AdamW optimizer, with a training batch size of 8 and a total of 100 training rounds.

[0134] In some embodiments of the present invention, the sentiment classification model is composed of multiple autoregressive self-attention mechanism models, and the output classification results include five categories, including: openness, conscientiousness, extraversion, agreeableness and neuroticism. The Big Five personality is a model used to describe the overall personality of a natural person. The five personality factors are the most core and stable of all personalities and are called the "Big Five", namely extraversion (good at talking, social interaction and self-confidence), agreeableness (easy-going, cooperative and trustworthy), conscientiousness (sense of responsibility for work, reliability, perseverance and achievement orientation), neuroticism (calmness, enthusiasm and security) and openness (curious, intelligent, imaginative and creative, artistic). Based on these five core personalities, the Big Five personality analysis is defined as: for a given natural person and its sufficient speech, the analysis method needs to give the personality characteristics of the corresponding person for each personality. An embodiment of the present invention is a fine-grained Big Five personality sentiment analysis and tracing algorithm based on deep learning. While analyzing the personality tendency of a given person's speech, it provides tracing evidence on which the analysis result depends, providing more accurate personality information of the target person. The model is built based on a bidirectional Transformer decoder, and the extraction task corresponding to the tracing is formalized as a classification task for clauses by dividing the original text into clauses. In addition, for paragraph-level text input, multiple clauses are input into the model at a time to supplement the contextual information corresponding to the clauses. The model can analyze the Big Five personality of the corresponding target based on multiple texts of a given target, and provide tracing evidence for each personality.

[0135] In some embodiments of the present invention, determining the sentiment analysis result of the original text data according to N classification results includes: performing sentiment polarity analysis on the classification results to obtain sentiment polarity data of the classification results, where the sentiment polarity data includes three categories: positive, neutral, and negative; filtering out data that is neutral in the sentiment polarity data; and synthesizing data that is positive and negative in all the sentiment polarity data to obtain the sentiment analysis result of the text data. Among them, data with neutral sentiment polarity does not show any sentiment tendency, has no analysis value, and can be filtered out.

[0136] Figure 4 The structure diagram of the sentiment classification model according to an embodiment of the present invention is schematically shown.

[0137] In some embodiments of the present invention, Figure 4As shown in the figure, the sentiment classification model consists of a BERT encoder, a contextual Attention module, and five personality decoding classifiers. The corresponding text and its context are vectorized through the BERT encoder to generate semantic information, and the semantic connection between the clause and the context is constructed in the contextual Attention module. Finally, the classification result of each clause is generated in the five personality decoding classifiers, and the classification result of the clause is used as the source evidence of each personality. After obtaining the clause segmentation result of the chapter-level text, for the subsequent personality analysis of each clause, the embodiment of the present invention uses the clause S i 、its above and the following as input.

[0138] In some embodiments of the present invention, BERT is used as a clause classifier to classify each generated clause. Before inputting the model clause, the clause, the corresponding preceding context, and the corresponding following context need to be converted from character form to vector form:

[0139] T i =TokenConvert(S i ); (seven)

[0140]

[0141]

[0142] Where T i ∈R n , n,n above and n below Representative Clause S i , above And below The length of the sequence.

[0143] In some embodiments of the present invention, the formula of the BERT decoder is as follows:

[0144] H i =BERT(T i ); (ten)

[0145]

[0146]

[0147] Among them, H i ∈R n×d , However, directly classifying each clause misses the rich context information in the character's speech. To this end, the embodiment of the present invention designs a context Attention module to construct the context information of the clause, and the formula is as follows:

[0148] u i =FFNN(H i ); (Thirteen)

[0149]

[0150]

[0151] in, Represents vector concatenation.

[0152] In some embodiments of the present invention, five classifiers are used to decode the features output by the contextual Attention module for five different personalities, and the formula is as follows:

[0153]

[0154] Among them, W i c ∈R d×3 represents the trainable classifier weight matrix, Representation clause H i The characteristic matrix corresponding to the [CLS] position in the middle.

[0155] In some embodiments of the present invention, a contextual Attention module is designed to construct the contextual information of the clause. First, the calculation formula of the above attention mechanism is as follows:

[0156] u i =FFNN(h i )

[0157]

[0158]

[0159] where h i ∈H i In order to share information between the attention mechanisms of the context and reduce the number of parameters of the algorithm, in the following attention mechanism, the present invention shares the parameters of the feedforward neural network of the above attention mechanism. The operation of the following attention mechanism is as follows:

[0160]

[0161]

[0162] Next, in order to decode the five personalities separately, the present invention uses five classifiers to classify the five personalities respectively, and the decoding uses the features spliced ​​after the output of the above and below attention mechanisms:

[0163]

[0164]

[0165]

[0166]

[0167]

[0168] Where W · ∈R d×3 is the trainable classifier weight matrix, Represents the concatenation of the previous attention and the following attention output, V i O ∈R 1×3 Indicates the result of openness analysis; V i C ∈R 1×3 Indicates the result of Conscientiousness analysis; V i E ∈R 1×3 V stands for Extraversion analysis result; i A ∈R 1×3 Represents the result of agreeableness analysis; V i N ∈R 1×3 Indicates the results of Neuroticism analysis.

[0169] In some embodiments of the invention, the loss function is defined as follows:

[0170]

[0171] in Represents the true result of a certain personality corresponding to the i-th clause.

[0172] In some other embodiments of the present invention, taking English text as an example, first, for the following English text:

[0173] "我需要多出去走走。我一直都在工作和上学,几乎没什么时间留给自己。我的父母都生病了,在家照顾他们本来就在我的计划之中。做我现在做的这些事会让人变得更坚强,但我想知道正常生活会是什么样。想知道自私一点或者甚至不自私,只是不要有那么多人依赖我会是什么样。我想认识男孩子,出去玩玩,但我太害羞了。我觉得自己长得还行,但这样够吗?我22岁了,有个男生跟我说了些话,让我很生气。我的很多朋友非但不为我高兴,还很消极。我们没有在约会,我从来没约会过,难道要一直单身下去吗。我想念史蒂文,但我应该想吗?他可能被派往海外打仗了。我只认识他几天,然后他就接到了出发的命令。他给了我他的电话号码,但我不能给他打电话。"

[0174] In some other embodiments of the present invention, the text is segmented into multiple clauses {S1, S2, …, S n} by using the full stop "。" as the delimiter:

[0175] ·I need to get out more.

[0176] ·I work all the time and go to school,and leaves so little timeforme.,

[0177] ·Both of my parents a sick and living at home was kind of alreadyplaned.It makes you a stronger person to get stuck doing the stuff I do,but Iwonder what it would be like to be normal.

[0178] ·What it would be like to be selfish or not even selfish,but to nothave so many people relie on me.

[0179] ·I want to meet boys and just hang out,but I'm so shy.I think I lookok,but is ok enough?

[0180] ·I'm 22years old and one guy has approched me with saying somethingto make me mad.

[0181] ·Alot of my frinds insted of being happy for me are so negative.

[0182] ·We are no dating,I've never been on a date,so should be single forever.

[0183] ·I miss steven,but should I he's been sent overseas probably tofight.

[0184] ·I only knew him for a few days and then he got his orders toleave.He gave me his phone number,but I can't call him.

[0185] In other embodiments of the present invention, unlike Chinese text that needs to be removed from the algorithm, Chinese characters rarely appear in English personality analysis, so there is no need to remove the Chinese text, and then mark the beginning and end of the sequence for each clause. For example:

[0186] "I work all the time and go to school, and leaves so little timeforme."

[0187] The sequence after splicing:

[0188] "[CLS]I work all the time and go to school,and leaves so little timeforme.[SEP]"

[0189] In some other embodiments of the present invention, the vector sequence converted using the BERT vocabulary is as follows:

[0190] 101,4119,1528,2990,2990,1920,2157,8024,6375,782,1447,1057,2238,1184,8024,2553,7557,4802,6371,800,812,819,8024,3466,3389,800,812,4638,2339,868,6395,8024,1963,33 00,2577,4542,8024,1377,809,5636,4510,2791,2238,1184,8024,2553,7557,4802,6371,800,812,4638,6716,819,2791,2238,5392,8024,4802,6371,800,812,4638,6716,819,511,102.

[0191] In some other embodiments of the present invention, after the numerical sequence passes through the model, the corresponding H i ∈R m×d The features are as follows:

[0192]

[0193] In some other embodiments of the present invention, it is necessary to extract the vector corresponding to the [CLS] position and input it into five categories, and the results are as follows:

[0194] V i O =(0.008,0.045,0.952)

[0195] V i C =(0.026,0.025,0.983)

[0196] V i E =(0.255,0.133,0.895)

[0197] V i A =(0.022,0.021,0.665)

[0198] V i N =(0.993,0.012,0.203)

[0199] In (x, y, z), x represents the absence of the personality tendency, y represents the clause showing a positive personality tendency, and z represents the clause showing a negative personality tendency. For the clause given in the previous article:

[0200] I work all the time and go to school,and leaves so little time forme.

[0201] The algorithm determined that all personality traits except neuroticism and agreeableness were present.

[0202] In some other embodiments of the present invention, the English text prediction results are shown as follows:

[0203]

[0204]

[0205]

[0206] According to an embodiment of one aspect of the present invention, there is provided an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned method.

[0207] According to an embodiment of one aspect of the present invention, a computer-readable storage medium is provided, on which executable instructions are stored, and when the instructions are executed by a processor, the processor implements the above method.

[0208] According to an embodiment of one aspect of the present invention, there is provided a computer program product, including a computer program, and the computer program implements the above method when executed by a processor.

[0209] So far, the embodiments of the present invention have been described in detail in conjunction with the accompanying drawings. It should be noted that the implementation methods not shown or described in the drawings or the body of the specification are all forms known to ordinary technicians in the relevant technical field and are not described in detail. In addition, the above definitions of each component are not limited to the various specific structures, shapes or methods mentioned in the embodiments, and ordinary technicians in the field can simply change or replace them.

[0210] It should also be noted that, in the specific embodiments of the present invention, unless otherwise indicated, the numerical parameters in this specification and the attached claims are approximate values ​​and can be changed according to the desired characteristics obtained through the content of the present invention. Specifically, all numbers used in the specification and claims to express the size, range conditions, etc. of the composition should be understood to be modified by the term "about" in all cases. In general, the meaning of the expression is to include a change of ±10% in some embodiments, a change of ±5% in some embodiments, a change of ±1% in some embodiments, and a change of ±0.5% in some embodiments by a specific number.

[0211] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present invention may be combined and / or combined in various ways, even if such combinations and / or combinations are not explicitly described in the present invention. In particular, the features described in the various embodiments and / or claims of the present invention may be combined and / or combined in various ways without departing from the spirit and teachings of the present invention. All of these combinations and / or combinations fall within the scope of the present invention.

[0212] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A sentiment analysis method, comprising: The original text data is segmented to generate N text clauses, where N is a positive integer greater than or equal to 1; Splicing each of the text clauses with the preceding clause and the following clause adjacent to the text clause to generate N text sequences, each of the text sequences including the preceding clause, the text clause to be analyzed, and the following clause; Performing feature extraction on the vector matrix of the text sequence to obtain a feature matrix of the text clause to be analyzed; Classifying the feature matrix to obtain a sentiment classification result of the text clause to be analyzed; Determine a sentiment analysis result of the original text data according to the N classification results; Wherein, extracting features from the vector matrix includes: Performing feature analysis on the vector matrix using a feature analysis model to obtain a feature matrix of the text sequence; The feature matrices of the preceding clause and the following clause in the feature matrix are filtered out, and only the feature matrix of the text clause to be analyzed is retained.

2. The sentiment analysis method according to claim 1, wherein: The original text data is segmented to generate N text clauses including: Perform a Chinese character quantity query on the text clause, and filter out the text clause when the proportion of Chinese characters in the text clause is less than a preset value; The original text data is re-segmented and a new text clause is generated.

3. The sentiment analysis method according to claim 1, wherein: The segmentation process of the original text data includes: The text data is segmented according to the punctuation marks of the text data.

4. The sentiment analysis method according to claim 1, wherein: Classifying the feature matrix includes: A sentiment classification model is used to perform sentiment analysis on the feature matrix to obtain a classification result of the text clause to be analyzed.

5. The sentiment analysis method according to claim 4, wherein: The sentiment classification model is composed of multiple autoregressive self-attention mechanism models, and the output classification results contain five categories, including: openness, conscientiousness, extroversion, agreeableness and neuroticism.

6. The sentiment analysis method according to claim 1, wherein: Determining the sentiment analysis result of the original text data according to the N classification results includes: By performing sentiment polarity analysis on the classification results, sentiment polarity data of the classification results are obtained, wherein the sentiment polarity data includes three categories: positive, neutral and negative; Filtering out data that is neutral in the sentiment polarity data; The data that is positive and negative in all the sentiment polarity data are integrated to obtain the sentiment analysis result of the text data.

7. An electronic device comprising: one or more processors; as well as a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

8. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method according to any one of claims 1 to 6.

9. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.