From API to NLI: A New Interface for Library Reuse

Abstract Developers frequently reuse APIs from existing libraries to implement certain functionality. However, learning APIs is difficult due to their large scale and complexity. In this paper, we design an abstract framework NLI2Code to ease the reuse process. Under the framework, users can reuse library functionalities with a high-level, automatically-generated NLI (Natural Language Interface) instead of the detailed API elements. The framework consists of three components: a functional feature extractor to summarize the frequently-used library functions in natural language form, a code pattern miner to give a code template for each functional feature, and a synthesizer to complete code patterns into well-typed snippets. From the perspective of a user, a reuse task under NLI2Code starts from choosing a functional feature and our framework will guide the user to synthesize the desired solution. We instantiated the framework as a tool to reuse Java libraries. The evaluation shows our tool can generate a high-quality natural language interface and save half of the coding time for newcomers to solve real-world programming tasks.

[1]  Fabio Casati,et al.  Programming bots by synthesizing natural language expressions into API invocations , 2017, 2017 32nd IEEE/ACM International Conference on Automated Software Engineering (ASE).

[2]  Westley Weimer,et al.  Synthesizing API usage examples , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[3]  Michael D. Ernst,et al.  Generalized Data Structure Synthesis , 2018, 2018 IEEE/ACM 40th International Conference on Software Engineering (ICSE).

[4]  Christoph Treude,et al.  NLP2Code: Code Snippet Content Assist via Natural Language Tasks , 2017, 2017 IEEE International Conference on Software Maintenance and Evolution (ICSME).

[5]  Viktor Kuncak,et al.  Synthesizing Java expressions from free-form queries , 2015, OOPSLA.

[6]  Sebastian Buchwald,et al.  Simple and Efficient Construction of Static Single Assignment Form , 2013, CC.

[7]  Christoph Treude,et al.  Extracting Development Tasks to Navigate Software Documentation , 2015, IEEE Transactions on Software Engineering.

[8]  Sumit Gulwani,et al.  Program Synthesis , 2017, Software Systems Safety.

[9]  Koushik Sen,et al.  CodeHint: dynamic and interactive synthesis of code snippets , 2014, ICSE.

[10]  Sumit Gulwani,et al.  Type-directed completion of partial expressions , 2012, PLDI.

[11]  Isil Dillig,et al.  Component-based synthesis for complex APIs , 2017, POPL.

[12]  Mukund Raghothaman,et al.  SWIM: Synthesizing What I Mean - Code Search and Idiomatic Snippet Synthesis , 2015, 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE).

[13]  Jens Krinke,et al.  Awareness and Experience of Developers to Outdated and License-Violating Code on Stack Overflow: An Online Survey , 2018, ArXiv.

[14]  Mira Mezini,et al.  Semi-automatically extracting FAQs to improve accessibility of software development knowledge , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[15]  Premkumar T. Devanbu,et al.  On the naturalness of software , 2016, Commun. ACM.

[16]  Rob Miller,et al.  Keyword programming in Java , 2008, Automated Software Engineering.

[17]  Armando Solar-Lezama,et al.  DemoMatch: API discovery from demonstrations , 2017, PLDI.

[18]  Hans van Vliet,et al.  Proceedings of the the 7th joint meeting of the European software engineering conference and the ACM SIGSOFT symposium on The foundations of software engineering , 2009, FSE 2009.

[19]  Bing Xie,et al.  NLI2Code: Reusing Libraries with Natural Language Interface , 2019, ICSR.

[20]  Christoph Treude,et al.  Augmenting API Documentation with Insights from Stack Overflow , 2016, 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE).

[21]  Miryung Kim,et al.  Analyzing and Supporting Adaptation of Online Code Examples , 2019, 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE).

[22]  Tao Xie,et al.  Inferring Resource Specifications from Natural Language API Documentation , 2009, 2009 IEEE/ACM International Conference on Automated Software Engineering.

[23]  Mihai Surdeanu,et al.  The Stanford CoreNLP Natural Language Processing Toolkit , 2014, ACL.

[24]  Anh Tuan Nguyen,et al.  T2API: synthesizing API code usage templates from English texts with statistical translation , 2016, SIGSOFT FSE.

[25]  Charles A. Sutton,et al.  Mining idioms from source code , 2014, SIGSOFT FSE.

[26]  Hoan Anh Nguyen,et al.  Graph-based mining of multiple object usage patterns , 2009, ESEC/FSE '09.

[27]  Jiawei Han,et al.  gSpan: graph-based substructure pattern mining , 2002, 2002 IEEE International Conference on Data Mining, 2002. Proceedings..

[28]  Tao Zhang,et al.  An Unsupervised Approach for Discovering Relevant Tutorial Fragments for APIs , 2017, 2017 IEEE/ACM 39th International Conference on Software Engineering (ICSE).

[29]  Jian Pei,et al.  MAPO: mining API usages from open source repositories , 2006, MSR '06.

[30]  Ruzica Piskac,et al.  Complete completion using types and weights , 2013, PLDI.

[31]  Martin P. Robillard,et al.  A field study of API learning obstacles , 2011, Empirical Software Engineering.

[32]  Paolo Tonella,et al.  Natural Language Parsing of Program Element Names for Concept Extraction , 2010, 2010 IEEE 18th International Conference on Program Comprehension.

[33]  Christoph Treude,et al.  Understanding Stack Overflow Code Fragments , 2017, 2017 IEEE International Conference on Software Maintenance and Evolution (ICSME).

[34]  Sumit Gulwani,et al.  Compositional Program Synthesis from Natural Language and Examples , 2015, IJCAI.

[35]  Kai Chen,et al.  Mining succinct and high-coverage API usage patterns from source code , 2013, 2013 10th Working Conference on Mining Software Repositories (MSR).

[36]  Miryung Kim,et al.  Are Code Examples on an Online Q&A Forum Reliable?: A Study of API Misuse on Stack Overflow , 2018, 2018 IEEE/ACM 40th International Conference on Software Engineering (ICSE).

[37]  Cristina V. Lopes,et al.  From Query to Usable Code: An Analysis of Stack Overflow Code Snippets , 2016, 2016 IEEE/ACM 13th Working Conference on Mining Software Repositories (MSR).