Unlock instant, AI-driven research and patent intelligence for your innovation.

Code snippet recommendation method and device based on deep neural network

A deep neural network and recommendation method technology, applied in the field of code recommendation, can solve the problems of inaccurate recommendation results, loss of structural information and sequence information, different execution sequence results and functions, etc., to achieve high similarity, easy to use, and avoid interference. Effect

Active Publication Date: 2020-05-12
NANJING UNIV OF AERONAUTICS & ASTRONAUTICS
View PDF8 Cites 6 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

Because the execution of the code is ordered, even if it is the same code statement, the different execution order will bring different results and functions
[0014] Existing code recommendation technologies mostly use code text and semantic information to make relevant recommendations. Only using text and semantic information for code recommendation will cause the loss of the structural information and sequence information of the code itself, resulting in inaccurate recommendation results.

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Code snippet recommendation method and device based on deep neural network
  • Code snippet recommendation method and device based on deep neural network
  • Code snippet recommendation method and device based on deep neural network

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0034] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.

[0035] A code recommendation method based on a deep neural network disclosed in an embodiment of the present invention first extracts code elements (including method names, parameters and return values, logic information, and code statement sequences) from the collected code fragments, and extracts code elements from the annotation documents Extract the first line as the description information, and embed the code elements and description information together into the vector space for model training; then, for a given code base from which the user wants to search code snippets, extract the code elements of each method in it, using the passed The trained model calculates the code vector; when the user query arrives, the vector representation of the query is calculated, and the corresponding code fragment of the vector close to the query vector is...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a code snippet recommendation method and device based on a deep neural network. The method comprises the steps that code elements including method names, parameters, return values, logic information and code statements are extracted from collected code snippets, description information is extracted from annotation documents, and the code elements and the description information are jointly embedded into a high-dimensional vector space for model training; a code element of each method is extracted from a given code library, and a code vector is calculated by using the trained model; and when the user query arrives, the code snippets are returned corresponding to the vectors close to the query vector. Compared with the prior art, the method learns unified vector representations of source codes and natural language queries, so that code segments related to query semantics can be retrieved according to the vectors of the source codes and the natural language queries. Various types of element information such as the statement sequence and the code structure is fully considered, so that the similarity between the recommended code snippets and the query is higher,and the user can better use the recommended code snippets.

Description

technical field [0001] The present invention relates to code recommendation, in particular to a code segment recommendation method and device based on a deep neural network. Background technique [0002] A code fragment refers to a set of code sequences, which can guide developers to quickly grasp the usage of a certain program interface or the implementation method of a certain programming task. In recent years, research in the direction of code recommendation has focused on how to use information retrieval or machine learning for code recommendation. The code features used in these studies are relatively single and fail to fully extract the information carried by the code. Taking ROSF as an example, in the data preparation stage, it first divides the Java project into multiple class files, and then divides the class files into multiple code fragments. Afterwards, for each code fragment, it uses topic models, code metrics, etc. to extract the features of the code fragment...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
IPC IPC(8): G06F8/20G06F8/41G06N3/04G06N3/08
CPCG06F8/24G06F8/427G06N3/08G06N3/044G06N3/045
Inventor 李伟湋艾磊邵宜超黄志球
Owner NANJING UNIV OF AERONAUTICS & ASTRONAUTICS