Abstract
dc:description.abstractApplication programming interfaces (APIs) are essential for modern software development, but learning to use them correctly from documentation alone is often challenging. Automatic API usage template mining tools abstract real-world examples into reusable templates based on their abstract syntax tree (AST) structure, but they suffer from structural rigidity and produce templates that are often difficult for developers to read. This thesis documents the methodology developed to improve auto-matic API usage template generation. We detail initial exploratory attempts to resolve template fragmentation via hierarchical clustering, as well as in-vestigations into alternative clustering algorithms. While these approaches encountered significant challenges related to over-generalization, the find-ings directly informed the design of Context-Aware Structural Generalization (CASGard), the tool that arose from this exploration. CASGard integrates large language models (LLMs), specifically CodeBERT, into the structural mining pipeline to assess semantic similarity. By dynamically adjusting the structural merge threshold based on CodeBERT semantic distance, CASGard combines the precision of AST-based generalization with the contextual information provided by neural semantic embeddings. Furthermore, we introduce a post-processing pipeline designed to map generic, machine-generated placeholder variables back to meaningful, domain-specific names, significantly enhancing the practical usability of the templates. During the empirical evaluation, a significant data contamination bug was identified and resolved in the baseline ASGard implementation. Fol-lowing this correction, validated experiments across 35 real-world Java APIs demonstrate that CASGard reduces the rate of unrepresentable input files by 30% overall compared to the baseline, and case studies show the post-processing pipeline restoring readability to the resulting templates.
Degree
thesis:*- Name thesis:degree_name
- Master of Science (MSc)
- Discipline thesis:degree_discipline
- Computer Science
- Grantor
- Science
- Year dc:date.issued
- 2026
Author and committee
dc:creator, dc:contributor.*- Author dc:creator
-
- Askari, Majid
- Advisor dc:contributor.advisor
-
- Walker, Robert
- Committee members dc:contributor.committeemember
-
- Far, Behrouz
- Alfadel, Mahmoud Abdulkarim
Rights
dc:rights- Statement dc:rights
-
- Unless otherwise indicated, this material is protected by copyright and has been made available with authorization from the copyright owner. You may use this material in any way that is permitted by the Copyright Act or through licensing that has been assigned to the document. For uses that are not allowable under copyright legislation or licensing, you are required to seek permission.
- Language dc:language.iso
- en
Identifiers
dc:identifier.*- Dc Identifier Citation
- Askari, M. (2026). Context-aware structural generalization for API usage pattern mining (Master's thesis, University of Calgary, Calgary, Canada). Retrieved from https://prism.ucalgary.ca.