Food safety risk analysis method and system based on big data

Through multi-source data processing and fine-grained sentiment analysis, a hot word cloud map and entity relationship network are built, which solves the problem of deviations in analysis results and indirect information expression in the field of food safety, and achieves a more accurate and efficient food safety risk analysis.

CN119149822AInactive Publication Date: 2024-12-17DONGPING COUNTY HONGTU AGRICULTURAL TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411620621.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2024-12-17
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing big data processing methods have problems such as single information sources, insufficient fine-grainedness, neglect of internal connections of hot words and phrases, and rough construction of entity relationship networks in the field of food safety, resulting in biased analysis results and inaccurate information expression.

Method used

Using food safety risk analysis methods based on big data, obtain multi-source network data, perform pre-processing and fine-grained sentiment analysis, dynamically extract hot words and phrases, build hot word cloud maps and time series heat maps, extract entity relationship networks, and identify related News reports, clustering and topic keyword generation, and trigger early warnings through real-time monitoring.

Benefits of technology

It improves the accuracy and efficiency of food safety risk analysis, can comprehensively and timely reflect the food safety situation in the target area, deeply explore public emotional attitudes and complex relationship networks, and promptly discover abnormal situations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119149822A_ABST
    Figure CN119149822A_ABST
Patent Text Reader

Abstract

The invention provides a food safety risk analysis method and system based on big data, and relates to the technical field of data processing, and the method comprises the steps: extracting key entity information of a food name, a brand, a production place and an event occurrence place in a news report according to a hot word cloud picture and a time sequence thermodynamic diagram, a structured entity relation network is constructed; according to the entity relationship network, combining the entity information and the timestamp, identifying a news report related to the specific food event; clustering the news reports to obtain different topic clusters; according to different topic clusters, generating topic keywords and abstracts of each topic cluster; by monitoring the text number increase rate, the emotional tendency change and the occurrence frequency of specific keywords in each topic cluster in real time, early warning is triggered when an abnormal condition is detected. The accuracy and efficiency of food safety risk analysis can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a food safety risk analysis method and system based on big data. Background Art

[0002] Existing big data processing methods still have some shortcomings in the field of food safety.

[0003] First, some data processing methods ignore the fusion of multi-source data, resulting in a single source of information and possible bias in the analysis results. Second, as one of the key steps, some existing methods of sentiment analysis are not fine-grained enough to capture the subtle changes in public sentiment towards food safety incidents.

[0004] In addition, when extracting hot words and phrases, some existing methods ignore the internal connections between these words and phrases, resulting in the constructed hot word cloud map and time series heat map information expression not being intuitive and comprehensive. At the same time, when constructing a structured entity relationship network, the existing methods are also rough in extracting entity information and establishing relationships, making it difficult to deeply explore the complex relationship network behind food safety incidents. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide a food safety risk analysis method and system based on big data, which can improve the accuracy and efficiency of food safety risk analysis.

[0006] In order to solve the above technical problems, the technical solution of the present invention is as follows: In a first aspect, a food safety risk analysis method based on big data, the method comprising: Obtain multi-source network data around food safety related keywords within a specific time period and in a target region; Preprocessing multi-source network data to obtain preprocessed data; Perform sentiment analysis on the fine-grained preprocessed data to obtain analysis results; Dynamically extract hot words and phrases in the analysis results to build hot word cloud diagrams and time series heat maps; Based on the hot word cloud diagram and time series heat map, extract the key entity information of food name, brand, origin and location of the event in the news report to build a structured entity relationship network; Based on the entity relationship network, combining entity information and timestamps, we identify news reports related to specific food events. Cluster news reports to obtain different topic clusters; generate the subject keywords and summary of each topic cluster according to different topic clusters; By real-time monitoring of the growth rate of the amount of text in each topic cluster, changes in sentiment, and the frequency of occurrence of specific keywords, an early warning is triggered when an abnormal situation is detected.

[0007] Furthermore, sentiment analysis is performed on the fine-grained preprocessed data to obtain analysis results, including: Randomly divide the preprocessed data into training set and test set; For each word in the vocabulary list, query the external knowledge base to obtain relevant information about it, by Calculate a weight factor for each word; For each text in the training set, calculate the frequency of each word, multiply the frequency of each word by its corresponding weight factor to get the weighted frequency, calculate the inverse document frequency of each word in the entire training set, and combine the weighted frequency and inverse document frequency to calculate the weighted TF-IDF value of each word; combine the weighted TF-IDF values ​​of all training texts into a numerical vector matrix, where each row of the numerical vector matrix represents a feature vector of a text, and the columns represent different lexical features; Calculate the frequency of each word in the test set text, multiply the frequency of each word in the test set text by its corresponding weight factor to obtain the weighted frequency; use the inverse document frequency value list calculated in the training set, multiply it by the weighted frequency of the test set text, and obtain the weighted TF-IDF value of each word; combine the weighted TF-IDF values ​​of all test set texts into a numerical vector matrix, where each row represents the feature vector of a test set text, and the columns of the test set matrix correspond to the columns of the training set matrix; Use the numerical vectors of the training set and their corresponding sentiment labels to train the prediction model, and input the numerical vectors of the test set into the trained prediction model; The trained prediction model predicts the sentiment tendency of each text and gives the corresponding sentiment label and sentiment intensity score; Calculate sentiment labels and sentiment intensity scores to form analysis results.

[0008] Furthermore, hot words and phrases in the analysis results are dynamically extracted to construct hot word cloud diagrams and time series heat maps, including: Segment the continuous text into independent words and phrases, and count the words and phrases after each segmentation; Filter out hot words and phrases according to preset standards, and sort the filtered hot words to obtain an optimized result set; Convert the filtered and sorted hot words and phrases into data formats; generate word cloud diagrams or time series heat maps based on demand; if the converted data contains timestamp information, generate time series heat maps based on time sequence and word heat.

[0009] Furthermore, based on the hot word cloud map and time series heat map, the key entity information of food name, brand, origin and event location in the news reports is extracted to construct a structured entity relationship network, including: Receiving preprocessed news report text as input data; Use pre-trained named entity recognition models to automatically identify food names, brands, origins, and event locations in text; Predefine the relationship types between entities and extract the relationships between entities from the text through rule matching; The extracted entities and the relationships between the entities are stored in a structured manner to obtain stored entity-relationship pairs; Based on the stored entity-relationship pairs, an entity-relationship network is constructed. In the entity-relationship network, nodes represent entities and edges represent relationships between entities.

[0010] Furthermore, the relationship types between entities are predefined, and the relationships between entities are extracted from the text through rule matching, including: Determine the entity relationship types to be extracted, and determine a series of initial rules for each relationship type to obtain an initial rule set; Perform preprocessing operations on the input text and identify entities in the text; Use the initial rule set to match the preprocessed text to extract the relationship between entities; The currently used rule set is regarded as a solution, and each solution corresponds to an evaluation score; Generate neighborhood solutions by adding, deleting or modifying rules based on the current rule set; According to the Metropolis criterion, it is decided whether to accept the neighborhood solution as the new current solution. After a certain number of iterations at each temperature, the temperature is reduced according to the set temperature drop rate. When the temperature reaches the preset number of iterations, the simulated annealing process is stopped, and the target text is subjected to relation extraction using the rule set optimized by simulated annealing to obtain the extracted entity relationship.

[0011] Furthermore, based on the entity relationship network, combined with entity information and timestamps, news reports related to specific food events are identified, including: According to the entity relationship network, combined with entity information and timestamp, Calculate similarities to identify news stories related to specific food events; in, is a weight; is the weight within the entity similarity; Representing a collection of entities and entity collection The size of the intersection of , that is, the number of entities in common between the two reports; Representing a collection of entities and entity collection The size of the union of , i.e., the number of all entities that are different in the two reports; Representing Entities The weight of is the weight; and is the time decay factor; and News reports and The publishing timestamp of is the base of natural logarithms; Representatives were reported in the news and The entity collection and The specific entity that appears in the intersection of It's a news report and The similarity.

[0012] Furthermore, the news reports are clustered to obtain different topic clusters; based on the different topic clusters, the subject keywords and summaries of each topic cluster are generated, including: According to the similarity between each pair of news reports, the corresponding news report pairs are gradually merged into topic clusters until a preset number of topic clusters is reached, wherein each finally formed topic cluster represents a specific topic; For each topic cluster, traverse all news reports in the topic cluster and calculate the frequency of occurrence of each word; Use the pre-trained part-of-speech tagging model to tag each word with part-of-speech, and filter out words that do not meet the conditions according to the set rules to obtain a word list after part-of-speech filtering for each topic cluster; After obtaining the word list after part-of-speech filtering, calculate the TF-IDF value of each word in each topic cluster; Filter keywords based on TF-IDF values ​​to get the final keywords; For each topic cluster, the importance score of each sentence in each report in the topic cluster is obtained by calculating the similarity between the sentence and the topic of the report. According to the importance score, several representative sentences or paragraphs in each topic cluster are selected and combined into a summary of the topic cluster.

[0013] Second, a food safety risk analysis system based on big data, including: An acquisition module is used to acquire multi-source network data around food safety related keywords within a specific time period and for a target area; A preprocessing module, used for preprocessing multi-source network data to obtain preprocessed data; The analysis module is used to perform sentiment analysis on the preprocessed data at a fine-grained level to obtain analysis results; A construction module is used to dynamically extract hot words and phrases in the analysis results to construct hot word cloud diagrams and time series heat maps; The extraction module is used to extract key entity information such as food name, brand, origin and location of the event in news reports based on the hot word cloud map and time series heat map to build a structured entity relationship network; A computational module for identifying news reports related to a specific food event based on an entity relationship network, combined with entity information and timestamps; A generation module is used to cluster news reports to obtain different topic clusters; based on different topic clusters, the subject keywords and summary of each topic cluster are generated; The early warning module is used to monitor the growth rate of the number of texts in each topic cluster, changes in sentiment tendencies, and the frequency of occurrence of specific keywords in real time, and trigger an early warning when an abnormal situation is detected.

[0014] According to a third aspect, a computing device includes: one or more processors; The storage device is used to store 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 described.

[0015] In a fourth aspect, a computer-readable storage medium stores a program, and when the program is executed by a processor, the method described is implemented.

[0016] The above scheme of the present invention includes at least the following beneficial effects.

[0017] It can comprehensively and timely collect network data related to food safety, ensure that the basic data for analysis is extensive and representative, and thus more accurately reflect the food safety status of the target area. Through pre-processing operations such as data cleaning, deduplication, and formatting, the quality and consistency of the data are effectively improved. Fine-grained sentiment analysis can more deeply explore the public's emotional attitudes and opinions on food safety incidents. By displaying hot words and phrases through visualization means, analysts can intuitively and quickly grasp the hot topics and trend changes in the field of food safety. The construction of a structured entity relationship network helps to reveal the complex correlations behind food safety incidents. Through similarity calculation, news reports related to specific food incidents can be accurately and quickly identified, which improves the efficiency and accuracy of information screening and helps to timely discover and track the dynamics of related events.

[0018] Cluster analysis can effectively classify a large number of news reports according to topics, making it easier for analysts to conduct in-depth research on different topics. At the same time, the generated topic keywords and summaries can concisely and clearly summarize the core content of each topic, improving the efficiency of information acquisition. Real-time monitoring and early warning mechanisms can promptly detect abnormal situations in the field of food safety. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a flow chart of a food safety risk analysis method based on big data provided by an embodiment of the present invention.

[0020] Figure 2 It is a schematic diagram of a food safety risk analysis system based on big data provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0021] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0022] like Figure 1 As shown, an embodiment of the present invention proposes a food safety risk analysis method based on big data, and the method comprises the following steps: Step 11, obtaining multi-source network data around food safety related keywords in a specific time period and for a target area; Step 12, preprocessing the multi-source network data to obtain preprocessed data; Step 13, performing sentiment analysis on the fine-grained preprocessed data to obtain analysis results; Step 14, dynamically extract hot words and phrases in the analysis results to construct a hot word cloud map and a time series heat map; Step 15, extracting key entity information of food name, brand, origin and location of event in news reports based on hot word cloud map and time series heat map, so as to construct a structured entity relationship network; Step 16, identifying news reports related to a specific food incident based on the entity relationship network, combining entity information and timestamps; Step 17, clustering the news reports to obtain different topic clusters; generating the subject keywords and summary of each topic cluster according to the different topic clusters; Step 18, by real-time monitoring the growth rate of the number of texts in each topic cluster, changes in sentiment tendency, and the frequency of occurrence of specific keywords, an early warning is triggered when an abnormal situation is detected.

[0023] In an embodiment of the present invention, step 11 ensures the timeliness and pertinence of the data, and can accurately capture food safety related information in the target area within a specific time period. Step 12 improves data quality, through pre-processing operations such as cleaning, denoising, and standardization, effectively eliminates redundant and erroneous information in the original data, and improves the accuracy and efficiency of subsequent analysis. Step 13, in-depth insight into public sentiment, fine-grained sentiment analysis can more accurately capture the public's attitude and emotional tendencies towards food safety incidents. Step 14 realizes information visualization, and intuitively displays the hot spots and trend changes in the field of food safety through word cloud diagrams and time series heat maps, helping analysts to quickly grasp key information and improve decision-making efficiency. Step 15 reveals the association relationship between entities. By constructing an entity relationship network, the connection and influence between the entities in the food safety incident can be clearly shown. Step 16 quickly locates related reports. By matching entity information and timestamps, news reports related to specific food incidents can be quickly and accurately identified, which is convenient for timely tracking of event progress and assessment of social impact. Step 17: To classify and summarize topics. By clustering the news reports, we can group them into different topics and generate corresponding keywords and summaries. This will help analysts to fully understand the content and focus of each topic and provide a basis for developing targeted response strategies. Step 18: To build a real-time early warning mechanism. By monitoring the changes in key indicators in the topic cluster, we can detect abnormal situations in time and trigger early warnings.

[0024] In a preferred embodiment of the present invention, the above step 11, obtaining multi-source network data around food safety related keywords in a specific time period and for a target area, may include: Determine a specific time period, for example: from January 1, 2023 to June 30, 2023; determine the target area, which can be a specific province, city or country, for example: Area A. Define a list of keywords related to food safety, such as: food poisoning, food recall, food contamination, excessive food additives, etc. Select appropriate data sources according to requirements, including social media platforms (such as Weibo, WeChat), news websites, forums, blogs, etc., to ensure that the data sources can provide data within the required time period and cover the target area.

[0025] Using web crawler technology, design corresponding data scraping rules for each data source, set up a scheduled task to ensure continuous data scraping within a specific time period; configure filtering rules to only scrape data containing keywords related to food safety. Deploy the web crawler, start scraping data from each data source, monitor the running status of the crawler to ensure the stability and integrity of data scraping, and conduct a preliminary screening of the scraped data to remove duplicate and invalid data. Integrate the data scraped from different data sources to form a unified data set, perform structured processing on the data set for subsequent analysis and processing; store the integrated data in a suitable database or data warehouse to ensure the security and accessibility of the data.

[0026] Through the above specific implementation process, step 11 can successfully obtain multi-source network data within a specific time period, for the target area, and around keywords related to food safety.

[0027] In a preferred embodiment of the present invention, in step 12 above, preprocessing the multi-source network data to obtain preprocessed data may include: Use a data deduplication algorithm, such as a hash-based deduplication method, to delete exactly the same data entries; remove irrelevant information: for example, delete HTML tags, advertisements, non-text content, etc., and retain pure text information for analysis. For missing fields in the data, fill them according to the data characteristics (such as using the mean, median or mode) or mark them as missing. Convert data from different sources into a unified format, such as date format, text encoding, etc. Perform operations such as case conversion, stop word removal (such as common words like "of", "is", etc.), and lemmatization (such as converting "ate", "have eaten" back to "eat") on the text data.

[0028] Based on keywords related to food safety, use text matching technology to filter out data directly related to food safety. Filter out low-quality data entries based on data quality indicators (such as text length, information completeness, etc.). Convert text data into numerical vectors to facilitate subsequent machine learning or deep learning model processing. Common methods include Bag of Words, TF-IDF (Term Frequency-Inverse Document Frequency), etc. Extract key features from the text as needed, such as named entities (such as names of people, places, institutions, etc.), sentiment words, etc.

[0029] In a preferred embodiment of the present invention, the above step 13, performing sentiment analysis on the fine-grained preprocessed data to obtain analysis results, may include: The preprocessed data is randomly divided into training and test sets, specifically including: Divide the dataset into two parts: training set and test set. Randomness ensures that the data distribution in the training set and the test set is similar, so that the performance of the model can be evaluated more fairly. Usually, the size of the training set will be larger than the test set, such as 70% of the data is used for training and 30% of the data is used for testing, but this ratio can be adjusted according to the specific situation.

[0030] For each word in the vocabulary list, query the external knowledge base to obtain relevant information about it, by A weight factor is calculated for each word, where the set of all unique words extracted from the preprocessed data is the sum of all unique words extracted from the preprocessed data. Preprocessing includes steps such as removing stop words, punctuation, lemmatization or stemming to obtain a cleaner and more standardized vocabulary list. An external knowledge base is a database or resource that stores a large amount of vocabulary-related information, such as WordNet, Wikipedia, sentiment lexicon, etc. These resources provide additional context, definition, relationship or sentiment tendency of the vocabulary. For each word in the vocabulary list, a query is initiated to the external knowledge base to obtain information related to the word, which includes synonyms, antonyms, definitions, contextual usage, sentiment scores, etc., depending on the knowledge base used and the purpose of the query. By querying the external knowledge base, richer information can be provided for subsequent text feature engineering. For example, in sentiment analysis, some words may have clear sentiment tendencies (such as "good" is positive and "bad" is negative), and this information may not be directly given explicitly from the text. By introducing external knowledge, these implicit sentiment signals can be captured more accurately, thereby improving the performance of the model.

[0031] For each text in the training set, calculate the frequency of each word, multiply the frequency of each word by its corresponding weight factor to get the weighted frequency, calculate the inverse document frequency of each word in the entire training set, and combine the weighted frequency and inverse document frequency to calculate the weighted TF-IDF value of each word; combine the weighted TF-IDF values ​​of all training texts into a numerical vector matrix, each row of the numerical vector matrix represents the feature vector of a text, and the column represents different lexical features; among them, for each text in the training set, traverse each word in the text and count the number of times each word appears, that is, the frequency. For each word, multiply its word frequency with the weight factor obtained by querying the external knowledge base to obtain the weighted word frequency. The weight factor can reflect the importance of the word, sentiment tendency and other information; traverse the entire training set and count the number of texts containing a certain word; for each word, multiply its weighted word frequency with the inverse document frequency to obtain the weighted TF-IDF value (word frequency-inverse document frequency); initialize a matrix with the number of rows being the number of texts in the training set and the number of columns being the number of words in the vocabulary list; for each text, fill the weighted TF-IDF value of each word in the matrix into the corresponding position to form the feature vector of the text.

[0032] Calculate the word frequency of each word in the test set text, multiply the word frequency of each word in the test set text with its corresponding weight factor to obtain the weighted word frequency; use the inverse document frequency value list calculated in the training set, multiply it with the weighted word frequency of the test set text, and obtain the weighted TF-IDF value of each word; combine the weighted TF-IDF values ​​of all test set texts into a numerical vector matrix, in which each row represents the feature vector of a test set text, and the columns of the test set matrix correspond to the columns of the training set matrix; similar to the training set, calculate the word frequency of each text in the test set, and multiply it with the weight factor to obtain the weighted word frequency; directly use the inverse document frequency value list calculated on the training set; multiply the weighted word frequency of the test set with the IDF value of the training set to obtain the weighted TF-IDF value of each word; similar to the training set, construct a numerical vector matrix for the test set, ensuring that the columns of the test set matrix correspond to the columns of the training set matrix.

[0033] Use the numerical vectors of the training set and their corresponding sentiment labels to train the prediction model, and input the numerical vectors of the test set into the trained prediction model, including: ensuring that the numerical vector matrix of the training set has been constructed, and each row corresponds to a feature vector of a text; preparing a list of sentiment labels corresponding to the numerical vectors of the training set, which may be binary (such as "positive" or "negative") or multi-class (such as "positive", "negative" and "neutral"), depending on the task requirements; reading the numerical vector matrix of the training set and the corresponding sentiment labels from the previously saved file; ensuring that the format of the data is suitable for the input of the neural network model. For example, the numerical values ​​can be normalized or standardized. Design the neural network structure according to the complexity of the problem and the dimension of the data, including determining the number of hidden layers, the number of neurons in each layer, the activation function, etc., and setting the initial values ​​of the network weights and biases. Use random initialization or a specific initialization method, such as He initialization or Xavier initialization; select an optimizer: such as Adam, SGD (stochastic gradient descent), etc., and set the initial learning rate; select a suitable loss function according to the nature of the problem, such as the cross entropy loss function for classification problems. To prevent overfitting, you can add L1, L2 regularization terms or Dropout layers; set the number of training rounds (epochs) and the batch size (batch size) for each round; in each batch, input data into the network and calculate the output of the network; use the defined loss function to calculate the difference between the network output and the actual label; calculate the gradient based on the loss, and update the weights and biases of the network; at the end of each epoch, use the validation set to evaluate the performance of the model. Record indicators such as loss and accuracy; adjust hyperparameters such as learning rate and regularization strength according to the performance of the validation set. You can use learning rate decay strategy or early stopping to prevent overfitting; if you decide to use cross-validation, divide the training set into k folds. For each fold, use the remaining k-1 folds as training data and the current fold as validation data. Repeat the above training process and record the performance indicators of each fold. Calculate the average performance indicators of all folds to more accurately evaluate the generalization ability of the model. Monitor the performance of the validation set during training. Save the model weights and configuration when the performance reaches the best, and export the trained model as a file for subsequent use or deployment.

[0034] The trained prediction model predicts the sentiment tendency of each text and gives the corresponding sentiment label and sentiment intensity score, including: obtaining the sentiment tendency prediction results of each text in the test set from the model; according to the design of the model, the prediction results can be discrete sentiment labels (such as "positive", "negative"), or continuous sentiment intensity scores (such as values ​​between 0 and 1, indicating the degree of negative to positive); if the model directly outputs sentiment labels, no conversion is required. If the model outputs continuous values, it may be necessary to set thresholds to convert these values ​​into discrete sentiment labels. For example, a score greater than 0.5 can be set as "positive" and a score less than 0.5 as "negative".

[0035] Calculate the sentiment labels and sentiment intensity scores to form the analysis results, including: organize the sentiment labels and sentiment intensity scores of each text in the test set into a data structure, such as a list or data frame; calculate various statistical indicators as needed, such as the number, proportion, average sentiment intensity score of various sentiment labels, etc.; use charts (such as bar charts, pie charts, box plots, etc.) to visualize the distribution of sentiment labels and the range of sentiment intensity scores, which helps to more intuitively understand the sentiment tendency and intensity distribution of the data.

[0036] In an embodiment of the present invention, by introducing an external knowledge base, a weight factor is calculated for each word, which comprehensively considers the frequency of the word, its importance in the knowledge base, and the scarcity of the word in the text set. This helps to capture the emotional meaning of the word more accurately, thereby improving the accuracy of sentiment analysis. Using weighted TF-IDF values ​​as text features can not only reflect the importance of the word in a single text, but also reflect its distribution in the entire text set. This feature representation method helps the model to better generalize to unseen data and improve the robustness of sentiment analysis. In addition to giving the overall sentiment label of the text, the method can also provide a sentiment intensity score, thereby achieving a fine-grained analysis of the text sentiment. The method can flexibly combine different external knowledge bases and weight calculation strategies to adapt to different application scenarios and needs. At the same time, with the update and expansion of the knowledge base, the performance of the method can also be further improved.

[0037] In a preferred embodiment of the present invention, the above step 14, dynamically extracting hot words and phrases in the analysis results to construct a hot word cloud diagram and a time series heat map, includes: Split the continuous text into independent word and phrase units, and count each segmented word and phrase. Specifically, it includes: performing necessary preprocessing on the continuous text, such as removing punctuation marks, stop words (such as common words like "de", "shi", etc.), and text cleaning (such as removing advertisements, special characters, etc.); using a word segmentation tool (such as jieba segmentation, NLTK, etc.) to split the preprocessed text into independent word and phrase units. Word segmentation tools usually perform word segmentation based on dictionaries and rules, and can identify words, phrases, etc. in a sentence; create a dictionary (such as a dictionary in Python) to store each segmented word and phrase and its occurrence count. Traverse the word segmentation results. For each word or phrase, check whether it already exists in the dictionary. If it exists, increment its count. If it does not exist, add it to the dictionary and initialize the count to 1.

[0038] Filter out hot words and phrases according to preset criteria, and sort the filtered hot words to obtain an optimized result set. Specifically, it includes: setting criteria for filtering hot words and phrases according to specific needs, such as setting a threshold for the occurrence frequency, a length limit for words or phrases, etc.; traversing the dictionary created in the above steps, and filtering out eligible hot words and phrases according to the preset criteria. For example, words that appear more than a certain threshold can be filtered out; sort the filtered hot words and phrases according to their occurrence count or other relevant metrics (such as TF-IDF value) so that the most important words and phrases can be prominently displayed when generating visual charts later.

[0039] Convert the filtered and sorted hot words and phrases into data formats; determine whether to generate a word cloud or a time series heat map according to the requirements; if the converted data contains timestamp information, generate a time series heat map according to the time order and word heat, specifically including: determine the required data format according to the requirements for subsequent generation of word cloud or time series heat maps. Usually, this includes organizing words and phrases and their corresponding counts into a specific data structure, such as a list, a data frame, etc.; convert the filtered and sorted hot words and phrases and their counts according to the target data format. For example, you can create a data frame with two columns, one for words or phrases and the other for the corresponding counts; determine the specific needs of the user and determine whether to generate a word cloud or a time series heat map. Word cloud maps are mainly used to show the frequency and importance of words, while time series heat maps focus on showing the changes in word heat over time; select appropriate visualization tools according to requirements, such as the WordCloud library in Python for generating word cloud maps, and libraries such as Matplotlib or Seaborn for generating time series heat maps; check whether the converted data contains timestamp information. If included, you can sort the data by timestamp; organize the hot words and phrases data with timestamps according to time series, ensuring that the data corresponding to each time point contains the words or phrases and their heat information; use the time series heat map generation tool (such as Matplotlib's heatmap function) to draw a heat map based on the prepared data. In the heat map, the horizontal axis represents time, the vertical axis represents words or phrases, and the color of each cell represents the heat of the corresponding time point and word. By adjusting settings such as color mapping and annotation, you can clearly show the trend of word heat over time.

[0040] In an embodiment of the present invention, by dividing the continuous text into independent vocabulary and phrase units and counting these units, the process can effectively extract the key information in the text. Further, through the generation of word cloud graphs and time series heat maps, this information can be intuitively and clearly visualized, which is convenient for users to quickly understand and grasp the core points of text data. The function of filtering and sorting hot words and phrases enables the system to automatically identify hot topics and trends within a certain time range or in the entire data set, which can help decision makers capture market dynamics and public focus in a timely manner. The step of converting the filtered and sorted hot words and phrases into a data format suitable for generating word cloud graphs or time series heat maps enhances the flexibility and adaptability of data processing. Different visualization requirements can be met by adjusting the data format, thereby providing users with a variety of data analysis perspectives. If the converted data contains timestamp information, generating a time series heat map can not only show the popularity of the words, but also reveal the changing trend of these hot words over time.

[0041] In a preferred embodiment of the present invention, the above step 15 extracts key entity information of food name, brand, origin and event location in news reports based on the hot word cloud map and time series heat map to construct a structured entity relationship network, including: Step 151, receiving the pre-processed news report text as input data, specifically includes: creating a data receiving interface for receiving the pre-processed news report text from the outside, this interface can be a function, API endpoint or a data pipeline, depending on the architecture and design of the system. Before receiving the data, the data format is verified to ensure that the incoming data conforms to the expected format and standards. For example, it can be checked whether the data is in text format, whether it contains necessary fields, etc.; the verified data is stored in the internal data structure of the system, such as a variable, database or data cache, so that it can be processed in subsequent steps.

[0042] Step 152, using a pre-trained named entity recognition model, automatically recognize the food name, brand, origin, and event location in the text, specifically including: investigating the pre-trained NER models available on the market, such as BERT-NER, Spacy's NER component, and the NER model in Hugging Face's Transformers library, and evaluating the performance and accuracy of these models in entity recognition of food names, brands, origins, and event locations. According to the evaluation results, select a pre-trained NER model with excellent performance and meeting the project requirements, ensuring that the model can cover the entity types required to be recognized and has good generalization capabilities. Configure the environment required to run the NER model in the system, including installing necessary libraries and dependencies, such as TensorFlow, PyTorch, or Spacy, depending on the type of model selected. Download the pre-trained NER model file from the official channel of the model provider, and then use the corresponding library function or API to load the model into the system to prepare to receive input data for entity recognition. If the news report text needs to be subjected to specific pre-processing operations (such as word segmentation, removal of stop words, etc.) before being input into the NER model, these steps are performed first. The news report text received in step 151 is passed as input data to the loaded NER model. The NER model automatically scans the input text, identifies the entities therein, and classifies them into categories such as food names, brands, origins, or places where events occurred. This process is usually completed based on the patterns and features learned within the model. After the NER model completes entity recognition, it generates an output containing the recognition results. This output is a list or a similar data structure, in which each element represents an identified entity and its related information (such as entity text, entity category, location in the original text, etc.); extract the identified entity and its category information, and store this information in a data structure that is convenient for subsequent processing, such as a dictionary, a list, or a custom object.

[0043] Step 153, pre-define the relationship type between entities, and extract the relationship between entities from the text through rule matching; Step 154, storing the extracted entities and the relationships between entities in a structured manner to obtain stored entity-relationship pairs, specifically including: designing a data structure suitable for storing entities and relationships, such as tables in relational databases, nodes and edges in graph databases, or objects and data dictionaries in memory, etc. Fill and store the entities and relationships extracted in step 153 according to the designed data structure. Ensure that each entity and relationship has a unique identifier, and that the associations between them are correctly preserved; in order to improve query efficiency, indexes can be established for the stored entities and relationships, and necessary optimization operations can be performed, such as partitioning, compression, etc.

[0044] Step 155, based on the stored entity-relationship pairs, construct an entity relationship network, in which nodes represent entities and edges represent relationships between entities, specifically including: preparing to construct an entity relationship network according to the entity-relationship pairs stored in step 154. Selecting a graph database or network library to support network construction and query operations; in the network, creating a node for each entity and an edge for each pair of entities with a relationship, and the nodes and edges should contain sufficient metadata to describe the attributes of the entities and relationships; optimizing the constructed entity relationship network, such as removing redundant edges, merging duplicate nodes, etc. At the same time, verifying the correctness and integrity of the network through query and visualization tools; providing a network query interface and analysis tools, allowing users to query entities, relationships and their associations in the network according to their needs, and these query and analysis results can help users better understand the content and contextual relationships in news reports.

[0045] In an embodiment of the present invention, through the named entity recognition model, the system can automatically and accurately identify key entity information such as food names, brands, places of origin, and places where events occurred from a large number of news report texts. This automated information extraction method greatly improves the efficiency and accuracy of information processing. By pre-defining the relationship types between entities and extracting these relationships from the text using rule matching, the system can reveal the intrinsic connections between entities. This helps users to understand the events and situations in news reports more deeply and discover potential associations and trends. The extracted entities and the relationships between entities are stored in a structured manner, making this information easier to manage and query. Users can easily retrieve specific entities or relationships for further data analysis and mining. The entity relationship network constructed based on the stored entity-relationship pairs provides users with an intuitive visualization tool. Through this network, users can clearly see the connections and interactions between various entities, so as to better understand the ins and outs and influencing factors of the event. The process has good flexibility and scalability. As news reports are constantly updated and changed, the system can continuously identify and extract new entities and relationships and dynamically update the entity relationship network.

[0046] In a preferred embodiment of the present invention, step 153 predefines the relationship type between entities and extracts the relationship between entities from the text through rule matching, including: Determine the entity relationship types to be extracted, and determine a series of initial rules for each relationship type to obtain an initial rule set, including: Determine which types of entity relationships need to be extracted from the text, such as "brand-production-food", "food-produced-origin", etc. For each relationship type, formulate a series of initial rules. These rules can be based on syntactic structure, keywords, pattern matching, etc. For example, for the "brand-production-food" relationship, you can formulate rules to match the sentence "a certain brand produces a certain food". Integrate all the initial rules formulated for different relationship types into an initial rule set.

[0047] Preprocess the input text and identify entities in the text, including: preprocess the input text, such as word segmentation, stop word removal, punctuation processing, etc., to facilitate subsequent rule matching; use named entity recognition (NER) technology to identify entities in the text, such as food names, brands, places of origin, etc. These entities will serve as the basis for subsequent relationship extraction.

[0048] Use the initial rule set to match the preprocessed text with rules to extract the relationship between entities, including: matching the preprocessed text with the initial rule set, trying to extract the relationship between entities, which can be achieved through regular expression matching, syntactic analysis and other methods; based on the results of rule matching, extracting entity pairs that meet specific relationships. For example, if the sentence "a certain brand produces a certain food" appears in the text, and the entity recognition step correctly identifies the brand and food name, then the "brand-production-food" relationship can be extracted.

[0049] The currently used rule set is regarded as a solution, and each solution corresponds to an evaluation score, which includes: the currently used rule set is regarded as a solution, which represents a possible way of entity relationship extraction; an evaluation score is calculated for each solution to measure its performance. The evaluation score can be based on multiple indicators, such as the recall rate of relationship extraction, which requires a well-labeled data set as an evaluation benchmark.

[0050] On the basis of the current rule set, neighborhood solutions are generated by adding, deleting or modifying rules. Specifically, minor modifications are made to the current rule set, such as adding a new rule, deleting an existing rule, or modifying part of a rule to generate neighborhood solutions. These modifications should be targeted to improve the performance of relationship extraction. When generating neighborhood solutions, attention should be paid to maintaining the diversity of solutions to avoid falling into local optimality.

[0051] According to the Metropolis criterion, it is decided whether to accept the neighborhood solution as the new current solution. After a certain number of iterations at each temperature, the temperature is reduced according to the set temperature drop rate. When the temperature reaches the preset number of iterations, the simulated annealing process is stopped, and the target text is subjected to relation extraction using the rule set optimized by simulated annealing to obtain the extracted entity relationship, which specifically includes: calculating the difference in evaluation scores between the neighborhood solution and the current solution, and deciding whether to accept the neighborhood solution as the new current solution according to the Metropolis criterion. If the evaluation score of the neighborhood solution is higher, or it meets certain random acceptance conditions (based on the current temperature), the neighborhood solution is accepted; the initial temperature is set, and a certain number of iterations are performed at each temperature, and each iteration generates and evaluates the neighborhood solution. After the iteration is completed, the temperature is reduced according to the set temperature drop rate; when the temperature reaches the preset minimum value or reaches the preset number of iterations, the simulated annealing process is stopped, and the target text is subjected to relation extraction using the rule set optimized by simulated annealing to obtain the final extracted entity relationship result.

[0052] In an embodiment of the present invention, by predefining the relationship types between entities and determining the initial rule set for each relationship type, the relationship between entities can be extracted more specifically, thereby improving the accuracy of relationship extraction. The simulated annealing algorithm can further optimize these rules to make the extraction results more accurate. The rule matching method is used for relationship extraction, so that the system can flexibly deal with different types of text and entity relationships. The rules can be adjusted and expanded according to actual needs to adapt to more application scenarios. The simulated annealing algorithm enables the system to automatically adapt to the complexity and diversity in the text by continuously iterating and optimizing the rule set. This adaptability helps to improve the performance of the system when processing texts of different styles and contents. Traditional entity relationship extraction methods often require a lot of manual annotation and adjustment. However, this method automatically optimizes the rule set through the simulated annealing algorithm, reduces the need for manual intervention, and improves work efficiency. The simulated annealing algorithm is a global optimization algorithm that can avoid falling into a local optimal solution to a certain extent, thereby finding a rule set that is closer to the global optimal solution, which makes the system more robust when processing complex and noisy texts. This method is not only applicable to the currently defined entity relationship types, but can also be expanded to more relationship types as needed. At the same time, with the accumulation of data and continuous optimization of rules, the performance of the system is expected to continue to improve.

[0053] In a preferred embodiment of the present invention, the above step 16, identifying news reports related to a specific food incident based on the entity relationship network, combined with entity information and timestamps, includes: According to the entity relationship network, combined with entity information and timestamp, Calculate similarities to identify news stories related to specific food events; in, is a weight; is the weight within the entity similarity; Representing a collection of entities and entity collection The size of the intersection of , that is, the number of entities in common between the two reports; Representing a collection of entities and entity collection The size of the union of , i.e., the number of all entities that are different in the two reports; Representing Entities The weight of is the weight; and is the time decay factor; and News reports and The publishing timestamp of is the base of natural logarithms; Representatives were reported in the news and The entity collection and The specific entity that appears in the intersection of It's a news report and The similarity.

[0054] In an embodiment of the present invention, by combining entity relationship networks, entity information and timestamps, the method can more accurately identify news reports related to specific food incidents. The entity relationship network reflects the connections between entities and helps to find reports that are directly or indirectly related to food incidents. The method uses a similarity calculation formula that contains multiple parameters, such as , , , and ) can be adjusted according to the actual situation to meet the needs of news report recognition in different scenarios. This flexibility enables this method to better cope with complex and changing real-world environments. The time decay factor ( and ), which means that the closer the release time of news reports is, the higher the similarity between them. This design is in line with the timeliness of news reports and helps to promptly discover and track the latest reports related to specific food incidents. By assigning a weight W to each entity, this method can distinguish the importance of different entities in news reports. For example, entities directly related to food incidents (such as food names, manufacturers, etc.) may be given higher weights, thereby playing a greater role in similarity calculations. This method not only considers the number of common entities in news reports, but also the number of all different entities. This comprehensive entity relationship analysis helps to more accurately evaluate the similarity between two reports and avoid misjudgment due to local similarities.

[0055] In a preferred embodiment of the present invention, in step 17, the news reports are clustered to obtain different topic clusters; based on the different topic clusters, the subject keywords and summary of each topic cluster are generated, including: According to the similarity between each pair of news reports, the corresponding news report pairs are gradually merged into topic clusters until a preset number of topic clusters is reached, wherein each finally formed topic cluster represents a specific topic, specifically including: initializing an empty topic cluster list; calculating the similarity between all news report pairs; merging the news report pairs with the highest similarity into a new topic cluster, or adding one of the reports to the topic cluster most similar to it; continuing to select the report pairs with the highest similarity from the unassigned topic clusters for merging, or adding the reports to the existing topic clusters, repeating the above steps until the preset number of topic clusters is reached or all news reports are assigned to a topic cluster; For each topic cluster, all news reports in the topic cluster are traversed to calculate the frequency of occurrence of each word, including: for each topic cluster, an empty word frequency dictionary is initialized, all news reports in the topic cluster are traversed, and for each report, all its words are further traversed. In the word frequency dictionary, the number of occurrences of each word is recorded. If the word already exists in the dictionary, its number of occurrences is increased by one; otherwise, a new entry is created for the word in the dictionary and its number of occurrences is set to one.

[0056] Use a pre-trained part-of-speech tagging model to tag each word, and filter out words that do not meet the conditions according to the set rules to obtain a list of words filtered by part-of-speech for each topic cluster. Specifically, prepare a pre-trained part-of-speech tagging model, which can be downloaded from a natural language processing library (such as spaCy, NLTK, etc.), ensure that the model has been loaded into memory and is ready to receive input text for part-of-speech tagging. Extract all words from each topic cluster, which can be extracted from news reports, social media posts, or other text sources, and organize these words into a list or similar data structure; for each word in the topic cluster, use the loaded part-of-speech tagging model to tag the part of speech, and the model will assign a part-of-speech tag to each word, such as noun (NOUN), verb (VERB), adjective (ADJ), etc.; according to the analysis requirements, set a set of filtering rules, which can be based on part-of-speech tags, such as retaining only nouns and verbs, or filtering according to other criteria (such as word frequency, length, etc.), and record these rules explicitly. Traverse each word in the topic cluster and its corresponding part-of-speech tag. For each word, check whether its part-of-speech tag meets the preset filtering rules. If it meets the rules, keep the word and its part-of-speech tag; if not, exclude it. Create a new data structure (such as a list, dictionary, etc.) to store the filtered words and their part-of-speech information, add each word that meets the rules and its part-of-speech tag to this data structure, and repeat the above steps until all words in the topic clusters are processed. Finally, each topic cluster will correspond to a list of words filtered by part-of-speech, which contains the most important or most relevant words and their part-of-speech information in the topic cluster.

[0057] After obtaining the word list after part-of-speech filtering, calculate the TF-IDF value of each word in each topic cluster; filter keywords based on the TF-IDF value to obtain the final keywords, specifically including: for each topic cluster and each word in it, calculate the word frequency (TF) in the topic cluster; calculate the inverse document frequency (IDF) of each word in all news reports, multiply the TF and IDF of each word to obtain the TF-IDF value of the word in the topic cluster; sort the words in each topic cluster according to the calculated TF-IDF value; select the top k words with the highest TF-IDF value as the keywords of the topic cluster; the value of k can be adjusted according to needs to obtain different numbers of keywords.

[0058] For each topic cluster, the importance score of each sentence in each report in the topic cluster is obtained by calculating the similarity between the sentence and the topic of the report. Specifically, for each report in each topic cluster, its topic is represented as a vector form of keywords, each sentence in the report is traversed, and the sentence is also represented as a vector form. The similarity between the sentence vector and the report topic vector is calculated (such as cosine similarity), and the similarity is used as the importance score of the sentence in the report.

[0059] According to the importance score, several representative sentences or paragraphs in each topic cluster are selected and combined into a summary of the topic cluster, which specifically includes: sorting the sentences in each topic cluster according to the calculated importance score; selecting the first few sentences or paragraphs with the highest scores as the representative content of the topic cluster, and combining these representative sentences or paragraphs to form a summary of the topic cluster. The number of selected sentences or paragraphs can be adjusted according to needs to obtain summaries of different lengths.

[0060] In an embodiment of the present invention, by calculating the similarity between each pair of news reports and gradually merging them into topic clusters, effective classification of a large number of news reports can be achieved. This method not only helps to group related reports together, but also reveals different report topics, thereby providing users with a clearer and more targeted information browsing experience. By calculating the frequency of occurrence of each word in each topic cluster, and combining part-of-speech tagging and TF-IDF value for screening, the keywords of each topic cluster can be accurately extracted. These keywords not only help users quickly understand the core content of the topic, but also serve as an important basis for search and recommendation, improving the efficiency and accuracy of information retrieval. By calculating the similarity between a sentence and the topic of the report, and selecting representative sentences or paragraphs according to the importance score, high-quality topic cluster summaries can be generated. These summaries not only retain the main information of the topic, but also perform effective content compression and refinement, which helps users quickly understand the overview and key points of the topic in a limited time. The steps of similarity calculation, keyword extraction and summary generation in the method can be adjusted and optimized according to actual needs, and have strong flexibility and scalability. For example, the parameters of similarity calculation can be adjusted to adapt to report data in different fields and scenarios.

[0061] In a preferred embodiment of the present invention, the above step 18 may include: Set a benchmark time interval (such as every hour or every day), and at the end of each time interval, count the number of new texts in the topic cluster. Calculate the growth rate, that is, the ratio of the number of new texts to the total number of texts in the previous time interval. If the growth rate exceeds the preset threshold, it is considered an abnormal situation.

[0062] Analyze whether the public's emotional attitude towards the topic has changed significantly, such as from positive to negative, or from neutral to extreme concern, and perform sentiment analysis on the text in the topic cluster, using the trained prediction model. Emotions are divided into several categories, such as positive, negative, and neutral, and the proportion of each category of emotion is calculated. Track the changes in these proportions over time. If the emotional tendency fluctuates drastically in a short period of time (such as a sudden increase in the proportion of negative emotions), an early warning is triggered.

[0063] Identify whether certain keywords that are closely related to the topic or indicative suddenly appear frequently, which may indicate new development trends or important events; pre-define a group of keywords related to the topic, and count the frequency of occurrence of these keywords in the topic cluster in real time. If the frequency of occurrence of a keyword increases significantly and exceeds the preset threshold, it is considered an abnormal situation.

[0064] When any of the above monitoring indicators shows an abnormal situation, the system should automatically trigger an early warning. The early warning can be sent in a variety of ways, such as email, text message, in-app notification, etc., to ensure that relevant personnel can immediately know and respond. The early warning information should include the specific indicators that triggered the early warning, a detailed description of the abnormal situation, and an analysis of possible causes.

[0065] like Figure 2 As shown, an embodiment of the present invention further provides a food safety risk analysis system based on big data, comprising: An acquisition module is used to acquire multi-source network data around food safety related keywords within a specific time period and for a target area; A preprocessing module, used for preprocessing multi-source network data to obtain preprocessed data; The analysis module is used to perform sentiment analysis on the preprocessed data at a fine-grained level to obtain analysis results; A construction module is used to dynamically extract hot words and phrases in the analysis results to construct hot word cloud diagrams and time series heat maps; The extraction module is used to extract key entity information such as food name, brand, origin and location of the event in news reports based on the hot word cloud map and time series heat map to build a structured entity relationship network; A computational module for identifying news reports related to a specific food event based on an entity relationship network, combined with entity information and timestamps; A generation module is used to cluster news reports to obtain different topic clusters; based on different topic clusters, the subject keywords and summary of each topic cluster are generated; The early warning module is used to monitor the growth rate of the number of texts in each topic cluster, changes in sentiment tendencies, and the frequency of occurrence of specific keywords in real time, and trigger an early warning when an abnormal situation is detected.

[0066] It should be noted that the system is a system corresponding to the above method, and all implementation methods in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.

[0067] The embodiment of the present invention further provides a computing device, comprising: a processor, a memory storing a computer program, wherein when the computer program is executed by the processor, the method described above is executed. All implementations in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.

[0068] The embodiment of the present invention also provides a computer-readable storage medium storing instructions, which, when executed on a computer, enable the computer to execute the method described above. All implementations in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.

[0069] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A food safety risk analysis method based on big data, characterized in that: The method comprises: Obtain multi-source network data around food safety related keywords within a specific time period and in a target region; Preprocessing multi-source network data to obtain preprocessed data; Perform sentiment analysis on the fine-grained preprocessed data to obtain analysis results; Dynamically extract hot words and phrases in the analysis results to build hot word cloud diagrams and time series heat maps; Based on the hot word cloud diagram and time series heat map, extract the key entity information of food name, brand, origin and location of the event in the news report to build a structured entity relationship network; Based on the entity relationship network, combining entity information and timestamps, we identify news reports related to specific food events. Cluster news reports to obtain different topic clusters; generate the subject keywords and summary of each topic cluster according to different topic clusters; By real-time monitoring of the growth rate of the amount of text in each topic cluster, changes in sentiment, and the frequency of occurrence of specific keywords, an early warning is triggered when an abnormal situation is detected.

2. The food safety risk analysis method based on big data according to claim 1, characterized in that: Perform sentiment analysis on the fine-grained preprocessed data to obtain analysis results, including: Randomly divide the preprocessed data into training set and test set; For each word in the vocabulary list, query the external knowledge base to obtain relevant information about it, by Calculate a weight factor for each word; For each text in the training set, calculate the frequency of each word, multiply the frequency of each word by its corresponding weight factor to get the weighted frequency, calculate the inverse document frequency of each word in the entire training set, and combine the weighted frequency and inverse document frequency to calculate the weighted TF-IDF value of each word; combine the weighted TF-IDF values ​​of all training texts into a numerical vector matrix, where each row of the numerical vector matrix represents a feature vector of a text, and the columns represent different lexical features; Calculate the frequency of each word in the test set text, multiply the frequency of each word in the test set text by its corresponding weight factor to obtain the weighted frequency; use the inverse document frequency value list calculated in the training set, multiply it by the weighted frequency of the test set text, and obtain the weighted TF-IDF value of each word; combine the weighted TF-IDF values ​​of all test set texts into a numerical vector matrix, where each row represents the feature vector of a test set text, and the columns of the test set matrix correspond to the columns of the training set matrix; Use the numerical vectors of the training set and their corresponding sentiment labels to train the prediction model, and input the numerical vectors of the test set into the trained prediction model; The trained prediction model predicts the sentiment tendency of each text and gives the corresponding sentiment label and sentiment intensity score; Calculate sentiment labels and sentiment intensity scores to form analysis results.

3. The food safety risk analysis method based on big data according to claim 2, characterized in that: Dynamically extract hot words and phrases in the analysis results to build hot word cloud charts and time series heat maps, including: Segment the continuous text into independent words and phrases, and count the words and phrases after each segmentation; Filter out hot words and phrases according to preset standards, and sort the filtered hot words to obtain an optimized result set; Convert the filtered and sorted hot words and phrases into data formats; generate word cloud diagrams or time series heat maps based on demand; if the converted data contains timestamp information, generate time series heat maps based on time sequence and word heat.

4. The food safety risk analysis method based on big data according to claim 3 is characterized in that: According to the hot word cloud map and time series heat map, extract the key entity information of food name, brand, origin and location of the event in the news report to build a structured entity relationship network, including: Receiving preprocessed news report text as input data; Use pre-trained named entity recognition models to automatically identify food names, brands, origins, and event locations in text; Predefine the relationship types between entities and extract the relationships between entities from the text through rule matching; The extracted entities and the relationships between the entities are stored in a structured manner to obtain stored entity-relationship pairs; Based on the stored entity-relationship pairs, an entity-relationship network is constructed. In the entity-relationship network, nodes represent entities and edges represent relationships between entities.

5. The food safety risk analysis method based on big data according to claim 4 is characterized in that: Predefine the relationship types between entities and extract the relationships between entities from the text through rule matching, including: Determine the entity relationship types to be extracted, and determine a series of initial rules for each relationship type to obtain an initial rule set; Perform preprocessing operations on the input text and identify entities in the text; Use the initial rule set to match the preprocessed text to extract the relationship between entities; The currently used rule set is regarded as a solution, and each solution corresponds to an evaluation score; Generate neighborhood solutions by adding, deleting or modifying rules based on the current rule set; According to the Metropolis criterion, it is decided whether to accept the neighborhood solution as the new current solution. After a certain number of iterations at each temperature, the temperature is reduced according to the set temperature drop rate. When the temperature reaches the preset number of iterations, the simulated annealing process is stopped, and the target text is subjected to relation extraction using the rule set optimized by simulated annealing to obtain the extracted entity relationship.

6. The food safety risk analysis method based on big data according to claim 5 is characterized in that: Based on the entity relationship network, combined with entity information and timestamps, news reports related to specific food events are identified, including: According to the entity relationship network, combined with entity information and timestamp, Calculate similarities to identify news stories related to specific food events; in, is a weight; is the weight within the entity similarity; Representing a collection of entities and entity collection The size of the intersection of , that is, the number of entities in common between the two reports; Representing a collection of entities and entity collection The size of the union of , i.e., the number of all entities that are different in the two reports; Representing Entities The weight of is the weight; and is the time decay factor; and News reports and The publishing timestamp of is the base of natural logarithms; Representatives were reported in the news and The entity collection and The specific entity that appears in the intersection of It's a news report and The similarity.

7. The food safety risk analysis method based on big data according to claim 6 is characterized in that: Cluster news reports to obtain different topic clusters; According to different topic clusters, generate the subject keywords and abstracts of each topic cluster, including: According to the similarity between each pair of news reports, the corresponding news report pairs are gradually merged into topic clusters until a preset number of topic clusters is reached, wherein each finally formed topic cluster represents a specific topic; For each topic cluster, traverse all news reports in the topic cluster and calculate the frequency of occurrence of each word; Use the pre-trained part-of-speech tagging model to tag each word with part-of-speech, and filter out words that do not meet the conditions according to the set rules to obtain a word list after part-of-speech filtering for each topic cluster; After obtaining the word list after part-of-speech filtering, calculate the TF-IDF value of each word in each topic cluster; Filter keywords based on TF-IDF values ​​to get the final keywords; For each topic cluster, the importance score of each sentence in each report in the topic cluster is obtained by calculating the similarity between the sentence and the topic of the report. According to the importance score, several representative sentences or paragraphs in each topic cluster are selected and combined into a summary of the topic cluster.

8. A food safety risk analysis system based on big data, characterized in that: Applied to the method according to any one of claims 1 to 7, comprising: An acquisition module is used to acquire multi-source network data around food safety related keywords within a specific time period and for a target area; A preprocessing module, used for preprocessing multi-source network data to obtain preprocessed data; The analysis module is used to perform sentiment analysis on the preprocessed data at a fine-grained level to obtain analysis results; A construction module is used to dynamically extract hot words and phrases in the analysis results to construct hot word cloud diagrams and time series heat maps; The extraction module is used to extract key entity information such as food name, brand, origin and location of the event in news reports based on the hot word cloud map and time series heat map to build a structured entity relationship network; A computational module for identifying news reports related to a specific food event based on an entity relationship network, combined with entity information and timestamps; A generation module is used to cluster news reports to obtain different topic clusters; based on different topic clusters, the subject keywords and summary of each topic cluster are generated; The early warning module is used to monitor the growth rate of the number of texts in each topic cluster, changes in sentiment tendencies, and the frequency of occurrence of specific keywords in real time, and trigger an early warning when an abnormal situation is detected.

9. A computing device, characterized in that include: one or more processors; A storage device 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 as claimed in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program, which, when executed by a processor, implements the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Device and method for identifying and evaluating emergency hot topic

    CN102937960A

  • Product information security risk monitoring method based on semantic analysis

    CN110008311A

  • Public opinion monitoring method and system based on topic detection, and storage medium

    CN110516067A

  • Network information topic detection method, system and device based on multi-feature fusion

    CN114579731A

  • Approaches for large-scale classification and semantic text summarization

    US20190163817A1

Cited By

  • Text analysis method and device, electronic terminal and computer readable storage medium

    CN121478783A