Using Consensual Biterms from Text Structures of Requirements and Code to Improve IR-Based Traceability Recovery

Hui Gao, Hongyu Kuang, Kexin Sun, Xiaoxing Ma, Alexander Egyed, Patrick Mäder, Guoping Rong, Dong Shao, He Zhang · DOI

Abstract

Traceability approves trace links among software artifacts based on whether two artifacts are related by system functionalities. The traces are valuable for software development, but are difficult to obtain manually. To cope with the costly and fallible manual recovery, automated approaches are proposed to recover traces through textual similarities among software artifacts, such as those based on Information Retrieval (IR). However, the low quality & quantity of artifact texts negatively impact the calculated IR values, thus greatly hindering the performance of IR-based approaches. In this study, we propose to extract co-occurred word pairs from the text structures of both requirements and code (i.e., consensual biterms) to improve IR-based traceability recovery. We first collect a set of biterms based on the part-of-speech of requirement texts, and then filter them through the code texts. We then use these consensual biterms to both enrich the input corpus for IR techniques and enhance the calculations of IR values. A nine-system-based evaluation shows that in general, when solely used to enhance IR techniques, our approach can outperform pure IR-based approaches and another baseline by 21.9% & 21.8% in AP, and 9.3% & 7.2% in MAP, respectively. Moreover, when used to collaborate with another enhancing strategy from different perspectives, it can outperform this baseline by 5.9% in AP and 4.8% in MAP.

Introduction

In software engineering, traceability is the ability to link different artifacts—such as a specific requirement (e.g., "The system shall send a confirmation email") to the actual source code that implements it. Maintaining these links is crucial for safety-critical systems and efficient maintenance, yet manual recovery is notoriously labor-intensive and error-prone.

To automate this process, researchers typically employ Information Retrieval (IR) techniques. However, IR-based traceability recovery faces two major hurdles:

  1. Vocabulary Mismatch: Requirements are written in natural language, while code uses technical identifiers and comments. They often use different words for the same concept.
  2. The Noise Problem: Common words (like "system" or "data") appear frequently across many artifacts but do not help distinguish one specific feature from another.

Existing solutions often attempt to filter noise using Part-of-Speech (POS) tagging (e.g., focusing only on nouns). While helpful, these methods often discard useful context and fail to bridge the semantic gap between the "language of requirements" and the "language of code."

The TAROT Framework

This paper introduces TAROT (TraceAbility Recovery by cOsensual biTerms), a framework designed to bridge this gap by focusing on biterms—unordered pairs of co-occurring words. The approach follows a four-step process:

1. Extracting Candidate Biterms

The system first identifies potential word pairs from both sides of the traceability link:

  • From Requirements: Using the Stanford CoreNLP toolkit, TAROT identifies grammatical relationships such as "noun-subject" or "adjectival modifier." For instance, from the requirement "A fake email is sent," it extracts biterms like (fake, email) and (send, email).
  • From Code: The system splits identifier names (e.g., getFakeEmail) and extracts all possible word pairs within the same code element.

2. Finding "Consensus"

This is the core innovation of TAROT. The system only retains biterms that appear in both the requirements and the code. These "consensual biterms" represent a shared technical vocabulary, acting as a semantic bridge between high-level descriptions and low-level implementations.

3. Corpus Enrichment

Once identified, these consensual biterms are "injected" back into the text of the artifacts. This process artificially increases the textual similarity between related items, making it easier for IR models to recognize the link.

4. Score Adjustment and Weighting

Finally, TAROT re-ranks the results using a weighting system based on the text structure. Biterms found in high-significance locations—such as a requirement's title or a Java class name—are given more weight than those found in requirement sub-flows or local variable names in the code.

Experimental Evaluation

The approach was evaluated on nine real-world software systems, including iTrust (a medical system), GanttProject (a project management tool), and the IlmSeven Dataset (comprising seven open-source projects like Maven, Pig, and Groovy). The researchers compared TAROT against standard IR models (VSM, LSI, and JS) and a state-of-the-art POS-based baseline (ConPOS).

Key Results

  • Performance Gains: When used to enhance standard IR techniques, TAROT outperformed the baselines by 21.9% in Average Precision (AP) and 9.3% in Mean Average Precision (MAP).
  • Synergy with Other Strategies: When combined with other advanced strategies like CLUSTER' (which uses code dependency analysis), TAROT provided a further boost, improving results by approximately 5-6%.
  • Robustness: The system proved effective even on projects with sparse or lower-quality documentation, demonstrating its utility in real-world development environments.

Discussion and Insights

The success of TAROT highlights several key principles in traceability recovery. First, biterms are superior to single terms; a word like "email" is vague, but a biterm like (send, email) captures a specific action and entity. Second, the power of consensus allows the system to automatically ignore "noise" biterms that only appear on one side of the artifact pair. Finally, the study confirms that structure matters—leveraging the hierarchy of requirements and code (e.g., titles vs. descriptions) significantly improves the accuracy of the recovered links.

Conclusion

TAROT offers a robust method for improving IR-based traceability by leveraging the structural and linguistic consensus between requirements and code. While the system currently relies on the accuracy of NLP tools like Stanford CoreNLP and is focused on requirements-to-code links, future work may extend this approach to other artifacts, such as design documents or test cases, and explore the integration of consensual biterms into deep learning-based traceability models.

Summary updated

BibTeX
@inproceedings{gao2022using,
  author = {Hui Gao and Hongyu Kuang and Kexin Sun and Xiaoxing Ma and Alexander Egyed and Patrick Mäder and Guoping Rong and Dong Shao and He Zhang},
  title = {{Using Consensual Biterms from Text Structures of Requirements and Code to Improve IR-Based Traceability Recovery}},
  booktitle = {ASE},
  year = {2022},
  doi = {10.1145/3551349.3556948},
}
Figure