摘要
A code snippet is a small region of reusable source code that is common to many functions. Skilled management and reuse of snippets can improve programming efficiency in practice. However, we find that most snippets are posted to online blogs or snippet management systems with little description and tagging, which leads to an embarrassing situation in which existing snippets are difficult to reuse. This occurs because snippets are usually hastily pushed to online services or saved in text files by programmers and also because existing management systems do not provide efficient labeling and reusing frameworks. In this paper, we propose to annotate snippets with a well-formed domain-specific ontology—programming ontology. With a thorough investigation of real world snippets, we designed a programming ontology to annotate and recommend snippets. We show how to annotate a snippet with ontology terms based on text classification models. In addition, we built a snippet management system that stores user snippets in the cloud and automatically recommends snippets, so that the retrieval of snippets becomes trivial in popular integrated developing environments, such as Eclipse and Visual Studio. Our evaluation results demonstrate that the ontology annotation algorithm is able to automatically annotate a snippet with a high degree of accuracy. The shared domain knowledge also makes it possible to share snippets among programmers and systems. As the number of labeled snippets increases, deep learning models can be trained and used to annotate code snippets with high accuracy.
源语言 | 英语 |
---|---|
页(从-至) | 2971-2985 |
页数 | 15 |
期刊 | Journal of Ambient Intelligence and Humanized Computing |
卷 | 10 |
期 | 8 |
DOI | |
出版状态 | 已出版 - 1 8月 2019 |