Abstract
API calls can be described using natural language and can be implemented using a programming language. A programming environment that can process natural language descriptions within source code and provide context aware code suggestions can significantly improve productivity of developers and make programming more accessible to non-programmers and less experienced programmers. This paper proposes a context-aware tool called API Call Programming Interface (ACPI) which allows developers to write a natural language description for methods within source code and get correct and compilable API Call (AC) based on the text description and surrounding code. Existing work and code suggestion tools only consider the user's natural language description as input and ignore the contextual surrounding code. We take surrounding code into account and include information about local variable names within the code suggestion. Our approach consists of three modules. First, Method Name Generator, an unsupervised neural-embeddings-based algorithm to map the natural language description of methods to a list of most likely method names. Second, an AST Generator, a supervised Machine Translation model that predicts the structure of the AST from the list of the method names. And third, a Code Synthesizer that assigns local variables names to the AST to get the final method calls. Further, we include a Ranking Module that ranks the list of suggested method names based on their completeness. We evaluated our approach on data from 1000 high-quality Java projects and achieved an accuracy of 61% for API calls suggestions from natural language descriptions, which outperforms prior work and demonstrates the potential of our approach. We also conducted productivity experiments with 148 undergraduate participants to measure the usefulness of ACPI. The experiment showed that programming with ACPI can reduce programming time by 45% and increase programming accuracy from 19% to 83% when compared to programming without ACPI in four code completion tasks.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have