# Combining Machine Learning and Logical Reasoning to Improve Requirements Traceability Recovery
## 3 A Hybrid Traceability Recovery Approach
### Phase 2 Logical Reasoning Recovery
#### 3.3.1 Structural Information between Source Code Components  
There many types structural information among source code components such as _implementation_, _inheritance_, and _method call_. The structural information reflects the closeness between source code components and is of great value for traceability link recovery. Based on our previous research [10], we have added the use of _class attribute_ and _method call_ relationships for traceability recovery. Such features are selected based on both our domain knowledge and empirical studies. Specifically, the _implements_ relationship between a class and an interface indicate the class has similar functions with the interface, and they should be analyzed together. _inherits_ relations represent the interrelationships between a class and its super-class, which are also closely associated. Moreover, if methods defined in one class are used by another class, it is also an important indicator of associated classes. Based on previous research [10], we found that _class attribute_ and _method call_ relationships between source code components also indicate potential traceability links. The _attributes_ of a class describe the properties of the class. If a class contains another class as its attribute, it usually means that there is an inclusion relationship between the two classes. According to empirical research, if a use case has a traceability link with a class A, then the use case usually also has a traceability link with other classes that have _attribute_ relationships with the class A. A method of a class often calls methods of another class. If there is a _method call_ relationship between two classes, it often means that there is a close relationship between them. According to empirical research, if there is a traceability link between a use case and class A, there is usually a traceability link between the use case and other classes that call methods of class A. Therefore, we propose to focus on the features of the source code structural information that are shown in Table 3. In previous research, we found that the method _parameter_ structural information is not helpful for traceability recovery, and even negatively impacts the results sometimes. Therefore, in this study, Phase 2 did not use method _parameter_ structural information for traceability recovery. According to the domain knowledge and the structural information features between source code components, we have proposed the following inference rules in order to discover more traceability links. Specifically, we traverse all the traceability links output from phase 1, and identify new links as long as they match our defined inference rules. \[Rule1:traceability\_link(use\_case(s_{i}),source\_code(c_{k})) \tag{2}\] \[\leftarrow traceability\_link(use\_case(s_{i}),source\_code(c_{j}))\] \[\wedge implement(source\_code(c_{k}),source\_code(c_{j}))\] \begin{table}
\begin{tabular}{l l l} \hline \hline
**Artifact** & **Feature** & **Description** \\ \hline \multirow{4}{*}{Source Code} & Class Implementation & The class implementation relationship \\  & Class Inheritance & The class inheritance relationship \\  & Method Return & The method return relationship \\  & Class Attribute & The class attribute relationship \\  & Method Call & The method call relationship \\ \hline \hline \end{tabular}
\end{table} 
Table 3: The structural information features of source code in Phase 2.