Elamur Research

Learning to Mine Aligned Code and Natural Language Pairs from Stack Overflow

Paper · 2018 · Pengcheng Yin, Bowen Deng, Edgar Chen et al.

Summary

Data-driven tools for code retrieval, summarization and synthesis from natural language need large parallel collections in which NL statements and code are closely aligned. Stack Overflow holds such data, but earlier extraction heuristics, such as taking every code block or only blocks from accepted answers, either add noise or discard much usable material. Yin et al. frame the task as classification. For each question title, which serves as the intent, every line-contiguous fragment of code in the answers is treated as a candidate. A classifier then judges each candidate using two kinds of features. Hand-crafted structural features, which are mostly language-independent, estimate whether the fragment is a sensible piece of code. Learned correspondence features come from a neural translation-style model that scores code given NL and NL given code. On small annotated Python and Java sets, the approach recovers many more pairs, and more accurate ones, than the baselines. It also performs reasonably when trained on one language and applied to the other. This matters because it makes NL-code corpus building practical for languages that lack annotations.

Key points

  • Each mined item is a triple: an intent (English description), optional context (setup code such as imports or variable definitions) and a snippet that actually implements the intent.
  • The labeled data covers only 152 Python and 102 Java question threads. These were drawn from the March 2017 SO dump by combining the top-100 most-viewed questions with a view-weighted sample, and only the top-3 answers per question were annotated.
  • Compared with prior heuristics, the method extracts up to roughly ten times more aligned pairs at equal accuracy, or more than halves the error rate when the number of pairs is held fixed.
  • About 36% of Python-tagged questions are "how to" requests, which is the category the work targets.
  • The annotations, annotation interface and mining code are released at conala-corpus.github.io (the CoNaLa project). The paper appeared at MSR '18.

Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.

 Institutions

 Fields, topics and concepts

Cite

Cite as Pengcheng Yin, Bowen Deng, Edgar Chen, Bogdan Vasilescu and Graham Neubig. 2018. Learning to Mine Aligned Code and Natural Language Pairs from Stack Overflow. arXiv:1805.08949.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.48550/arxiv.1805.08949 · arXiv 1805.08949

@misc{yin2018learning,
  title = {{Learning to Mine Aligned Code and Natural Language Pairs from Stack Overflow}},
  author = {Pengcheng Yin, Bowen Deng, Edgar Chen, Bogdan Vasilescu and Graham Neubig},
  year = {2018},
  doi = {10.48550/arxiv.1805.08949},
  eprint = {1805.08949},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.1805.08949}
}

References

48 references, from the paper's own bibliography.

  1. authorpersonMiltiadis Allamanis, personEarl T Barr, personChristian Bird, and personCharles Sutton. year2015. Suggesting Accurate Method and Class Names. In booktitle Joint Meeting on Foundations of Software Engineering (ESEC/FSE). ACM, pages38–49. OpenAlex ↗ · Scholar ↗
  2. authorpersonMiltiadis Allamanis, personHao Peng, and personCharles Sutton. year2016. A Convolutional Attention Network for Extreme Summarization of Source Code. journal arXiv preprint arXiv:1602.03001 (year2016). our card
  3. authorpersonMiltiadis Allamanis, personDaniel Tarlow, personAndrew D Gordon, and personYi Wei. year2015. Bimodal Modelling of Source Code and Natural Language. In booktitle International Conference on Machine Learning (ICML). pages2123–2132. our card
  4. authorpersonDzmitry Bahdanau, personKyunghyun Cho, and personYoshua Bengio. year2015. Neural Machine Translation by Jointly Learning to Align and Translate. In booktitle International Conference on Learning Representations (ICLR). our card
  5. authorpersonAntonio Valerio Miceli Barone and personRico Sennrich. year2017. A Parallel Corpus of Python Functions and Documentation Strings for Automated Code Documentation and Code Generation. journal arXiv preprint arXiv:1707.02275 (year2017). our card
  6. authorpersonShaunak Chatterjee, personSudeep Juvekar, and personKoushik Sen. year2009. Sniff: A Search Engine for Java Using Free-form Queries. In booktitle International Conference on Fundamental Approaches to Software Engineering. Springer, pages385–400. OpenAlex ↗ · Scholar ↗
  7. authorpersonAditya Desai, personSumit Gulwani, personVineet Hingorani, personNidhi Jain, personAmey Karkare, personMark Marron, personSubhajit Roy, and personothers. year2016. Program Synthesis using Natural Language. In booktitle International Conference on Software Engineering (ICSE). ACM, pages345–356. OpenAlex ↗ · Scholar ↗
  8. authorpersonPremkumar Devanbu. year2015. New Initiative: the Naturalness of Software. In booktitle International Conference on Software Engineering (ICSE), Vol. volume2. IEEE, pages543–546. OpenAlex ↗ · Scholar ↗
  9. authorpersonChristine Franks, personZhaopeng Tu, personPremkumar Devanbu, and personVincent Hellendoorn. year2015. CACHECA: A Cache Language Model based Code Suggestion Tool. In booktitle International Conference on Software Engineering (ICSE), Vol. volume2. IEEE, pages705–708. OpenAlex ↗ · Scholar ↗
  10. authorpersonMark Gabel and personZhendong Su. year2010. A Study of the Uniqueness of Source Code. In booktitle International Symposium on Foundations of Software Engineering (FSE). ACM, pages147–156. OpenAlex ↗ · Scholar ↗
  11. authorpersonYarin Gal and personZoubin Ghahramani. year2016. A Theoretically Grounded Application of Dropout in Recurrent Neural Networks. In booktitle Annual Conference on Neural Information Processing Systems (NIPS). pages1019–1027. our card
  12. authorpersonJiatao Gu, personZhengdong Lu, personHang Li, and personVictor O.K. Li. year2016. Incorporating Copying Mechanism in Sequence-to-Sequence Learning. In booktitle Annual Meeting of the Association for Computational Linguistics (ACL). publisherACL, pages1631–1640. our card
  13. authorpersonAbram Hindle, personEarl T Barr, personMark Gabel, personZhendong Su, and personPremkumar Devanbu. year2016. On the naturalness of software. journal Commun. ACM volume59, number5 (year2016), pages122–131. OpenAlex ↗ · Scholar ↗
  14. authorpersonPo-Sen Huang, personXiaodong He, personJianfeng Gao, personLi Deng, personAlex Acero, and personLarry Heck. year2013. Learning Deep Structured Semantic Models for Web Search using Clickthrough Data. In booktitle International Conference on Information and Knowledge Management (CIKM). ACM, pages2333–2338. OpenAlex ↗ · Scholar ↗
  15. authorpersonSrinivasan Iyer, personIoannis Konstas, personAlvin Cheung, and personLuke Zettlemoyer. year2016. Summarizing Source Code using a Neural Attention Model. In booktitle Annual Meeting of the Association for Computational Linguistics (ACL). publisherACL, pages2073–2083. OpenAlex ↗ · Scholar ↗
  16. authorpersonAlan Jaffe, personJeremy Lacomis, personEdward J. Schwartz, personClaire Le Goues, and personBogdan Vasilescu. year2018. Meaningful Variable Names for Decompiled Code: A Machine Translation Approach. In booktitle International Conference on Program Comprehension (ICPC). ACM. OpenAlex ↗ · Scholar ↗
  17. authorpersonNal Kalchbrenner and personPhil Blunsom. year2013. Recurrent Continuous Translation Models. In booktitle Conference on Empirical Methods in Natural Language Processing (EMNLP). publisherACL, pages1700–1709. our card
  18. authorpersonDiederik P. Kingma and personJimmy Ba. year2014. Adam: A Method for Stochastic Optimization. journal CoRR volumeabs/1412.6980 (year2014). http://arxiv.org/abs/1412.6980 our card
  19. authorpersonPhilipp Koehn. year2010. booktitle Statistical Machine Translation. publisherCambridge Press. OpenAlex ↗ · Scholar ↗
  20. authorpersonXi Victoria Lin, personChenglong Wang, personLuke Zettlemoyer, and personMichael D Ernst. year2018. NL2Bash: A Corpus and Semantic Parser for Natural Language Interface to the Linux Operating System. journal International Conference on Language Resources and Evaluation (LREC) (year2018). our card
  21. authorpersonNicholas Locascio, personKarthik Narasimhan, personEduardo De Leon, personNate Kushman, and personRegina Barzilay. year2016. Neural Generation of Regular Expressions from Natural Language with Minimal Domain Knowledge. In booktitle Conference on Empirical Methods in Natural Language Processing (EMNLP). publisherACL, pages1918–1923. OpenAlex ↗ · Scholar ↗
  22. authorpersonThang Luong, personHieu Pham, and personChristopher D. Manning. year2015. Effective Approaches to Attention-based Neural Machine Translation. In booktitle Conference on Empirical Methods in Natural Language Processing (EMNLP). publisherACL, pages1412–1421. our card
  23. authorpersonLance A Miller. year1981. Natural Language Programming: Styles, Strategies, and Contrasts. journal IBM Systems Journal volume20, number2 (year1981), pages184–215. OpenAlex ↗ · Scholar ↗
  24. authorpersonDana Movshovitz-Attias and personWilliam W Cohen. year2013. Natural Language Models for Predicting Programming Comments. In booktitle Annual Meeting of the Association for Computational Linguistics (ACL). publisherACL, pages35–40. OpenAlex ↗ · Scholar ↗
  25. authorpersonGraham Neubig. year2017. Neural Machine Translation and Sequence-to-Sequence Models: A Tutorial. journal arXiv preprint arXiv:1703.01619 (year2017). OpenAlex ↗ · Scholar ↗
  26. authorpersonGraham Neubig, personChris Dyer, personYoav Goldberg, personAustin Matthews, personWaleed Ammar, personAntonios Anastasopoulos, personMiguel Ballesteros, personDavid Chiang, personDaniel Clothiaux, personTrevor Cohn, personKevin Duh, personManaal Faruqui, personCynthia Gan, personDan Garrette, personYangfeng Ji, personLingpeng Kong, personAdhiguna Kuncoro, personGaurav Kumar, personChaitanya Malaviya, personPaul Michel, personYusuke Oda, personMatthew Richardson, personNaomi Saphra, personSwabha Swayamdipta, and personPengcheng Yin. year2017. DyNet: The Dynamic Neural Network Toolkit. journal arXiv preprint arXiv:1701.03980 (year2017). our card
  27. authorpersonAnh Tuan Nguyen, personHoan Anh Nguyen, personTung Thanh Nguyen, and personTien N Nguyen. year2014. Statistical Learning Approach for Mining API Usage Mappings for Code Migration. In booktitle International Conference on Automated Software Engineering (ASE). ACM, pages457–468. OpenAlex ↗ · Scholar ↗
  28. authorpersonAnh Tuan Nguyen, personTung Thanh Nguyen, and personTien N Nguyen. year2013. Lexical Statistical Machine Translation for Language Migration. In booktitle Joint Meeting on Foundations of Software Engineering (ESEC/FSE). ACM, pages651–654. OpenAlex ↗ · Scholar ↗
  29. authorpersonHaoran Niu, personIman Keivanloo, and personYing Zou. year2016. Learning to Rank Code Examples for Code Search Engines. journal Empirical Software Engineering (year2016), pages1–33. OpenAlex ↗ · Scholar ↗
  30. authorpersonYusuke Oda, personHiroyuki Fudaba, personGraham Neubig, personHideaki Hata, personSakriani Sakti, personTomoki Toda, and personSatoshi Nakamura. year2015. Learning to Generate Pseudo-Code from Source Code Using Statistical Machine Translation. In booktitle International Conference on Automated Software Engineering (ASE). IEEE, pages574–584. OpenAlex ↗ · Scholar ↗
  31. authorpersonSebastiano Panichella, personJairo Aponte, personMassimiliano Di Penta, personAndrian Marcus, and personGerardo Canfora. year2012. Mining Source Code Descriptions from Developer Communications. In booktitle International Conference on Program Comprehension (ICPC). IEEE, pages63–72. OpenAlex ↗ · Scholar ↗
  32. authorpersonChris Quirk, personRaymond Mooney, and personMichel Galley. year2015. Language to Code: Learning Semantic Parsers for If-This-Then-That Recipes. In booktitle Annual Meeting of the Association for Computational Linguistics (ACL). pages878–888. our card
  33. authorpersonMaxim Rabinovich, personMitchell Stern, and personDan Klein. year2017. Abstract Syntax Networks for Code Generation and Semantic Parsing. In booktitle Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). publisherAssociation for Computational Linguistics, addressVancouver, Canada, pages1139–1149. http://aclweb.org/anthology/P17-1105 our card
  34. authorpersonVeselin Raychev, personMartin Vechev, and personAndreas Krause. year2015. Predicting Program Properties from “Big Code”. In booktitle ACM Symposium on Principles of Programming Languages (POPL). ACM, pages111–124. OpenAlex ↗ · Scholar ↗
  35. authorpersonVictor S Sheng, personFoster Provost, and personPanagiotis G Ipeirotis. year2008. Get Another Label? Improving Data Quality and Data Mining using Multiple, Noisy Labelers. In booktitle ACM SIGKDD International Conference on Knowledge Discovery and Data Mining. ACM, pages614–622. OpenAlex ↗ · Scholar ↗
  36. authorpersonRichard Socher, personEric H Huang, personJeffrey Pennin, personChristopher D Manning, and personAndrew Y Ng. year2011. Dynamic Pooling and Unfolding Recursive Autoencoders for Paraphrase Detection. In booktitle Advances in Neural Information Processing Systems (NIPS). pages801–809. OpenAlex ↗ · Scholar ↗
  37. authorpersonGiriprasad Sridhara, personLori Pollock, and personK Vijay-Shanker. year2011. Generating Parameter Comments and Integrating with Method Summaries. In booktitle International Conference on Program Comprehension (ICPC). IEEE, pages71–80. OpenAlex ↗ · Scholar ↗
  38. authorpersonNitish Srivastava, personGeoffrey E. Hinton, personAlex Krizhevsky, personIlya Sutskever, and personRuslan Salakhutdinov. year2014. Dropout: a Simple Way to Prevent Neural Networks from Overfitting. journal Journal of Machine Learning Research volume15, number1 (year2014), pages1929–1958. our card
  39. authorpersonIlya Sutskever, personOriol Vinyals, and personQuoc VV Le. year2014. Sequence to Sequence Learning with Neural Networks. In booktitle Advances in Neural Information Processing Systems (NIPS). pages3104–3112. our card
  40. authorpersonBogdan Vasilescu, personCasey Casalnuovo, and personPremkumar Devanbu. year2017. Recovering Clear, Natural Identifiers from Obfuscated JavaScript Names. In booktitle Joint Meeting on the Foundations of Software Engineering (seriesESEC/FSE). publisherACM. to appear. OpenAlex ↗ · Scholar ↗
  41. authorpersonYushi Wang, personJonathan Berant, and personPercy Liang. year2015. Building a Semantic Parser Overnight. In booktitle Annual Meeting of the Association for Computational Linguistics (ACL). publisherACL, pages1332–1342. our card
  42. authorpersonYi Wei, personNirupama Chandrasekaran, personSumit Gulwani, and personYoussef Hamadi. year2015. booktitle Building Bing Developer Assistant. typeTechnical Report. institutionMSR-TR-2015-36, Microsoft Research. OpenAlex ↗ · Scholar ↗
  43. authorpersonEdmund Wong, personTaiyue Liu, and personLin Tan. year2015. CloCom: Mining Existing Source Code for Automatic Comment Generation. In booktitle International Conference on Software Analysis, Evolution, and Reengineering (SANER). IEEE, pages380–389. OpenAlex ↗ · Scholar ↗
  44. authorpersonEdmund Wong, personJinqiu Yang, and personLin Tan. year2013. AutoComment: Mining question and answer sites for automatic comment generation. In booktitle International Conference on Automated Software Engineering (ASE). IEEE, pages562–567. OpenAlex ↗ · Scholar ↗
  45. authorpersonDi Yang, personAftab Hussain, and personCristina Videira Lopes. year2016. From query to usable code: an analysis of Stack Overflow code snippets. In booktitle Working Conference on Mining Software Repositories (MSR). ACM, pages391–402. OpenAlex ↗ · Scholar ↗
  46. authorpersonZiyu Yao, personDaniel S. Weld, personWei-Peng Chen, and personHuan Sun. year2018. StaQC: A Systematically Mined Question-Code Dataset from Stack Overflow. In booktitle WWW 2018: The 2018 Web Conference. OpenAlex ↗ · Scholar ↗
  47. authorpersonPengcheng Yin and personGraham Neubig. year2017. A Syntactic Neural Model for General-Purpose Code Generation. In booktitle Meeting of the Association for Computational Linguistics (ACL). our card
  48. authorpersonAlexey Zagalsky, personOhad Barzilay, and personAmiram Yehudai. year2012. Example overflow: Using Social Media for Code Recommendation. In booktitle International Workshop on Recommendation Systems for Software Engineering (RSSE). IEEE Press, pages38–42. OpenAlex ↗ · Scholar ↗

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/yin-2018-learning-mine-aligned-code-natural/