Graph-Based Statistical Language Model for Code
Authors:
- Anh Tuan NguyenANAnh Tuan Nguyen
- Tien N. NguyenTNTien N. Nguyen
- 1 May 2015
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- Vol. 1 (02705257) , 858-868
Abstract
n-gram statistical language model has been successfully applied to capture programming patterns to support code completion and suggestion. However, the approaches using n-gram face challenges in capturing the patterns at higher levels of abstraction due to the mismatch between the sequence nature in n-grams and the structure nature of syntax and semantics in source code. This paper presents GraLan, a graph-based statistical language model and its application in code suggestion. GraLan can learn from a source code corpus and compute the appearance probabilities of any graphs given the observed (sub)graphs. We use GraLan to develop an API suggestion engine and an AST-based language model, ASTLan. ASTLan supports the suggestion of the next valid syntactic template and the detection of common syntactic templates. Our empirical evaluation on a large corpus of open-source projects has shown that our engine is more accurate in API code suggestion than the state-of-the-art approaches, and in 75% of the cases, it can correctly suggest the API with only five candidates. ASTLan has also high accuracy in suggesting the next syntactic template and is able to detect many useful and common syntactic templates.Keywords
This publication has 37 references indexed in Scilit:
- Live API documentation2014
- ExPort: Detecting and visualizing API usages in large source code repositories2013
- Typestate-based semantic code search over partial programs2012
- Synthesizing API usage examples2012
- An evaluation of the strategies of sorting, filtering, and grouping API methods for Code Completion2011
- Exemplar: A Source Code Search Engine for Finding Highly Relevant ApplicationsIEEE Transactions on Software Engineering, 2011
- Recommending source code examples via API call usages and documentation2010
- Using task context to improve programmer productivity2006
- Using structural context to recommend source code examples2005
- Automatic method completion2004