Java Internal Annotation Generation via Context-Aware Encoder-Decoder

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing methods focus on generating summary annotations for Java methods, but struggle with automatically generating internal annotations due to their diverse and complex semantics, and the difficulty in determining corresponding target codes, which are often similar across projects, making it challenging to migrate summary annotation generation techniques to internal annotation tasks effectively.

Innovation Solution

A deep learning-based Java program internal annotation generation method using an encoder-decoder network with a pretrained language model like CodeBERT, which combines target code and context code information to preprocess and generate high-quality internal annotations, improving code understanding and maintainability by extracting and filtering relevant data flow information and performing part-of-speech tagging.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Ease of manufacture

If summary annotation generation methods are used for internal annotations, then the generation process is simpler, but the generation quality is lower due to diverse and complex semantics

Engineering Contradiction:
Improvegeneration process simplicityVSAvoidannotation generation quality
Core Design Contradiction:
Ease of manufactureVSManufacturing precision

Solution Approach 1:

The patent segments the annotation generation task into two distinct parts: summary annotation generation and internal annotation generation. Each part is handled by specialized processing paths within the model, allowing summary annotations to be generated simply while internal annotations receive more complex processing to handle their diverse semantics, thus resolving the contradiction between simplicity and quality.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent applies different processing qualities to different parts of the annotation task. Summary annotations use a simpler generation approach, while internal annotations use a more sophisticated approach with additional processing steps. This local differentiation allows the system to maintain simplicity where possible while achieving high quality where needed.

Inventive Principle:
Principle #3Local quality

2Productivity

If only target code is used for annotation generation, then the generation process is faster, but the accuracy is insufficient due to similar target codes across different projects

Engineering Contradiction:
Improvegeneration speedVSAvoidannotation accuracy
Core Design Contradiction:
ProductivityVSMeasurement precision

Solution Approach 1:

The patent merges multiple information sources to generate annotations: target code, context code, and documentation code are all fed into the generation model. This combination provides richer input information that helps distinguish between similar codes from different projects, improving annotation accuracy while maintaining reasonable generation speed through efficient processing of multiple inputs.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The patent performs preliminary processing of the codebase by extracting and organizing context code and documentation code before the actual annotation generation. This preliminary action prepares the necessary information in advance, allowing the generation process to access rich contextual information without significantly impacting generation speed.

Inventive Principle:
Principle #10Preliminary action

3Manufacturing precision

If more information such as context code is added for internal annotation generation, then the generation quality improves, but the processing complexity increases

Engineering Contradiction:
Improveannotation generation qualityVSAvoidprocessing complexity
Core Design Contradiction:
Manufacturing precisionVSDevice complexity

Solution Approach 1:

The patent implements a universal encoder-decoder model architecture that handles multiple types of input (target code, context code, documentation code) through a single processing framework. This multi-functional model reduces processing complexity by providing a unified approach to handling diverse inputs, rather than requiring separate processing pipelines for each input type.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Solution Approach 2:

The patent introduces an intermediary processing layer that manages the integration of multiple information sources. The encoder-decoder architecture acts as an intermediary that systematically processes and integrates target code, context code, and documentation code, reducing the complexity of managing multiple inputs by providing a structured intermediate representation.

Inventive Principle:
Principle #24Intermediary (Mediator)

Data Source

PatentUS12106095B2Deep learning-based java program internal annotation generation method and system
Publication Date: 2024.10.01 NANJING UNIV
  • US12106095B2 patent drawing
  • US12106095B2 patent drawing
  • US12106095B2 patent drawing

AI summary

A deep learning-based Java program internal annotation generation method and system is provided. The method includes acquiring items with a Stars number ranked in the top, and extracting corresponding internal annotations and method statement lists; obtaining an <annotation, target code> pair; selecting an annotation in a Verb-dobj form; obtaining a code context associated with a target code segment; preprocessing the annotation, the target code, and the context to obtain a triplet dataset; randomly dividing the constructed dataset into a training set, a validation set, and a test set, and constructing an encoder-decoder network at the same time; enabling the training set in division to be used for model training, performing evaluation on the validation set to obtain a model with the best effect on the validation set as a target model; and predicting data in the test set with the obtained target model to generate a predicted annotation.