Computer Engineering, Volume. 51, Issue 8, 74(2025)
API Usage Constraint Knowledge Construction Based on Large Language Model
Application Programming Interface (API) usage constraints are the conditions or restrictions that developers must follow when invoking APIs to ensure correct usage and prevent misuse. API documentation is an important tool for extracting these constraints. Existing Natural Language Processing (NLP)-based methods for extracting API usage constraints often rely on syntactic patterns, but their ability to handle complex coordinated sentences and impose strict requirements on syntactic structures is limited. To address these issues, this paper proposes an API usage constraint knowledge extraction method based on Large Language Model (LLM), referred to as AUCK. AUCK first preprocesses Java API documentation and extracts sentences containing API usage constraints. It then summarizes the syntactic patterns of coordinated sentences and designs corresponding cases to guide a LLM to decompose coordinated sentences into simple sentences. Finally, it summarizes the syntactic patterns of triplets and design cases to guide the LLM in extracting API usage constraint triplets. Experimental results on Java API documentation show that AUCK achieves an accuracy of 92.23% and recall of 93.14%, significantly outperforming existing methods, including DRONE (accuracy: 80.61%, recall: 86.81%), the mainstream triplet extraction tool OpenIE (accuracy: 76.92%, recall: 52.63%), and the large language model ChatGPT-3.5 (accuracy: 82.23%, recall: 67.71%). In addition, the application of AUCK to Android and Python API documentation verifies its good transferability.
Get Citation
Copy Citation Text
LIU Genhao, ZHANG Neng, ZHENG Zibin. API Usage Constraint Knowledge Construction Based on Large Language Model[J]. Computer Engineering, 2025, 51(8): 74
Category:
Received: Nov. 18, 2024
Accepted: Aug. 26, 2025
Published Online: Aug. 26, 2025
The Author Email: ZHANG Neng (nengzhang@ccnu.edu.cn)