An integrated evolution method based on association rules and deep learning

CN117270946BActive Publication Date: 2026-09-22CHONGQING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311228815.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-22
Publication Date
2026-09-22
Estimated Expiration
2043-09-22

AI Technical Summary

Technical Problem

[0003]研究表明:软件维护成本约占软件总成本的百分之七十,产生高成本的主要原因之一是软件代码的难以理解

Benefits of technology

[0033]实验结果证明,本发明提出的方法,能够针对方法名更新任务取得优秀表现。在实际开发的过程中,可以利用本发明自动的检测并更新方法名,避免开发人员因忽略或忘记而引入不一致方法名,造成软件质量缺陷。同时,本发明可以减少软件代码维护和审查的人工和时间成本。综上,可说明本发明能够在集成演化过程中,保证集成演化质量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117270946B_ABST
    Figure CN117270946B_ABST
Patent Text Reader

Abstract

The application relates to an integrated evolution method based on the combination of association rules and deep learning. A classifier component is used to process the modified version code and the modified version code after modification to obtain method body information sequence E input Method name information sequence is input as a sample, and the sample is classified into a single method body token modification sample and a plurality of method body token modification samples according to the token quantity of the modified method body. The single method body token modification sample is input into a heuristic rule component, and a new method name is generated after three steps of locating the existing modified token, constructing a replacement pair and matching updating. If the matching is unsuccessful, the sample is input into a deep learning model component. The deep learning model component is responsible for processing the sample that cannot be updated by the heuristic rule component and the plurality of method body token modification samples. After text embedding, coding and decoding, a new method name is generated, and finally, the method name updating is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to software quality assurance, and more particularly to an integrated evolutionary method based on association rules and deep learning. Background Technology

[0002] With the continuous advancement of modern technology, project scale is showing a trend of continuous growth and evolution. Simultaneously, project requirements are becoming more numerous and faster, accelerating the project evolution process. How to ensure the quality of project evolution during integration is one of the key issues that needs current attention and research.

[0003] Studies show that software maintenance costs account for approximately 70% of total software costs, and one of the main reasons for this high cost is the difficulty in understanding software code. On the one hand, ensuring the quality of integration and evolution can improve code quality and readability. For example, integrating changes to code and comments can increase code comprehensibility during the integration process, further reducing the time and cost for software maintainers. On the other hand, maintaining quality during the integration and evolution process can reduce the introduction of inconsistencies in code, thereby minimizing the impact of bugs or defects, such as changes to method names and code during integration and evolution. Summary of the Invention

[0004] To address the aforementioned problems in existing technologies, the technical problem this invention aims to solve is that: during the software code integration and evolution process, it is often difficult to guarantee the quality of integration and evolution, thereby increasing the maintenance cost of software code and potentially leading to inconsistent software defects. Furthermore, existing technologies lack methods for quality assurance during the integration and evolution process. This invention provides a general method for integration and evolution based on a combination of association rules and deep learning to ensure the quality of software code integration and evolution.

[0005] To solve the above technical problems, the present invention adopts the following technical solution: an integrated evolution method based on association rules and deep learning, comprising three components: component one is a classifier component, component two is a heuristic rule component, and component three is a deep learning model component.

[0006] S101: Data Collection. Retrieve data from the existing software database. Construct method body-method name co-change instances by modifying the method bodies and corresponding method names. Each method body-method name co-change instance consists of... src Code dst >, where Code src For the method before modification, Code dst This is the modified method.

[0007] ​S102: Preprocess instances where the method body and method name both change, ultimately obtaining framework input samples. Each framework input sample consists of the following components: src Code dst Name src Body src Name dst Body dst E input T nsrc T dsrc >, where Code src This indicates the method before modification. (Code) dst Indicates the modified method, Name src Indicates the original method name, Body src Indicates the method body before modification, Name dst Indicates the modified method name, Body dst E represents the modified method body. input The method body modification sequence, T nsrc T represents the sequence of tokens in the method body before modification. dsrc This represents the modified method body sub-token sequence.

[0008] S103: Use 80% of the frame input samples as the training set and the remaining frame input samples as the validation set; the training set and the validation set together constitute the total dataset.

[0009] S104: Classify all frame input samples in the total dataset, input each frame input sample into component one, and divide the frame input samples into frame input samples with a single method body token modification and frame input samples with multiple method body token modifications.

[0010] S105: Design component two, which receives a single method body token modification framework input sample and generates a recommended modified method name.

[0011] S106: Training Component 3. Each frame input sample in the training set is a training sample. Component 3 is trained using all the training samples in the training set to obtain the trained Component 3.

[0012] ​S107: Apply the framework to obtain the modified code snippet of the target software. After preprocessing the modified code snippet of the target software in S102, the framework input sample corresponding to the target software is obtained. After classification in S104, the framework input sample corresponding to the target software is input into component two for processing. The framework input samples with multiple modified method body tokens and the framework input samples with single modified method body tokens that failed to generate method names in component two are all input into the trained component three for processing to generate the recommended modified method name.

[0013] As an improvement, S102 preprocessing of instances where both the method body and method name change includes the following steps:

[0014] S102-1: Separate the method body and method name, and obtain the method code before modification for instances where both the method body and method name have changed. src and the modified method code dst First, use the JavaLang tool to parse and obtain the code. src The original method body in Body src The method name before modification (Name) src and Code dst Modified method body Body dst and the modified method name dst If parsing fails, a regular expression is used for parsing; if parsing still fails, the code snippet is discarded. If parsing succeeds, a corresponding quadruple of the original and modified code is obtained. <Name src Body src Name dst Body dst >

[0015] S102-2: Token splitting, dividing the quadruple <Name src Body src Name dst Body dst To perform tokenization, first use a lexical analyzer to remove the body. src and Body dst The inline comments are segmented into token-level sequences based on spaces and punctuation marks. Each token in the token sequence is then further segmented to obtain sub-token-level sequences. A special identifier "" is added after each segmentation of the same token. <con>"By concatenating the segmented sub-tokens to indicate that these sub-tokens belong to the same token, we can ultimately obtain the sequence of sub-tokens for the original method name." Method body subtotal sequence before modification Modified method name subtotal sequence and the modified method body sub-token sequence in, This represents the Kth method name sub-token in the sequence of method name sub-tokens before modification. This represents the L-th method body sub-token in the sequence of method body sub-tokens before modification. This represents the Mth sub-token in the modified method name sub-token sequence. This represents the Nth method body sub-token in the modified method body sub-token sequence.

[0016] S102-3: Edit sequence construction, use the SequenceMatcher alignment tool to align sequence T bsrc and sequence T bdst The sub-tokens are aligned one by one, and an edit operation is added after each aligned sub-token to obtain the edit sequence. in This represents the first sub-token of the method body before modification. Represents the i-th modified method body sub-token, a I Indicates the i-th edit operation, a i Let i = 1, 2, ..., I, collectively referred to as a. a has four possible choices: insert, delete, equal, and replace. i This indicates that one option is selected at a time. When 'a' is 'insert' or 'delete', the special character "φ" is added as a supplement to the blank part.

[0017] S102-4: Method body sub-token type annotation, using Javalang tools to annotate T bdst Each method body sub-token is labeled with a statement type to obtain the input sequence. in This represents the Qth unmodified method body sub-token. a represents the Q-th modified method body sub-token. Q Indicates the Qth edit operation, l Q This represents the Qth modified method body sub-token. The corresponding statement type tag.

[0018] S102-5: Integrate the Code obtained from S102-1 src Code dst Name src Body src Name dst Body dst T obtained in S102-2 nsrc ,T dsrc T obtained in S102-4 input This constitutes the frame input samples, and each frame input sample is in the form of... src Code dst Name src Body src Name dst Body dst E input ,T nsrc ,T ndst >

[0019] As an improvement, the step of the S105 component-two heuristic rule component receiving a framework input sample with a single method body token modification to generate a recommended modified method name is as follows:

[0020] S105-1: Locate the modified token, which is represented by a sequence of sub-tokens. Receive the frame input sample from S104 that has undergone modification of the single method body token through the E... input Perform a traversal and count E input For each quaternion sequence where the edit operation is not equal, after finding the sub-tokens whose edit operations are not equal, cut the tokens according to the sequence in S102-2. <con>"Using the principle of connecting the same token, traverse the sub-token sequence forward and backward respectively until it no longer appears." <con>Stop when the time is right, and you will get the complete sequence of modified sub-tokens. in and Representing sequence E respectively token The S-th method body token before modification and the method body token after modification.

[0021] S105-2: Construct replacement pairs and list the E values ​​obtained in S105-1 using exhaustive heuristics. token All possible potential updates corresponding to E, each potential update constitutes a replacement pair, and all replacement pairs constitute the set of replacement pairs; when E is given token It can form a replacement pair <t bsrc [i:j],t bdst [i:j]>, where t bdst [i:j] represents the sequence of sub-tokens from the i-th to the j-th element before modification, t bdst [i:j] represents the sequence of modified sub-tokens from the i-th to the j-th.

[0022] S105-3: Matching Update, iterate through all replacement pairs in the replacement pair set obtained in S105-2, if t bsrc [i:j] is the sequence of method names T before modification. nsrc A subsequence of is then represented by t. bdst [i:j] is related to t bsrc [i:j] in T nsrc The replacement is performed, and the replaced method name is output as the predicted method name. If no match is found after the traversal is completed, the corresponding frame input sample is passed to the trained component three for processing.

[0023] As an improvement, the S106 training process includes the following specific steps:

[0024] S106-1: Parameter initialization, in the third embedding layer of component, E in the frame input sample input The original method body sub-token Subtotal after method body modification Initialize using the FastText model; process the E values ​​in the frame input samples. input Editing operation a in i With statement type label l i i = 1, 2, ..., I, use random initialization; all trainable parameters in the encoding layer use random initialization; all trainable parameters in the decoding layer use random initialization.

[0025] S106-2: Embedding, inputting all frame input samples from the training set into the component three deep learning model component, and component three's E-values ​​on the frame input samples. input Embed each quadruple in the i-th quadruple. Mapped to vector quadruples Obtain the embedded sequence Will Mapped to vector Obtain the embedded sequence in, Represents the sub-token of the i-th method body before modification. The vector obtained after embedding; Represents the i-th modified method body sub-token The vector obtained after embedding; Indicates the i-th edit operation a i The vector obtained after embedding; Indicates the i-th sub-token type l i The vector obtained after embedding; Represents the i-th sub-token of the method name before modification. The vector obtained after embedding; E represents nemb The embedding vector of the Kth unmodified method name sub-token.

[0026] S106-3: Encoding, using an encoder to convert the E obtained from S106-2... bemb and E nemb Feature extraction is performed step by step to obtain a high-dimensional vector space feature representation of the input information. Two different sub-encoders are used during encoding: a method body information sub-encoder and a pre-modification method name sub-encoder. Each encoder consists of a context embedding layer, a common attention mechanism layer, and a model layer, respectively. Both the context embedding layer and the model layer are bidirectional LSTM models. E... nemb The input is fed into the original method name sub-encoder to obtain the corresponding high-dimensional vector space feature representation U. n E bemb The input is fed into the method body information sub-encoder to obtain the corresponding high-dimensional vector space feature representation U. b .

[0027] S106-4: Decoding, converting the U obtained from S106-3 encoding... n and U b The input is fed into a decoder composed of a single-layer LSTM, which decodes and generates the modified method name; simultaneously, a pointer generation network is used to generate the method name from E. input and T nsrc Copying a portion of the sub-tokens to mitigate the impact of OOV; for step j step The generated method name is the sub-token. The corresponding formula is:

[0028]

[0029] in, express The final generation probability, This represents the generation probability of a single-layer LSTM decoding. Indicates from T nsrc The probability of copy generation. Indicates from E input The probability of copy generation. The trainable parameters are between 0 and 1, representing the generation probabilities of LSTM decoding. The weighting percentage and from T nsrc Probability of copy generation The weighting percentage; based on the generation probability, the final generated method name sub-token sequence T is obtained. npre .

[0030] The S106-5 optimization utilizes the final generated method name token sequence T obtained from the S106-4 decoding in each training iteration. npre The modified method name sub-token sequence T in the training set samples ndst The loss value is calculated using the negative log-likelihood function. The calculated loss value is then used to backpropagate the loss and continuously optimize the training parameters. Training stops when the loss no longer decreases or the preset number of iterations is reached.

[0031] S106-6: Save the model. Use all the frame input samples in the validation set to validate the model trained in S106-5. Select the model parameters that perform best in the validation set and save them to obtain the trained component three.

[0032] Compared with the prior art, the present invention has at least the following advantages:

[0033] Experimental results demonstrate that the method proposed in this invention achieves excellent performance in method name update tasks. In actual development, this invention can automatically detect and update method names, preventing developers from introducing inconsistent method names due to oversight or forgetfulness, thus avoiding software quality defects. Simultaneously, this invention can reduce the manual and time costs of software code maintenance and review. In summary, this invention can ensure the quality of integration evolution during the integration process. Attached Figure Description

[0034] Figure 1 This forms the overall framework of the method of the present invention. Detailed Implementation

[0035] The present invention will now be described in further detail.

[0036] See Figure 1 This invention describes an integrated evolutionary method based on association rules and deep learning. This method is applicable to real-time update tasks such as real-time annotation updates and real-time method name updates. Its core idea is to input a common change instance, consisting of information from the previous and new versions, into an update framework. The framework automatically processes a series of related update tasks using the input information, such as real-time method name updates and real-time annotation updates. This invention mainly consists of three parts: a classifier component, a heuristic rule component, and a deep learning model component. The collected common change instances are preprocessed to obtain framework input samples. The classifier component divides the framework input samples into two categories: framework input samples processed based on heuristic rules and framework input samples processed based on the deep learning model. These are then processed separately by the heuristic rule component and the deep learning model component, respectively. Simultaneously, if there are framework input samples that the rules cannot process, these samples are re-inputted into the deep learning model component for further processing.

[0037] For the sake of technical explanation and experimental convenience, this invention will be further explained using a method name update task as an example. Specifically, instances of joint changes between method body and method name in the target software code library are collected and preprocessed to obtain framework input samples. In the classifier component, based on the input framework samples, tokens whose edited information is not equal are selected, and duplicates are removed. The framework input samples are then divided into two categories: those with a single modified method body token and those with multiple modified method body tokens. Framework input samples with a single modified method body token are input to the heuristic rule component for processing, while those with multiple modified method body tokens are input to the deep learning model component for processing.

[0038] The heuristic rule component process is derived from analyzing and summarizing a large number of framework input samples. It uses heuristic rules to generate multiple replacement pairs, iteratively checking whether the modified sub-token sequence in the replacement pair is a sub-sequence of the original method name, and then replacing it to generate a new method name. If the heuristic rule cannot generate a new method name, the framework input sample is also input into the deep learning model component. The deep learning model component adopts an LSTM+Attention mechanism architecture, continuously learning, understanding, and extracting features, and generating a new method name through embedding, encoding, and decoding. Simultaneously, to alleviate the Out-of-Vocabulary (OOV) problem, a pointer generation network is used during decoding to copy tokens from the input information to generate the final new method name.

[0039] An ensemble evolutionary approach based on association rules and deep learning comprises three components: a classifier component, a heuristic rule component, and a deep learning model component.

[0040] S101: Data Collection. Retrieve data from the existing software database. Construct method body-method name co-change instances by modifying the method bodies and corresponding method names. Each method body-method name co-change instance consists of... src Code ast >, where Code src For the method before modification, Code dst This is the modified method.

[0041] S102: Preprocess instances where the method body and method name both change, ultimately obtaining framework input samples. Each framework input sample consists of the following components: src Code dst Name src Body src Name dst Body dst E input T nsrc T dsrc >, where Code src This indicates the method before modification. (Code) dst Indicates the modified method, Name src Indicates the original method name, Body src Indicates the method body before modification, Name dst Indicates the modified method name, Body dst E represents the modified method body. input The method body modification sequence, T nsrc T represents the sequence of tokens in the method body before modification. dsrc This represents the modified method body sub-token sequence.

[0042] S103: Use 80% of the frame input samples as the training set and the remaining frame input samples as the validation set. The training set and validation set together constitute the total dataset.

[0043] S104: Classify all frame input samples in the total dataset, input each frame input sample into component one, and divide the frame input samples into frame input samples with a single method body token modification and frame input samples with multiple method body token modifications.

[0044] S105: Design component two, which receives a single method body token modification framework input sample and generates a recommended modified method name.​​

[0045] S106: Training Component 3. Each frame input sample in the training set is a training sample. Component 3 is trained using all the training samples in the training set to obtain the trained Component 3.

[0046] S107: Apply the framework to obtain modified code snippets of the target software. These modified code snippets, after preprocessing in S102, yield corresponding framework input samples. After classification in S104, framework input samples with single method body token modifications are input to component two for processing. Framework input samples with multiple method body token modifications and those with single method body token modifications for which component two failed to generate method names are all input to the trained component three for processing. Recommended modified method names are generated.

[0047] Specifically, the preprocessing of the method body-method name common change instance in S102 includes the following steps:

[0048] S102-1: Separate the method body and method name, and obtain the method code before modification for instances where both the method body and method name have changed. src and the modified method code dst First, use the JavaLang tool to parse and obtain the code. src The original method body in Body src The method name before modification (Name) src and Code dst Modified method body Body dst and the modified method name dst If parsing fails, a regular expression is used for parsing; if parsing still fails, the code snippet is discarded. If parsing succeeds, a corresponding quadruple of the original and modified code is obtained. <Name src Body src Name dst Body dst >

[0049] S102-2: Token splitting, dividing the quadruple <Name src Body src Name dst Body ast To perform tokenization, first use a lexical analyzer to remove the body. src and Body dst Inline comments are segmented into token-level sequences based on spaces and punctuation marks. Each token in the token sequence is then further segmented to obtain sub-token-level sequences. A special identifier is added after segmenting the same token. <con>"By concatenating the segmented sub-tokens to indicate that these sub-tokens belong to the same token, we can ultimately obtain the sequence of sub-tokens for the original method name." Method body subtotal sequence before modification Modified method name subtotal sequence and the modified method body sub-token sequence in, This represents the Kth method name sub-token in the sequence of method name sub-tokens before modification. This represents the L-th method body sub-token in the sequence of method body sub-tokens before modification. This represents the Mth sub-token in the modified method name sub-token sequence. This represents the Nth method body sub-token in the modified method body sub-token sequence.

[0050] S102-3: Edit sequence construction, use the SequenceMatcher alignment tool to align sequence T bsrc and sequence T bdst The sub-tokens are aligned one by one, and an edit operation is added after each aligned sub-token to obtain the edit sequence. in This represents the first sub-token of the method body before modification. Represents the i-th modified method body sub-token, a I Indicates the i-th edit operation, a i Let i = 1, 2, ..., I, collectively referred to as a. a has four possible choices: insert, delete, equal, and replace. i This indicates that one option is selected at a time. When 'a' is 'insert' or 'delete', the special character "φ" is added as a supplement to the blank part.

[0051] S102-4: Method body sub-token type annotation, using Javalang tools to annotate T bdst Each method body sub-token is labeled with a statement type to obtain the input sequence. in This represents the Qth unmodified method body sub-token. a represents the Q-th modified method body sub-token. Q Indicates the Qth edit operation, l Q This represents the Qth modified method body sub-token. The corresponding statement type tag.

[0052] S102-5: Integrate the Code obtained from S102-1 src Code dst Name src Body src Name dst Body dst T obtained in S102-2 nsrc ,T dsrc E obtained in S102-4 input This constitutes the frame input samples, and each frame input sample is in the form of... src Code dst Name src Body src Name dst Body dst Ein put ,T nsrc ,T ndst >

[0053] Specifically, the steps of the S105 component, the heuristic rule component, in receiving a framework input sample with a single method body token modification to generate a recommended modified method name are as follows:

[0054] S105-1: Locate the modified token, which is represented by a sequence of sub-tokens. Receive the frame input sample from S104 that has undergone modification of the single method body token through the E... input Perform a traversal and count E input For each quaternion sequence where the edit operation is not equal, after finding the sub-tokens whose edit operations are not equal, cut the tokens according to the sequence in S102-2. <con>"Using the principle of connecting the same token, traverse the sub-token sequence forward and backward respectively until it no longer appears." <con>Stop when the time is right, and you will get the complete modified sub-token sequence E. token =[< in and Representing sequence E respectively token The S-th method body token before modification and the method body token after modification.

[0055] S105-2: Construct replacement pairs and list the E values ​​obtained in S105-1 using exhaustive heuristics. token All possible potential updates corresponding to E, each potential update constitutes a replacement pair, and all replacement pairs constitute the set of replacement pairs; when E is given token It can form a replacement pair <t bsrc [i:j],t bdst [i:j]>, where t bsrc [i:j] represents the sequence of sub-tokens from the i-th to the j-th element before modification, t bdst [i:j] represents the sequence of modified sub-tokens from the i-th to the j-th.

[0056] S105-3: Matching Update, iterate through all replacement pairs in the replacement pair set obtained in S105-2, if t bstc [i:j] is the sequence of method names T before modification. nsrc A subsequence of is then represented by t. bdst [i:j] is related to t bsrc [i:j] in T nsrc The replacement is performed, and the replaced method name is output as the predicted method name. If no match is found after the traversal is completed, the corresponding frame input sample is passed to the trained component three for processing.

[0057] Specifically, the S106 training process includes the following steps:

[0058] S106-1: Parameter initialization, in the third embedding layer of component, E in the frame input sample input The original method body sub-token Subtotal after method body modification Initialize using the FastText model; process the E values ​​in the frame input samples. input Editing operation a in i With statement type label l i i = 1, 2, ..., I, use random initialization; all trainable parameters in the encoding layer use random initialization; all trainable parameters in the decoding layer use random initialization.

[0059] S106-2: Embedding, inputting all frame input samples from the training set into the component three deep learning model component, and component three's E-values ​​on the frame input samples. input Embed each quadruple in the i-th quadruple. Mapped to vector quadruples Obtain the embedded sequence Will Mapped to vector Obtain the embedded sequence in, Represents the sub-token of the i-th method body before modification. The vector obtained after embedding; Represents the i-th modified method body sub-token The vector obtained after embedding; Indicates the i-th edit operation a i The vector obtained after embedding; Indicates the i-th sub-token type l i The vector obtained after embedding; Represents the i-th sub-token of the method name before modification. The vector obtained after embedding; E represents nemb The embedding vector of the Kth unmodified method name sub-token.

[0060] S106-3: Encoding, using an encoder to convert the E obtained from S106-2... bemb and E nemb Feature extraction is performed step by step to obtain a high-dimensional vector space feature representation of the input information. Two different sub-encoders are used during encoding: a method body information sub-encoder and a pre-modification method name sub-encoder. Each encoder consists of a context embedding layer, a common attention mechanism layer, and a model layer, respectively. Both the context embedding layer and the model layer are bidirectional LSTM models. E... nemb The input is fed into the original method name sub-encoder to obtain the corresponding high-dimensional vector space feature representation U. n E bemb The input is fed into the method body information sub-encoder to obtain the corresponding high-dimensional vector space feature representation U. b .

[0061] S106-4: Decoding, converting the U obtained from S106-3 encoding... n and U b The input is fed into a decoder composed of a single-layer LSTM, which decodes and generates the modified method name; simultaneously, a pointer generation network is used to generate the method name from E. input and T nsrc Copying a portion of the sub-tokens to mitigate the impact of OOV; for step j step The generated method name is the sub-token. The corresponding formula is:

[0062]

[0063] in, express The final generation probability, This represents the generation probability of a single-layer LSTM decoding. Indicates from T nsrc The probability of copy generation. Indicates from E input The probability of copy generation. The trainable parameters are between 0 and 1, representing the generation probabilities of LSTM decoding. The weighting percentage and from T nsrc Probability of copy generation The weighting percentage; based on the generation probability, the final generated method name sub-token sequence T is obtained. npre .

[0064] The S106-5 optimization utilizes the final generated method name token sequence T obtained from the S106-4 decoding in each training iteration. npre The modified method name sub-token sequence T in the training set samples ndst The loss value is calculated using the negative log-likelihood function. The calculated loss value is then used to backpropagate the loss and continuously optimize the training parameters. Training stops when the loss no longer decreases or the preset number of iterations is reached.

[0065] S106-6: Save the model. Use all the frame input samples in the validation set to validate the model trained in S106-5. Select the model parameters that perform best in the validation set and save them to obtain the trained component three.

[0066] experiment

[0067] The data selected for the real-time method name update task in this invention comes from the website GitHub. Specifically, 1496 repositories were first cloned from GitHub, each with at least 500 commits. Then, method body-method name change instances were constructed by extracting modified method bodies and corresponding method names from the non-merged commits of each repository. Specifically, the existing GumTree matching algorithm was used to calculate the method mapping between the pre- and post-modification versions of the code, and then the ASTs of each pre- and post-modification method were compared based on the mapping to identify and extract modified method code. After filtering instances with unchanged method names, 215,347 instances of common method body-method name changes were obtained. After collecting these common change instances, further filtering of unqualified instances is needed to construct a better dataset. First, abstract methods, methods with empty method bodies, and methods with identical pre- and post-modification method bodies need to be filtered. Second, duplicate data needs to be filtered to prevent data leakage. To reduce training time, the 90th quantile of the dataset was used to limit the maximum length of method body information, the original method name, and the modified method name. This ensured that most methods were included within this length without causing training failures on the device. Ultimately, 108,360 instances of combined method body-method name changes were obtained. After preprocessing using the method of this invention, the dataset consisting of the framework input samples was obtained.

[0068] During dataset partitioning, submissions were sorted in ascending order of creation time. The first 80% of submissions were allocated to the training set, while the remaining 20% ​​were randomly shuffled and evenly distributed across the validation and test sets. This ensured that all method name updates in the training set occurred before updates in the validation and test sets, preventing data leakage and potential overestimation of method performance. Therefore, the final training, validation, and test sets consisted of 86,609, 10,805, and 10,946 framework input samples, respectively. After designing and training the framework using the training and validation sets, the test set was used as experimental input for comparison.

[0069] This invention employs four evaluation metrics for the real-time method name update task: Accuracy, Precision, Recall, and F-score. Accuracy is a token-level evaluation metric used to measure the extent to which the proposed method can generate correct method names. Specifically, if the generated method name is identical in order and content to the modified method name (Ground Truth), it is considered correct. Specifically, Accuracy is the percentage of correct predictions made by the MNU model in the test set. Precision, Recall, and F-score are sub-token-level evaluation metrics used to assess the extent to which the MNU model can generate correct method name sub-tokens, i.e., the proportion of correct generated method name sub-tokens to the modified method name sub-tokens. The calculation formulas for the sub-token no of the correct method name and the sub-tokenr of the predicted method name are as follows:

[0070]

[0071]

[0072]

[0073] The sub-token(name) returns the sub-token for the method name 'name'. The Precision, Recall, and F-score for predicting the method name are the average scores of all data.

[0074] This invention selected three methods for comparison in the real-time update task of method name to verify the performance of the method MAP mentioned in this invention on the method name update task, namely Origin, Cognac and NMT.

[0075] Origin is a commonly used method in update tasks. It directly outputs the method name of the previous version. By comparing it with this method, you can verify whether the recommended method name generated by the MAP method is closer to the method name of the modified version.

[0076] Cognac is a deep learning model based on a seq2seq structure. It leverages global context knowledge and prior knowledge gained through empirical analysis to generate recommended method names. Furthermore, it achieves excellent performance in the method name generation task. By comparing it with this method, we can verify whether MAP outperforms the method name generation method in the method name update task.

[0077] NMT is a seq2seq model based on LSTM and Attention mechanisms, often used as a comparison method for generation tasks. Its structural components are similar to those of the MAP deep learning model. By comparing it with NMT, we can verify whether MAP outperforms general generation methods in the method name update task. The comparison results are shown in Table 1.

[0078] Table 1. Performance Comparison Results of Real-Time Update by Method Name

[0079]

[0080] The following findings may be made:

[0081] ① Under all evaluation metrics, the MAP method proposed in this invention outperforms the comparative methods, indicating that the method of this invention has superior performance in the task of real-time method name update.

[0082] ② In the comparison with Origin, it can be found that Origin has about 50% of the three indicators of Precision, Recall and Fscore, indicating that the original method name itself contains some information about the modified method name, which can be utilized. After the MAP method, these three indicators are improved by more than 20%, indicating that the problem raised and the method of this invention have practical significance.

[0083] ③ In comparison with Cognac, it can be found that Cognac does not perform well in method name update tasks. This may be because the Cognac method does not utilize the information of the method body and method name before modification, and needs to generate a completely new method name from scratch. The MAP method, on the other hand, takes into account the information of both the previous and new versions, using an updated method instead of generating from scratch, resulting in better performance. This demonstrates the effectiveness of the MAP method of this invention in method name update tasks.

[0084] ④ In the comparison with NMT, it can be found that NMT still performs worse than the MAP method in the method name update task. This may be because the MAP method is designed for the software engineering domain and utilizes the type information of the code. Compared with the general method, although the improvement in Precision, Recall, and Fscore is not significant, the improvement in Accuracy is about 10%, which shows the effectiveness of the method of this invention for software engineering tasks.

[0085] In summary, experimental results demonstrate that the MAP method proposed in this invention achieves excellent performance in method name update tasks. In actual development, this invention can automatically detect and update method names, preventing developers from introducing inconsistent method names due to oversight or forgetfulness, thus avoiding software quality defects. Furthermore, this invention can reduce the manual and time costs of software code maintenance and review.

[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.< / con> < / con> ​< / con> < / con> < / con> ​< / con>

Claims

1. An ensemble evolutionary method based on association rules and deep learning, characterized in that: It includes three components: the first is the classifier component, the second is the heuristic rule component, and the third is the deep learning model component. S101: Data Collection. Retrieve data from the existing software database. Construct method body-method name co-change instances by modifying the method bodies and corresponding method names. Each method body-method name co-change instance consists of... ,in, The method before modification, This is the modified method; S102: Preprocess instances where the method body and method name both change, ultimately obtaining framework input samples. Each framework input sample consists of < , , >, among which This indicates the method before modification. This indicates the modified method. Indicates the method name before modification. This indicates the method body before modification. Indicates the modified method name. This indicates the modified method body. Indicates the sequence of modifications to the method body. This represents the sequence of subtotal tokens in the method body before modification. This represents the modified method body sub-token sequence; S103: Use 80% of the frame input samples as the training set and the remaining frame input samples as the validation set; the training set and the validation set together constitute the total dataset. S104: Classify all frame input samples in the total dataset, input each frame input sample into component one, and divide the frame input samples into frame input samples with a single method body token modification and frame input samples with multiple method body token modifications. S105: Design Component 2, which receives a single method body token modification framework input sample and generates a recommended modified method name; The steps of the S105 component's heuristic rule component in receiving a single method body token modification framework input sample to generate recommended modified method names are as follows: S105-1: Locate the modified token, represented by a sequence of sub-tokens. Receive the frame input sample from S104 that has undergone modification of the single method body token. Perform traversal and statistics For each quaternion sequence where the edit operation is not equal, after finding the sub-tokens whose edit operations are not equal, cut the tokens according to the sequence in S102-2. <con>"Using the principle of connecting the same token, traverse the sub-token sequence forward and backward respectively until it no longer appears." <con>Stop when the time is right, and you will get the complete sequence of modified sub-tokens. ,in Representing sequences respectively The Middle The method body token before modification and the method body token after modification;< / con> < / con> S105-2: Construct replacement pairs, using the exhaustive heuristic rule to list the pairs obtained in S105-1. All possible potential updates corresponding to this, each potential update constitutes a replacement pair, and all replacement pairs constitute the set of replacement pairs; when given It can form a replacement pair , in Indicates the first The first to the second A sequence of sub-tokens before modification. Indicates the first The first to the second A sequence consisting of modified sub-tokens; S105-3: Matching Update, iterate through all replacement pairs in the set of replacement pairs obtained in S105-2, if It is the sequence of method names before modification. A subsequence of , then use right exist The replacement is performed, and the method name obtained after replacement is output as the predicted method name. If no match is found after the traversal is completed, the corresponding frame input sample is passed into the trained component three for processing. S106: Training Component 3. Each frame input sample in the training set is a training sample. Component 3 is trained using all the training samples in the training set to obtain the trained Component 3. S107: Apply the framework to obtain the modified code snippet of the target software. After preprocessing the modified code snippet of the target software in S102, the framework input sample corresponding to the target software is obtained. After classification in S104, the framework input sample corresponding to the target software is input into component two for processing. The framework input samples with multiple modified method body tokens and the framework input samples with single modified method body tokens that failed to generate method names in component two are all input into the trained component three for processing to generate the recommended modified method name.

2. The ensemble evolution method based on association rules and deep learning as described in claim 1, characterized in that: The preprocessing of the method body-method name common change instance in S102 includes the following steps: S102-1: Separate the method body and method name, and obtain the method code before modification for instances where both the method body and method name have changed. and the modified method code First, use the JavaLang tool to parse and obtain... The method body before modification Method name before modification ,as well as Modified method body in and the modified method name If parsing fails, use regular expressions for parsing; if parsing still fails, discard the code snippet. If the parsing is successful, a corresponding quadruple of the original and modified versions will be obtained. ; S102-2: Token splitting, dividing the quadruple To perform tokenization, a lexical analyzer is first used to remove... and Inline comments are segmented into token-level sequences based on spaces and punctuation marks. Each token in the token sequence is then further segmented to obtain sub-token-level sequences. A special identifier is added after segmenting the same token. <con>"By concatenating the segmented sub-tokens to indicate that these sub-tokens belong to the same token, we can ultimately obtain the sequence of sub-tokens for the original method name." , Method body sub-token sequence before modification Modified method name subtotal sequence and the modified method body sub-token sequence ,in, This indicates the first subtotal in the method name subtotal sequence before modification. A method name token. This indicates the first sub-token in the method body's token sequence before modification. A method body token. This indicates the first subtotal in the modified method name subtotal sequence. Individual tokens, This indicates the first subtotal in the modified method body token sequence. A method body sub-token;< / con> S102-3: Edit the sequence structure and use the SequenceMatcher alignment tool to... and The sub-tokens are aligned one by one, and an edit operation is added after each aligned sub-token to obtain the edit sequence. ,in Indicates the first The original method body token. Indicates the first A modified method body sub-token. Indicates the first One editing operation, Collectively referred to as , There are four possible choices: insert, delete, equal, and replace. This means choosing one option at a time. Add special characters "" when inserting or deleting. "As a supplement to the blanks; S102-4: Method body sub-token type annotation, using Javalang tools to... Each method body sub-token is labeled with a statement type to obtain the input sequence. ,in Indicates the first The original method body token. Indicates the first A modified method body sub-token. Indicates the first One editing operation, Indicates the first Modified method body sub-token The corresponding statement type label; S102-5: Integrating the results from S102-1 ; obtained from S102-2 , ; obtained from S102-4 This constitutes the frame input samples, and each frame input sample is in the form of < >

3. The ensemble evolution method based on association rules and deep learning as described in claim 2, characterized in that: The S106 training process includes the following specific steps: S106-1: Parameter initialization, in the third embedding layer of component 3, for the frame input sample The original method body token Subtotal after method body modification Initialize using the FastText model; process the input samples in the framework. Editing operations in With statement type label Use random initialization; use random initialization for all trainable parameters in the encoding layer; use random initialization for all trainable parameters in the decoding layer. S106-2: Embedding, inputting all frame input samples from the training set into the component three deep learning model component, and component three inputs the frame input samples... Embed each quadruple in the array, and embed the first quadruple into the array. Quadruples Mapped to vector quadruples The embedded sequence is obtained. ,Will Mapped to vector The embedded sequence is obtained. ,in, Indicates the first The original method body token The vector obtained after embedding; Indicates the first Modified method body sub-token The vector obtained after embedding; Indicates the first Editing operations The vector obtained after embedding; Indicates the first Subtotal type The vector obtained after embedding; Indicates the first The original method name token The vector obtained after embedding; express The Middle The method name before modification is embedded in the token vector; S106-3: Encoding, using an encoder to convert the result obtained in S106-2 and Feature extraction is performed step by step to obtain a high-dimensional vector space feature representation of the input information. Two different sub-encoders are used during encoding: a method body information sub-encoder and a method name sub-encoder before modification. Each encoder consists of a context embedding layer, a common attention mechanism layer, and a model layer, respectively. Both the context embedding layer and the model layer are bidirectional LSTM models. The input is fed into the original method name sub-encoder to obtain the corresponding high-dimensional vector space feature representation. ;Will The input is fed into the method body information sub-encoder to obtain the corresponding high-dimensional vector space feature representation. ; S106-4: Decoding, obtained by encoding S106-3 and The input is fed into a decoder composed of a single-layer LSTM, which decodes and generates the modified method name; simultaneously, a pointer generation network is used to... and Copying a portion of the sub-tokens in the middle mitigates the impact of OOV; for the steps The generated method name is the sub-token. The corresponding formula is: in, express The final generation probability, This represents the generation probability of a single-layer LSTM decoding. Indicates from The probability of copy generation. Indicates from The probability of copy generation. , The trainable parameters are between 0 and 1, representing the generation probabilities of LSTM decoding. weighting percentage and The weighting percentage; based on the generation probability, the final generated method name sub-token sequence is obtained. ; The S106-5 optimization utilizes the final generated method name token sequence obtained from the S106-4 decoding in each training iteration. The modified method name subtotal sequence in the training set samples Calculate the loss value using the negative log-likelihood function; use the calculated loss value to backpropagate the loss and continuously optimize the training parameters; stop training when the loss no longer decreases or the preset number of iterations is reached. S106-6: Save the model. Use all the frame input samples in the validation set to validate the model trained in S106-5. Select the model parameters that perform best in the validation set and save them to obtain the trained component three.