Abstract
Most application development happens in the context of complex APIs; reference documentation for APIs has grown tremendously in variety, complexity, and volume, and can be difficult to navigate. There is a growing need to develop well-organized ways to access the knowledge latent in the documentation; several research efforts deal with the organization (ontology) of API-related knowledge. Extensive knowledge-engineering work, supported by a rigorous qualitative analysis, by Maalej & Robillard [3] has identified a useful taxonomy of API knowledge. Based on this taxonomy, we introduce a domain-independent technique to extract knowledge types from API reference documentation. Our system, OntoCat, introduces nine different features and their semantic and statistical combinations to classify different knowledge types. We tested OntoCat on Python API reference documentation. Our experimental results show the effectiveness of the system and open the scope of related research areas such as user behavior and documentation quality.
Introduction
Modern software development is inextricably linked to the use of complex Application Programming Interfaces (APIs). As these APIs grow in functionality, their accompanying reference documentation has expanded significantly in volume and complexity. For instance, the documentation for JDK 6 is approximately six times longer than Tolstoy’s War and Peace. Navigating these massive technical manuals to find specific information—such as how to achieve a specific task or the rationale behind a design choice—remains a significant challenge for developers.
While documentation is typically organized by structural elements like classes and methods, developers often seek information based on its type. Previous research established a taxonomy of twelve distinct API knowledge types to address this. However, manually labeling documentation according to this taxonomy is labor-intensive and does not scale to the millions of pages produced today. We present OntoCat, an automated system designed to categorize API documentation into these knowledge types using machine learning and natural language processing.
The OntoCat Methodology
OntoCat utilizes a multi-class classification approach based on Support Vector Machines (SVM). To handle the diversity of the twelve categories, the system employs a "one-vs-all" ensemble strategy. The classification is driven by nine distinct features that combine semantic, statistical, and linguistic information:
- Semantic Relatedness (NPMI): The system calculates Normalized Point-wise Mutual Information to determine the strength of association between words within a specific technical corpus, such as Python manuals.
- Topical Breadth and Intensity: By clustering related terms, OntoCat distinguishes between paragraphs focused on a single intense topic and those spanning multiple concepts.
- Graph Entropy: Borrowing from social network analysis, words are treated as nodes in a network. The "importance" of a phrase is measured by the change in the network's entropy (disorder) when that phrase is removed.
- Linguistic Context: OntoCat uses Part-of-Speech (PoS) tagging and dependency parsing to understand grammatical relationships, helping identify "Task Phrases" or "Directives" based on verb usage and sentence structure.
Evaluation and Dataset
The performance of OntoCat was evaluated using the pydoctypes dataset, which consists of 1,864 manually annotated "stretches" (sentences or paragraphs) from Python API documentation. The distribution of these entries across the various knowledge types is shown in the table below.
The researchers employed a 50/50 training-testing split, repeating the experiment five times to ensure the stability of the results. External corpora, including the full text of Python manuals and relevant Wikipedia pages, were used to calculate word relationships and identify domain-specific terminology like version control statements.
Key Results and Discussion
Experimental results demonstrate that OntoCat significantly outperforms random guessing across all categories (p < 0.001), achieving an average F-score of 0.67. The system showed particularly high accuracy in identifying Code Examples (0.83) and Functionality and Behavior (0.77).
A key finding was the strong correlation (Spearman’s Rho = 0.8) between the volume of training data and the resulting F-score. Categories with fewer entries, such as "Control Flow" and "Non-information," yielded lower F-scores (0.31 and 0.29, respectively), suggesting that performance will improve as more labeled data becomes available. Interestingly, "Non-information" (boilerplate text) was most effectively identified through an exclusion strategy: if no informative classifier claimed a sentence, it was labeled as "Non-info."
Conclusion
OntoCat provides a scalable solution for organizing the latent knowledge in API documentation. Beyond improving documentation navigation, this technology has several potential applications, including documentation auditing to identify missing "Rationale" sections and the development of automated question-answering systems for developers. Future work will focus on addressing data scarcity for underrepresented categories and refining the system's ability to handle inherently ambiguous technical sentences.
Summary updated