Font Size: a A A

Research On Code Snippet Recommendation Method Based On Code Statement Granularity Representation

Posted on:2021-06-24Degree:MasterType:Thesis
Country:ChinaCandidate:L AiFull Text:PDF
GTID:2518306479460794Subject:Software engineering
Abstract/Summary:PDF Full Text Request
Code snippet recommendation belongs to code recommendation method which uses code snippets as a recommendation target.Because code snippet recommendation is helpful to improve the efficiency and quality of software development,it has become a hot spot for researchers and practitioners in the field of software engineering.According to different application scenarios,code snippet recommendation can be divided into code snippet recommendation without query and code snippet recommendation with query.These two types of methods use programming context and natural language query as input respectively.They provide support for developers according to different needs at different stages of the development process.Existing work usually processes code snippets as textual or structural data at the token granularity,and extracts the feature information of interest from them to represent the code snippets.Then information retrieval,machine learning,and heuristic rules are used to perform search according to their input,aim to form a recommended result list.However,there are problems such as insufficient use of code statement semantic information,inability to resolve programming style differences,and inability to make up for the semantic gap between natural language and programming language,which leads to low precision of recommendation and poor practical effect of recommendation results.These problems limit the promotion and use of the code snippet recommendation method in actual production environments.For the above problems,we have carried out the following research:(1)A code snippet recommendation framework based on statement granularity representation method is proposed,which defines code snippet recommendation process and research framework of this thesis.For the problem of insufficient use of semantic and sequence information in code snippet representation,the framework proposes a statement granularity code snippet representation method to implement code statement granularity code snippet representation and provides support for recommendation methods.(2)For the code snippet recommendation without query scenario,a code snippet recommendation method based on sequence matching is proposed.It uses the programming context as input to perform code snippet recommendation,and uses statement granularity code snippet representation method to perform data representation during the recommendation process.Also,it uses sequence matching algorithm as the core algorithm for recommendation,making full use of the statement sequence information and structure information of the code snippet,which improves the accuracy of the code snippet recommendation and optimizes the ranking results.(3)For the code snippet recommendation scenario with query,a code snippet recommendation method based on joint embedding is proposed.It uses the natural language query as input to perform code snippet recommendation.In the recommendation process,the statement granularity code snippet representation method and joint embedding technology are used to map the code snippet and natural language to the same vector space while maintaining semantic relevance.To a degree,it bridges the semantic gap between natural language and program language,which improves the accuracy of code snippet recommendation,and optimizes the ranking results.(4)A code snippet recommendation prototype tool is designed and implemented which combines the two code snippet recommendation methods.It is embedded in the developer programming environment as a plug-in and provides developers with high-quality and usable code snippets in a variety of situations.Also,it provides a user-friendly interface and functions for developers.Finally,the utility of the tool is verified,and the usage and function of the tool are demonstrated.
Keywords/Search Tags:Code Snippet Recommendation, Code Snippet Representation, Information Retrieval, Joint Embedding, Prototype System
PDF Full Text Request
Related items