Code comparison method and device, equipment and medium
By comparing codes from the perspective of product requirements and matching different code content and requirements, the problems of code inconsistency and error modification in multi-branch development are solved, and the system stability is improved.
Patent Information
- Application Number
- CN202311028904.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-15
- Publication Date
- 2025-01-14
AI Technical Summary
During multi-branch development, it is difficult to ensure the consistency of different branches, which makes it difficult to move code, which may cause source code inconsistency and incorrect modification, affecting system stability.
By matching the content of the different code with the product requirements from the perspective of product requirements, establish the correspondence between the different code content and the requirements, and identify the error branch modification.
Accurately identify error branch modifications, ensure code consistency, and improve system stability.
Smart Images

Figure CN119311301A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of artificial intelligence and finance, and more specifically, to a code comparison method, apparatus, device and medium. Background Art
[0002] With the development of technology, agile iteration and flexible production are gradually increasing, which puts higher requirements on the stability of the system. If you need to keep different codes between different versions, you can use a specific code base to establish multiple branches for management. For example, continue to develop new features on the main branch while maintaining the current version of the code on another branch. In this development process, there is parallel development, and different branches are developed simultaneously by different developers.
[0003] In the process of implementing the inventive concept of the present disclosure, the inventors found that it is difficult to ensure the consistency of different branches during the development process, so it becomes more difficult to move code between different branches, which will cause inconsistency in the source code. If you accidentally make changes in the wrong branch, it may cause unnecessary troubles and errors, which in turn affects the stability of the system. Therefore, how to quickly and accurately identify the wrong branch modification is a problem that needs to be solved urgently. Summary of the invention
[0004] In view of the above problems, the present disclosure provides a code comparison method, apparatus, device, medium and program product.
[0005] One aspect of an embodiment of the present disclosure provides a code comparison method, comprising: obtaining at least one difference code content between a target code version and a historical code version, wherein the target code version and the historical code version are different code versions based on the same development product; matching each difference code content with N product requirement items respectively, wherein the N product requirement items include the requirement content of the development product, and N is an integer greater than or equal to 1; and outputting a product requirement item result matched to each difference code content, wherein the product requirement item result includes K of the N product requirement items, and K is an integer greater than or equal to 0, and K is less than or equal to N.
[0006] According to an embodiment of the present disclosure, obtaining each difference code content includes: inputting the difference code statement in each difference code content into a natural language processing model to obtain the code group to which the difference code statement belongs; matching each difference code content with N product requirement items respectively includes: matching the code group to which the difference code statement belongs with N product requirement items respectively; wherein the code group includes a function group, a module group and a module content group, the function group is used to implement the business function of the product to which it belongs, the module group is used to implement the data processing process involved in the business function, and the module content group is used to provide the fields involved in the data processing process.
[0007] According to an embodiment of the present disclosure, obtaining the content of each difference code includes: obtaining description information of the code group to which the difference code statement belongs, the description information being used to characterize at least one of the function, purpose and feature of the code group; matching the code group to which the difference code statement belongs with N product requirement items respectively includes: matching the description information with the N product requirement items respectively.
[0008] According to an embodiment of the present disclosure, obtaining the description information of the code group to which the difference code statement belongs includes: determining a target code group in the stock code content and code comments of the stock code statements therein; and obtaining the description information of the code group to which the difference code statement belongs based on the code comments of the stock code statements in the target code group.
[0009] According to an embodiment of the present disclosure, before obtaining the difference code content between the target code version and the historical code version, the method also includes: dividing the existing code content into M functional groups, wherein each functional group is divided into at least one module group, each module group is divided into at least one module content group, and M is an integer greater than or equal to 1; determining the existing code statements and code comments within the scope of each functional group, each module group, and each module content group in the M functional groups; wherein determining the target code group in the existing code content and the code comments of the existing code statements therein includes: determining the target code group and the code comments of the existing code statements therein based on the difference code statements and the code group name to which they belong.
[0010] According to an embodiment of the present disclosure, after determining the code group to which each difference code content belongs, the method further includes: if the code group to which each difference code content belongs is a function group or a module group, generating a new function tag; if the code group to which each difference code content belongs is a module content group, generating a modified function tag.
[0011] According to an embodiment of the present disclosure, in addition to matching the description information with N product requirement items respectively, it also includes: matching the newly added function tags with N product requirement items respectively; or matching the modified function tags with N product requirement items respectively.
[0012] According to an embodiment of the present disclosure, matching the description information with N product requirement items respectively includes: extracting S1 keywords in the description information based on an annotation code dictionary, wherein the annotation code dictionary is obtained based on code annotations in the existing code content; extracting S2 keywords for each of the N requirement items based on a requirement content dictionary, wherein the requirement content dictionary is obtained based on existing product requirement content, and both S1 and S2 are integers greater than or equal to 1; calculating the degree of overlap between the S1 keywords and the S2 keywords for each requirement item, wherein if the degree of overlap is greater than or equal to a preset threshold, the requirement item is used as a matched product requirement item result.
[0013] According to an embodiment of the present disclosure, before obtaining at least one difference code content between the target code version and the historical code version, the method also includes: receiving a code comparison request for the target code version, and determining the historical code version in response to the code comparison request; wherein, outputting the product requirement item result matched to each difference code content includes: if the match is successful, then displaying each difference code content and at least one matched product requirement item result in response to the code comparison request, and / or displaying the verification pass result of the target code version; if the match fails, then displaying each difference code content in response to the code comparison request, and / or displaying the verification exception result of the target code version.
[0014] Another aspect of an embodiment of the present disclosure provides a code comparison device, including: a code difference locating module, used to obtain at least one difference code content between a target code version and a historical code version, wherein the target code version and the historical code version are different code versions based on the same development product; a requirement item matching module, used to match each difference code content with N product requirement items respectively, wherein the N product requirement items include the requirement content of the development product, and N is an integer greater than or equal to 1; a matching result output module, used to output the product requirement item results matched to each difference code content, wherein the product requirement item results include K of the N product requirement items, K is an integer greater than or equal to 0, and K is less than or equal to N.
[0015] Another aspect of an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the method as described above.
[0016] Another aspect of the embodiments of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the method as described above.
[0017] Another aspect of the embodiments of the present disclosure further provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0018] One or more of the above-mentioned embodiments have the following beneficial effects: from the perspective of product requirements, the difference code content is matched on the dimension of requirement items, and a corresponding relationship between each difference code content and N product requirement items is established. It can be determined whether the difference code content is associated with the product requirement items, which facilitates the discovery of scenarios where erroneous branch modifications are made under non-requirement content or erroneous requirement content, and helps to accurately identify erroneous branch modifications. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0020] Figure 1 The following schematically shows an application scenario diagram of the code comparison method according to an embodiment of the present disclosure;
[0021] Figure 2 A flowchart of a code comparison method according to an embodiment of the present disclosure is schematically shown;
[0022] Figure 3 A matching flow chart according to an embodiment of the present disclosure is schematically shown;
[0023] Figure 4 A matching flow chart according to another embodiment of the present disclosure is schematically shown;
[0024] Figure 5 Schematically shows a flow chart of obtaining description information according to an embodiment of the present disclosure;
[0025] Figure 6 Schematically shows a flow chart of determining a target code group according to an embodiment of the present disclosure;
[0026] Figure 7 A matching flow chart according to another embodiment of the present disclosure is schematically shown;
[0027] Figure 8 A flowchart of a code comparison method according to another embodiment of the present disclosure is schematically shown;
[0028] Fig. 9 A block diagram of outputting a newly added function label or modifying a function label according to an embodiment of the present disclosure is schematically shown;
[0029] Fig.10 A block diagram schematically shows requirement item matching according to an embodiment of the present disclosure;
[0030] Fig.11A schematic diagram of a code comparison device according to an embodiment of the present disclosure is shown; and
[0031] Fig.12 A block diagram of an electronic device suitable for implementing a code comparison method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0032] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0033] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0034] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0035] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0036] In practice, in order to meet the requirements of version updates, multiple delivery dates and multiple production dates, or the same delivery date with different production dates, are usually used for testing and version production. For example, for the same delivery date with different production dates, multiple branches are usually established using the Git code library, and the codes for multiple production dates are provided and delivered separately. In this development process, parallel development occurs, and different branches are developed simultaneously by different developers. Different branches will affect each other, which puts higher requirements on the stability of the system.
[0037] For example, establishing multiple branches in a Git code repository for release means creating one or more new branches in addition to the original main branch (usually the "master" branch) for software development, testing, and release. Each branch can be modified and updated independently of other branches, which makes it easy to develop and maintain different versions.
[0038] When you need to release a new feature or fix a bug, you can make modifications on the corresponding branch and submit the changes. Once you have completed all the changes required on the branch, you can merge it back to the main branch to make the changes available to all users. If you need to keep different codes between different versions, you can use branches to manage them. For example, continue to develop new features on the main branch while maintaining the current version of the code on another branch. This release method can help developers better organize and manage the software development process, but there are still problems such as inconsistency of source code and modifications on the wrong branch may affect the stability of the system.
[0039] In some embodiments of the present disclosure, a code comparison method is provided. From the perspective of product requirements, the difference code content is matched on the dimension of requirement items, and a corresponding relationship between each difference code content and N product requirement items is established. It can be determined whether the difference code content is associated with the product requirement item, which is convenient for discovering scenarios of erroneous branch modifications under non-requirement content or erroneous requirement content, and helps to accurately identify erroneous branch modifications.
[0040] It should be noted that the code comparison method and device disclosed in the present invention can be used in related aspects of software development in the financial field, and can also be used in any field other than the financial field. The application field of the present invention is not limited.
[0041] Figure 1 The following schematically shows an application scenario diagram of the code comparison method according to an embodiment of the present disclosure. It should be noted that: Figure 1 What is shown are merely examples to which the embodiments of the present disclosure can be applied, so as to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0042] like Figure 1 As shown, the application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0043] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0044] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0045] The server 105 may be a server that provides various services, such as a background management server (only an example) that provides support for websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0046] Server 105 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud computing, network services, and middleware services.
[0047] In some embodiments, multiple users can develop and maintain their respective branches through terminal devices 101, 102, and 103. The code comparison method provided in the embodiment of the present disclosure can be executed by terminal devices 101, 102, 103 or server 105. Accordingly, the code comparison device provided in the embodiment of the present invention can generally be set in terminal devices 101, 102, 103 or server 105.
[0048] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0049] The following will be based on Figure 1 The scene described by Figure 2 to Figure 10 The code comparison method of the embodiment of the present disclosure is described in detail.
[0050] Figure 2 The flowchart of the code comparison method according to the embodiment of the present disclosure is schematically shown.
[0051] like Figure 2 As shown, the code comparison method of this embodiment includes:
[0052] In operation S210, at least one difference code content between a target code version and a historical code version is obtained, where the target code version and the historical code version are different code versions based on the same development product.
[0053] For example, each code version corresponds to each branch of the Git code repository. The target code version refers to the code version to be compared to determine whether it has been modified incorrectly. The historical code version refers to the code version to be compared with the target code version, such as the previous version, the previous version, or a version before the target code version.
[0054] For example, the target code version data package and the previous historical version code data package of the development product software are loaded from the Git code library, and the difference between the target code version data package and the previous historical version code data package is identified to obtain the difference code statement.
[0055] The difference code content includes the difference code statements and / or code comments between the target code version and the historical code version, and in some embodiments, may also include the code group, description information of the code group, new function labels, and modified function labels, etc. Product requirement items refer to the requirements for developing products, including functional requirements, performance requirements, etc.
[0056] For example, each code version may have a separator, and one or more difference code statements are determined according to the boundary of the separator, for example, one difference code statement is included in the same separation range, and multiple difference code statements are included in different separation ranges. Alternatively, the code of each code version may be parsed to obtain a tree structure, and one or more difference code statements may be determined according to branch information. For example, one difference code statement is included under the same branch, and multiple difference code statements are included under different branches.
[0057] In operation S220, each difference code content is matched with N product requirement items, where the N product requirement items include requirement content for developing a product, and N is an integer greater than or equal to 1. Any one of the N product requirement items is different from at least one other requirement item.
[0058] For example, it can be achieved through at least one matching method such as keyword matching, semantic matching, rule matching and manual approval.
[0059] In operation S230 , the product requirement item results matched to each difference code content are output, and the product requirement item results include K of the N product requirement items, where K is an integer greater than or equal to 0, and K is less than or equal to N.
[0060] If the matching conditions are met, one or more product requirement items matched by each difference code content are output. If the matching conditions are not met, no product requirement item can be output. The matching conditions may include a similarity greater than a first threshold, a number of identical or similar keywords greater than a second threshold, and meeting specific rules.
[0061] The matched product requirement results are output for reference by developers or other relevant personnel. For example, it is determined whether the product requirement matched by the difference code content is correct and whether it is required for the current stage of product development. If not, or the product requirement is not matched, it is determined that the target code version is the wrong branch, the difference code content is an incorrect modification, and the possible consequences can be further determined.
[0062] According to the embodiments of the present disclosure, from the perspective of product requirements, the difference code content is matched on the dimension of requirement items, and a corresponding relationship between each difference code content and N product requirement items is established. It can be determined whether the difference code content is associated with the product requirement items, which facilitates the discovery of scenarios where erroneous branch modifications are made under non-requirement content or erroneous requirement content, and helps to accurately identify erroneous branch modifications.
[0063] Figure 3 The matching flow chart according to the embodiment of the present disclosure is schematically shown.
[0064] like Figure 3 As shown, in this embodiment, operation S310 is one of the embodiments of operation S210, and operation S320 is one of the embodiments of operation S220, including:
[0065] In operation S310, a difference code sentence in each difference code content is input into a natural language processing model to obtain a code group to which the difference code sentence belongs.
[0066] The natural language processing model can be a classification model built based on natural language processing technology (NLP). It can be pre-trained based on a supervised algorithm in the field of machine learning, and after the training is completed, it can be used for prediction and output the prediction results of the code group to which the difference code statement belongs.
[0067] In operation S320, the code groups to which the difference code statements belong are matched with N product requirement items respectively.
[0068] Among them, the code group includes a function group, a module group and a module content group. The function group is used to implement the business functions of the product, the module group is used to implement the data processing process involved in the business functions, and the module content group is used to provide the fields involved in the data processing process.
[0069] For example, the functional group (X) is a business function that can be put into production independently. The module group (Y) is the component involved in a single business function. The module content group (Z) is the underlying data.
[0070] According to the embodiments of the present disclosure, matching in the form of code groups can provide more complete information, which is conducive to accurately matching product requirement items.
[0071] Figure 4 A matching flow chart according to another embodiment of the present disclosure is schematically shown.
[0072] like Figure 4 As shown, in this embodiment, operation S410 is one of the embodiments of operation S210, and operation S420 is one of the embodiments of operation S320, including:
[0073] In operation S410, description information of the code group to which the difference code statement belongs is obtained.
[0074] The description information refers to the information describing the code group, which may include the function, purpose and characteristics of the code group. Assuming that the difference code statement belongs to a functional group, the description information of the code group to which the difference code statement belongs may be an introduction to a specific function implemented by the functional group. The description information is helpful for further matching and analysis.
[0075] For example, a functional group is a business function that can be put into production independently, and the description information of one of them includes the deposit report generation function. A module group is a component involved in a single business function, and the description information of one of them includes the existence of a process table, such as the public deposit data and personal deposit data that need to be loaded for deposit report generation. The module content is the underlying data, and the description information of one of them includes that the public deposit data is composed of a certain field in the general ledger file, customer information file, institution information file, etc.
[0076] The code content of the code group to which the difference code statement belongs can be processed by a generative model to generate code comments and extract description information in combination with the code comments, or directly generate description information. The description information can also be obtained through the existing code content. The description information can also be manually input. This disclosure does not make specific limitations.
[0077] In operation S420, the description information is matched with the N product requirements respectively. If the description information and the requirements can establish a one-to-one or many-to-one matching relationship, the matching is successful. If the description information and the requirements cannot match, it means that there is an error branch.
[0078] There are many ways to match description information with product requirements. The specific method selected depends on the specific implementation situation and requirements. For example, it may include at least one of the following:
[0079] Keyword matching: Match the keywords in the description information with the keywords in the product requirements. Natural language processing technology can be used to extract keywords from the description information and product requirements, and match and calculate similarity to determine the degree of match between them.
[0080] Semantic matching: By using semantic analysis technology, the description information and product requirements are semantically represented and matched. You can use a word vector model or a deep learning model to convert the text into a semantic vector representation, and then calculate the similarity or correlation between the description information and the product requirements.
[0081] Rule matching: Match the description information with product requirements according to pre-set rules. A series of rules can be formulated based on domain knowledge and expert experience to determine the degree of match between description information and product requirements.
[0082] Manual review: The description information and product requirements are reviewed and matched by professionals. The degree of match between the description information and product requirements is determined manually, combining the understanding and judgment of the description information and product requirements.
[0083] It should be noted that the selection of matching methods should be flexibly applied according to specific circumstances to ensure the accuracy and reliability of the matching between the description information and the product requirements. In practical applications, multiple matching methods can be combined and different factors can be comprehensively considered to improve the accuracy and effect of matching.
[0084] According to the embodiments of the present disclosure, the description information can convert the code statement form of the code group and characterize the function of the code group in the form of natural language, which is conducive to accurate matching with product requirement items.
[0085] Figure 5 The flowchart of obtaining description information according to an embodiment of the present disclosure is schematically shown.
[0086] like Figure 5 As shown, this embodiment is one of the embodiments of operation S410, including:
[0087] In operation S510 , a target code group in the stock code content and code comments of the stock code statements therein are determined.
[0088] The stock code content includes the code statements and code group division results in the existing code library, for example, the code statements include the code statements and comments of at least one product that has been developed. The comments attached to the stock code statements include the description and explanation of the code statements, which are used to help developers understand the functions and logic of the code.
[0089] The target code group is a code group in the stock code content, which can be determined based on its function, module or other characteristics. For example, by analyzing the code comments of the stock code statements, the code function, structure, logic and other characteristics of the stock code can be understood. Furthermore, the target code group can be determined based on the comparison between the stock code statements and the difference code statements.
[0090] In operation S520, description information of the code group to which the difference code statement belongs is obtained based on the code comments of the stock code statements in the target code group.
[0091] For example, there is a stock code content, which contains three different code groups: code group A, code group B and code group C. Each code group has corresponding stock code statements and code comments. By analyzing the code comments of the stock code statements, it can be determined that code group A is the target code group, and then the description information of the code group to which each difference code statement belongs can be obtained.
[0092] By collating and summarizing the code comments of the existing code statements in the target code group, such as refining themes through semantic analysis and generating code comments, the description information of the code group to which each difference code statement belongs can be obtained. This can more accurately describe the functions, uses and characteristics of the code group to which the difference code belongs, and provide comprehensive, accurate and more valuable information for matching and analysis.
[0093] Figure 6 The flowchart of determining the target code group according to an embodiment of the present disclosure is schematically shown.
[0094] like Figure 6 As shown, this embodiment includes:
[0095] Before obtaining the difference code content between the target code version and the historical code version, in operation S610, the stock code content is divided into M functional groups, wherein each functional group is divided into at least one module group, each module group is divided into at least one module content group, and M is an integer greater than or equal to 1. In operation S620, the stock code statements and code comments within the scope of each functional group, each module group, and each module content group in the M functional groups are determined.
[0096] First, the stock code content is divided according to its functional characteristics, and the code is grouped into different functional groups. Each functional group can represent different functional modules or functional characteristics.
[0097] Next, within each functional group, it is further divided into at least one module group. The module group can represent different modules or sub-functions within the functional group. The module group can be divided based on code structure, module division rules, functional description, etc. For example, it can be divided according to the directory structure of the code file, naming rules, class or function functions, etc.
[0098] A stock code may contain functions such as data processing, user interface and database access, which correspond to three different functional groups. Each functional group can be divided according to modules. For example, the data processing functional group can be divided into data input module and data processing module group. The module content group includes the input fields involved in the data input module.
[0099] Then, within each functional group, module group, and module content group, the stock code statements within the scope and their corresponding code comments are determined. This allows each code group to be further analyzed and processed in subsequent steps.
[0100] Therefore, the existing code content is subdivided and organized to better understand and process the structure and function of the code in subsequent analysis. For example, the code comments of the existing code statements are analyzed through natural language processing technology to obtain information such as the functions, uses, constraints, etc. described in the comments. By comparing the code statements, structures, functions, and comments of each code group, the same or similar target code groups can be found.
[0101] Operation S630 is one of the embodiments of operation S510. In operation S630, the target code group and the code comments of the existing code statements therein are determined based on the difference code statements and the names of the code groups to which they belong.
[0102] After obtaining the difference code statement and the name of the code group to which it belongs, the name of the code group to which the difference code statement belongs can be matched with the name of the previously divided function group, module group and module content group. If the name of the code group to which the difference code statement belongs is consistent with the name of a previously divided function group, module group or module content group, then the code group can be determined to be the target code group.
[0103] In some embodiments, after determining the code group to which each difference code content belongs, the method further includes: if the code group to which each difference code content belongs is a function group or a module group, generating a new function tag; if the code group to which each difference code content belongs is a module content group, generating a modified function tag.
[0104] For example, NLP natural language learning technology is used to distinguish the modules to which the difference codes located by the Gitflow method belong. That is, the difference codes located by the Gitflow method are input to determine whether it is a new function or a modification of the original function. Judgment logic: the addition of a function group or module group is a new function, and the change of module content is a modification of the original function.
[0105] For example, in combination with the process of obtaining description information based on the stock code content, if a function is newly added, the new label is output first, and the description information of the new module group and function group is listed (such as: new function, loan statistics by type, pension savings file mapping). If it is modified under the original module, the modification label and the description information of the module content group are output. (For example: modification function, personal deposit interface file mapping, institutional parameters).
[0106] In some embodiments, in addition to matching the description information with the N product requirement items, the process further includes: matching the newly added function tags with the N product requirement items, or matching the modified function tags with the N product requirement items.
[0107] According to the embodiments of the present disclosure, the requirements may include new requirements and requirements for modifying existing functions. Therefore, combining the new function tags and modified function tags with the description information and matching them with the product requirements can obtain a more accurate matching result.
[0108] Figure 7 A matching flow chart according to another embodiment of the present disclosure is schematically shown.
[0109] like Figure 7 As shown, this embodiment is one of the embodiments of operation S420, including:
[0110] In operation S710, S1 keywords in the description information are extracted based on an annotated code dictionary, where the annotated code dictionary is obtained based on code annotations in the stock code content.
[0111] The annotated code dictionary includes a dictionary of code statements, code comments and corresponding keywords, wherein code statements and code comments are optional. In some embodiments, keywords greater than S1 can be extracted from the description information, and filtered based on the number of occurrences to obtain S1 keywords, which can avoid noise.
[0112] In some embodiments, the annotated code dictionary includes a function group dictionary (metadataA), a module group dictionary (metadataB), and a module content dictionary (metadataC). The corresponding dictionary may be determined according to the code group to which the difference code statement belongs.
[0113] In operation S720, S2 keywords of each demand item in the N demand items are extracted based on the demand content dictionary, where the demand content dictionary is obtained based on the demand content of the stock products, and both S1 and S2 are integers greater than or equal to 1.
[0114] The demand content dictionary is a dictionary containing one or more keywords in the product demand content, and the keywords are extracted by analyzing the demand items in advance.
[0115] In operation S730, the overlap between the S1 keywords and the S2 keywords of each requirement item is calculated, wherein if the overlap is greater than or equal to a preset threshold, the requirement item is taken as a matched product requirement item result.
[0116] In some embodiments, a similarity calculation method, such as cosine similarity, can be used to calculate the overlap between keywords. A preset threshold is used to determine whether the overlap meets the requirement. If the requirement is met, the requirement item is used as the matched product requirement item result. The preset threshold can be a set similarity threshold. If the calculated overlap is greater than or equal to the threshold, the match is considered successful.
[0117] In other embodiments, the number of keywords that are similar or identical to the S2 keywords and the S1 keywords of each requirement item can be calculated, and the overlap degree is represented by the number of keywords. If the number of keywords is large, it means that the overlap degree is high and the requirement item is hit.
[0118] In some embodiments, before obtaining at least one difference code content between the target code version and the historical code version, the method further includes: receiving a code comparison request for the target code version, and determining the historical code version in response to the code comparison request.
[0119] In some embodiments, outputting the product requirement item result matched to each difference code content includes: if the match is successful, displaying each difference code content and at least one matched product requirement item result in response to the code comparison request, and / or displaying the verification pass result of the target code version. If the match fails, displaying each difference code content in response to the code comparison request, and / or displaying the verification exception result of the target code version.
[0120] For example, a front-end query page for error branch modification troubleshooting results is provided to support testers to query by entering version numbers. After receiving the code comparison request from the front-end page, the version number (target code version) entered by the tester will be used as the search condition to first locate the difference code between this version and the two most recent versions. Based on the difference code located by the difference module, the corresponding functions of the modified program are located, such as generating new function labels, modifying function labels, and description information. The new function labels, modified function labels, and description information are matched with the requirement items, and the matching results are displayed on the front-end.
[0121] ① Determine whether there is a record with "Troubleshooting Status" of "Under Troubleshooting" for the version number. If so, notify the front desk to display the prompt "Task Troubleshooting, please try again later" to the user.
[0122] ② If there is no record with "Troubleshooting Status" as "Under Investigation", the query results of the difference code content (update) and the requirement item content (include) are displayed. If the difference code content can establish a one-to-one or many-to-one matching relationship with the requirement item content, the content matching situation returns "Verification passed", otherwise it is "Verification exception". Both "Verification passed" and "Verification exception" support the query of matching details.
[0123] The following is an example of displaying matching results:
[0124] ① The difference code content is output as: A. Label: Modify existing, description information: Interest rate approval authority parameter mapping.
[0125] Requirement item content: Take values from the requirement sub-items in the existing system: a. Interest rate approval is connected to the sofr interest rate.
[0126] If the difference code content can establish a one-to-one matching relationship with the requirement item content, the front-end display will be:
[0127] A-matching requirement item-a verification passed
[0128] ② The difference code content is output as follows: A. Label: Modify existing, description information: Interest rate approval authority parameter mapping. B. Label: Add new function, description information: Interest rate approval period parameter.
[0129] Requirement item content: Take values from the requirement sub-items in the existing system: a. Interest rate approval is connected to the sofr interest rate.
[0130] The difference code content can establish a many-to-one matching relationship with the requirement item content. The front-end display is:
[0131] A-matching requirement item-a B-matching requirement item-a Verification passed
[0132] ③ The difference code content is output as follows: A. Label: Modify existing, description information: Interest rate approval authority parameter mapping. B. Label: Modify existing, description information: User management matching.
[0133] Requirement item content: Take values from the requirement sub-items in the existing system: a. Interest rate approval is connected to the sofr interest rate.
[0134] If there is an exception, the front-end will display:
[0135] A-matching requirement item-a B-no requirement item matching verification exception
[0136] Figure 8 The flowchart of a code comparison method according to another embodiment of the present disclosure is schematically shown.
[0137] like Figure 8 As shown, this embodiment includes:
[0138] In operation S810, in response to the tester inputting instructions, the Gitflow method is used to locate the difference code between the current version number and the two most recent versions. The instruction includes the version number to be queried, that is, the target code version. Consider two most common situations: 1. Match with the previous code to locate the modified content. 2. Consider the case of a rollback version, it is necessary to consider matching with the previous code to locate whether the rollback is correct.
[0139] In operation S820, the function positioning is modified to determine at least one difference code content.
[0140] First, the existing program code content is collected, one-hot encoded, and word2vec dimension reduction is performed on the existing code content, and the data is divided into three categories for storage: function group (X), module group (Y), and module content group (Z). For example, based on the code comments in the existing system, this part of the code is recorded as the formation process of the public deposit interface file and is divided into a separate function group.
[0141] An example of the data after the stock code content is grouped is shown in Table 1:
[0142] Table 1
[0143]
[0144] An example of a function group dictionary is shown in Table 2:
[0145] Table 2
[0146]
[0147]
[0148] An example of a module group dictionary is shown in Table 3:
[0149] Table 3
[0150] DW_DAT_MRM_V0003 Public deposit interface file mapping DW_DAT_MRM_V0004 Personal deposit interface file mapping
[0151] An example of a module content group dictionary is shown in Table 4:
[0152] Table 4
[0153] DIC_V00021 Running batch stride length DIC_V00007 General ledger interface detailed statistics
[0154] Then, NLP natural language learning technology is used to distinguish the code groups to which the difference codes located by the Gitflow method belong, and to generate new function labels or modify function labels.
[0155] Next, based on each code group in the stock code content and the above dictionary, the difference code sentences in each difference code content are analyzed and description information is output.
[0156] In operation S830 , matching is performed with the requirement item based on the newly added function label, the modified function label and the description information.
[0157] In operation S840, the query results are displayed, and the tester observes whether the difference code content matches the product requirement items and determines whether the match is correct, thereby determining whether there is any abnormal modification content and paying attention to suspicious information in the foreground system.
[0158] Fig. 9 A block diagram of outputting a newly added function label or a modified function label according to an embodiment of the present disclosure is schematically shown.
[0159] like Fig. 9 As shown, the difference code content is the code of the target code version, and the historical version content is the code of the historical code version. In the data preprocessing result, the target code version and the historical code version are segmented based on the NLP technology. Different from the embodiment in which the difference code sentence in each difference code content is input into the natural language processing model to obtain the code group to which the difference code sentence belongs, in this embodiment, label information extraction is performed, that is, the dictionary obtained by encapsulating the existing annotation code is used to distinguish each code group of the target code version and the historical code version. Then, in the difference code content comparison stage, the function groups are compared first, and the end is found if the same function groups are found. If the function group (X a1 ) and functional group (X b1 ) are different, then compare the module groups. If the module group (Y a1 ) and module group (Y b1 ) are different, the module contents are compared. The final determination is whether the difference is in the function group or module group, or in the module content, so that a new function label or a modified content label is output in the transformation function output stage.
[0160] Fig.10 A block diagram of requirement item matching according to an embodiment of the present disclosure is schematically shown.
[0161] like Fig.10As shown, for the difference code content, based on the transformation function, in the data preprocessing stage, the description information of the difference code content (i.e., the difference code statement and the code group to which it belongs) is obtained (such as the description information of the code group to which the difference code statement belongs). For the requirement item content, in the data preprocessing stage, the requirement item name and the requirement introduction content are obtained. In the label information extraction stage, based on the annotation code dictionary and the requirement content field, the keywords of the new function label, modified function label, description information and requirement item content are extracted. In the label overlap comparison stage, the overlap ratio between the new function label, modified function label and description information in each difference code content and the requirement item content is calculated. If the overlap ratio is greater than a certain value, the output match is consistent in the matching result display stage, otherwise the output match is inconsistent, indicating that there is a probability of an erroneous branch.
[0162] According to an embodiment of the present disclosure, the difference code content between different Git branches is matched with the project in the dimension of requirement items, and a one-to-many or one-to-one correspondence between the requirement items and the difference code content is established. Modules and requirement item matching updates that cannot be matched with the requirement items will be marked with prompts to confirm the functional attribution of this part of the content under the main branch, and prompts will be given to developers and testers.
[0163] Based on the above code comparison method, the present disclosure also provides a code comparison device. Fig.11 The device is described in detail.
[0164] Fig.11 The structure block diagram of the code comparison device according to the embodiment of the present disclosure is schematically shown.
[0165] like Fig.11 As shown, the code comparison device 1100 of this embodiment includes a code difference positioning module 1110 , a requirement item matching module 1120 and a matching result output module 1130 .
[0166] The code difference locating module 1110 may perform operation S210 to obtain at least one difference code content between a target code version and a historical code version, where the target code version and the historical code version are different code versions based on the same development product.
[0167] The requirement item matching module 1120 may perform operation S220 to match each difference code content with N product requirement items, respectively, where the N product requirement items include requirement content of the developed product, and N is an integer greater than or equal to 1.
[0168] The matching result output module 1130 can perform operation S230 to output the product requirement item results matched by each difference code content, where the product requirement item results include K of the N product requirement items, where K is an integer greater than or equal to 0, and K is less than or equal to N.
[0169] In some embodiments, the code difference location module 1110 may perform operation S310, and the requirement item matching module 1120 may perform operation S320, which will not be described in detail herein.
[0170] In some embodiments, the code difference location module 1110 may perform operation S410, and the requirement item matching module 1120 may perform operation S420, which will not be described in detail herein.
[0171] In some embodiments, the code difference locating module 1110 may perform operations S510 to S520 and operations S610 to S630, which are not described in detail herein.
[0172] In some embodiments, the requirement item matching module 1120 may perform operations S710 to S730, which will not be described in detail herein.
[0173] It should be noted that the code comparison device 1100 includes two parts for performing the above Figure 2 to Figure 10 The modules of each step of any embodiment described. The implementation methods, technical problems solved, functions realized, and technical effects achieved of each module / unit / subunit, etc. in the device part embodiment are respectively the same or similar to the implementation methods, technical problems solved, functions realized, and technical effects achieved of each corresponding step in the method part embodiment, and will not be repeated here.
[0174] According to an embodiment of the present disclosure, any multiple modules among the code difference location module 1110, the requirement item matching module 1120 and the matching result output module 1130 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module.
[0175] According to an embodiment of the present disclosure, at least one of the code difference location module 1110, the requirement item matching module 1120 and the matching result output module 1130 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in an appropriate combination of any of them. Alternatively, at least one of the code difference location module 1110, the requirement item matching module 1120 and the matching result output module 1130 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.
[0176] Fig.12 A block diagram of an electronic device suitable for implementing a code comparison method according to an embodiment of the present disclosure is schematically shown.
[0177] like Fig.12 As shown, the electronic device 1200 according to an embodiment of the present disclosure includes a processor 1201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1202 or a program loaded from a storage part 1208 into a random access memory (RAM) 1203. The processor 1201 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 1201 may also include an onboard memory for caching purposes. The processor 1201 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0178] In RAM 1203, various programs and data required for the operation of electronic device 1200 are stored. Processor 1201, ROM 1202 and RAM 1203 are connected to each other via bus 1204. Processor 1201 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 1202 and / or RAM 1203. It should be noted that the program can also be stored in one or more memories other than ROM 1202 and RAM 1203. Processor 1201 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in one or more memories.
[0179] According to an embodiment of the present disclosure, the electronic device 1200 may further include an input / output (I / O) interface 1205, which is also connected to the bus 1204. The electronic device 1200 may further include one or more of the following components connected to the I / O interface 1205: an input portion 1206 including a keyboard, a mouse, etc. An output portion 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc. A storage portion 1208 including a hard disk, etc. And a communication portion 1209 including a network interface card such as a LAN card, a modem, etc. The communication portion 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed, so that the computer program read therefrom is installed into the storage portion 1208 as needed.
[0180] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments. It may also exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0181] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 1202 and / or RAM 1203 described above and / or one or more memories other than ROM 1202 and RAM 1203.
[0182] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided by the embodiment of the present disclosure.
[0183] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 1201. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0184] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 1209, and / or installed from the removable medium 1211. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0185] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1209, and / or installed from the removable medium 1211. When the computer program is executed by the processor 1201, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0186] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0187] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0188] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0189] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A code comparison method, comprising: Obtaining at least one difference code content between a target code version and a historical code version, wherein the target code version and the historical code version are different code versions based on the same development product; Matching each difference code content with N product requirement items respectively, wherein the N product requirement items include the requirement content of the developed product, and N is an integer greater than or equal to 1; Output the product requirement item results matched to each difference code content, wherein the product requirement item results include K of the N product requirement items, where K is an integer greater than or equal to 0, and K is less than or equal to N.
2. The method according to claim 1, wherein: Obtaining each difference code content includes: Inputting the difference code sentence in each difference code content into a natural language processing model to obtain the code group to which the difference code sentence belongs; Matching each difference code content with the N product requirement items includes: Matching the code groups to which the difference code statements belong with the N product requirement items respectively; Among them, the code group includes a function group, a module group and a module content group. The function group is used to implement the business function of the product, the module group is used to implement the data processing process involved in the business function, and the module content group is used to provide the fields involved in the data processing process.
3. The method according to claim 2, wherein: Obtaining each difference code content includes: Obtaining description information of the code group to which the difference code statement belongs, wherein the description information is used to characterize at least one of a function, a purpose, and a feature of the code group; Matching the code groups to which the difference code statements belong respectively with the N product requirement items includes: The description information is matched with the N product requirement items respectively.
4. The method according to claim 3, wherein: Obtaining the description information of the code group to which the difference code statement belongs includes: Determine the target code group in the stock code content and the code comments of the stock code statements therein; Based on the code comments of the stock code statements in the target code group, description information of the code group to which the difference code statement belongs is obtained.
5. The method according to claim 4, wherein: Before obtaining the difference code content between the target code version and the historical code version, the method further includes: Dividing the stock code content into M function groups, wherein each function group is divided into at least one module group, each module group is divided into at least one module content group, and M is an integer greater than or equal to 1; Determine the stock code statements and code comments within the scope of each function group, each module group and each module content group in the M function groups; Wherein, determining the target code group in the stock code content and the code annotations of the stock code statements therein comprises: The target code group and code comments of the stock code statements therein are determined based on the difference code statements and the name of the code group to which they belong.
6. The method according to claim 3, wherein: After determining the code group to which each difference code content belongs, the method further includes: If the code group to which each difference code content belongs is a function group or a module group, generating a new function tag; If the code group to which each difference code content belongs is a module content group, a modification function tag is generated.
7. The method according to claim 6, wherein: In addition to matching the description information with the N product requirements, the following steps are also included: Match the newly added function tags with N product requirement items respectively; or The modified function tags are matched with N product requirement items respectively.
8. The method according to any one of claims 3 to 7, wherein: Matching the description information with the N product requirement items respectively includes: Extracting S1 keywords in the description information based on an annotation code dictionary, where the annotation code dictionary is obtained based on code annotations in the stock code content; Extracting S2 keywords of each demand item in the N demand items based on a demand content dictionary, wherein the demand content dictionary is obtained based on the demand content of the stock product, and both S1 and S2 are integers greater than or equal to 1; The degree of overlap between the S1 keywords and the S2 keywords of each requirement item is calculated, wherein if the degree of overlap is greater than or equal to a preset threshold, the requirement item is taken as a matched product requirement item result.
9. The method according to claim 1, wherein: Before obtaining at least one difference code content between the target code version and the historical code version, the method further includes: receiving a code comparison request for the target code version, and determining the historical code version in response to the code comparison request; The output of the product requirement item results matched to each difference code content includes: If the match is successful, then displaying the content of each difference code and the result of at least one matched product requirement item in response to the code comparison request, and / or displaying the verification result of the target code version; If the match fails, each difference code content is displayed in response to the code comparison request, and / or the verification exception result of the target code version is displayed.
10. A code comparison device, comprising: A code difference locating module, used to obtain at least one difference code content between a target code version and a historical code version, wherein the target code version and the historical code version are different code versions based on the same development product; A requirement item matching module, used to match each difference code content with N product requirement items respectively, wherein the N product requirement items include the requirement content of the developed product, and N is an integer greater than or equal to 1; The matching result output module is used to output the product requirement item results matched to each difference code content, and the product requirement item results include K of the N product requirement items, K is an integer greater than or equal to 0, and K is less than or equal to N.
11. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are enabled to execute the method according to any one of claims 1 to 9.
12. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the method according to any one of claims 1 to 9.
Citation Information
Cited By
Method and apparatus for managing code data, device, and medium
WO2026188421A1