Skip to main content

NLI2Code: Reusing Libraries with Natural Language Interface

  • Conference paper
  • First Online:
Reuse in the Big Data Era (ICSR 2019)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 11602))

Included in the following conference series:

  • 940 Accesses

Abstract

Modern software development typically involves composing functionality by reusing existing libraries. This task is difficult due to the gap of abstraction levels between user tasks and APIs. In this paper we propose a new concept LibNLI (Library Natural Language Interface) to bridge the gap. LibNLI is a domain-specific language encapsulating APIs into library functions, which is more high-level and instructive than library APIs. In LibNLI, user can reuse libraries with the description of the current programming task. We design an abstract framework NLI2Code to illustrate how to build and use LibNLI.

The framework combines three components: functional feature summarizes functionality of a library, code pattern maps each functional feature to its implementation, synthesizer creates local variables to complete code patterns into well-typed snippets. The main goal of NLI2Code is to show feasibility of reusing libraries with natural language interface and lay out the design space to motivate further related research.

We have performed a preliminary evaluation by instantiating this framework in a tool NLI4j to reuse Java libraries. The results affirm its capability to summarize accurate functional features and synthesize correct implementation. LibNLI for the evaluated libraries is published.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    https://github.com/Wusjn/MPS-Projects.

References

  1. The Eclipse Foundation. http://www.eclipse.org/

  2. IntelliJ IDEA (2019). http://www.jetbrains.com/idea/

  3. JetBrains MPS (2019). https://www.jetbrains.com/mps/

  4. Allamanis, M., Sutton, C.: Mining idioms from source code. In: Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 472–483. ACM (2014)

    Google Scholar 

  5. Barzilay, O., Treude, C., Zagalsky, A.: Facilitating crowd sourced software engineering via stack overflow. In: Sim, S.E., Gallardo-Valencia, R.E. (eds.) Finding Source Code on the Web for Remix and Reuse, pp. 289–308. Springer, New York (2013). https://doi.org/10.1007/978-1-4614-6596-6_15

    Chapter  Google Scholar 

  6. Buse, R.P., Weimer, W.: Synthesizing API usage examples. In: Proceedings of the 34th International Conference on Software Engineering, pp. 782–792. IEEE Press (2012)

    Google Scholar 

  7. Campbell, B.A., Treude, C.: Nlp2Code: code snippet content assist via natural language tasks. In: 2017 IEEE International Conference on Software Maintenance and Evolution (ICSME), pp. 628–632. IEEE (2017)

    Google Scholar 

  8. Feng, Y., Martins, R., Wang, Y., Dillig, I., Reps, T.W.: Component-based synthesis for complex apis. ACM SIGPLAN Not. 52(1), 599–612 (2017)

    Article  Google Scholar 

  9. Gabel, M., Su, Z.: A study of the uniqueness of source code. In: Proceedings of the Eighteenth ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 147–156. ACM (2010)

    Google Scholar 

  10. Galenson, J., Reames, P., Bodik, R., Hartmann, B., Sen, K.: CodeHint: dynamic and interactive synthesis of code snippets. In: Proceedings of the 36th International Conference on Software Engineering, pp. 653–663. ACM (2014)

    Google Scholar 

  11. Gu, X., Zhang, H., Zhang, D., Kim, S.: Deep API learning. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 631–642. ACM (2016)

    Google Scholar 

  12. Gulwani, S., Polozov, O., Singh, R., et al.: Program synthesis. Found. Trends® Program. Lang. 4(1–2), 1–119 (2017)

    Google Scholar 

  13. Gvero, T., Kuncak, V.: Synthesizing java expressions from free-form queries. ACM SIGPLAN Not. 50, 416–432 (2015)

    Article  Google Scholar 

  14. Gvero, T., Kuncak, V., Kuraj, I., Piskac, R.: Complete completion using types and weights. ACM SIGPLAN Not. 48, 27–38 (2013)

    Article  Google Scholar 

  15. Huang, Q., Xia, X., Xing, Z., Lo, D., Wang, X.: API method recommendation without worrying about the task-API knowledge gap. In: Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, pp. 293–304. ACM (2018)

    Google Scholar 

  16. Jiang, H., Zhang, J., Ren, Z., Zhang, T.: An unsupervised approach for discovering relevant tutorial fragments for APIs. In: Proceedings of the 39th International Conference on Software Engineering, pp. 38–48. IEEE Press (2017)

    Google Scholar 

  17. Li, J., Wang, Y., Lyu, M.R., King, I.: Code completion with neural attention and pointer networks. arXiv preprint arXiv:1711.09573 (2017)

  18. Little, G., Miller, R.C.: Keyword programming in Java. Autom. Softw. Eng. 16(1), 37 (2009)

    Article  Google Scholar 

  19. Loncaric, C., Ernst, M.D., Torlak, E.: Generalized data structure synthesis. In: 2018 IEEE/ACM 40th International Conference on Software Engineering (ICSE), pp. 958–968. IEEE (2018)

    Google Scholar 

  20. Nguyen, T., Rigby, P.C., Nguyen, A.T., Karanfil, M., Nguyen, T.N.: T2API: synthesizing API code usage templates from English texts with statistical translation. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 1013–1017. ACM (2016)

    Google Scholar 

  21. Nguyen, T.T., Nguyen, H.A., Pham, N.H., Al-Kofahi, J.M., Nguyen, T.N.: Graph-based mining of multiple object usage patterns. In: Proceedings of the the 7th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering, pp. 383–392. ACM (2009)

    Google Scholar 

  22. Pel, J., et al.: PrefixSpan: mining sequential patterns by prefix-projected growth. In: Proceedings of 17th IEEE International Conference on Data Engineering (ICDE), Heidelberg, Germany, pp. 215–224 (2001)

    Google Scholar 

  23. Perelman, D., Gulwani, S., Ball, T., Grossman, D.: Type-directed completion of partial expressions. ACM SIGPLAN Not. 47, 275–286 (2012)

    Article  Google Scholar 

  24. Rabinovich, M., Stern, M., Klein, D.: Abstract syntax networks for code generation and semantic parsing. arXiv preprint arXiv:1704.07535 (2017)

  25. Raghothaman, M., Wei, Y., Hamadi, Y.: Swim: synthesizing what i mean-code search and idiomatic snippet synthesis. In: 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE), pp. 357–367. IEEE (2016)

    Google Scholar 

  26. Raza, M., Gulwani, S., Milic-Frayling, N.: Compositional program synthesis from natural language and examples. In: Twenty-Fourth International Joint Conference on Artificial Intelligence (2015)

    Google Scholar 

  27. Robillard, M.P.: What makes APIs hard to learn? Answers from developers. IEEE Softw. 26(6), 27–34 (2009)

    Article  Google Scholar 

  28. Robillard, M.P., Deline, R.: A field study of API learning obstacles. Empirical Softw. Eng. 16(6), 703–732 (2011)

    Article  Google Scholar 

  29. Treude, C., Robillard, M.P.: Augmenting API documentation with insights from stack overflow. In: 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE), pp. 392–403. IEEE (2016)

    Google Scholar 

  30. Treude, C., Robillard, M.P., Dagenais, B.: Extracting development tasks to navigate software documentation. IEEE Trans. Softw. Eng. 41(6), 565–581 (2015)

    Article  Google Scholar 

  31. Treude, C., Sicard, M., Klocke, M., Robillard, M.: TaskNav: task-based navigation of software documentation. In: Proceedings of the 37th International Conference on Software Engineering, vol. 2, pp. 649–652. IEEE Press (2015)

    Google Scholar 

  32. Wang, J., Dang, Y., Zhang, H., Chen, K., Xie, T., Zhang, D.: Mining succinct and high-coverage API usage patterns from source code. In: Proceedings of the 10th Working Conference on Mining Software Repositories, pp. 319–328. IEEE Press (2013)

    Google Scholar 

  33. Xie, T., Pei, J.: MAPO: mining API usages from open source repositories. In: Proceedings of the 2006 International Workshop on Mining Software Repositories, pp. 54–57. ACM (2006)

    Google Scholar 

  34. Yan, X., Han, J.: gSpan: graph-based substructure pattern mining. In: 2002 Proceedings of IEEE International Conference on Data Mining, pp. 721–724. IEEE (2002)

    Google Scholar 

  35. Yessenov, K., Kuraj, I., Solar-Lezama, A.: DemoMatch: API discovery from demonstrations. ACM SIGPLAN Not. 52, 64–78 (2017)

    Article  Google Scholar 

  36. Zamanirad, S., Benatallah, B., Barukh, M.C., Casati, F., Rodriguez, C.: Programming bots by synthesizing natural language expressions into API invocations. In: 2017 32nd IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 832–837. IEEE (2017)

    Google Scholar 

Download references

Acknowledgement

This paper is supported by National Key Research and Development Program of China (Grant No. 2016YFB1000801) and National Natural Science Fund for Distinguished Young Scholars (Grant No. 61525201).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Bing Xie .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Shen, Q., Xie, B., Zou, Y., Zhu, Z., Wu, S. (2019). NLI2Code: Reusing Libraries with Natural Language Interface. In: Peng, X., Ampatzoglou, A., Bhowmik, T. (eds) Reuse in the Big Data Era. ICSR 2019. Lecture Notes in Computer Science(), vol 11602. Springer, Cham. https://doi.org/10.1007/978-3-030-22888-0_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-22888-0_12

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-22887-3

  • Online ISBN: 978-3-030-22888-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics