Tourist emotion-based text travel scene public opinion analysis, early warning and attribution method
Through deep learning algorithms and natural language processing technology, integrating large language models and analyzing Weibo data, the problem that existing technology Chinese tourism scenario emotion analysis is difficult to capture rich emotional expressions is solved, and multi-dimensional emotion analysis and public opinion warning is realized, providing decision-making support for the cultural and tourism industry.
Patent Information
- Application Number
- CN202411871249.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-18
AI Technical Summary
Existing emotional analysis of cultural and tourism scenarios is difficult to capture tourists' rich emotional expressions, and it is impossible to quickly and effectively extract and analyze key information related to Weibo's Chinese cultural and tourism.
Using deep learning algorithms and natural language processing technology, through the Python programming language and Pytorch framework, a large language model is integrated to realize the crawling and analysis of cultural and tourism-related Weibo pictures and text data, conduct seven-level sentiment analysis and multi-dimensional analysis, and provide public opinion warning and attribution analysis.
It realizes multi-dimensional sentiment analysis and reason analysis of Weibo data, provides public opinion warning and attribution analysis, and provides decision-making support tools for the cultural and travel industry to help monitor and understand consumer feedback, and promptly discover and deal with negative reviews.
Smart Images

Figure CN119848691A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer artificial intelligence, and in particular relates to a public opinion analysis, early warning and attribution method for cultural and tourism scenes based on tourists' emotions. Background Art
[0002] Existing cultural tourism scene sentiment analysis performs coarse-grained sentiment detection in three categories (positive, negative, and neutral), which is difficult to capture tourists' rich emotional expressions in practical applications. Such analysis methods are mostly limited to basic sentiment classification and provide very limited effective information when used in actual scenarios.
[0003] There is a problem in the prior art that key information cannot be quickly and effectively extracted and analyzed from cultural and tourism articles appearing on Weibo. Summary of the invention
[0004] The purpose of the present invention is to make corresponding improvements to the defects and shortcomings of the existing technology in the public opinion analysis of cultural and tourism scenes based on tourist comments. The present invention proposes a method for public opinion analysis, early warning and attribution of cultural and tourism scenes based on tourist emotions, and realizes the crawling and analysis of cultural and tourism related Weibo image and text data through deep learning algorithms and natural language processing technology. This method uses Python programming language and Pytorch framework, integrates a large language model for attribution analysis and multi-dimensional analysis, and realizes the function of Weibo data processing and analysis. The outstanding contribution of the present invention lies in the customized solution for cultural and tourism scenes. By applying machine learning models, we can not only realize the seven-level analysis of the intensity and emotion of Weibo data and cause analysis, but also provide public opinion early warning and attribution analysis, providing a decision support tool for the cultural and tourism industry.
[0005] A method for public opinion analysis, early warning and attribution of cultural tourism scenes based on tourists' emotions, comprising the following steps: S1. Data crawling: Use the Scrapy library to build a crawler, dynamically adjust the crawling time period according to the input signal, and store the user name, comment content and release date information in a structured jsonl file for the keyword "travel"; S2. Seven-level degree analysis: Combining BERT, ResNet and Vision Transformer, a multi-layer Transformer encoder is used to fuse text and image information, and a softmax function is used to obtain a seven-level sentiment score; S3. Multi-dimensional analysis: Combined with the text review analysis model, a prompt word is constructed to guide the analysis process, and the comments in step S1 are classified into multiple categories, indicating the ratings of the products or services of the tourist attractions; S4. Attribution analysis: Use the text comment analysis model in step S3 to sort out the reasons for the comments in step S1.
[0006] Furthermore, it also includes visualization processing: combining MySQL database and Java backend operation, and displaying the seven-level analysis results of step S2 through data visualization.
[0007] Furthermore, the data crawling in step S1 includes the following steps: Use the Scrapy library to build a crawler process and dynamically adjust the crawling time period of Weibo data according to different input signals; By setting the crawling time period, cultural and tourism related Weibo data within the expected time period is obtained; In the data parsing stage, the user name, comment content and publishing date information in the web page are extracted and stored in a structured jsonl file.
[0008] Furthermore, the seven-level degree analysis step in step S2 is: The BERT model pre-trained on Chinese text is used to encode the Weibo text content, the corresponding input image is encoded using the ResNet model, and the image encoding result is input into the Vision Transformer to further obtain image features; Adjust the spatial dimensions of the ResNet model encoding and the image feature data of the Vision Transformer so that they have the same feature dimensions; A multi-layer Transformer encoder module is used to fuse text and image information to obtain multimodal features. The multimodal features are calculated through a fully connected layer and a softmax function is used to obtain a sentiment score.
[0009] Furthermore, the seven-level division steps are: According to the sentiment score, it is divided into three coarse-grained categories: "positive", "neutral" and "negative". The three coarse-grained categories are divided into seven fine-grained levels, corresponding to "very satisfied", "satisfied", "relatively satisfied", "average", "not very satisfied", "unsatisfied", and "very dissatisfied".
[0010] Furthermore, the text comment analysis model in step S3 is: Llama3-8B-Chinese-Chat large language model.
[0011] Furthermore, the attribution analysis content in step S4 includes "traffic", "environment", "safety" and "others".
[0012] The above one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects: The present invention can not only help the cultural and tourism industry (including tourist attractions, hotels, restaurants, etc.) monitor and understand consumers' feedback on their services or products, but also promptly discover and handle negative reviews, and analyze user emotions from multiple angles.
[0013] By analyzing tourists' emotions and opinions, problem points such as service quality and facility conditions can be quickly identified and improved in a timely manner. This can not only improve the satisfaction of existing customers, but may also be converted into word-of-mouth promotion, thereby attracting more new customers.
[0014] The present invention can provide rich sentiment data and user feedback, which can be used as a basis for decision making, helping companies better understand market trends, consumer needs and preferences, and thus make more accurate and effective decisions.
[0015] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 It is a schematic diagram of the process provided by the present invention. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described below in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present invention. The following embodiments are used to illustrate the present invention, but cannot be used to limit the scope of the present invention.
[0019] Combine the following Figure 1The present invention is described in the data crawling module. This invention can realize the functions of crawling, accumulating data and gradually adding data. The invention designs a multifunctional data crawling strategy that supports scheduled crawling, instant crawling and crawling in a specified time period. The invention adopts a data aggregation strategy that can continuously accumulate result data without losing any historical analysis information. The present invention also adopts an incremental update method. When the program is running, the model will focus on the currently crawled data without repeatedly processing historical data, reducing redundant data processing processes. Through the method of the present invention, we can identify negative comments that have a greater impact on cultural and tourism scenarios, and find the factors that lead to these negative comments through cause analysis, providing early warning and attribution support.
[0020] The technical solution adopted in the present invention is: A method for public opinion analysis, early warning and attribution of cultural tourism scenes based on tourists' emotions, comprising the following steps: S1. Data crawling: Use the Scrapy library to build a crawler, dynamically adjust the crawling time period according to the input signal, and store information such as user name, comment content, and release date in a structured jsonl file for the keyword "travel".
[0021] S2. Seven-level degree analysis: Combining BERT, ResNet and Vision Transformer, a multi-layer Transformer encoder is used to fuse text and image information, and a softmax function is used to obtain a seven-level sentiment score.
[0022] S3. Multi-dimensional analysis: Combined with the text review analysis model, prompt words are constructed to guide the analysis process, and customer reviews are classified into multiple categories to represent the ratings of tourist attraction products or services.
[0023] S4. Attribution analysis: The same text review analysis model is used to organize the reasons for each review content and classify the review content into a certain theme, such as "traffic", "environment", "safety" or "other".
[0024] The present invention can also perform visualization processing. A web UI is designed, which combines MySQL database and Java backend operation to display the seven-level sentiment analysis results through data visualization (bar chart and line chart, etc.).
[0025] Data crawling in step S1: Use the Scrapy library to build a crawler process, and dynamically adjust the crawling time period of Weibo data according to different input signals. Through this time period setting, we get the cultural and tourism related Weibo data within the expected time. In the data parsing stage, we extract information such as user name, comment content and release date from the web page and store it in a structured jsonl file. Through this crawler design, we can collect Weibo data on the theme of "travel", including user feedback, travel experience sharing, and evaluation of tourist destinations.
[0026] The user selects the time range of the comments to be analyzed. For example, hourly crawling is performed autonomously. When the program is run for the first time, it will record the current time and the time of the previous hour in a format such as "2024-7-12-12-23-22" and crawl the data for that time period. In addition, there is a design for dynamic crawling of data, which will automatically crawl every hour.
[0027] Seven-level degree analysis in step S2: First, the BERT model pre-trained with Chinese text is used to encode the microblog text content, and the corresponding input image is encoded using the ResNet model, and the image encoding result is input into the VisionTransformer to further obtain image features. After that, the spatial dimensions of the two parts of the encoded data are adjusted so that they have the same feature dimensions. The text and image information are fused using a multi-layer Transformer encoder module to obtain multimodal features. The multimodal features will be calculated through a fully connected layer, and the sentiment score is obtained using the softmax function. According to this score, it is first divided into three coarse-grained categories of "positive", "neutral" and "negative", and then divided into seven fine-grained levels, corresponding to "very satisfied", "satisfied", "relatively satisfied", "average", "not very satisfied", "unsatisfied", and "very dissatisfied". Specifically, the seven-level degree analysis model calculates a score of 0~1 for each sentiment polarity, and according to the score, we divide it into different degree levels. Predict a score. For the positive category, if the score is between 0 and 0.8, we classify it as the "relatively satisfied" level; if the score is between 0.8 and 0.95, we classify it as the "satisfied" level; if the score is between 0.95 and 1, we classify it as the "very satisfied" level; for the negative category, if the score is between 0 and 0.6, we classify it as the "not very satisfied" level; if the score is between 0.6 and 0.8, we classify it as the "unsatisfied" level; if the score is between 0.8 and 1, we classify it as the "very unsatisfied" level; for the neutral category, we directly classify it as "average" without any degree of division.
[0028] We first use the BERT model pre-trained on Chinese corpus to encode the input text, which generates a series of hidden layer representations. ,in Represents a size of matrix; represents the length of the token sequence, and is the dimension of each token vector. In , each is a vector corresponding to each input token sequence. A token refers to a word or word unit after word segmentation. For example, "China" is directly used as a single token. is located at the beginning of the input sequence and is a vector corresponding to a special token. The subscript C represents Classification. It does not represent a part of the input token, and its function is to summarize the information of the entire sentence. The remaining correspond to the vector representations of ordinary tokens respectively, loading the information of the input sequence. S represents the number of vectors corresponding to these ordinary tokens. For image data, we use the ResNet model to encode and obtain , where the input of the ResNet model is an RGB image with a shape of 224×224×3, and the output is a feature map is a three-dimensional matrix with a shape of representing the number of feature vectors in the feature map, denotes the length of each feature vector, which can also be called the depth, i.e., the third dimension. Each in represents a two-dimensional matrix, and they represent the two-dimensional feature maps at each depth position, with a total of m, corresponding to . After that, the encoded feature map is subjected to a deformation process to make its third dimension the same as that of the text, i.e., , and it is flattened into a two-dimensional matrix, i.e., the shape changes from to , to obtain : Among them, is the flattened matrix, and each in represents a vector with a length of . is the projection matrix in the deformation process, used to change the dimension of , and is a constant used in the deformation process. Subsequently, is input into the Vision Transformer module to extract a more refined image feature map : in For the Vision Transformer model, and Same shape, but The value of represents a more fine-grained feature. Then, a multi-layer Transformer encoder module is used to fuse text and image information to obtain multimodal features. : is the multimodal data Transformer encoder module, is a vector operation symbol, the purpose is to and Connect along the third dimension. is the final multimodal feature, which is a two-dimensional matrix with vectors, each with a third dimension of We will feed these features into two fully connected layers to calculate the sentiment classification task. We get the representation : in, is the activation function, , is the middle value, is the result obtained by the first fully connected layer, which is used for weighted calculation ,after After the last fully connected layer, we get , The weights and biases required for the calculation of the fully connected layer.
[0029] is a vector of shape 1×3, where 3 corresponds to the number of final classification categories (positive, negative, neutral). , we apply the Softmax function to normalize this vector: The Softmax function can process a vector x and constrain the values of x to range, and the sum of the values in the vector is 1. is a 1×3 vector for the final sentiment prediction. For example, a CLS is [0.6, 0.3, 0.1]. The indexes 0, 1, and 2 correspond to the three coarse-grained categories "positive", "neutral", and "negative" respectively.
[0030] Finally, we analyze three situations. When the index corresponding to the maximum value is 0, if the value is between 0 and 0.8, we judge it as "relatively satisfied", if it is between 0.8 and 0.95, we judge it as "satisfied", and if it is between 0.95 and 1, we judge it as "very satisfied"; when the index corresponding to the maximum value of CLS is 1, regardless of the size of the number, we judge it as "average"; when the index corresponding to the maximum value of CLS is 2, if the value is between 0 and 0.6, we judge it as "not very satisfied", if it is between 0.6 and 0.8, we judge it as "unsatisfied", and if it is between 0.8 and 1, we judge it as "very unsatisfied".
[0031] Multi-dimensional analysis in step S3: We considered six aspects: scenic spot service quality, problem-solving ability, customer engagement, brand image, customer feedback, and social responsibility for dimensional analysis. Corresponding prompt words were constructed for each dimension. Taking the five-category category as an example, the constructed prompt words are as follows: "Please analyze the following tourist comments", and then enter the customer comments, "Based on the content, classify their opinions on the products or services of the tourist attraction", the dimension requirements, "into five digital categories of 0, 1, 2, 3, and 4, representing poor, poor, average, good, and good, respectively. If a dimension is not clearly reflected in the comment, it is classified as 'average' (i.e., score 2) by default." After the prompt words are constructed, we feed the prompt words and tourist comment data into the large language model. Here we use the text comment analysis model as an auxiliary analysis tool, where the text comment analysis model is a large language model named Llama3-8B-Chinese-Chat, which is trained with full parameter fine-tuning on a mixed Chinese and English dataset containing about 100,000 preference pairs. The model weights are publicly available on the https: / / huggingface.co / website and can be freely downloaded. The Llama3-8B-Chinese-Chat model is used for text question answering. For a question, the model will parse its content, understand and output the answer in text form. The large language model is used to divide the tourist review data into six dimensions: "scenic spot service quality", "problem solving ability", "customer engagement", "brand image", "customer feedback" and "social responsibility".
[0032] Attribution analysis in step S4: This part of the analysis classifies the graphic comments into several basic categories, including "traffic", "environment", "safety" and "others". The attribution model used is consistent with the text comment analysis model mentioned above, but the prompt words used focus on the analysis of the comment topic.
[0033] The specific method of steps S3 and S4 is as follows: The analysis process using the large language model Llama3-8B-Chinese-Chat is as follows: First, construct the text prompt: in, For the prompt word part, For the content part related to the review to be analyzed, each and Both represent a sentence segment. The Combine function is defined as the element-by-element concatenation of two lists: Prompt construction process example: ; ; ; Therefore, the final prompt is constructed as =“ ". The number of fields p and t composed of different dimensions of analysis will be different, so it is replaced by n.
[0034] Then, the constructed prompt is input into the large language model M to get the output : Finally, we use a template screening method F to filter out the output categories of the model: in, The function will match one by one from output element.
[0035] In visualization: A web user interface (UI) was designed for visualization of analytical data. MySQL database was used as data storage, Java was used as the backend development language, and front-end page technology was used to achieve data visualization. The system displays the distribution of various indicators in the form of bar charts and line charts. For the seven-level sentiment analysis results, we subdivided them into seven different score intervals, each of which was displayed through a bar chart. In addition, users can click on the bar chart of each score interval to further view the specific comment details within the score interval, including but not limited to pictures, user names, and detailed comment content.
[0036] The accuracy of the samples in the "very dissatisfied" category of the invention reaches more than 90%, and it can accurately extract extremely negative comment information. In terms of attribution of warning information, the method we designed has an attribution accuracy of more than 85%, and the calculation method is the average accuracy of each factor.
[0037] The method of the present invention can not only perform seven levels of satisfaction evaluation, but also conduct in-depth attribution analysis, specifically to the subject classification of comments. In addition, the invention can also conduct multi-dimensional analysis, examining comments from multiple fields including scenic spot service quality, problem solving ability and customer engagement.
[0038] The present invention can not only help the cultural and tourism industry (including tourist attractions, hotels, restaurants, etc.) monitor and understand consumers' feedback on their services or products, but also promptly discover and handle negative reviews, and analyze user emotions from multiple angles.
[0039] By analyzing tourists' emotions and opinions, problem points such as service quality and facility conditions can be quickly identified and improved in a timely manner. This can not only improve the satisfaction of existing customers, but may also be converted into word-of-mouth promotion, thereby attracting more new customers.
[0040] This approach can provide rich sentiment data and user feedback that can serve as a basis for decision making, helping companies better understand market trends, consumer needs and preferences, and thus make more accurate and effective decisions.
[0041] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for public opinion analysis, early warning and attribution of cultural tourism scenes based on tourists' emotions, characterized in that: The following steps are involved: S1. Data crawling: Use the Scrapy library to build a crawler, dynamically adjust the crawling time period according to the input signal, and store the user name, comment content and release date information in a structured jsonl file for the keyword "travel"; S2. Seven-level degree analysis: Combining BERT, ResNet and Vision Transformer, a multi-layer Transformer encoder is used to fuse text and image information, and a softmax function is used to obtain a seven-level sentiment score; S3. Multi-dimensional analysis: Combined with the text review analysis model, a prompt word is constructed to guide the analysis process, and the comments in step S1 are classified into multiple categories, indicating the ratings of the products or services of the tourist attractions; S4. Attribution analysis: Use the text comment analysis model in step S3 to sort out the reasons for the comments in step S1.
2. According to claim 1, a method for analyzing, warning and attributing public opinion in cultural and tourism scenes based on tourists' emotions is characterized in that: It also includes visualization processing: combining MySQL database and Java backend operations to display the seven-level analysis results of step S2 through data visualization.
3. According to claim 1, a method for analyzing, warning and attributing public opinion in cultural and tourism scenes based on tourists' emotions is characterized in that: The data crawling in step S1 includes the following steps: Use the Scrapy library to build a crawler process and dynamically adjust the crawling time period of Weibo data according to different input signals; By setting the crawling time period, cultural and tourism related Weibo data within the expected time period is obtained; In the data parsing stage, the user name, comment content and publishing date information in the web page are extracted and stored in a structured jsonl file.
4. According to claim 1, a method for analyzing, warning and attributing public opinion of cultural and tourism scenes based on tourists' emotions is characterized in that: The seven-level degree analysis steps in step S2 are: The BERT model pre-trained on Chinese text is used to encode the Weibo text content, the corresponding input image is encoded using the ResNet model, and the image encoding result is input into the Vision Transformer to further obtain image features; Adjust the spatial dimensions of the ResNet model encoding and the image feature data of the Vision Transformer so that they have the same feature dimensions; A multi-layer Transformer encoder module is used to fuse text and image information to obtain multimodal features. The multimodal features are calculated through a fully connected layer and a softmax function is used to obtain a sentiment score.
5. According to claim 4, a method for analyzing, warning and attributing public opinion of cultural and tourism scenes based on tourists' emotions is characterized in that: The seven-level division steps are: According to the sentiment score, it is divided into three coarse-grained categories: "positive", "neutral" and "negative". The three coarse-grained categories are divided into seven fine-grained levels, corresponding to "very satisfied", "satisfied", "relatively satisfied", "average", "not very satisfied", "unsatisfied", and "very dissatisfied".
6. According to claim 1, a method for analyzing, warning and attributing public opinion of cultural and tourism scenes based on tourists' emotions is characterized in that: The text review analysis model in step S3 is: Llama3-8B-Chinese-Chat large language model.
7. According to claim 1, a method for analyzing, warning and attributing public opinion of cultural and tourism scenes based on tourists' emotions is characterized in that: The attribution analysis content in step S4 includes "traffic", "environment", "safety" and "others".
Citation Information
Cited By
Tourism demand prediction method and device based on TFT model, and storage medium
CN121146179A