Java Internal Annotation Generation via Context-Aware Encoder-Decoder
Find Innovative SolutionsGenerate 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
Engineering 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
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.
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.
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
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.
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.
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
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.
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.
Data Source
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.


