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

Code abstract generation method based on code knowledge graph and knowledge migration

A technology of code summary and knowledge map, which is applied in the field of automatic code generation summary, can solve problems such as unused knowledge map and unused API description information, and achieve the effect of improving quality

Active Publication Date: 2020-10-20
HARBIN INST OF TECH
View PDF4 Cites 12 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

Although this document uses API sequence information that can reveal the functional semantics of the code, it does not use knowledge graphs, nor does it use API description information that can provide more specific description information

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 abstract generation method based on code knowledge graph and knowledge migration
  • Code abstract generation method based on code knowledge graph and knowledge migration
  • Code abstract generation method based on code knowledge graph and knowledge migration

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0053] Take the following Java code as an example:

[0054] public static Uri.Builder appendId(Uri.Builder builder, long id) {return builder.append EncodedPath(string.valueOf(id));

[0055]}

[0056] The API sequence extracted from the code is:

[0057] String. valueOf

[0058] By querying as Figure 4 In the knowledge map shown, replace the API sequence with the API sequence description sequence (including function description and problem description), as follows:

[0059] Returns the string representation of the Object argument.

[0060] Why String.valueOf(null) is causing null pointer exception.

[0061] The result of its artificial summary is: appends the given id to the end of the path.

[0062] Only the API description is used, and the API summary generated by using the API summary model pre-trained on large-scale projects is: returns a string representation of this object.

[0063] It can be seen that the model has been able to capture part of the semantic inform...

Embodiment 2

[0071] Take the following Java code as an example:

[0072]

[0073] The API sequence extracted from the code is:

[0074] String. startsWith

[0075] String. startsWith

[0076] String.substring

[0077] String. startsWith

[0078] String. length

[0079] String.substring

[0080] By querying as Figure 4 In the knowledge map shown, replace the API sequence with the API sequence description sequence, as follows:

[0081] InputStream.available

[0082] InputStream.read

[0083] OutputStream.write

[0084] OutputStream.flush

[0085] By querying as Figure 4 In the knowledge map shown, replace the API sequence with the API sequence description sequence (including function description and problem description), as follows:

[0086] Returns an estimate of the number of bytes that can be read(orskipped over) from this input stream without blocking by the next invocation of a method for this input stream.

[0087] What does InputStream. available() do in Java.

[0088...

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 abstract generation method based on a code knowledge graph and knowledge migration. The method comprises the following steps: 1, extracting and fusing multi-source datato construct the code knowledge graph; 2, generating an abstract syntax tree by using a code parsing tool, and traversing method calling nodes in the abstract syntax tree to obtain an API calling sequence; 3, searching API description information in the API calling sequence from the code knowledge graph; 4, mining large-scale open source projects, constructing an API sequence abstract generation data set, training a text abstract generation model, and learning background knowledge related to API functions; 5, constructing a code abstract generation model; and 6, training a code abstract generation model on the code abstract data set, and generating a code abstract by utilizing the model. According to the method, the code knowledge graph and knowledge migration are used for the code abstract generation task, the ability of the model to extract code functional semantic information can be enhanced, the model is assisted in understanding codes, and the code abstract generation quality is improved.

Description

technical field [0001] The invention relates to a method for automatically generating abstracts for codes, in particular to a method for automatically generating abstracts for codes based on code knowledge graphs and knowledge transfer technology. Background technique [0002] In the iterative process of actual software project development, due to the differences in programming abilities and habits of each developer, developers and maintainers need to spend a lot of time and energy reading and understanding existing codes, so as to maintain and reuse them. [0003] Code summarization provides a high-level natural language description of the functions performed by the code, which is beneficial for software maintenance, code classification and retrieval. Existing code summaries often need to be written manually, but many large-scale projects lack code summaries. With the expansion of the software system scale and the version change in the face of requirements, the code summar...

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): G06F16/36G06F16/34G06F40/295G06F40/284
CPCG06F16/367G06F16/345G06F40/295G06F40/284Y02D10/00
Inventor 苏小红苏佳蒋远王甜甜赵玲玲
Owner HARBIN INST OF TECH
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