A text review topic sentiment analysis method, device and equipment

By using TF-IDF and SO-PPMI algorithms to select sentiment seed words and combining them with the WLDA model, a museum-specific sentiment dictionary was constructed. This solved the problem of accuracy in sentiment analysis of museum reviews and enabled precise analysis of visitor emotions and problem identification.

CN119046463BActive Publication Date: 2026-06-02NAT UNIV OF DEFENSE TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NAT UNIV OF DEFENSE TECH
Filing Date
2024-08-23
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing text commentary sentiment analysis methods lack the ability to extract domain-specific keywords and analyze sentiment trends in the museum field, resulting in inaccurate analysis results that fail to reflect visitors' true emotions and needs.

Method used

The TF-IDF algorithm is used to rank the importance of the vocabulary set, and seed words with positive and negative sentiment are selected. The SO-PPMI algorithm is combined to select target words, and a weighted LDA model (WLDA) is constructed to conduct topic analysis. The sentiment lexicon is used to determine the sentiment tendency of the topic.

Benefits of technology

This improves the accuracy and comprehensibility of sentiment analysis of museum reviews, enabling better extraction of visitors' emotional attitudes and satisfaction, and identification of potential problems and improvement suggestions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046463B_ABST
    Figure CN119046463B_ABST
Patent Text Reader

Abstract

The application provides a text review subject sentiment analysis method, device and equipment, which comprises the following steps: preprocessing obtained review data about a museum to obtain a vocabulary set; performing importance sorting on the vocabulary in the vocabulary set based on a TF-IDF algorithm; screening first and second emotional seed words based on the sorting result; selecting target words with a required similarity to the emotional seed words from the vocabulary set based on a SO-PPMI algorithm; forming an emotional dictionary based on the target words and a general emotional dictionary; determining the weight of each word based on the similarity between each word and each emotional seed word recorded in the emotional dictionary; constructing a WLDA model based on the weight and an LDA model, and determining the subject words corresponding to each subject based on the model; and determining the emotional tendency of each subject based on the subject, the subject words and the emotional dictionary. The method can quickly and accurately perform sentiment analysis on museum reviews.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of sentiment analysis technology, specifically relating to a method, apparatus, and device for sentiment analysis of text comment topics. Background Technology

[0002] Currently, mainstream methods in topic sentiment analysis based on commentary texts include text clustering, subtle topic analysis, and Latent Dirichlet Allocation (LDA). LDA is a generative probabilistic model that assumes text is generated from a mixture of latent topics, with each topic treated as a distribution of a set of words to identify topics in the text set. However, LDA assumes that all words in the text contribute equally to the topic, i.e., they have the same weight, which contradicts reality. Therefore, weighted LDA is proposed, which introduces a weight for each word to reflect its importance in topic identification. Furthermore, word weights typically rely on corpus-based statistical information, requiring the construction of a fusion sentiment lexicon based on the museum domain. This method filters sentiment words with high SO-PPMI values ​​from the museum corpus and constructs a fusion sentiment lexicon together with a general sentiment lexicon, calculating word weights accordingly. The resulting topic sentiment analysis method has two advantages: firstly, a domain-specific sentiment lexicon more accurately reflects the topic and sentiment of museum reviews, effectively filtering out noise from general vocabulary and irrelevant words, thus improving the applicability and accuracy of topic extraction; secondly, the domain-specific vocabulary set makes the model pay more attention to words expressing sentiment and opinions in museum reviews, making its output easier to understand and interpret.

[0003] With the rapid development of the cultural tourism market, the public's enthusiasm for museum tourism is high; however, some museums suffer from homogenization and a lack of diversity in public cultural services, necessitating improvements to the museum system. Visitor reviews on online platforms genuinely reflect visitors' experiences and emotions, highlighting key factors influencing their feelings towards museums. This is crucial for museums to further enhance their public services based on their unique characteristics. Currently, text-based thematic sentiment analysis methods are mature; however, for museum visitor reviews, there is a lack of extraction of domain-specific keywords and analysis and application of sentiment analysis. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a method, apparatus and equipment for thematic sentiment analysis of text reviews that can perform rapid and accurate sentiment analysis of museum reviews.

[0005] The present invention includes providing a method for sentiment analysis of text comments, comprising:

[0006] The obtained review data about the museum was preprocessed to obtain a vocabulary set;

[0007] The words in the vocabulary set are ranked by importance based on the TF-IDF algorithm;

[0008] Based on the ranking results, the first and second sentiment seed words that can clearly express positive and negative sentiment tendencies were selected;

[0009] Based on the SO-PPMI algorithm, target words with a first similarity to the first sentiment seed word or a second similarity to the second sentiment seed word are selected from the vocabulary set. The first similarity is any value within a first threshold range, and the second similarity is any value within a second threshold range. Different target words have different first or second similarities.

[0010] The target vocabulary is integrated with a general sentiment dictionary to form a sentiment dictionary for museum reviews;

[0011] The weight of a word is determined based on the similarity between each word in the vocabulary set and each sentiment seed word recorded in the sentiment dictionary;

[0012] Based on the weights and LDA model, a WLDA model is constructed, and based on the WLDA model, the topic to which each word belongs and the influence of each word on its topic are learned, thereby determining the topic words corresponding to each topic. The topics are related to the museum's commentary direction.

[0013] The sentiment tendency of each topic is determined based on the stated topic, the keywords, and the sentiment dictionary.

[0014] In some embodiments, the preprocessing of the obtained museum review data to obtain a vocabulary set includes:

[0015] The obtained museum review data is converted into a word vector sequence;

[0016] The word vector sequence is processed by word segmentation, part-of-speech tagging, and stop word removal to obtain the vocabulary set.

[0017] In some embodiments, ranking the words in the vocabulary set based on the TF-IDF algorithm includes:

[0018] The term frequency and reverse file frequency of each word in the vocabulary set are calculated based on the TF-IDF algorithm;

[0019] The TF-IDF weight values ​​of the corresponding words are calculated based on the word frequency and the reverse file frequency.

[0020] The importance of each word is ranked based on its TF-IDF weight value.

[0021] In some embodiments, the step of filtering based on the ranking results to obtain the first and second sentiment seed words that can clearly express positive and negative sentiment tendencies includes:

[0022] The top n candidate words are determined based on the ranking results;

[0023] Based on the candidate vocabulary screening, the first and second sentiment seed words are determined.

[0024] In some embodiments, the selection of target words from the vocabulary set based on the SO-PPMI algorithm that have a first similarity to the first sentiment seed word or a second similarity to the second sentiment seed word includes:

[0025] Based on the first sentiment seed word, the second sentiment seed word, and the vocabulary set, the cross-value of each corresponding word is calculated and determined:

[0026]

[0027] in, Words that represent the seeds of emotion It is the probability that the word to be tested will appear together with any sentiment seed word. and These represent the probabilities of the word to be tested and the sentiment seed word appearing, respectively. It is the positive cross-information between the word to be tested and the sentiment seed word; all negative cross-information is set to 0.

[0028] Calculate the average cross value of each word with the first sentiment seed word and the second sentiment seed word respectively;

[0029] Based on the average cross-value, the first sentiment seed word, and the second sentiment seed word, the semantic tendency of each test word is calculated and determined. The semantic tendency can characterize the similarity between each test word and its corresponding sentiment seed word.

[0030]

[0031] in, and These represent the number of positive and negative seed words, respectively.

[0032] In some embodiments, the step of constructing a WLDA model based on the weights and the LDA model, and learning the topic to which each word belongs and the influence of each word on its topic based on the WLDA model, thereby determining the topic words corresponding to each topic, includes:

[0033] Construct a WLDA model based on the aforementioned weights and LDA model;

[0034] Determine the topic of the comments about the museum, with each piece of comment data corresponding to a single comment topic;

[0035] Under the WLDA model, Gibbs sampling is performed on the comment topics;

[0036] Based on the Gibbs sampling results, the latent topic distribution value and latent word distribution value of the WLDA model are estimated and determined. The latent topic distribution value and latent word distribution value represent the probability that each test word is assigned to each comment topic.

[0037] The vocabulary belonging to each comment topic is determined based on the implicit topic distribution value and the implicit vocabulary distribution value;

[0038] The topic words for each comment topic are determined by filtering based on the implicit word distribution values ​​of the words belonging to each comment topic.

[0039] In some embodiments, the method further includes:

[0040] The perplexity of the vocabulary set is calculated based on the comment data;

[0041] The topic variance of each topic is calculated based on the divergence algorithm, and the topic variance is used to determine topic similarity.

[0042] Based on the perplexity and topic similarity, a perplexity-topic variance index is calculated and determined, and the number of LDA models is determined based on the perplexity-topic variance index, with each topic corresponding to one LDA model:

[0043]

[0044] Among them, the The perplexity-topic variance index, the For the degree of confusion, the stated The variance is the subject matter variance.

[0045] In some embodiments, determining the sentiment tendency of each topic based on the topic, topic terms, and sentiment dictionary includes:

[0046] For each of the aforementioned topics, each topic word belonging to that topic is matched one by one with the words in the sentiment dictionary;

[0047] The number of positive and negative keywords is counted based on the matching results;

[0048] The sentiment tendency of the corresponding topic is determined based on the direction to which the topic with the most positive and negative keywords belongs.

[0049] Another embodiment of the present invention also provides a text comment topic sentiment analysis device, comprising:

[0050] The preprocessing module is used to preprocess the obtained review data about the museum to obtain a vocabulary set;

[0051] The sorting module is used to sort the words in the vocabulary set by importance based on the TF-IDF algorithm;

[0052] The filtering module is used to filter the sorting results to obtain the first and second sentiment seed words that can clearly express positive and negative sentiment tendencies;

[0053] The selection module is used to select target words from the vocabulary set that have a first similarity with the first sentiment seed word or a second similarity with the second sentiment seed word according to the SO-PPMI algorithm. The first similarity is any value within a first threshold range, and the second similarity is any value within a second threshold range. Different target words have different first similarity or second similarity.

[0054] The fusion module is used to merge the target vocabulary with a general sentiment dictionary to form a sentiment dictionary corresponding to museum reviews;

[0055] The first determining module is used to determine the weight of each word based on the similarity between each word in the vocabulary set and each sentiment seed word recorded in the sentiment dictionary;

[0056] The construction module is used to construct a WLDA model based on the weights and the LDA model, and learn the topic to which each word belongs and the influence of each word on its topic based on the WLDA model, thereby determining the topic words corresponding to each topic, wherein the topic is related to the museum's commentary direction;

[0057] The second determining module is used to determine the sentiment tendency of each topic based on the topic, topic words, and sentiment dictionary.

[0058] Another embodiment of the present invention also provides an electronic device, characterized in that it includes:

[0059] At least one processor; and,

[0060] A memory communicatively connected to the at least one processor; wherein,

[0061] The memory stores instructions that can be executed by the at least one processor to implement the text comment topic sentiment analysis method as described in any one of the above descriptions.

[0062] The beneficial effects of this invention include preprocessing the original review data and then processing the processed review data based on the TF-IDF algorithm to obtain a ranking result of TF-IDF values. Based on this ranking result and the SO-PPMI algorithm, a domain sentiment lexicon is constructed and combined with a general domain sentiment lexicon to form a fused sentiment lexicon. Based on this sentiment lexicon, the SO-PPMI value of each word in the museum review data is calculated and used as a weight to construct a weighted LDA model, forming a WLDA model. Next, this model is used to assist in the analysis of the themes of the museum reviews, obtaining keywords under each theme of the museum, and performing sentiment word matching with the previously constructed fused sentiment lexicon to obtain the sentiment tendency of each theme. Based on the obtained theme words and their sentiment tendencies, it is possible to extract tourists' emotional attitudes towards the scenic spot, their satisfaction levels, as well as potential problems and improvement suggestions.

[0063] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings.

[0064] The technical solution of this application will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0065] The accompanying drawings are provided to further illustrate the present application and form part of the specification. They are used together with the embodiments of the present application to explain the application and do not constitute a limitation thereof. In the drawings:

[0066] Figure 1 This is a flowchart illustrating the text comment sentiment analysis method in an embodiment of the present invention.

[0067] Figure 2 This is a flowchart illustrating a text comment topic sentiment analysis method according to another embodiment of the present invention.

[0068] Figure 3 This is a schematic diagram illustrating the application process of a text comment topic sentiment analysis method according to another embodiment of the present invention.

[0069] Figure 4 This is a structural block diagram of the text comment topic sentiment analysis device in an embodiment of the present invention. Detailed Implementation

[0070] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings, but these are not intended to limit the scope of the invention.

[0071] It should be understood that various modifications can be made to the embodiments disclosed herein. Therefore, the following description should not be considered as limiting, but merely as an example of embodiments. Other modifications within the scope and spirit of this disclosure will be apparent to those skilled in the art.

[0072] The accompanying drawings, which are included in and form part of this specification, illustrate embodiments of the present disclosure and, together with the general description of the disclosure given above and the detailed description of the embodiments given below, serve to explain the principles of the disclosure.

[0073] These and other features of the invention will become apparent from the following description of preferred forms of embodiments given as non-limiting examples, with reference to the accompanying drawings.

[0074] It should also be understood that although the invention has been described with reference to some specific examples, those skilled in the art can certainly implement many other equivalent forms of the invention, which have the features described in the claims and are therefore all within the scope of protection defined herein.

[0075] The above and other aspects, features and advantages of this disclosure will become more apparent when taken in conjunction with the accompanying drawings and in view of the following detailed description.

[0076] Specific embodiments of the present disclosure are described thereafter with reference to the accompanying drawings; however, it should be understood that the disclosed embodiments are merely examples of the present disclosure and can be implemented in various ways. Well-known and / or repeated functions and structures are not described in detail to avoid unnecessary or redundant details that could obscure the present disclosure. Therefore, the specific structural and functional details disclosed herein are not intended to be limiting, but merely to serve as the basis and representative basis for the claims to teach those skilled in the art to use the present disclosure in a variety of substantially any suitable detailed structures.

[0077] This specification may use the phrases “in one embodiment,” “in another embodiment,” “in yet another embodiment,” or “in still another embodiment,” all of which may refer to one or more of the same or different embodiments according to this disclosure.

[0078] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0079] As shown in the figure, the present invention includes...

[0080] like Figure 1 As shown, this embodiment of the invention provides a method for sentiment analysis of text comments, including:

[0081] S1: Preprocess the obtained comments data about the museum to obtain a vocabulary set;

[0082] S2: Sort the words in the vocabulary set by importance based on the TF-IDF algorithm;

[0083] S3: Based on the ranking results, select the first and second sentiment seed words that can clearly express positive and negative sentiment tendencies;

[0084] S4: Based on the SO-PPMI algorithm, select target words from the vocabulary set that have a first similarity with the first sentiment seed word or a second similarity with the second sentiment seed word. The first similarity is any value within a first threshold range, and the second similarity is any value within a second threshold range. Different target words correspond to different first or second similarities.

[0085] S5: Integrate the target vocabulary with a general sentiment dictionary to form a sentiment dictionary corresponding to museum reviews;

[0086] S6: Determine the weight of each word based on the similarity between each word in the vocabulary set and each sentiment seed word recorded in the sentiment dictionary;

[0087] S7: Construct a WLDA model based on the weights and LDA model, and learn the topic to which each word belongs and the influence of each word on its topic based on the WLDA model, thereby determining the topic words corresponding to each topic, which are related to the museum's commentary direction;

[0088] S8: Determine the sentiment tendency of each topic based on the topic, keywords, and sentiment dictionary.

[0089] Based on the above, the method described in this embodiment preprocesses the obtained original comment data. For example, after obtaining comment data from a museum's forum or an event's message area, the preprocessed comment data is first calculated using the TF-IDF algorithm to obtain a ranking result of TF-IDF values. Then, based on this ranking result and the SO-PPMI algorithm, a domain sentiment lexicon is constructed and fused with a general domain sentiment lexicon to form a fused sentiment lexicon. Based on this sentiment lexicon, the system can calculate the SO-PPMI value of each word in the museum comment data using the SO-PPMI algorithm and use it as a weight to construct a weighted LDA model, forming a WLDA model. Next, this model is used to assist in the analysis of the museum comment themes, obtaining keywords under each theme of the museum, and performing sentiment word matching with the previously constructed fused sentiment lexicon to obtain the sentiment tendency of each theme. Based on the obtained theme words and their sentiment tendencies, the system can extract tourists' emotional attitudes towards the scenic spot, their satisfaction levels, and potential problems and improvement suggestions.

[0090] The topic sentiment analysis method described in this embodiment can more accurately reflect the topic and sentiment of museum reviews by constructing a sentiment lexicon for a specific domain. It effectively filters out noise generated by general vocabulary and irrelevant words, improving the applicability and accuracy of topic extraction. On the other hand, by combining the LDA model with the weights of each word, the model can pay more attention to words with sentiment and opinions in museum reviews, ensuring that its output is easier to understand and interpret.

[0091] In one embodiment, the preprocessing of the obtained museum review data to obtain a vocabulary set includes:

[0092] S9: Convert the obtained museum review data into a word vector sequence;

[0093] S10: Perform word segmentation, part-of-speech tagging, and stop word removal on the word vector sequence to obtain the vocabulary set.

[0094] For example, the preprocessing step in this embodiment aims to convert the original text data into a word vector sequence, including word segmentation, part-of-speech tagging, and stop word removal of the comment data. The resulting word vector sequence is then used as input to the subsequent sentiment discrimination model. Specifically, in practical applications, the posseg interface in the Chinese text segmentation tool jieba can be used for word segmentation, deduplication, and part-of-speech tagging of each word, followed by punctuation removal. Stop word removal can be implemented, for example, based on an existing stop word list, by adding some Chinese punctuation, colors, text, and emoticons to the original comment data, and then filtering out and retaining non-stop words. For example, taking a piece of data from a museum as an example... Figure 2 As shown, it demonstrates the complete process of word sequence generation, which includes word segmentation, part-of-speech tagging, stop word removal, and finally the generation of word sequence.

[0095] Furthermore, after obtaining the word vector sequence, it is necessary to construct a sentiment lexicon for the museum domain. For example, after data preprocessing, keywords that significantly reflect the sentiment tendency of the text can be selected. This selection process preferably uses the widely accepted TF-IDF (Term Frequency-Inverse Document Frequency) technique in text mining to rank the words according to their importance in the document set. Based on the ranking results, the system can filter positive and negative sentiment seed words that are highly representative in expressing obvious sentiment tendencies. The number is not unique; for example, it can be 50 of each. Then, the SO-PPMI (Semantic Orientation-Pointwise Mutual Information) algorithm is used to extract sentiment words with high similarity to sentiment seed words in different directions from the dataset, forming a new sentiment lexicon. Next, a threshold is set to filter new sentiment words from the new sentiment lexicon and add them to the existing general sentiment lexicon, thereby effectively expanding the lexicon and constructing a sentiment lexicon for museum reviews.

[0096] Specifically, the step of ranking the words in the vocabulary set based on the TF-IDF algorithm includes:

[0097] S11: Calculate the word frequency and reverse file frequency of each word in the vocabulary set based on the TF-IDF algorithm;

[0098] S12: Calculate the TF-IDF weight value of the corresponding word based on the word frequency and the reverse file frequency;

[0099] S13: Rank the importance of each word based on the TF-IDF weight values ​​of each word.

[0100] Museum reviews contain a large number of internet slang terms and sentiment-laden words that are not included in current general sentiment dictionaries. However, the most important aspect of a domain-specific sentiment dictionary is the expansion of sentiment terms, requiring the selection of uniquely important seed sentiment terms, which directly impacts the accuracy of sentiment judgment results. Therefore, this embodiment uses the TF-IDF algorithm, calculating term frequency and inverse document frequency to assess the importance of terms. If a word appears frequently in a particular review but rarely in others, it is considered to have good category discrimination ability and can be used for classification. TF (Term Frequency) represents the frequency of a given word in a document; the higher the TF, the more frequently the word appears in the database. Its calculation formula is as follows:

[0101]

[0102] in, Indicates words, Represents a text sequence. Words Number of times it appears.

[0103] IDF (Inverse Document Frequency) is a measure of the general importance of a word, calculated by dividing the total number of documents by the number of documents containing that word, and then taking the logarithm. A higher IDF indicates that the word appears less frequently in other texts, meaning it is more representative. The calculation formula is as follows:

[0104]

[0105] The final weight is calculated using the following formula:

[0106] As shown above, Indicates words, Represents a text sequence. Words Number of times it appears.

[0107] Next, the first and second sentiment seed words that can clearly express positive and negative sentiment tendencies are obtained by filtering based on the ranking results, including:

[0108] S14: Determine the top n candidate words based on the ranking results;

[0109] S15: Determine the first and second sentiment seed words based on the candidate vocabulary selection.

[0110] For example, based on the words in all comments, calculate the TF-IDF value of each word, select the top 1000 (or other number of) words, and then manually select 50 seed words each with obvious positive and negative sentiment. Some of the selected seed words include:

[0111] The primary emotional keywords are: worthwhile, high-quality, humanistic, worth the trip, and worth watching.

[0112] Second emotional seed words: outdated, unseen, spoils the mood, incongruous, waste of time.

[0113] Further, the SO-PPMI algorithm-based selection of target words from the vocabulary set that have a first similarity to the first sentiment seed word or a second similarity to the second sentiment seed word includes:

[0114] S16: Calculate and determine the point cross-values ​​of each corresponding word based on the first sentiment seed word, the second sentiment seed word, and the vocabulary set:

[0115]

[0116] in, Words that represent the seeds of emotion It is the probability that the word to be tested will appear together with any sentiment seed word. and These represent the probabilities of the word to be tested and the sentiment seed word appearing, respectively. It is the positive cross-information between the word to be tested and the sentiment seed word; all negative cross-information is set to 0.

[0117] S17: Calculate the average point cross value of each word with the first sentiment seed word and the second sentiment seed word respectively;

[0118] S18: Based on the average cross-value, the first sentiment seed word, and the second sentiment seed word, the semantic tendency of each test word is calculated and determined. The semantic tendency can characterize the similarity between each test word and its corresponding sentiment seed word.

[0119]

[0120] in, and These represent the number of positive and negative seed words, respectively.

[0121] For example, the selected first sentiment seed word, second sentiment seed word, and vocabulary set are input into the SO-PPMI algorithm. Sentiment words with high similarity to the seed words are selected as new words. Due to the large size of the vocabulary set, or comment data, words with a frequency less than 10 can be removed to reduce computational load. The PMI (Pointwise Mutual Information) can be used to assess the strength of the association between two words, measuring the product of the frequency of their co-occurrence and their individual frequencies. However, PMI tends to assign excessively high scores to events with very low occurrence frequencies. To address this issue, this embodiment introduces PPMI (Positive Pointwise Mutual Information), setting all negative PPMI to 0 to avoid giving excessively high scores to rare events. Its calculation formula is as follows:

[0122]

[0123] in, Words that represent the seeds of emotion It is the probability that the word to be tested will appear together with any sentiment seed word. and These represent the probabilities of the word to be tested and the sentiment seed word appearing, respectively. It is the positive mutual information between the word to be tested and the sentiment seed word.

[0124] Next, the average PPMI value of each word in the corpus is compared with the sets of positive and negative seed words to calculate the target word's (Semantic tendency), the calculation formula is as follows:

[0125]

[0126] in, and These represent the number of the first and second sentiment seed words, respectively.

[0127] Through the above calculations, the sentiment score of each word in the vocabulary set and its corresponding sentiment seed word can be calculated. At this point, the system can combine a preset threshold range, such as filtering out words with sentiment scores in the range of [-37.12, 37.53], and determine them as effective new words, i.e., target words, for addition to the general sentiment dictionary. For example, the effective new words can be integrated with the currently used sentiment dictionary, which may include the HowNet sentiment dictionary, the sentiment vocabulary question bank, the NT-USD Chinese sentiment dictionary, and existing positive and negative connotation dictionaries, thus forming a specific sentiment dictionary for museum reviews.

[0128] Furthermore, the LDA (Latent Dirichlet Allocation) model is a widely used topic model that can automatically learn topics from a document collection; however, it assumes that each word contributes equally to the topic, which can introduce errors in real-world situations and is not the optimal choice. Therefore, this embodiment introduces WLDA (Weighted Latent Dirichlet Allocation), an improved LDA model, which significantly improves the quality of the topic model and its relevance to reviews by introducing word weights. Since museum terminology and sentiment words may contain more information than other words, the topic model constructed using this embodiment can be more effective in determining the topic of reviews.

[0129] In the WLDA model, the system calculates the SO-PPMI value for each word based on each sentiment seed word recorded in the sentiment dictionary (all words in the sentiment dictionary are sentiment seed words). Based on this newly calculated SO-PPMI value, a weight is assigned to the corresponding word, i.e., a word weight. Gibbs sampling is performed based on these word weights; words with higher weights have a greater impact on their respective topics, thus guiding the model to focus more on important words. Then, based on the weighted distribution of topic words, the sentiment tendency of topic words under each topic is further analyzed. By giving keywords higher weights, the WLDA model more accurately identifies the main topics in comments, improving the model's accuracy. Simultaneously, the weighting method ensures that the topics generated by the model better match the actual important words in the dataset, thereby enhancing the model's interpretability.

[0130] Specifically, in combination Figure 3As shown, the WLDA model is constructed based on the weights and the LDA model, and the topic to which each word belongs and the influence of each word on its topic are learned based on the WLDA model, thereby determining the topic words corresponding to each topic, including:

[0131] S19: Construct a WLDA model based on the weights and the LDA model;

[0132] S20: Determine the comment topics related to the museum, with each comment data corresponding to a comment topic;

[0133] S21: Under the WLDA model, Gibbs sampling is performed on the comment topics;

[0134] S22: Based on the Gibbs sampling results, the latent topic distribution value and latent word distribution value of the WLDA model are estimated and determined. The latent topic distribution value and latent word distribution value represent the probability that each test word is assigned to each comment topic.

[0135] S23: Determine the vocabulary belonging to each comment topic based on the implicit topic distribution value and the implicit vocabulary distribution value;

[0136] S24: Based on the implicit word distribution value of the vocabulary under each comment topic, determine the topic words corresponding to each comment topic.

[0137] For example, as described above, the system can calculate the SO-PPMI value between each word in the vocabulary set and each sentiment seed word in the vocabulary based on the sentiment seed words recorded in the sentiment dictionary, and use this value as the weight of the word. Then, a WLDA model is constructed based on this weight value and the LDA model. Next, all topics related to museum reviews can be determined based on preset topics or topics involved in the review data. Then, based on the weights of each word, Gibbs sampling is performed on each topic (review topic), and the calculation process is as follows:

[0138]

[0139] in, This represents the total number of words in the museum review data. Document Chinese vocabulary Belongs to the topic Quantity, This indicates that the influence of the current word is not considered during the Gibbs sampling process.

[0140] Based on this, the latent topic distribution of the entire model is estimated ( ) and implicit vocabulary ( The distribution of a word in a document, i.e., the probability that each word is assigned to a topic, is as follows:

[0141]

[0142]

[0143] Based on this, all words under each topic are sorted by The values ​​are sorted from highest to lowest, and the top S values ​​are selected as keywords for the topic.

[0144] In another embodiment, the method further includes:

[0145] S25: Calculate and determine the perplexity of the vocabulary set based on the comment data;

[0146] S26: Calculate the topic variance for each topic based on the divergence algorithm, and the topic variance is used to determine topic similarity;

[0147] S27: Calculate and determine the perplexity-topic variance index based on the perplexity and topic similarity, and determine the number of LDA models based on the perplexity-topic variance index, with each topic corresponding to one LDA model:

[0148]

[0149] Among them, the The perplexity-topic variance index, the For the degree of confusion, the stated The variance is the subject matter variance.

[0150] For example, to determine the number of comment topics, this embodiment chooses to combine perplexity and topic similarity to measure the optimal number of topics. For topic models, perplexity evaluates the quality of the topic model and measures the model's predictive ability for unknown data; the lower the perplexity, the stronger the model's generalization ability and the better its fit to the data. Its calculation formula is as follows:

[0151]

[0152] in, The test set represents the corpus. Representing the Number of museum reviews Representative Comments The number of words in yes The probability of occurrence This refers to the perplexity of the corpus.

[0153] In addition, topic variance needs to be calculated based on KL (Kullback-Leibler divergence) to measure topic similarity. A larger topic variance indicates higher topic discrimination and a more stable topic structure. The calculation formula is as follows:

[0154]

[0155] in, The extracted topic, Indicates the number of topics extracted. This represents the mean of the "topic-word" probability distribution. This refers to the similarity between subjects. This represents the subject variance of the database test set.

[0156] Since the number of subjects used in perplexity and topic variance calculations is generally inconsistent, determining the number of subjects using only a single indicator can lead to biased results. Therefore, it is necessary to combine the two indicators to balance the model's predictive power and topic identification capabilities to obtain the optimal number of subjects. The formula for calculating the perplexity-topic variance index is as follows:

[0157]

[0158] Furthermore, when training the WLDA model, a series of topic numbers can be preset, training from 2 topics to 20 topics. Gibbs sampling is used to train the WLDA model for each different number of topics. Then, the dataset is divided into training and test sets, and three indices are calculated: perplexity, topic variance, and perplexity-topic variance. The number of topics corresponding to the model with low perplexity and high topic variance is selected comprehensively. Based on the training results, it can be seen that, based on the perplexity-topic variance index, the perplexity-topic variance index gradually decreases and then tends to stabilize. When the number of topics approaches 10, the rate of decrease in the perplexity-topic variance index begins to slow down, indicating that adding more topics does not lead to better data fitting, and the topics are already sufficiently discriminative, allowing the model to clearly distinguish different topics. Considering that too many topics may lead to an overly complex model that is difficult to interpret and understand, 10 topics may provide an easily manageable and interpretable set of topics; after weighing efficiency and complexity, 10 topics can be selected as the optimal number of topics.

[0159] In another embodiment, determining the sentiment tendency of each topic based on the topic, topic terms, and sentiment dictionary includes:

[0160] S28: For each topic, match each topic word belonging to the topic with the words in the sentiment dictionary one by one;

[0161] S29: Count the number of positive and negative keywords based on the matching results;

[0162] S30: Determine the sentiment tendency of the corresponding topic based on the direction of the topic with the largest number of positive and negative topic words.

[0163] For example, after determining the museum's keywords and themes, for each theme, the words it contains can be matched one by one with similar words recorded in the previously constructed fusion sentiment word dictionary. If a positive sentiment word is identified, 1 point is added to the positive sentiment score; if a negative sentiment word is identified, 1 point is added to the negative sentiment score. Neutral words that are matched or words that do not appear in the dictionary are scored as 0 points. Then, the sentiment scores of all words for that theme are added together. A score greater than 0 indicates positive sentiment, less than 0 indicates negative sentiment, and 0 indicates neutral sentiment, thus obtaining the sentiment tendency of each theme. In other words, the sentiment tendency of the corresponding theme is determined based on the direction of the keyword with the most positive and negative keywords.

[0164] like Figure 4 As shown, another embodiment of the present invention also provides a text comment topic sentiment analysis device, including:

[0165] The preprocessing module is used to preprocess the obtained review data about the museum to obtain a vocabulary set;

[0166] The sorting module is used to sort the words in the vocabulary set by importance based on the TF-IDF algorithm;

[0167] The filtering module is used to filter the sorting results to obtain the first and second sentiment seed words that can clearly express positive and negative sentiment tendencies;

[0168] The selection module is used to select target words from the vocabulary set that have a first similarity with the first sentiment seed word or a second similarity with the second sentiment seed word according to the SO-PPMI algorithm. The first similarity is any value within a first threshold range, and the second similarity is any value within a second threshold range. Different target words have different first similarity or second similarity.

[0169] The fusion module is used to merge the target vocabulary with a general sentiment dictionary to form a sentiment dictionary corresponding to museum reviews;

[0170] The first determining module is used to determine the weight of each word based on the similarity between each word in the vocabulary set and each sentiment seed word recorded in the sentiment dictionary;

[0171] The construction module is used to construct a WLDA model based on the weights and the LDA model, and learn the topic to which each word belongs and the influence of each word on its topic based on the WLDA model, thereby determining the topic words corresponding to each topic, wherein the topic is related to the museum's commentary direction;

[0172] The second determining module is used to determine the sentiment tendency of each topic based on the topic, topic words, and sentiment dictionary.

[0173] In some embodiments, the preprocessing of the obtained museum review data to obtain a vocabulary set includes:

[0174] The obtained museum review data is converted into a word vector sequence;

[0175] The word vector sequence is processed by word segmentation, part-of-speech tagging, and stop word removal to obtain the vocabulary set.

[0176] In some embodiments, ranking the words in the vocabulary set based on the TF-IDF algorithm includes:

[0177] The term frequency and reverse file frequency of each word in the vocabulary set are calculated based on the TF-IDF algorithm;

[0178] The TF-IDF weight values ​​of the corresponding words are calculated based on the word frequency and the reverse file frequency.

[0179] The importance of each word is ranked based on its TF-IDF weight value.

[0180] In some embodiments, the step of filtering based on the ranking results to obtain the first and second sentiment seed words that can clearly express positive and negative sentiment tendencies includes:

[0181] The top n candidate words are determined based on the ranking results;

[0182] Based on the candidate vocabulary screening, the first and second sentiment seed words are determined.

[0183] In some embodiments, the selection of target words from the vocabulary set based on the SO-PPMI algorithm that have a first similarity to the first sentiment seed word or a second similarity to the second sentiment seed word includes:

[0184] Based on the first sentiment seed word, the second sentiment seed word, and the vocabulary set, the cross-value of each corresponding word is calculated and determined:

[0185]

[0186] in, Words that represent the seeds of emotion It is the probability that the word to be tested will appear together with any sentiment seed word. and These represent the probabilities of the word to be tested and the sentiment seed word appearing, respectively. It is the positive cross-information between the word to be tested and the sentiment seed word; all negative cross-information is set to 0.

[0187] Calculate the average cross value of each word with the first sentiment seed word and the second sentiment seed word respectively;

[0188] Based on the average cross-value, the first sentiment seed word, and the second sentiment seed word, the semantic tendency of each test word is calculated and determined. The semantic tendency can characterize the similarity between each test word and its corresponding sentiment seed word.

[0189]

[0190] in, and These represent the number of positive and negative seed words, respectively.

[0191] In some embodiments, the step of constructing a WLDA model based on the weights and the LDA model, and learning the topic to which each word belongs and the influence of each word on its topic based on the WLDA model, thereby determining the topic words corresponding to each topic, includes:

[0192] Construct a WLDA model based on the aforementioned weights and LDA model;

[0193] Determine the topic of the comments about the museum, with each piece of comment data corresponding to a single comment topic;

[0194] Under the WLDA model, Gibbs sampling is performed on the comment topics;

[0195] Based on the Gibbs sampling results, the latent topic distribution value and latent word distribution value of the WLDA model are estimated and determined. The latent topic distribution value and latent word distribution value represent the probability that each test word is assigned to each comment topic.

[0196] The vocabulary belonging to each comment topic is determined based on the implicit topic distribution value and the implicit vocabulary distribution value;

[0197] The topic words for each comment topic are determined by filtering based on the implicit word distribution values ​​of the words belonging to each comment topic.

[0198] In some embodiments, the apparatus further includes:

[0199] The third determining module is used to calculate and determine the perplexity of the vocabulary set based on the comment data;

[0200] The calculation module is used to calculate the topic variance of each topic according to the divergence algorithm, and the topic variance is used to determine the topic similarity.

[0201] The fourth determining module is used to calculate and determine the perplexity-topic variance index based on the perplexity and topic similarity, and to determine the number of LDA models based on the perplexity-topic variance index, with each topic corresponding to one LDA model:

[0202]

[0203] Among them, the The perplexity-topic variance index, the For the degree of confusion, the stated The variance is the subject matter variance.

[0204] In some embodiments, determining the sentiment tendency of each topic based on the topic, topic terms, and sentiment dictionary includes:

[0205] For each of the aforementioned topics, each topic word belonging to that topic is matched one by one with the words in the sentiment dictionary;

[0206] The number of positive and negative keywords is counted based on the matching results;

[0207] The sentiment tendency of the corresponding topic is determined based on the direction to which the topic with the most positive and negative keywords belongs.

[0208] Another embodiment of the present invention also provides an electronic device, comprising:

[0209] At least one processor; and,

[0210] A memory communicatively connected to the at least one processor; wherein,

[0211] The memory stores instructions that can be executed by the at least one processor to implement the text comment topic sentiment analysis method as described in any of the embodiments above.

[0212] Another embodiment of the present invention also provides a storage medium including a stored program, wherein, when the program is executed, a device including the storage medium is controlled to perform the text comment topic sentiment analysis method as described in any of the embodiments above.

[0213] This invention also provides a computer program product, which is tangibly stored on a computer-readable medium and includes computer-readable instructions. When executed, these computer-executable instructions cause at least one processor to perform a text comment topic sentiment analysis method, such as the one described in the embodiments above. It should be understood that the various solutions in this embodiment have the corresponding technical effects in the above-described method embodiments, and will not be repeated here.

[0214] It should be noted that the computer storage medium in this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access storage medium (RAM), a read-only storage medium (ROM), an erasable programmable read-only storage medium (EPROM or flash memory), an optical fiber, a portable compact disk read-only storage medium (CD-ROM), an optical storage medium, a magnetic storage medium, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program configured for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, antenna, optical fiber, RF, etc., or any suitable combination thereof.

[0215] One or more embodiments in this application are intended to cover all such substitutions, modifications, and variations falling within the broad scope of this application. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments in this application should be included within the protection scope of this application. The above embodiments are merely exemplary embodiments of the present invention and are not intended to limit the present invention; the protection scope of the present invention is defined by the claims.

Claims

1. A method for sentiment analysis of text comments, characterized in that, include: The obtained review data about the museum was preprocessed to obtain a vocabulary set; The words in the vocabulary set are ranked by importance based on the TF-IDF algorithm; Based on the ranking results, the first and second sentiment seed words that can clearly express positive and negative sentiment tendencies were selected; Based on the SO-PPMI algorithm, target words with a first similarity to the first sentiment seed word or a second similarity to the second sentiment seed word are selected from the vocabulary set. The first similarity is any value within a first threshold range, and the second similarity is any value within a second threshold range. Different target words have different first or second similarities. The target vocabulary is integrated with a general sentiment dictionary to form a sentiment dictionary for museum reviews; The weight of a word is determined based on the similarity between each word in the vocabulary set and each sentiment seed word recorded in the sentiment dictionary; Based on the weights and LDA model, a WLDA model is constructed, and based on the WLDA model, the topic to which each word belongs and the influence of each word on its topic are learned, thereby determining the topic words corresponding to each topic. The topics are related to the museum's commentary direction. The sentiment tendency of each topic is determined based on the stated topic, the keywords, and the sentiment dictionary.

2. The text comment topic sentiment analysis method according to claim 1, characterized in that, The obtained museum review data is preprocessed to obtain a vocabulary set, including: The obtained museum review data is converted into a word vector sequence; The word vector sequence is processed by word segmentation, part-of-speech tagging, and stop word removal to obtain the vocabulary set.

3. The text comment topic sentiment analysis method according to claim 1, characterized in that, The process of ranking the words in the vocabulary set based on the TF-IDF algorithm includes: The term frequency and reverse file frequency of each word in the vocabulary set are calculated based on the TF-IDF algorithm; The TF-IDF weight values ​​of the corresponding words are calculated based on the word frequency and the reverse file frequency. The importance of each word is ranked based on its TF-IDF weight value.

4. The text comment topic sentiment analysis method according to claim 1, characterized in that, The first and second sentiment seed words, which are selected based on the ranking results and can clearly express positive and negative sentiment tendencies, include: The top n candidate words are determined based on the ranking results; Based on the candidate vocabulary screening, the first and second sentiment seed words are determined.

5. The text comment topic sentiment analysis method according to claim 1, characterized in that, The SO-PPMI algorithm-based selection of target words from the vocabulary set that have a first similarity to the first sentiment seed word or a second similarity to the second sentiment seed word includes: Based on the first sentiment seed word, the second sentiment seed word, and the vocabulary set, the cross-value of each corresponding word is calculated and determined: in, Words that represent the seeds of emotion It is the probability that the word to be tested will appear together with any sentiment seed word. and These represent the probabilities of the word to be tested and the sentiment seed word appearing, respectively. It is the positive cross-information between the word to be tested and the sentiment seed word; all negative cross-information is set to 0. Calculate the average cross value of each word with the first sentiment seed word and the second sentiment seed word respectively; Based on the average cross-value, the first sentiment seed word, and the second sentiment seed word, the semantic tendency of each test word is calculated and determined. The semantic tendency can characterize the similarity between each test word and its corresponding sentiment seed word. in, and These represent the number of the first and second sentiment seed words, respectively.

6. The text comment topic sentiment analysis method according to claim 1, characterized in that, The WLDA model is constructed based on the weights and the LDA model, and the topic to which each word belongs and the influence of each word on its topic are learned based on the WLDA model, thereby determining the topic words corresponding to each topic, including: Construct a WLDA model based on the aforementioned weights and LDA model; Determine the topic of the comments about the museum, with each piece of comment data corresponding to a single comment topic; Under the WLDA model, Gibbs sampling is performed on the comment topics; Based on the Gibbs sampling results, the latent topic distribution value and latent word distribution value of the WLDA model are estimated and determined. The latent topic distribution value and latent word distribution value represent the probability that each test word is assigned to each comment topic. The vocabulary belonging to each comment topic is determined based on the implicit topic distribution value and the implicit vocabulary distribution value; The topic words for each comment topic are determined by filtering based on the implicit word distribution values ​​of the words belonging to each comment topic.

7. The text comment topic sentiment analysis method according to claim 1, characterized in that, The method further includes: The perplexity of the vocabulary set is calculated based on the comment data; The topic variance of each topic is calculated based on the divergence algorithm, and the topic variance is used to determine topic similarity. Based on the perplexity and topic similarity, a perplexity-topic variance index is calculated and determined, and the number of LDA models is determined based on the perplexity-topic variance index, with each topic corresponding to one LDA model: Among them, the The perplexity-topic variance index, the For the degree of confusion, the stated The variance is the subject matter variance.

8. The text comment topic sentiment analysis method according to claim 1, characterized in that, The determination of the sentiment tendency of each topic based on the topic, keyword, and sentiment dictionary includes: For each of the aforementioned topics, each topic word belonging to that topic is matched one by one with the words in the sentiment dictionary; The number of positive and negative keywords is counted based on the matching results; The sentiment tendency of the corresponding topic is determined based on the direction to which the topic with the most positive and negative keywords belongs.

9. A text comment topic sentiment analysis device, characterized in that, include: The preprocessing module is used to preprocess the obtained review data about the museum to obtain a vocabulary set; The sorting module is used to sort the words in the vocabulary set by importance based on the TF-IDF algorithm; The filtering module is used to filter the sorting results to obtain the first and second sentiment seed words that can clearly express positive and negative sentiment tendencies; The selection module is used to select target words from the vocabulary set that have a first similarity with the first sentiment seed word or a second similarity with the second sentiment seed word according to the SO-PPMI algorithm. The first similarity is any value within a first threshold range, and the second similarity is any value within a second threshold range. Different target words have different first similarity or second similarity. The fusion module is used to merge the target vocabulary with a general sentiment dictionary to form a sentiment dictionary corresponding to museum reviews; The first determining module is used to determine the weight of each word based on the similarity between each word in the vocabulary set and each sentiment seed word recorded in the sentiment dictionary; The construction module is used to construct a WLDA model based on the weights and the LDA model, and learn the topic to which each word belongs and the influence of each word on its topic based on the WLDA model, thereby determining the topic words corresponding to each topic, wherein the topic is related to the museum's commentary direction; The second determining module is used to determine the sentiment tendency of each topic based on the topic, topic words, and sentiment dictionary.

10. An electronic device, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor to implement the text comment topic sentiment analysis method as described in any one of claims 1-8.