## 2 Materials and Methods
### Candidate Word Set Construction  
After analyzing the impact of the stop word list and the user-defined dictionary, we selected Jieba as our primary text segmentation tool [38]. The TF-IDF algorithm, widely used in information retrieval and text mining, evaluates the significance of a word within a dataset. The importance of a word increases with its frequency in a document but decreases with its prevalence across the corpus [39]. The TF-IDF algorithm comprises two components: term frequency (TF) and inverse document frequency (IDF).  
Term frequency (TF) is the frequency of a word's appearance in a document, serving as the initial computation of its weight. Inverse document frequency (IDF) assesses the overall importance of a word within the corpus.  
\[\mathbf{TF(t,d)}=1+\log(\mathbf{f_{t,d}}) \tag{1}\]  
Here, \(\mathbf{TF(t,d)}\) indicates the frequency of the term \(t\) in the document \(d\), and \(\mathbf{f_{t,d}}\) reflects how many times the term appears in the document. Compared to the traditional method of simply counting word occurrences, which calculates TF as the raw count of how many times term \(t\) appears in document \(d\), this approach uses logarithmic scaling to reduce the impact of high-frequency words [40]. While the traditional TF effectively captures term frequency, it tends to assign disproportionately high weights to very frequent words, overshadowing the significance of less frequent but potentially more informative terms. To address this, the improved method applies a logarithmic scale to the calculation, smoothing term frequencies. This adjustment diminishes the dominance of high-frequency words while preserving the significance of low-frequency words, allowing for a more balanced representation of content.  
We use a modified approach to calculate the inverse document frequency (IDF).  
\[\mathbf{IDF(t,D)}=\log\biggl{(}\frac{\mathbf{N}}{1+\mathbf{DF(t,D)}}\biggr{)} \tag{2}\]  
Here, \(\mathbf{IDF(t,D)}\) represents the inverse document frequency (IDF) of the word \(t\) across the document collection \(D\). The total number of documents within the document collection is represented by \(\mathbf{N}\), and \(\mathbf{IDF(t,D)}\) indicates the number of documents that contain the  
Figure 3: Distribution of data.  
specified term. Additionally, this method includes a plus-one smoothing term, ensuring that, even in extreme cases (e.g., when a word appears in all documents), a meaningful IDF value is produced. This approach seeks to reduce the influence of high-frequency terms while enhancing the significance of rare terms. Given the rarity of gas pipeline emergencies, we have selected these calculation methods to more accurately represent their infrequency and importance. Additionally, this method incorporates a plus-one smoothing term to ensure that, even in extreme cases (e.g., when a term appears in all documents), a meaningful IDF value is produced. This prevents the weight from dropping to zero, thereby avoiding the potential loss of crucial information.  
\[\text{TF}-\text{IDF}=(1+\log(\mathbf{f_{t,d}}))\times\log\biggl{(}\frac{ \mathbf{N}}{1+\mathbf{DF}(\mathbf{t,D})}\biggr{)} \tag{3}\]  
TF-IDF is a statistical technique that calculates the weight of terms. The TF-IDF matrix aids in assessing the importance of specific terms in domain data. However, these measures alone are not enough to effectively pinpoint key risk factors. This paper utilizes a dual-logic approach with the TF-IDF matrix, analyzing both documents and their TF-IDF values to conduct this filtering. The implementation was performed in Python, including data pre-processing steps like Chinese word segmentation. By sorting and filtering TF-IDF values, words with higher scores were chosen as candidates for the domain-specific dictionary.