{'fraction_non_alphanumeric': 0.018977673325499413, 'fraction_numerical': 0.007168037602820212, 'mean_word_length': 4.978573937478047, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Research on Enterprise Hidden Danger Association Rules Based on Text Analysis

Descriptive fields are used in the daily operation of an enterprise as a dimension for recording hidden danger letters. However, it is quite difficult to extract corresponding effective data from such text information to guide the operation of the enterprise. In view of this problem, this paper first grouped the hidden danger data of different enterprise types, then used Chinese word segmentation technology to transform the corresponding descriptive fields into structural data, extracted the topic model using Latent Dirichlet Allocation (LDA) algorithm, and finally used Apriori algorithm to find the association rules of hidden dangers under different enterprise types. After the analysis of the experimental results, the association rules validated accord with common sense and can provide data support for hidden danger supervision.


Introduction
How to ensure the safety of personnel in the production of enterprises is not only a corporate problem, but also a social issue. With the development of information technology, various organizations began to use electronic media to store daily operational data. These data also include information on production safety. It is a rather difficult problem that how to delete useless information from massive data and integrate effective information to obtain the required model to guide the operation of the organization. Especially for data such as production safety, most of them cannot be represented by data such as scalars, but texts are used to record data on production safety, such as production processes, hidden danger descriptions, and accident information. There is an urgent need to solve the problem of the complexity of semi-structured data in Chinese text, so that a large number of organizational safety production text data can be used in existing machine learning to obtain a model that can provide data support for future production safety. Therefore, research on information mining technology based on production safety text is very important and urgent.
Due to the rise of machine learning, corresponding algorithms have been applied to the data analysis of production safety management. In English, there is a study on the relationship between motor vehicle injury degree and hospital-related factors [1], analysis of fire factors in Spain [2], assessment of regional society, economy and environment through hydraulic fracturing activity [3], and study the relation between the full moon and traffic accidents through traffic accident information [4]. However, because of the limitations of some algorithm models, when text data is used in data analysis, most of the information is reduced. For example, the information of the text type data is 2 reduced according to the manually defined fault classification, resulting in the lack of fault detailed information in the data analysis. A small part of the use of word segmentation [5,6] to convert text information into a corresponding keyword network to achieve the introduction of text information. However, due to the different grammatical structures between Chinese and English, the corresponding results can not be directly applied to the analysis of Chinese texts.
With the development of Chinese words segmentation, such as text segmentation technology based on analysis [7], Context Information and Fragments Based Cross-Domain Chinese Word Segmentation [8], and A new feature selection method for handling redundant information in text classification [9]. How to make full use of the text data that has been reduced or even neglected in the past, the detailed data from the cause to the result is completely incorporated into the data analysis, and finally the model that can be used completely and comprehensively for event correlation analysis begins to be paid more and more attention by researchers. Now there is an analysis of the comprehensive strength of tourism in Zhejiang Province [10], using text mining rheumatoid arthritis and diabetes to understand the mechanism of traditional Chinese medicine treatment of different diseases [11], power work sheet text data analysis mining model research [12] and other articles The application of text mining has achieved good results. However, they are all a classification study on one aspect. The final result is the relationship between cause and effect, without taking into account the relationship between effect and effect. In daily safety production management, it is necessary not only to prevent accidents caused by corresponding hidden dangers, but also to consider the problems of concurrent accidents caused by the connection between them. This article is about research in this area.
In this paper, data analysis is carried out based on The R Programming language. The first step is to use the Chinese word segmentation Rwordseg in the R environment to perform word segmentation and word frequency statistics on the description fields and the sub-category fields of the hidden danger information. The second step is to classify the enterprise information according to the types of regulatory industries, and to extract and classify the data after the segmentation. The third step is to further analyze the relationship between the types of enterprise supervision and the types of hidden dangers, to obtain the potential risks of the identified types of enterprises, and to obtain the relationship between the hidden dangers of a certain type of enterprises.

Experimental Design
The first step of the experiment is to preprocess the data, which is mainly divided into two parts. First, extract the description text in the hidden danger information record without missing and can be used normally. Use the Chinese word segmentation Rwordseg in the R environment to perform Chinese word segmentation on the corresponding description text. Delete the useless information of the word frequency data information after the word segmentation, such as auxiliary words, prepositions and the like. This package uses rjava to call Java's Chinese word segmentation tool Ansj, which is based on the ictclas Chinese word segmentation algorithm of the Chinese academy of sciences and adopts Hidden Markov Model (HMM). The algorithm implements the following steps: 1. Full-segmentation, atomic segmentation; 2. N-short path rough segmentation, according to hidden Markov model and viterbi algorithm, to achieve optimal path planning;3. Name recognition; 4, system dictionary supplement; 5, user-defined dictionary supplement; 6, part-of-speech tagging (optional). When using this package for Chinese word segmentation of description field of hidden danger, some professional words cannot be distinguished correctly, so professional words can be distinguished correctly by adding dictionary. After extracting the useful data, the result of word segmentation is transformed into the word frequency matrix. Second, extract the account information of the corresponding enterprise according to the record extracted from the first.
The second step is to classify companies and hidden dangers, which are also divided into two parts. First, classify enterprises according to the types of regulated industries. Secondly, the classification of hidden danger is to classify hidden danger topics based on LDA topic model algorithm and extract the topics for a single record. Compared with the commonly used clustering algorithm, which regards a record as a unit, LDA thematic model algorithm assumes that each record is composed of multiple different topics in different proportions, making the classification more detailed. In this way, the text information that was not used in the big data analysis of the past hidden dangers is fully utilized, so that the classification obtained is more detailed than in the past. This makes the final analysis more applicable to the actual situation.
The third step is to find out the pattern of hidden dangers in different types of enterprises. According to the classification in a single enterprise, the number of hidden dangers is converted into the proportion corresponding. Synthesize the hidden dangers of each enterprise under the single enterprise classification, and finally use the Apriori algorithm to obtain the association rules between them.
After the above three steps, an enterprise can be classified. After the classification, other potential risks can be predicted through the detected hidden dangers to provide data support for the hidden danger investigation work.

Data Preprocessing
Clean the raw data. The first step is to screen out the enterprise account records for which the required regulatory industry type fields are not missing. In order to avoid the lack of information in the hidden danger record due to recording errors or irregularities. Eventually, the analysis results in error. Remove the bad record that the description field is empty or the related description field is less than 10 words after word segmentation. Through the above methods, the inferior record can be largely removed, and finally the processed hidden danger record The names of the enterprises in the industrial-mechanical classification are extracted from the enterprise account information table processed above, with a total of 172 enterprises. According to the enterprise name, the corresponding records are extracted from the processed hidden danger information table. There are 14088 records in total.
Extracting the information in the text requires that the text be first converted to the corresponding word frequency vector for subsequent operations. In this paper, the segmentationCN function based on the Rwordseg package in the R language is used to process the corresponding sentences and finally convert them into word frequency vectors. The word vector that combines all hidden trouble records becomes the word frequency vector matrix, and each row represents a word frequency vector corresponding to a record.

Classification
In the LDA topic model algorithm, it is assumed that the data set contains a total of K topics, and each piece of data is composed of different topics in different proportions. It is necessary to determine the appropriate number of topics so that the classification between the finalized topics is clear and the distribution of the topics of the data is realistic.
The calculated topic model Perplexity is usually used to determine the optimal number of topics. Its formula is as follows: (1)

(2)
Where M is the size of the test corpus, N_d is the text size (i.e. number of words) of part d, z is the topic, w is the document, and gamma is the text-topic distribution learned from the training set. When the number of topics is calculated from 2 to 100, the model perplexity changes. The results are shown in Figure 2 below:

Figure 2. Topic model Perplexity
The abscissa is the topic number and the ordinate is the model perplexity. As shown in the figure, it is necessary to select the K value of the position where the model perplexity is relatively flat, but the number of topics thus obtained tends to be too large, resulting in the semantic ambiguity of the topic. The essence of the topic extraction model is to divide the document into detailed and clear topics. Therefore, it is very important to consider the difference between the topics. This paper uses the mean square error between the calculated topics to judge the difference between the topics. The formula is as follows:

(3)
Where K is the number of topics and q_n is the word probability vector of the corresponding topic. When the number of topics is changed from 2 to 100, the mean square error between the topics changes. The result is shown in Figure 3 below:

Figure 3. Standard deviation between topics
The abscissa is the topic number and the ordinate is the degree of confusion. It can be seen from the figure that, starting from the number of topics is 15, the increase speed of the mean variance of topics becomes slow, that is, the change degree of differences becomes smaller. Therefore, the clarity of confusion, difference and semantics should be taken into comprehensive consideration, and 20 should be selected as the appropriate number for the subsequent topic analysis.
Finally, the distribution of the top ten words of the 20 hidden danger topics obtained from the 172 companies from the industrial mechanical type through the LDA topic model algorithm is shown in Table 1

Association Rules Mining and Results Analysis
After obtaining the distribution of the topics for each hidden danger record. According to the goal of the text-based analysis of enterprise hidden danger association rules in this paper, it is necessary to consider the distribution of the topic of each hidden danger record under the same enterprise. Considering that the association rules between hidden dangers do not involve the discussion of a single, and the data needs to be converted into discrete data in the Apriori algorithm, it is stipulated that the proportion of topics with a single topic ratio of less than or equal to 0.1 in a record is set to 0, and the value of 0.1 or more is set to 1. When considering the hidden dangers of an enterprise, it is necessary to consider the time relationship between them. So it is necessary to merge the records over a period of time. The vector of the same time period after processing is added by OR operation. Finally, for each enterprise, form a sum vector of one or several time periods. Finally, 14088 hidden trouble dangers of 172 enterprises were transformed into 603 vectors about 20 topic classification, and then the association rules were excavated.
Finally, rules 5242201 are obtained. The number of rules increases with the increase of LHS. The changes are as Table 2 follows: As the length of the LHS increases, the number of rules increases. There are only 223 rules when there is only one LHS, and when the number of LHSs reaches nine, the relevant rules reach 1847560. But most of these rules are not valuable rules, that is, they do not provide much help in hidden danger investigation. The following is a discussion of selecting some valuable rules by lift.
Under the different 10 RHSs, the ten rules for ranking first by lift are as Table 3 follows: Among them, the four rules of 1, 3, 4, and 6 have a degree of lift greater than 3, which is considered to be a rule in which the rule of value is applicable in most cases. For example. In the first rule, in the case of the hidden danger classification topic 5, 7, 10, 13, 15, 19, the confidence and lift of the topic 1 are quite high. Indicates that the correlation between LHS and RHS is extremely high. All these classification topics in LHS need to be recorded, so the hidden danger in these aspects must be caused by the staff's failure to timely find out the problems in recording and registration. The theme 1 corresponds to the hidden dangers of registration. According to the above analysis, the association rules proposed in this paper are consistent with common sense, and thus are applicable to the investigation of hidden dangers.
The relationship network diagram of the rules in Table 2 is as Figure 4 follows:  The starting point of the arrow is LHS, the ending point of the arrow is RHS, the number represents the type of topic, and the size of the circle in the middle indicates the relative confidence of this rule. It can be seen from the figure that the topic 19 appears most frequently in the LHS segment, indicating that the topic 19 is a fundamental hazard in the industrial-mechanical type of enterprise, and most of the other hidden dangers are related to it. Theme 19 is the specification problem of the operator when operating the machine. Tthe industrial-mechanical type enterprise focuses on the mechanical operation, so the irregular operation of the machine will lead to a series of other hidden dangers. This on the other hand shows the correctness of the resulting rules.

Conclusion
Use Chinese word segmentation to convert text into word frequency vectors. The LDA algorithm that determines the optimal number of topics by the topic model Perplexity, topic difference and topic clarity. The descriptive text of the hidden danger information is transformed into a suitable and appropriate distribution of topics. This kind of semi-structured data is transformed into structured data with clear classification. The Apriori association mining algorithm is applied to the transformed structured data to obtain the association rules between hidden dangers.
The descriptive texts of the hidden dangers in the research are semi-structured texts, from which the association rules between various types of hidden dangers under different types of enterprises are mined. It provides data support for guiding enterprises' self-inspection of hidden dangers in daily management and relevant law enforcement departments to focus on different types of enterprises' hidden dangers.