Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

Code annotation generation method based on structural perception

An annotation and code technology, applied in the field of code annotation generation based on structure awareness, which can solve problems such as tediousness and time-consuming

Active Publication Date: 2019-07-02
FUDAN UNIV
View PDF5 Cites 25 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0002] We have observed a large number of program source code released in recent years and found that manually writing detailed comments for them is a tedious and time-consuming job

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 annotation generation method based on structural perception
  • Code annotation generation method based on structural perception
  • Code annotation generation method based on structural perception

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0068] The specific training process of the comment generator and the specific implementation of the comment generation of Python code will be given below.

[0069] 1. The training of the annotation generator, the specific steps are:

[0070] (1) Prepare a large number of codes and comments corresponding to each sentence of code as training data. Here we take the Python code as an example. For example, a sentence of code in the training data set is "for cache in caches.all():", and the corresponding comment is "for every cache in return value of the function caches.all.". Next, we will mainly focus on the adjustment of the model parameters during the training process of this code.

[0071] (2) For each code sequence x s Generate its corresponding abstract syntax tree. For Python code, you can use the built-in ast package to complete the process. At this time, the words represented by each node in the abstract syntax tree form the abstract syntax tree sequence x t ; Label ...

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 belongs to the technical field of computer application, and particularly relates to a code annotation generation method based on structural perception. Hierarchical information of a codefragment is obtained by using an abstract syntax tree, so that a code annotation generator based on structural perception is constructed. According to the model called Code2Text, a source code is combined with an abstract syntax tree of the source code, and the model is applied to the field of code annotation. A dual encoder in the Code2Text encodes the source code sequence input and the abstractsyntax structure input respectively, and each word in the source code and each node in the abstract syntax tree are utilized to accurately adjust the generated word through a dual attention mechanismso as to guide the decoding process. The method can assist a programmer to generate annotations so as to reduce the manual writing cost, and can also provide reference for the programmer without experience to understand existing codes; and the method can be used for application program code detection of data use.

Description

technical field [0001] The invention belongs to the technical field of computer applications, and in particular relates to a method for generating code annotations based on structure awareness. Background technique [0002] We have observed a large number of program source code released in recent years and found that manually writing detailed comments for them is a tedious and time-consuming job. However, these annotations play an irreplaceable role in software development. For example, it can guide novice engineers to quickly understand the purpose of each piece of code, and it can also help them read a piece of legacy code written in a non-mainstream programming language. Therefore, we need an effective automatic source code annotation method, and the goal is to automatically add corresponding high-quality natural language, that is, annotations, to the code. [0003] The method of generating annotations from code can also be used in the detection of application code used...

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/40G06F8/41
CPCG06F8/42G06F8/40
Inventor 熊贇徐少峰潘文韬朱扬勇
Owner FUDAN UNIV
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products