# BiLSTM-CRF-KG: A Construction Method of Software Requirements Specification Graph
## 3 Structural Information Extraction Model of Functional Requirements
### Preprocessing of the Original Corpus  
The steps of preprocessing the original corpus are shown in Figure 2.  
Before entity recognition and relation extraction, this project must carry out sentence segmentation, word segmentation and part of speech tagging on the original corpus.  
First of all, Chinese sentence segmentation needs to be carried out, which is based on regular matching on the original corpus. The characteristic characters should be counted at the end of Chinese text sentences. A regular expression group should be constructed that matches a complete sentence, and it is utilized as the input parameter of the split() segmentation function to carry out Chinese sentence segmentation.  
Secondly, the Jieba tool is utilized to segment Chinese words and label parts of speech of each clause. This is because a part of speech is used in the following, named entity pruning and disambiguation operations. The word attribute of each particle represents  
Figure 1: Overall framework design.  
the content of the participiple, and the flag attribute represents the participiple's part of speech.  
Then, the BMEWO named entity and 0-1 relation dimension are utilized for each participiple. BMEWO annotation is the most common method of naming entity annotation, among which B represents the entity start word, M stands for the entity intermediate word, E represents the entity ending word, W represents the entity whole word and O represents the non-entity word. For the relational words, the 0-1 annotation method is mainly used. Among them, 1 represents the relation word and 0 represents the non-relational word.  
Finally, the original corpus is divided into independent words, and the features of each word are recorded as \(w_{i}\).  
\[w_{i}=w(word,flag,e,r) \tag{1}\]  
Among them, _word_ represents the content of word segmentation, \(flag\) represents the part of speech of word segmentation, \(e\) represents the attribute of named entity and \(r\) represents the attribute of relation. The implementation of this part is shown in Algorithm 1.  
```
1:Corpus
2:w
3:sentences = Corpus.split()
4:i = 0
5:for s in sentences do
6:temp = jieba.cut(s)
7:\(w_{i}\).\(word=temp.word\)
8:\(w_{i}\).\(flag=temp.word\)
9:\(w_{i}\).\(e=BMEWO(w_{i}\).\(word)\)
10:\(w_{i}\).\(r=relationtagging(w_{i}\).\(word)\)
11:i++
12:endfor
13:return w
14:endfor
15:return w



==WARNING: Truncated because of repetitions==
is carried out layer by layer according to the breadth first strategy of the tree, and the triples are constructed step by step. The head node is RTreej-1, the relationship node is RTreej, and the tail node is RTreej+1n.

After generating the function-function triplet, this study uses the py2 neo module of Python to embed the function structure graph and save it to the neo4j database. The implementation of this part is shown in Algorithm 4.
```  
+++  
In order to solve this problem, this study disassembles the U/C matrix into multiple send/use/create (S/U/C) matrices. The main operations are as follows: based on a functional entity, only retain its corresponding entire row information and data column information with \"C\", and then modify all \"U\" in the column with \"C\" to \"S\". The process is shown in Figure 6.  
In the process of demand research and demand analysis, the S/U/C matrix can be used to record the relationship between functions and data, so as to find the possible  
Figure 6: Convert U/C matrix to S/U/C matrix.  
problems such as function omission and data loss in the process of demand research. The implementation of this part is shown in Algorithm 5.  
```
0:UC
0:SUC
1:for f in functionSet do
2:Cset=set0
3:for i in functionSet do
4:for j in dataSet do
5:if i==j then
6:SUC[f][i][j] = UC[i][j]
7:if UC[i][j]==C' or UC[i][j]=='CU' then
8:Cset.add(j)
9:endif
10:endif
11:endfor
12:endfor
13:for k in CSet do
14:for j in functionSet do
15:if UC[j][k] == \"U' then
16:SUC[f][j][k] = 'S'
17:endif
18:endfor
19:endfor
20:endfor
21:return SUC
```  
**Algorithm 5** Converting traditional U/C matrix into S/U/C matrix