Code snippet recommendation method based on sequence-to-sequence model

Inactive Publication Date: 2020-02-04
NANJING UNIV OF AERONAUTICS & ASTRONAUTICS
View PDF5 Cites 14 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0006] Aiming at the deficiencies in the prior art above, the purpose of the present invention is to provide a method for recommending code fragments based on a sequence-to-sequence model to solve the problem of semantic differences between queries and codes in the prior art; the method of the present invention no longer It directly calculates the similarity between the query and the code, but first trains a query generation model to generate a query for the code fragment, and then, by calculating the similarity between the query input by the user and the generated query corresponding to the code fragment, the retrieval And recommend highly relevant code snippets to developers

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 based on sequence-to-sequence model
  • Code snippet recommendation method based on sequence-to-sequence model
  • Code snippet recommendation method based on sequence-to-sequence model

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0024] In order to facilitate the understanding of those skilled in the art, the present invention will be further described below in conjunction with the embodiments and accompanying drawings, and the contents mentioned in the embodiments are not intended to limit the present invention.

[0025] refer to figure 1 As shown, a code fragment recommendation method based on a sequence-to-sequence model of the present invention includes the following:

[0026] (1) Data collection and cleaning

[0027] Considering that the application scenario of code snippet recommendation is that developers input queries to obtain code snippet recommendation results, in order to ensure that the collected data conforms to the application scenario and ensure the authenticity and reliability of the data, the present invention chooses to collect code from the Stack Overflow question-and-answer website Fragments and corresponding queries.

[0028] There are more than 17.9 million questions on the Sta...

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 based on a sequence-to-sequence model. The method comprises the steps of collecting and cleaning code snippets and corresponding queries; extracting code information; performing an identifier replacement operation on the code snippets; combining the code snippets after the identifier replacement operation and the corresponding queries into a set of (code, query) pairs, and taking the set as a training set of a query generation model; training a query generation model by using the sequence-to-sequence model; generating a query for thecode snippets of the recommendation code library; inputting a query, and executing similarity calculation between the query and the generated query; and according to a similarity calculation result,constructing a generated query list according to a descending order of similarity scores, and retrieving code snippets corresponding to queries in the list from a recommendation code library to serveas code snippet recommendation results. The method is superior to some existing research works, the code snippet recommendation effect can be effectively improved, and the software development efficiency is improved.

Description

technical field [0001] The invention belongs to the technical field of software engineering, and in particular relates to a method for implementing code segment recommendation by using program static analysis, natural language processing and neural network technology. Background technique [0002] In the current open source software ecological environment, massive codes and various related code description information can be obtained openly and free of charge, and the number and scale of software are rapidly expanding, which also lays the foundation for code reuse. Gabel et al. conducted statistics and research on about 420 million lines of code of more than 6,000 open source projects, and found that software usually lacks uniqueness, that is, program code is often repeated, which also provides theoretical support for code reuse. Effective code reuse can improve developers' development efficiency and reduce development costs. [0003] In the actual software development proc...

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
Patent Type & Authority Applications(China)
IPC IPC(8): G06F8/20G06F8/41G06F16/903G06F11/36
CPCG06F8/20G06F8/427G06F11/3608G06F16/90335
Inventor 周宇闫鑫黄志球
Owner NANJING UNIV OF AERONAUTICS & ASTRONAUTICS
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products