# Combining Machine Learning and Logical Reasoning to Improve Requirements Traceability Recovery
## 3 A Hybrid Traceability Recovery Approach
### Phase 1 Machine Learning Recovery
#### 3.2.1 Feature Extraction  
As use cases and source code are written in natural languages and programming languages, respectively, they involve different types of information that are not all useful for identifying traceability links. For example, the specific programming statements typically do not correspond to requirements, while class names, method names, and method comments are very likely to reflect the functional requirements. Similarly, use cases are documented with various fields, only some of which are meaningful for traceability link analysis. In this paper, we exclusively investigate the following features which are meaningful for recovering traceability links (Table 1).  
\begin{table}
\begin{tabular}{l l l} \hline \hline
**Artifact** & **Feature** & **Description** \\ \hline Use & Title & The title of use case \\ Case & Description & The description of use case \\ \hline \multirow{4}{*}{Source Code} & Class Name & The class name \\  & Class Comment & The comment associated with a class \\  & Method Name & The method name in a class \\  & Method Comment & The comment associated with a method \\  & Class Attribute & The class attribute (Type, name) \\  & Method Parameter & The method parameter (type, name, Javadoc) \\  & Method Return & The method return (type, name, Javadoc) \\ \hline \hline \end{tabular}
\end{table}
Table 1: The vital features of a traceability link vector in Phase 1.  
Building on our previous research [10], we further explore the class attributes, method parameters, and method return information of the source code as the features in the traceability link vectors. Also, we find that the type, name and Javadoc of the class attributes, method parameters and method return are the most influential information for identifying traceability links. Here, we illustrate the importance of such information in detail.  
Figure 2: The analysis process of our proposed hybrid approach for recovering traceability links.  
**Type.** Figure 3 shows a code segment of parameter type information as an example. In the parameter list \((IdentityCard~{}c)\) of the method \(registerIdentityCard\), the parameter name \(c\) is abbreviated and contains no information, but the parameter type \(IdentityCard\) is valuable information. This suggests that the type information of the parameter should be considered to be relevant and useful.  
**Name.** An example of parameter name information of a code feature is shown in Figure 4. In the parameter list \((int~{}citizenId,~{}String~{}newEmail)\) of the method \(modifyCitizenEmail\), the parameter types \(int\) and \(String\) are common Java keywords and contain no useful information, whereas the parameter names \(citizenId\), \(newEmail\) are valuable information. Thus the name information of the parameter should also be considered.  
**Javadoc.** An example of Javadoc information of a code feature is shown in Figure 5. Javadoc is a standardized and widely accepted way to document Java programs, from which we can extract classes and methods from the program source code. For example:  
_@param_ The description of a method parameter  
_@return_ The description of the method return value  
Therefore, Javadoc comments are also useful information. The parameter type and parameter name of the parameter list \((int~{}pId)\) do not contain much information, but the _@param_ annotation contains a lot of valuable information. Therefore the Javadoc comments for the parameters also include important information that is considered in our approach.  
Specifically, for the method parameter and method return features, we focus on their type, name and Javadoc information. Since the Class Attribute does not have corresponding Javadoc comments, its type and name information are considered. In the experimental evaluation, we will evaluate the experimental results of adding these three features.