arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1911.07781cs.SE
收藏

结合程序分析和统计语言模型的代码语句补全

Combining Program Analysis and Statistical Language Model for Code Statement Completion

Son Nguyen, Tien N. Nguyen, Yi Li, Shaohua Wang

摘要:

自动代码完成有助于提高开发人员在编程任务中的生产力。程序包含通过代码语句表达的指令,代码语句被认为是程序执行的基本单元。本文介绍了AutoSC,它结合了程序分析和软件自然性原则来填充一个部分完成的语句。AutoSC受益于两个方向的优势,其中完成的代码语句既频繁又有效。AutoSC首先在大型代码语料库上进行训练,以获得候选语句的模板。然后,它使用程序分析来验证模板,并将其具体化为语法上和类型上有效的候选语句。最后,通过使用在代码语料库中的源代码的词汇形式上训练的语言模型来对这些候选进行排名。我们对真实项目的大数据集的实证评估表明,AutoSC在语句完成方面达到了38.9-41.3%的前1准确率和48.2-50.1%的前5准确率。它还优于最先进的方法,从9 X-69 X的前1精度。

英文摘要:

Automatic code completion helps improve developers' productivity in their programming tasks. A program contains instructions expressed via code statements, which are considered as the basic units of program execution. In this paper, we introduce AutoSC, which combines program analysis and the principle of software naturalness to fill in a partially completed statement. AutoSC benefits from the strengths of both directions, in which the completed code statement is both frequent and valid. AutoSC is first trained on a large code corpus to derive the templates of candidate statements. Then, it uses program analysis to validate and concretize the templates into syntactically and type-valid candidate statements. Finally, these candidates are ranked by using a language model trained on the lexical form of the source code in the code corpus. Our empirical evaluation on the large datasets of real-world projects shows that AutoSC achieves 38.9-41.3% top-1 accuracy and 48.2-50.1% top-5 accuracy in statement completion. It also outperforms a state-of-the-art approach from 9X-69X in top-1 accuracy.

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

↑