# IWF-TextRank Keyword Extraction Algorithm Modelling
## 2 Materials and Methods
### Feature Analysis Model
#### 2.4.2 Semantic Feature Modelling  
(1) Word2 vec algorithm  
Word2 vec is a natural language processing model proposed by [PERSON] [27] in 2013, which contains two training models, Skip-gram and Continuous Bag of Words (CBOW) [28]. This paper selects the CBOW model in Word2 Vec to vectorise semantics. As shown in Figure 2a, the core idea of the CBOW model is to predict the probability distribution of the target word through the words in the context. It is essentially a three-layer neural network, including an input layer, a hidden layer, and an output layer. 1. Input layer: The input layer converts known context words into a computer-recognisable form, that is, into a C \(\times\) V one-hot tensor X. Here, C represents the number of context words and V is the size of the dictionary. One-hot encoding is only used to solve the problem that text words cannot be directly processed by computers, and there is no need to represent the relationship between words. 2. Hidden layer: The role of the hidden layer is to reduce the dimensionality of the input word vector. By performing matrix multiplication with a V \(\times\) N weight matrix, the C \(\times\) V one-hot tensor is converted to a C \(\times\) N vector representation, where N is the length of the word vector. Then, the C word vectors are added together to obtain a 1 \(\times\) N vector to represent the entire context. This dimensionality reduction process retains semantic information while reducing computational complexity. 3. Output layer: The output layer contains a softmax classifier, which multiplies the 1 \(\times\) N vector obtained from the hidden layer with the N \(\times\) V output weight matrix to obtain a 1 \(\times\) V vector, which represents the predicted probability distribution of the target word. The vector is normalised by the softmax function to obtain the probability distribution of the target word. Figure 2: Working diagram of CBOW model and Skip-gram model. (a) CBOW model; (b) Skip-gram model. In contrast, as in Figure 2b, the Skip-gram model reverses the use of known target words to predict their contexts, which is suitable for large corpora. The CBOW model is suitable for corpora with high domain specialisation due to its higher computational accuracy and shorter time consumption. In this study, when processing the text of traffic accident data, the CBOW model achieves higher computational efficiency in a shorter time while being able to accurately generate the semantic vectors of the text. These word vectors are used for subsequent semantic feature computation to enhance keyword extraction. (2) Semantic features of words  
The classical keyword extraction algorithms ignore the semantic information between words, while the context of words and the articulation between sentences and between words can be reflected by semantic information. Therefore, this paper incorporates the semantic features of words based on the consideration of word frequency, word nature, and word length features, and uses the CBOW model in Word2 vec to train the data obtained from the dataset to obtain the word vectors, and combines with the cosine calculation formula to calculate the similarity of the words. Assuming the existence of two words, \(I\) and \(J\), the similarity between words is calculated as:  
\[Sim(I,J)=cos\theta=\frac{I.J}{\left|I\right|\left|J\right|}=\frac{\sum_{l=1}^{ n}I_{i}.J_{i}}{\sqrt{\sum_{i=1}^{n}\left(I_{i}\right)^{2}\times\sqrt{\sum_{i=1}^{ n}\left(I_{i}\right)^{2}}}} \tag{6}\]  
where \(I_{i}\) represents the components of vector \(I\), and \(J_{i}\) represents the components of the vector \(J\). The semantic weight of a word can be further calculated after obtaining the word similarity. The formula is as follows:  
\[w_{sim}(v_{i})=\sum_{v_{j}\in V}\frac{Sim\big{(}v_{i},v_{j}\big{)}}{\left|V \right|} \tag{7}\]  
where \(w_{sim}(v_{i})\) represents the semantic weight of node \(i\); \(Sim\big{(}v_{i},v_{j}\big{)}\) represents the semantic weight of semantic similarity between node \(i\) and node \(j\); and V represents the set of nodes.