arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 1805.08949cs.CLcs.SE
收藏

从堆栈溢出中挖掘对齐代码和自然语言对

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

Carnegie Mellon University(卡内基梅隆大学)

Pengcheng Yin, Bowen Deng, Edgar Chen, Bogdan Vasilescu, Graham Neubig

摘要:

对于像从自然语言合成代码、代码检索和代码摘要这样的任务,数据驱动模型已经显示出很大的前景。然而,创建这些模型需要在自然语言(NL)和具有细粒度对齐的代码之间并行数据。Stack Overflow(SO)是创建这样一个数据集的一个很有前途的来源:问题是多种多样的,其中大多数都有相应的答案和高质量的代码片段。然而,现有的探试法(例如,将帖子的标题与接受的答案中的代码配对)在它们的覆盖范围和所获得的NL代码对的正确性方面都是有限的。在本文中,我们提出了一种新的方法来挖掘高质量的对齐数据从SO使用两组功能:手工制作的功能,考虑到提取的片段的结构,和对应的功能,通过训练概率模型,以捕捉NL和代码之间的相关性,使用神经网络。这些特征被馈送到分类器中,该分类器确定所挖掘的NL代码对的质量。使用Python和Java作为测试床的实验表明,所提出的方法大大扩展了现有挖掘方法的覆盖范围和准确性,即使只使用少量的标记示例。此外,我们发现,即使在一种语言上训练分类器并在另一种语言上测试时,也能获得合理的结果,这表明将NL代码挖掘扩展到各种程序设计语言的前景超出了我们能够注释数据的语言。

英文摘要:

For tasks like code synthesis from natural language, code retrieval, and code summarization, data-driven models have shown great promise. However, creating these models require parallel data between natural language (NL) and code with fine-grained alignments. Stack Overflow (SO) is a promising source to create such a data set: the questions are diverse and most of them have corresponding answers with high-quality code snippets. However, existing heuristic methods (e.g., pairing the title of a post with the code in the accepted answer) are limited both in their coverage and the correctness of the NL-code pairs obtained. In this paper, we propose a novel method to mine high-quality aligned data from SO using two sets of features: hand-crafted features considering the structure of the extracted snippets, and correspondence features obtained by training a probabilistic model to capture the correlation between NL and code using neural networks. These features are fed into a classifier that determines the quality of mined NL-code pairs. Experiments using Python and Java as test beds show that the proposed method greatly expands coverage and accuracy over existing mining methods, even when using only a small number of labeled examples. Further, we find that reasonable results are achieved even when training the classifier on one language and testing on another, showing promise for scaling NL-code mining to a wide variety of programming languages beyond those for which we are able to annotate data.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑