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

从Source Code中挖掘习语

Mining Idioms from Source Code

Miltiadis Allamanis, Charles Sutton

摘要:

我们提出了第一种方法,自动挖掘代码习惯用法从语料库以前写的,惯用的软件项目。我们认为,代码习惯用法是一个语法片段,在项目中重复出现,并具有单一的语义角色。习惯用法可能有元变量,比如for循环的主体。现代IDE通常提供手动定义习惯用法并根据需要插入它们的工具,但这并不能帮助程序员用他们不熟悉的语言或使用库编写习惯用法代码。我们提出了HAGGIS,一个系统的挖掘代码成语,建立在最近的先进技术,从统计自然语言处理,即非参数贝叶斯概率树替换语法。我们将HAGGIS应用于GitHub上几个最流行的开源项目。我们提出了广泛的证据表明,由此产生的习惯用法是语义上有意义的,证明他们确实在软件项目中反复出现,而且他们更频繁地出现在从问答网站收集的说明性代码示例中。对最常见的习惯用法的手动检查表明,它们描述了重要的程序概念,包括对象创建、异常处理和资源管理。

英文摘要:

We present the first method for automatically mining code idioms from a corpus of previously written, idiomatic software projects. We take the view that a code idiom is a syntactic fragment that recurs across projects and has a single semantic role. Idioms may have metavariables, such as the body of a for loop. Modern IDEs commonly provide facilities for manually defining idioms and inserting them on demand, but this does not help programmers to write idiomatic code in languages or using libraries with which they are unfamiliar. We present HAGGIS, a system for mining code idioms that builds on recent advanced techniques from statistical natural language processing, namely, nonparametric Bayesian probabilistic tree substitution grammars. We apply HAGGIS to several of the most popular open source projects from GitHub. We present a wide range of evidence that the resulting idioms are semantically meaningful, demonstrating that they do indeed recur across software projects and that they occur more frequently in illustrative code examples collected from a Q&A site. Manual examination of the most common idioms indicate that they describe important program concepts, including object creation, exception handling, and resource management.

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

↑