Computer Engineering, Volume. 51, Issue 8, 74(2025)

API Usage Constraint Knowledge Construction Based on Large Language Model

LIU Genhao1, ZHANG Neng2、*, and ZHENG Zibin1
Author Affiliations
  • 1School of Software Engineering, Sun Yat-sen University, Zhuhai 519082, Guangdong, China
  • 2School of Computer Science, Central China Normal University, Wuhan 430079, Hubei, China
  • show less

    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.

    Tools

    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

    Download Citation

    EndNote(RIS)BibTexPlain Text
    Save article for my favorites
    Paper Information

    Category:

    Received: Nov. 18, 2024

    Accepted: Aug. 26, 2025

    Published Online: Aug. 26, 2025

    The Author Email: ZHANG Neng (nengzhang@ccnu.edu.cn)

    DOI:10.19678/j.issn.1000-3428.0070623

    Topics