Project information processing method and device, electronic equipment and readable storage medium

By extracting and analyzing semantic vectors and constraint vectors in project function description files and source code files, using natural language processing and graph neural network technology, the problem of insufficient consistency measurement accuracy between project function description files and source code files is solved. , achieving higher consistency judgment accuracy.

CN119201193APending Publication Date: 2024-12-27MOUNT HUANGSHAN SHANGWEI NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411235872.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

In the prior art, the consistency measurement between the project function description file and the source code file is not accurate, especially in terms of deep code constraints, which leads to the consistency measurement between the description document and the source code. .

Method used

By obtaining project function description files and the latest source code files, the extraction method describes semantic vectors, associative semantic vectors, call constraint semantic vectors and parameter constraint vectors, using natural language processing and graph neural network technology, based on attention transformation and abstract syntax tree, Determine functional consistency and constraint consistency and add consistency labels to the functional description file.

Benefits of technology

Improve the accuracy of consistency judgment between project function description files and source code files, shorten the vocabulary gap between programming languages ​​and natural languages, comprehensive measurement consistency from the two directions of functional descriptions and code constraints, and improve accuracy sex.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201193A_ABST
    Figure CN119201193A_ABST
Patent Text Reader

Abstract

The invention provides a project information processing method and device, electronic equipment and a readable storage medium. The method comprises the following steps: extracting a method description semantic vector of each method and an association semantic vector between every two methods in a project function description file; according to the method, the function consistency and the constraint consistency are determined according to the item function description file, the source code semantic vector and the parameter constraint vector of each method in the latest source code file and the calling constraint semantic vector between any two methods, and then the consistency label is added to the item function description file based on the function consistency and the constraint consistency. According to the method, a vocabulary gap between a programming language and a natural language is shortened, the consistency between the project function description file and the corresponding latest source code file is comprehensively measured from the two directions of function description and code constraint, and the judgment precision of the consistency between the project function description file and the corresponding latest source code file is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of information system project management, and in particular to a project information processing method, device, electronic device and readable storage medium. Background Art

[0002] Information system project management refers to the process of planning, organizing, directing and controlling various projects of the comprehensive information system to achieve project goals. In information system project management, one of the core tasks is to store and maintain project function description files for source code files in each project. These project function description files are used to record information such as the functional modules and data structures of the project. Therefore, the maintenance and management of project function description files are of great significance to operation and maintenance personnel and project managers. Among them, the comprehensive information system may frequently update the source code files of the corresponding projects as the requirements are updated, but the project function description files may not be updated in time. Therefore, after the source code is updated, it is very important to check the project function description files in time to ensure that the content in the description document is consistent with the updated source code to avoid inconsistent or outdated information. By regularly comparing the description document and the source code, the differences between the document and the code can be discovered and resolved in time, ensuring that the project team has a consistent understanding of the project and improving the development efficiency and quality of the project.

[0003] At present, the maintenance of description documents is usually done manually by technical personnel, and some of the work uses natural language processing technology to extract the semantic expression of the description document and the semantic expression of the source code file respectively, and determine whether the two are consistent by calculating the semantic similarity between the description document and the source code file. However, since the semantic logic in the programming language is not only reflected in the language expression, but also in various operations and the calls of classes or methods, there is a "lexical gap" between the programming language and the natural language, which makes it difficult to calculate the similarity between the code and the comments. More importantly, this method can only determine whether the code function described in the description document is consistent with the actual code function of the source code to a certain extent, but it cannot judge the deep code constraints, such as the input and output parameter constraints of a single method, the call constraints between methods in the class, etc., resulting in poor accuracy in the consistency measurement between the description document and the source code. Summary of the invention

[0004] The present invention provides a project information processing method, device, electronic device and readable storage medium, which are used to solve the defect of poor consistency measurement accuracy in the prior art.

[0005] The present invention provides a project information processing method, comprising:

[0006] Obtain a project function description file and the latest source code file corresponding to the project function description file, and obtain a call relationship graph and an abstract syntax tree of the latest source code file;

[0007] Extracting the method description semantic vector of each method in the project function description file and the association semantic vectors between each method;

[0008] Extracting source code semantic vectors of each method in the latest source code file based on the natural language code of each method obtained after natural language conversion of the latest source code file, and extracting call constraint semantic vectors between any two methods in the latest source code file and parameter constraint vectors of each method based on the call relationship graph and the abstract syntax tree;

[0009] Based on the method description semantic vector of each method in the project function description file and the source code semantic vector of each method in the latest source code file, the functional consistency is determined; based on the method description semantic vector of each method in the project function description file and the association semantic vectors between each method, as well as the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method, the constraint consistency is determined; and based on the functional consistency and the constraint consistency, a consistency label is added to the project function description file.

[0010] According to a project information processing method provided by the present invention, the method description semantic vectors of each method in the project function description file and the association semantic vectors between each method, as well as the call constraint semantic vectors between any two methods in the latest source code file and the parameter constraint vectors of each method, determine the constraint consistency, specifically including:

[0011] Performing an attention transformation on the method description semantic vector of each method in the project function description file and the parameter constraint vector of the corresponding method in the latest source code file to obtain the parameter description semantic vector of each method in the project function description file;

[0012] Determining a parameter constraint matching result based on the semantic similarity between the parameter description semantic vector of each method in the project function description file and the parameter constraint vector of the corresponding method in the latest source code file;

[0013] For any two methods in the project function description file, if there is a direct calling relationship between the two methods in the calling relationship graph of the latest source code file, an attention transformation is performed on the association semantic vector between the two methods in the project function description file and the call constraint semantic vector between the corresponding two methods in the latest source code file to obtain the call association semantic vector between the two methods in the project function description file; otherwise, the association semantic vector between the two methods in the project function description file is used as the call association semantic vector;

[0014] Determine a call constraint matching result based on the semantic similarity between a call association semantic vector between any two methods in the project function description file and a call constraint semantic vector between corresponding two methods in the latest source code file;

[0015] The constraint consistency is determined based on the parameter constraint matching result and the call constraint matching result.

[0016] According to a project information processing method provided by the present invention, the calling constraint semantic vector between any two methods in the latest source code file is determined based on the following steps:

[0017] Based on the call relationship graph of the latest source code file, determining whether there is a direct call relationship between any two methods;

[0018] If there is a direct calling relationship between the two methods, determining a calling constraint semantic vector between the two methods based on the source code semantic vectors of the two methods;

[0019] Otherwise, the calling constraint semantic vector between any two methods is set to an all-zero vector.

[0020] According to a project information processing method provided by the present invention, determining the call constraint semantic vector between the arbitrary two methods based on the source code semantic vectors of the arbitrary two methods specifically includes:

[0021] The two methods are respectively recorded as a first method and a second method;

[0022] Using the first method as a query vector and the second method as a key vector, performing attention transformation on the source code semantic vectors of the first method and the second method to obtain attention weights corresponding to each vector value of the source code semantic vector of the second method, and determining a first constraint vector based on the source code semantic vector of the second method and the attention weights corresponding to each vector value thereof;

[0023] Using the second method as a query vector and the first method as a key vector, performing attention transformation on the source code semantic vectors of the first method and the second method to obtain attention weights corresponding to each vector value of the source code semantic vector of the first method, and determining a second constraint vector based on the source code semantic vector of the first method and the attention weights corresponding to each vector value thereof;

[0024] The first constraint vector and the second constraint vector are merged to obtain a call constraint semantic vector between the arbitrary two methods.

[0025] According to a project information processing method provided by the present invention, the parameter constraint vector of any method in the latest source code file is determined based on the following steps:

[0026] Obtaining a node representation vector of each node in an abstract syntax tree of the latest source code file based on a graph neural network;

[0027] Determine, from the abstract syntax tree of the latest source code file, a method declaration node, a variable declaration node, and a variable assignment node of the any method as parameter constraint nodes of the any method;

[0028] The node representation vectors of the parameter constraint nodes of any of the methods are merged to obtain the parameter constraint vector of any of the methods.

[0029] According to a project information processing method provided by the present invention, the associated semantic vector between any two methods in the project function description file is determined based on the following steps:

[0030] Recording the two methods in the project function description file as a third method and a fourth method respectively;

[0031] Using the third method as a query vector and the fourth method as a key vector, performing attention transformation on the method description semantic vectors of the third method and the fourth method to obtain attention weights corresponding to each vector value of the method description semantic vector of the fourth method, and determining a first association vector based on the method description semantic vector of the fourth method and the attention weights corresponding to each vector value thereof;

[0032] Using the fourth method as a query vector and the third method as a key vector, performing attention transformation on the method description semantic vectors of the third method and the fourth method to obtain attention weights corresponding to each vector value of the method description semantic vector of the third method, and determining a second association vector based on the method description semantic vector of the third method and the attention weights corresponding to each vector value thereof;

[0033] The first association vector and the second association vector are merged to obtain an association semantic vector between any two methods in the project function description file.

[0034] According to a project information processing method provided by the present invention, the natural language code of each method in the latest source code file is converted based on the following steps:

[0035] Convert the source code of each method in the latest source code file into natural language code based on the trained natural language conversion model;

[0036] The natural language conversion model is obtained by training based on sample source code files belonging to the same programming language as the latest source code file and their corresponding sample natural language expressions.

[0037] The present invention also provides a project information processing device, comprising:

[0038] A data acquisition unit, used to acquire a project function description file and a latest source code file corresponding to the project function description file, and acquire a call relationship graph and an abstract syntax tree of the latest source code file;

[0039] A description file processing unit, used for extracting the method description semantic vector of each method in the project function description file and the association semantic vectors between each method;

[0040] a source code file processing unit, configured to extract source code semantic vectors of each method in the latest source code file based on the natural language code of each method obtained after natural language conversion of the latest source code file, and extract a call constraint semantic vector between any two methods in the latest source code file and a parameter constraint vector of each method based on the call relationship graph and the abstract syntax tree;

[0041] A consistency measurement unit is used to determine the functional consistency based on the method description semantic vector of each method in the project functional description file and the source code semantic vector of each method in the latest source code file, determine the constraint consistency based on the method description semantic vector of each method in the project functional description file and the association semantic vectors between each method, as well as the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method, and add a consistency label to the project functional description file based on the functional consistency and the constraint consistency.

[0042] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the project information processing methods described above is implemented.

[0043] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the project information processing method as described in any one of the above is implemented.

[0044] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the project information processing method described in any one of the above is implemented.

[0045] The present invention provides a project information processing method, device, electronic device and readable storage medium, which extracts method description semantic vectors of each method in a project function description file and associated semantic vectors between each method, as well as source code semantic vectors, parameter constraint vectors and call constraint semantic vectors between any two methods in the latest source code file of each method, thereby determining functional consistency based on the method description semantic vectors of each method in the project function description file and the source code semantic vectors of each method in the latest source code file, and determining constraint consistency based on the method description semantic vectors of each method in the project function description file and associated semantic vectors between each method, as well as call constraint semantic vectors and parameter constraint vectors of each method in the latest source code file, and then adding consistency tags to the project function description files based on functional consistency and constraint consistency, thereby shortening the "lexicon gap" between programming languages ​​and natural languages, and comprehensively measuring the consistency between the project function description files and their corresponding latest source code files from the two directions of functional description and code constraints, thereby improving the accuracy of determining the consistency between the project function description files and their corresponding latest source code files. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0047] Figure 1 It is a flowchart of a project information processing method provided by the present invention;

[0048] Figure 2 It is a flowchart of the constraint consistency determination method provided by the present invention;

[0049] Figure 3 It is a structural schematic diagram of the project information processing device provided by the present invention;

[0050] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0052] Figure 1 It is a flowchart of a project information processing method provided by the present invention, such as Figure 1 As shown, the method includes:

[0053] Step 110, obtaining a project function description file and a latest source code file corresponding to the project function description file, and obtaining a call relationship graph and an abstract syntax tree of the latest source code file;

[0054] Step 120, extracting the method description semantic vector of each method in the project function description file and the association semantic vectors between each method;

[0055] Step 130, extracting source code semantic vectors of each method in the latest source code file based on the natural language code of each method obtained after natural language conversion of the latest source code file, and extracting call constraint semantic vectors between any two methods in the latest source code file and parameter constraint vectors of each method based on the call relationship graph and the abstract syntax tree;

[0056] Step 140, determines the functional consistency based on the method description semantic vector of each method in the project functional description file and the source code semantic vector of each method in the latest source code file, determines the constraint consistency based on the method description semantic vector of each method in the project functional description file and the association semantic vectors between each method, as well as the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method, and adds a consistency label to the project functional description file based on the functional consistency and the constraint consistency.

[0057] Here, a corresponding project function description file is maintained for each source code file in the project management system, but the project developer may not update the corresponding project function description file in a timely manner when updating the source code file, resulting in inconsistency between the two. It should be noted that the inconsistency between the project function description file and its source code file mentioned here refers to the inconsistency between the function or usage constraints of the method described in the project function description file and the corresponding method in the source code file, but the class name, method name and member variable name are consistent. Among them, the project function description file is a text file with a certain format that contains the class description text of the object-oriented class created in the corresponding source code file and the method function description text of each method in the class. The method function description text describes the corresponding method from the perspectives of function, usage, etc. In order to detect the inconsistency in time, the project function description file and the latest source code file corresponding to the project function description file can be obtained for matching. At the same time, the code analysis tool can also be used to obtain the call relationship graph and abstract syntax tree of the latest source code file, where each node in the call relationship graph represents the method contained in the latest source code file (the method name of the method is stored in the node attribute), and each edge connects the nodes corresponding to the two methods in the latest source code file that have a direct call relationship.

[0058] For the project function description file, it can be based on a natural language processing (NLP) model, such as a long short-term memory network and its variants or a gated recurrent unit and its variants that are more suitable for sequence information extraction, etc., and a pre-trained language model Transformer model and its variants can also be used to improve the semantic extraction ability of the project function description file while reducing the training cost. The embodiment of the present invention does not specifically limit this. After the project function description file is divided according to the method name, the divided paragraphs corresponding to each method (the method function description text corresponding to the method) are input into the natural language processing model, and the method description semantic vector of each method in the project function description file output by the model can be obtained.

[0059] Then, considering the deep code constraints of each method, such as the input and output parameter constraints of a single method, the calling constraints between methods in a class, etc., in order to determine whether the description of the above constraints in the project function description file is consistent with the actual constraints between the codes in the latest source code file, the method description semantic vectors of each method in the project function description file can be used to extract the associated parts between the method description semantic vectors of any two methods as the associated semantic vectors between the two methods. Among them, the associated semantic vector between any two methods contains the associated semantics between the method function description texts of the corresponding methods, including the calling relationship and other associated relationships between the corresponding methods.

[0060] In some embodiments, when obtaining the associated semantic vector between any two methods in the project function description file, any two methods in the project function description file can be recorded as a third method (hereinafter referred to as method M) and a fourth method (hereinafter referred to as method N) respectively. On the one hand, method M is used as the query vector (Query) in the attention mechanism and method N is used as the key vector (Key), and the method description semantic vectors of method M and method N are subjected to attention transformation (for example, the dot product of the method description semantic vectors of method M and method N can be solved), and the attention weights corresponding to each vector value of the method description semantic vector of method N are obtained, and the attention weights corresponding to each vector value of the method description semantic vector of method N and its method description semantic vector are weighted, that is, each vector value of the method description semantic vector of method N is multiplied by the corresponding attention weight to obtain the first associated vector. On the other hand, method N is used as the query vector and method M is used as the key vector, and the method description semantic vectors of method M and method N are subjected to attention transformation to obtain the attention weights corresponding to each vector value of the method description semantic vector of method M, and the attention weights corresponding to each vector value of the method description semantic vector of method M are weighted, and the second associated vector is obtained. Subsequently, the first association vector and the second association vector are fused to obtain an association semantic vector between method M and method N.

[0061] For the latest source code file corresponding to the project function description file, considering that there is a "vocabulary gap" between programming language and natural language, in order to shorten the "vocabulary gap", the latest source code file can be first converted to natural language to obtain the natural language code of each method. Specifically, a knowledge base can be constructed based on a public statement library (storing various statements, such as functional descriptions of conditional judgment statements, error capture statements, etc.), a public function library (storing functional descriptions of various public functions) and various project function description files stored in the system, and the source code of each method in the latest source code file is converted to natural language code by using a trained natural language conversion model, by referring to the functional descriptions of various methods or statements in the knowledge base, that is, the source code of each method written in a programming language is converted to a natural language code described in a natural language. Among them, the natural language conversion model is obtained by training based on a sample source code file belonging to the same programming language as the latest source code file and its corresponding sample natural language expression. In some embodiments, the natural language conversion model can be constructed based on a large language model, thereby utilizing the natural language processing capabilities of the large language model itself to improve the accuracy of natural language conversion.

[0062] After obtaining the natural language code of each method, the source code semantic vector of each method can be extracted based on the natural language code of each method. Here, similar to the method of obtaining the method description semantic vector in the project function description file, the natural language code of each method can be input into the above-mentioned natural language processing model to obtain its corresponding source code semantic vector. Since the source code of each method is converted into a natural language code in the form of a natural language, the source code semantic vector of each method extracted by the natural language processing model will be closer to the method description semantic vector of each method in the project function description file in the vector space, thereby improving the comparability between the project function description file and the latest source code file. In addition, in order to extract the deep code constraints in the latest source code file, the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method can be extracted based on the call relationship graph and the abstract syntax tree. Among them, the call constraint semantic vector between any two methods contains the call relationship between the corresponding two methods, and the parameter constraint vector of any method contains the parameter information in the method.

[0063] In some embodiments, in order to obtain the call constraint semantic vector between any two methods in the latest source code file, it is possible to determine whether there is a direct call relationship between any two methods based on the call relationship graph of the latest source code file, that is, whether there is an edge between the corresponding nodes of the two methods in the call relationship graph. If there is a direct call relationship between the above two methods, the call constraint semantic vector between the above two methods is determined based on the source code semantic vectors of the above two methods; otherwise, the call constraint semantic vector between the above two methods is set to an all-zero vector.

[0064] In other embodiments, if there is a direct call relationship between any two of the above methods, the associated information in the source code semantic vectors of the above two methods can be extracted based on the attention mechanism, thereby obtaining the call constraint semantic vector between the above two methods. Specifically, any two methods are respectively recorded as method A (hereinafter referred to as method A) and method B (hereinafter referred to as method B). On the one hand, method A is used as the query vector of the attention mechanism and method B is used as the key vector. The source code semantic vectors of method A and method B are subjected to attention transformation to obtain the attention weights corresponding to each vector value of the source code semantic vector of method B, and the attention weights corresponding to each vector value of the source code semantic vector of method B are weighted to obtain the first constraint vector. On the other hand, method B is used as the query vector and method A is used as the key vector. The source code semantic vectors of method A and method B are subjected to attention transformation to obtain the attention weights corresponding to each vector value of the source code semantic vector of method A, and the attention weights corresponding to each vector value of the source code semantic vector of method A are weighted to obtain the second constraint vector. Subsequently, the first constraint vector and the second constraint vector are fused to obtain the call constraint semantic vector between method A and method B.

[0065] It should be noted that, it can be seen from the above embodiments that when there is a direct calling relationship between any two methods, the method for obtaining the calling constraint semantic vector between the above any two methods is similar to the method for obtaining the association semantic vector between each method in the project function description file. The reason for this is that when there is a direct calling relationship between two methods, when judging whether the project function description file and the latest source code file are consistent in calling constraints, it will be determined based on the similarity between the association semantic vectors between each method in the project function description file and the calling constraint semantic vectors between any two methods in the latest source code file. Therefore, it is necessary to make the association semantic vectors between each method in the project function description file and the calling constraint semantic vectors between any two methods in the latest source code file as close as possible in terms of semantic expression ability, so as to more accurately measure the similarity between the association semantic vector and the calling constraint semantic vector. Therefore, considering that in the above embodiment, a special attention mechanism is used to obtain the correlation information between the two methods to improve the semantic expression ability when obtaining the associated semantic vector, and the method description semantic vector and the source code semantic vector of any method have similar semantic expression abilities due to the use of the same model structure, a similar attention mechanism is also used when obtaining the call constraint semantic vector to ensure that the associated semantic vector and the call constraint semantic vector have similar semantic expression abilities.

[0066] In some embodiments, in order to obtain the parameter constraint vector of any method in the latest source code file, the node representation vector of each node in the abstract syntax tree of the latest source code file can be obtained based on the graph neural network. Subsequently, the method declaration node, variable declaration node and variable assignment node of the method are determined from the abstract syntax tree of the latest source code file as the parameter constraint node of the method, and the node representation vector of the above parameter constraint node of the method is obtained, so as to fuse the node representation vector of the parameter constraint node of the method to obtain the parameter constraint vector of the method.

[0067] After obtaining the method description semantic vectors of each method in the project function description file and the associated semantic vectors between each method, as well as the source code semantic vectors, parameter constraint vectors and call constraint semantic vectors between any two methods in the latest source code file of each method in the above manner, the functional consistency can be determined based on the method description semantic vectors of each method in the project function description file and the source code semantic vectors of each method in the latest source code file, and the constraint consistency can be determined based on the method description semantic vectors of each method in the project function description file and the associated semantic vectors between each method, as well as the call constraint semantic vectors and parameter constraint vectors of each method between any two methods in the latest source code file, and based on the above functional consistency and constraint consistency, a consistency label can be added to the project function description file. Among them, the similarity between the method description semantic vectors of each method in the project function description file and the source code semantic vectors of the corresponding methods in the latest source code file can be calculated. If the similarity between the method description semantic vectors and the source code semantic vectors of all methods is higher than the first threshold, the functional consistency is determined to be consistent.

[0068] In some embodiments, Figure 2 As shown, constraint consistency can be determined as follows:

[0069] Step 210, performing an attention transformation on the method description semantic vector of each method in the project function description file and the parameter constraint vector of the corresponding method in the latest source code file to obtain the parameter description semantic vector of each method in the project function description file;

[0070] Step 220, determining a parameter constraint matching result based on the semantic similarity between the parameter description semantic vector of each method in the project function description file and the parameter constraint vector of the corresponding method in the latest source code file;

[0071] Step 230, for any two methods in the project function description file, if the two methods have a direct calling relationship in the calling relationship graph of the latest source code file, an attention transformation is performed on the association semantic vector between the two methods in the project function description file and the call constraint semantic vector between the corresponding two methods in the latest source code file to obtain the call association semantic vector between the two methods in the project function description file; otherwise, the association semantic vector between the two methods in the project function description file is used as the call association semantic vector;

[0072] Step 240, determining a call constraint matching result based on the semantic similarity between the call association semantic vector between any two methods in the project function description file and the call constraint semantic vector between the corresponding two methods in the latest source code file;

[0073] Step 250: Determine the constraint consistency based on the parameter constraint matching result and the call constraint matching result.

[0074] Specifically, when determining whether the parameter constraints are consistent, the method description semantic vector of each method in the project function description file and the parameter constraint vector of the corresponding method in the latest source code file can be subjected to attention transformation to obtain the attention weight of each vector value of the method description semantic vector of each method in the project function description file, thereby weighting the method description semantic vector of each method in the project function description file, highlighting the semantic information related to the parameter constraints in the method description semantic vector, and obtaining the parameter description semantic vector of each method in the project function description file. Subsequently, based on the semantic similarity between the parameter description semantic vector of each method in the project function description file and the parameter constraint vector of the corresponding method in the latest source code file, the parameter constraint matching result is determined. Among them, if the semantic similarity between the parameter description semantic vector and the parameter constraint vector of all methods is greater than the second threshold, the parameter constraint matching result is determined to be a match.

[0075] When determining whether the call constraints are consistent, for any two methods in the project function description file, if there is a direct call relationship between the above two methods in the call relationship graph of the latest source code file, the associated semantic vector between the above two methods in the project function description file and the call constraint semantic vector between the corresponding two methods in the latest source code file are subjected to attention transformation to obtain the attention weight of each vector value of the associated semantic vector between the above two methods, thereby weighting the associated semantic vector between the above two methods, highlighting the semantic information related to the call constraint in the associated semantic vector, and obtaining the call associated semantic vector between the above two methods; otherwise, the associated semantic vector between the above two methods is directly used as the call associated semantic vector. Subsequently, based on the semantic similarity between the call associated semantic vector between any two methods in the project function description file and the call constraint semantic vector between the corresponding two methods in the latest source code file, the call constraint matching result is determined. Among them, if the semantic similarity between the call associated semantic vector and the call constraint semantic vector between the binary combinations of all methods is greater than the third threshold, the call constraint matching result is determined to be a match.

[0076] Subsequently, based on the above parameter constraint matching results and the above call constraint matching results, the constraint consistency is determined. Wherein, the constraint consistency is consistent only when the parameter constraint matching results and the call constraint matching results are both matched. Then, based on the above function consistency and constraint consistency, a consistency tag is added to the project function description file. Wherein, the consistency tag of the project function description file is consistent only when the function consistency and constraint consistency are both consistent.

[0077] In summary, the method provided by the embodiment of the present invention extracts the method description semantic vectors of each method in the project function description file and the associated semantic vectors between each method, as well as the source code semantic vectors, parameter constraint vectors and call constraint semantic vectors between any two methods in the latest source code file of each method, thereby determining the functional consistency based on the method description semantic vectors of each method in the project function description file and the source code semantic vectors of each method in the latest source code file, and determining the constraint consistency based on the method description semantic vectors of each method in the project function description file and the associated semantic vectors between each method, as well as the call constraint semantic vectors and parameter constraint vectors of each method between any two methods in the latest source code file, and then adding a consistency label to the project function description file based on the functional consistency and constraint consistency, shortening the "lexicon gap" between programming language and natural language, and comprehensively measuring the consistency between the project function description file and its corresponding latest source code file from the two directions of functional description and code constraint, thereby improving the determination accuracy of the consistency between the project function description file and its corresponding latest source code file.

[0078] The project information processing device provided by the present invention is described below. The project information processing device described below and the project information processing method described above can be referenced to each other.

[0079] Based on any of the above embodiments, Figure 3 is a schematic diagram of the structure of the project information processing device provided by the present invention, such as Figure 3 As shown, the device comprises:

[0080] The data acquisition unit 310 is used to acquire a project function description file and a latest source code file corresponding to the project function description file, and acquire a call relationship graph and an abstract syntax tree of the latest source code file;

[0081] Description file processing unit 320, used for extracting method description semantic vectors of each method in the project function description file and association semantic vectors between each method;

[0082] The source code file processing unit 330 is used to extract the source code semantic vector of each method in the latest source code file based on the natural language code of each method obtained after natural language conversion of the latest source code file, and extract the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method based on the call relationship graph and the abstract syntax tree;

[0083] The consistency measurement unit 340 is used to determine the functional consistency based on the method description semantic vector of each method in the project functional description file and the source code semantic vector of each method in the latest source code file, determine the constraint consistency based on the method description semantic vector of each method in the project functional description file and the association semantic vectors between each method, as well as the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method, and add a consistency label to the project functional description file based on the functional consistency and the constraint consistency.

[0084] The device provided by the embodiment of the present invention extracts the method description semantic vectors of each method in the project function description file and the associated semantic vectors between each method, as well as the source code semantic vectors of each method in the latest source code file, the parameter constraint vectors and the call constraint semantic vectors between any two methods, thereby determining the functional consistency based on the method description semantic vectors of each method in the project function description file and the source code semantic vectors of each method in the latest source code file, and determining the constraint consistency based on the method description semantic vectors of each method in the project function description file and the associated semantic vectors between each method, as well as the call constraint semantic vectors and the parameter constraint vectors of each method between any two methods in the latest source code file, and then adding a consistency label to the project function description file based on the functional consistency and constraint consistency, shortening the "lexicon gap" between programming language and natural language, and comprehensively measuring the consistency between the project function description file and its corresponding latest source code file from the two directions of functional description and code constraint, thereby improving the determination accuracy of the consistency between the project function description file and its corresponding latest source code file.

[0085] Based on any of the above embodiments, the method description semantic vectors of each method in the project function description file and the association semantic vectors between each method, as well as the call constraint semantic vectors between any two methods in the latest source code file and the parameter constraint vectors of each method, determine the constraint consistency, specifically including:

[0086] Performing an attention transformation on the method description semantic vector of each method in the project function description file and the parameter constraint vector of the corresponding method in the latest source code file to obtain the parameter description semantic vector of each method in the project function description file;

[0087] Determining a parameter constraint matching result based on the semantic similarity between the parameter description semantic vector of each method in the project function description file and the parameter constraint vector of the corresponding method in the latest source code file;

[0088] For any two methods in the project function description file, if there is a direct calling relationship between the two methods in the calling relationship graph of the latest source code file, an attention transformation is performed on the association semantic vector between the two methods in the project function description file and the call constraint semantic vector between the corresponding two methods in the latest source code file to obtain the call association semantic vector between the two methods in the project function description file; otherwise, the association semantic vector between the two methods in the project function description file is used as the call association semantic vector;

[0089] Determine a call constraint matching result based on the semantic similarity between a call association semantic vector between any two methods in the project function description file and a call constraint semantic vector between corresponding two methods in the latest source code file;

[0090] The constraint consistency is determined based on the parameter constraint matching result and the call constraint matching result.

[0091] Based on any of the above embodiments, the call constraint semantic vector between any two methods in the latest source code file is determined based on the following steps:

[0092] Based on the call relationship graph of the latest source code file, determining whether there is a direct call relationship between any two methods;

[0093] If there is a direct calling relationship between the two methods, determining a calling constraint semantic vector between the two methods based on the source code semantic vectors of the two methods;

[0094] Otherwise, the calling constraint semantic vector between any two methods is set to an all-zero vector.

[0095] Based on any of the above embodiments, determining the call constraint semantic vector between the arbitrary two methods based on the source code semantic vectors of the arbitrary two methods specifically includes:

[0096] The two methods are respectively recorded as a first method and a second method;

[0097] Using the first method as a query vector and the second method as a key vector, performing attention transformation on the source code semantic vectors of the first method and the second method to obtain attention weights corresponding to each vector value of the source code semantic vector of the second method, and determining a first constraint vector based on the source code semantic vector of the second method and the attention weights corresponding to each vector value thereof;

[0098] Using the second method as a query vector and the first method as a key vector, performing attention transformation on the source code semantic vectors of the first method and the second method to obtain attention weights corresponding to each vector value of the source code semantic vector of the first method, and determining a second constraint vector based on the source code semantic vector of the first method and the attention weights corresponding to each vector value thereof;

[0099] The first constraint vector and the second constraint vector are merged to obtain a call constraint semantic vector between the arbitrary two methods.

[0100] Based on any of the above embodiments, the parameter constraint vector of any method in the latest source code file is determined based on the following steps:

[0101] Obtaining a node representation vector of each node in an abstract syntax tree of the latest source code file based on a graph neural network;

[0102] Determine, from the abstract syntax tree of the latest source code file, a method declaration node, a variable declaration node, and a variable assignment node of the any method as parameter constraint nodes of the any method;

[0103] The node representation vectors of the parameter constraint nodes of any of the methods are merged to obtain the parameter constraint vector of any of the methods.

[0104] Based on any of the above embodiments, the associated semantic vector between any two methods in the project function description file is determined based on the following steps:

[0105] Recording the two methods in the project function description file as a third method and a fourth method respectively;

[0106] Using the third method as a query vector and the fourth method as a key vector, performing attention transformation on the method description semantic vectors of the third method and the fourth method to obtain attention weights corresponding to each vector value of the method description semantic vector of the fourth method, and determining a first association vector based on the method description semantic vector of the fourth method and the attention weights corresponding to each vector value thereof;

[0107] Using the fourth method as a query vector and the third method as a key vector, performing attention transformation on the method description semantic vectors of the third method and the fourth method to obtain attention weights corresponding to each vector value of the method description semantic vector of the third method, and determining a second association vector based on the method description semantic vector of the third method and the attention weights corresponding to each vector value thereof;

[0108] The first association vector and the second association vector are merged to obtain an association semantic vector between any two methods in the project function description file.

[0109] Based on any of the above embodiments, the natural language code of each method in the latest source code file is converted based on the following steps:

[0110] Convert the source code of each method in the latest source code file into natural language code based on the trained natural language conversion model;

[0111] The natural language conversion model is obtained by training based on sample source code files belonging to the same programming language as the latest source code file and their corresponding sample natural language expressions.

[0112] Figure 4is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 4 As shown, the electronic device may include: a processor (processor) 410, a memory (memory) 420, a communication interface (Communications Interface) 430 and a communication bus 440, wherein the processor 410, the memory 420, and the communication interface 430 communicate with each other through the communication bus 440. The processor 410 can call the logic instructions in the memory 420 to execute the project information processing method, which includes: obtaining a project function description file and the latest source code file corresponding to the project function description file, and obtaining a call relationship graph and an abstract syntax tree of the latest source code file; extracting the method description semantic vector of each method in the project function description file and the association semantic vector between each method; extracting the source code semantic vector of each method in the latest source code file based on the natural language code of each method obtained after natural language conversion of the latest source code file, and extracting the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method based on the call relationship graph and the abstract syntax tree; determining functional consistency based on the method description semantic vector of each method in the project function description file and the source code semantic vector of each method in the latest source code file, determining constraint consistency based on the method description semantic vector of each method in the project function description file and the association semantic vector between each method, as well as the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method, and adding a consistency label to the project function description file based on the functional consistency and the constraint consistency.

[0113] In addition, the logic instructions in the above-mentioned memory 420 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0114] On the other hand, the present invention also provides a computer program product, the computer program product includes a computer program stored on a non-transitory computer-readable storage medium, the computer program includes program instructions, when the program instructions are executed by a computer, the computer can execute the project information processing method provided by the above methods, the method comprising: obtaining a project function description file and the latest source code file corresponding to the project function description file, and obtaining a call relationship graph and an abstract syntax tree of the latest source code file; extracting a method description semantic vector of each method in the project function description file and an associated semantic vector between each method; extracting the natural language code of each method obtained after natural language conversion based on the latest source code file, and extracting the latest source code file. The method described in the project function description file is used to determine the source code semantic vector of each method in the project function description file, and based on the call relationship graph and the abstract syntax tree, the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method are extracted; based on the method description semantic vector of each method in the project function description file and the source code semantic vector of each method in the latest source code file, the functional consistency is determined; based on the method description semantic vector of each method in the project function description file and the association semantic vectors between each method, as well as the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method, the constraint consistency is determined; and based on the functional consistency and the constraint consistency, a consistency label is added to the project function description file.

[0115] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the above-mentioned project information processing methods, the methods comprising: obtaining a project function description file and the latest source code file corresponding to the project function description file, and obtaining a call relationship graph and an abstract syntax tree of the latest source code file; extracting a method description semantic vector of each method in the project function description file and an associated semantic vector between each method; extracting a source code semantic vector of each method in the latest source code file based on the natural language code of each method obtained after natural language conversion of the latest source code file, and based on the The call relationship graph and abstract syntax tree are used to extract the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method; based on the method description semantic vector of each method in the project function description file and the source code semantic vector of each method in the latest source code file, the functional consistency is determined; based on the method description semantic vector of each method in the project function description file and the association semantic vectors between each method, as well as the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method, the constraint consistency is determined; and based on the functional consistency and the constraint consistency, a consistency label is added to the project function description file.

[0116] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0117] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.

[0118] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A project information processing method, characterized in that: include: Obtain a project function description file and the latest source code file corresponding to the project function description file, and obtain a call relationship graph and an abstract syntax tree of the latest source code file; Extracting the method description semantic vector of each method in the project function description file and the association semantic vectors between each method; Extracting source code semantic vectors of each method in the latest source code file based on the natural language code of each method obtained after natural language conversion of the latest source code file, and extracting call constraint semantic vectors between any two methods in the latest source code file and parameter constraint vectors of each method based on the call relationship graph and the abstract syntax tree; Based on the method description semantic vector of each method in the project function description file and the source code semantic vector of each method in the latest source code file, the functional consistency is determined; based on the method description semantic vector of each method in the project function description file and the association semantic vectors between each method, as well as the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method, the constraint consistency is determined; and based on the functional consistency and the constraint consistency, a consistency label is added to the project function description file.

2. The project information processing method according to claim 1, characterized in that: The method description semantic vectors of each method in the project function description file and the association semantic vectors between each method, as well as the call constraint semantic vectors between any two methods in the latest source code file and the parameter constraint vectors of each method, determine the constraint consistency, specifically including: Performing an attention transformation on the method description semantic vector of each method in the project function description file and the parameter constraint vector of the corresponding method in the latest source code file to obtain the parameter description semantic vector of each method in the project function description file; Determining a parameter constraint matching result based on the semantic similarity between the parameter description semantic vector of each method in the project function description file and the parameter constraint vector of the corresponding method in the latest source code file; For any two methods in the project function description file, if there is a direct calling relationship between the two methods in the calling relationship graph of the latest source code file, an attention transformation is performed on the association semantic vector between the two methods in the project function description file and the call constraint semantic vector between the corresponding two methods in the latest source code file to obtain the call association semantic vector between the two methods in the project function description file; otherwise, the association semantic vector between the two methods in the project function description file is used as the call association semantic vector; Determine a call constraint matching result based on the semantic similarity between a call association semantic vector between any two methods in the project function description file and a call constraint semantic vector between corresponding two methods in the latest source code file; The constraint consistency is determined based on the parameter constraint matching result and the call constraint matching result.

3. The project information processing method according to claim 2, characterized in that: The call constraint semantic vector between any two methods in the latest source code file is determined based on the following steps: Based on the call relationship graph of the latest source code file, determining whether there is a direct call relationship between any two methods; If there is a direct calling relationship between the two methods, determining a calling constraint semantic vector between the two methods based on the source code semantic vectors of the two methods; Otherwise, the calling constraint semantic vector between any two methods is set to an all-zero vector.

4. The project information processing method according to claim 3, characterized in that: The determining, based on the source code semantic vectors of the arbitrary two methods, the calling constraint semantic vector between the arbitrary two methods specifically includes: The two methods are respectively recorded as a first method and a second method; Using the first method as a query vector and the second method as a key vector, performing attention transformation on the source code semantic vectors of the first method and the second method to obtain attention weights corresponding to each vector value of the source code semantic vector of the second method, and determining a first constraint vector based on the source code semantic vector of the second method and the attention weights corresponding to each vector value thereof; Using the second method as a query vector and the first method as a key vector, performing attention transformation on the source code semantic vectors of the first method and the second method to obtain attention weights corresponding to each vector value of the source code semantic vector of the first method, and determining a second constraint vector based on the source code semantic vector of the first method and the attention weights corresponding to each vector value thereof; The first constraint vector and the second constraint vector are merged to obtain a call constraint semantic vector between the arbitrary two methods.

5. The project information processing method according to claim 2, characterized in that: The parameter constraint vector of any method in the latest source code file is determined based on the following steps: Obtaining a node representation vector of each node in an abstract syntax tree of the latest source code file based on a graph neural network; Determine, from the abstract syntax tree of the latest source code file, a method declaration node, a variable declaration node, and a variable assignment node of the any method as parameter constraint nodes of the any method; The node representation vectors of the parameter constraint nodes of any of the methods are merged to obtain the parameter constraint vector of any of the methods.

6. The project information processing method according to claim 1, characterized in that: The associated semantic vector between any two methods in the project functional description file is determined based on the following steps: Recording the two methods in the project function description file as a third method and a fourth method respectively; Using the third method as a query vector and the fourth method as a key vector, performing attention transformation on the method description semantic vectors of the third method and the fourth method to obtain attention weights corresponding to each vector value of the method description semantic vector of the fourth method, and determining a first association vector based on the method description semantic vector of the fourth method and the attention weights corresponding to each vector value thereof; Using the fourth method as a query vector and the third method as a key vector, performing attention transformation on the method description semantic vectors of the third method and the fourth method to obtain attention weights corresponding to each vector value of the method description semantic vector of the third method, and determining a second association vector based on the method description semantic vector of the third method and the attention weights corresponding to each vector value thereof; The first association vector and the second association vector are merged to obtain an association semantic vector between any two methods in the project function description file.

7. The project information processing method according to claim 1, characterized in that: The natural language codes of each method in the latest source code file are converted based on the following steps: Convert the source code of each method in the latest source code file into natural language code based on the trained natural language conversion model; The natural language conversion model is obtained by training based on sample source code files belonging to the same programming language as the latest source code file and their corresponding sample natural language expressions.

8. A project information processing device, characterized in that: include: A data acquisition unit, used to acquire a project function description file and a latest source code file corresponding to the project function description file, and acquire a call relationship graph and an abstract syntax tree of the latest source code file; A description file processing unit, used for extracting the method description semantic vector of each method in the project function description file and the association semantic vectors between each method; a source code file processing unit, configured to extract source code semantic vectors of each method in the latest source code file based on the natural language code of each method obtained after natural language conversion of the latest source code file, and extract a call constraint semantic vector between any two methods in the latest source code file and a parameter constraint vector of each method based on the call relationship graph and the abstract syntax tree; A consistency measurement unit is used to determine the functional consistency based on the method description semantic vector of each method in the project functional description file and the source code semantic vector of each method in the latest source code file, determine the constraint consistency based on the method description semantic vector of each method in the project functional description file and the association semantic vectors between each method, as well as the call constraint semantic vector between any two methods in the latest source code file and the parameter constraint vector of each method, and add a consistency label to the project functional description file based on the functional consistency and the constraint consistency.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the project information processing method according to any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the project information processing method according to any one of claims 1 to 7 is implemented.