Holistic combination of structural and textual code information for context based API recommendation

Context based API recommendation is an important way to help developers find the needed APIs effectively and efficiently. For effective API recommendation, we need not only a joint view of both structural and textual code information, but also a holistic view of correlated API usage in control and d...

Full description

Saved in:
Bibliographic Details
Main Authors: CHEN, Chi, PENG, Xin, XING, Zhengchang, SUN, Jun, WANG, Xin, ZHAO, Yifan, ZHAO, Wenyun
Format: text
Language:English
Published: Institutional Knowledge at Singapore Management University 2022
Subjects:
API
Online Access:https://ink.library.smu.edu.sg/sis_research/6714
https://ink.library.smu.edu.sg/context/sis_research/article/7717/viewcontent/09409670.pdf
Tags: Add Tag
No Tags, Be the first to tag this record!
Institution: Singapore Management University
Language: English
id sg-smu-ink.sis_research-7717
record_format dspace
spelling sg-smu-ink.sis_research-77172024-03-05T07:07:51Z Holistic combination of structural and textual code information for context based API recommendation CHEN, Chi PENG, Xin XING, Zhengchang SUN, Jun WANG, Xin ZHAO, Yifan ZHAO, Wenyun Context based API recommendation is an important way to help developers find the needed APIs effectively and efficiently. For effective API recommendation, we need not only a joint view of both structural and textual code information, but also a holistic view of correlated API usage in control and data flow graph as a whole. Unfortunately, existing API recommendation methods exploit structural or textual code information separately. In this work, we propose a novel API recommendation approach called APIRec-CST (API Recommendation by Combining Structural and Textual code information). APIRec-CST is a deep learning model that combines the API usage with the text information in the source code based on an API Context Graph Network and a Code Token Network that simultaneously learn structural and textual features for API recommendation. We apply APIRec-CST to train a model for JDK library based on 1,914 open-source Java projects and evaluate the accuracy and MRR (Mean Reciprocal Rank) of API recommendation with another 6 open-source projects. The results show that our approach achieves respectively a top-1, top-5, top-10 accuracy and MRR of 60.3%, 81.5%, 87.7% and 69.4%, and significantly outperforms an existing graph-based statistical approach and a tree-based deep learning approach for API recommendation. A further analysis shows that textual code information makes sense and improves the accuracy and MRR. The sensitivity analysis shows that the top-k accuracy and MRR of APIRec-CST are insensitive to the number of APIs to be recommended in a hole. We also conduct a user study in which two groups of students are asked to finish 6 programming tasks with or without our APIRec-CST plugin. The results show that APIRec-CST can help the students to finish the tasks faster and more accurately and the feedback on the usability is overwhelmingly positive. 2022-08-01T07:00:00Z text application/pdf https://ink.library.smu.edu.sg/sis_research/6714 info:doi/10.1109/TSE.2021.3074309 https://ink.library.smu.edu.sg/context/sis_research/article/7717/viewcontent/09409670.pdf http://creativecommons.org/licenses/by-nc-nd/4.0/ Research Collection School Of Computing and Information Systems eng Institutional Knowledge at Singapore Management University Semantics Deep Learning Data Models Context Modeling Computational Modeling Task Analysis Token Networks API Recommendation Deep Learning Data Flow Control Flow Text Software Engineering
institution Singapore Management University
building SMU Libraries
continent Asia
country Singapore
Singapore
content_provider SMU Libraries
collection InK@SMU
language English
topic Semantics
Deep Learning
Data Models
Context Modeling
Computational Modeling
Task Analysis
Token Networks
API
Recommendation
Deep Learning
Data Flow
Control Flow
Text
Software Engineering
spellingShingle Semantics
Deep Learning
Data Models
Context Modeling
Computational Modeling
Task Analysis
Token Networks
API
Recommendation
Deep Learning
Data Flow
Control Flow
Text
Software Engineering
CHEN, Chi
PENG, Xin
XING, Zhengchang
SUN, Jun
WANG, Xin
ZHAO, Yifan
ZHAO, Wenyun
Holistic combination of structural and textual code information for context based API recommendation
description Context based API recommendation is an important way to help developers find the needed APIs effectively and efficiently. For effective API recommendation, we need not only a joint view of both structural and textual code information, but also a holistic view of correlated API usage in control and data flow graph as a whole. Unfortunately, existing API recommendation methods exploit structural or textual code information separately. In this work, we propose a novel API recommendation approach called APIRec-CST (API Recommendation by Combining Structural and Textual code information). APIRec-CST is a deep learning model that combines the API usage with the text information in the source code based on an API Context Graph Network and a Code Token Network that simultaneously learn structural and textual features for API recommendation. We apply APIRec-CST to train a model for JDK library based on 1,914 open-source Java projects and evaluate the accuracy and MRR (Mean Reciprocal Rank) of API recommendation with another 6 open-source projects. The results show that our approach achieves respectively a top-1, top-5, top-10 accuracy and MRR of 60.3%, 81.5%, 87.7% and 69.4%, and significantly outperforms an existing graph-based statistical approach and a tree-based deep learning approach for API recommendation. A further analysis shows that textual code information makes sense and improves the accuracy and MRR. The sensitivity analysis shows that the top-k accuracy and MRR of APIRec-CST are insensitive to the number of APIs to be recommended in a hole. We also conduct a user study in which two groups of students are asked to finish 6 programming tasks with or without our APIRec-CST plugin. The results show that APIRec-CST can help the students to finish the tasks faster and more accurately and the feedback on the usability is overwhelmingly positive.
format text
author CHEN, Chi
PENG, Xin
XING, Zhengchang
SUN, Jun
WANG, Xin
ZHAO, Yifan
ZHAO, Wenyun
author_facet CHEN, Chi
PENG, Xin
XING, Zhengchang
SUN, Jun
WANG, Xin
ZHAO, Yifan
ZHAO, Wenyun
author_sort CHEN, Chi
title Holistic combination of structural and textual code information for context based API recommendation
title_short Holistic combination of structural and textual code information for context based API recommendation
title_full Holistic combination of structural and textual code information for context based API recommendation
title_fullStr Holistic combination of structural and textual code information for context based API recommendation
title_full_unstemmed Holistic combination of structural and textual code information for context based API recommendation
title_sort holistic combination of structural and textual code information for context based api recommendation
publisher Institutional Knowledge at Singapore Management University
publishDate 2022
url https://ink.library.smu.edu.sg/sis_research/6714
https://ink.library.smu.edu.sg/context/sis_research/article/7717/viewcontent/09409670.pdf
_version_ 1794549748450983936