Key class identification method and device, equipment, medium and product

By combining dynamic analysis and community detection technology, the identification of key categories in the software system is solved, and the problem of low accuracy in the identification of key categories in the existing technology is improved, and the understanding and maintenance capabilities of core elements of the software system are improved.

CN119718952APending Publication Date: 2025-03-28ZHEJIANG GONGSHANG UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411909376.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The existing key class identification methods have low accuracy, mainly because they ignore the impact of method execution patterns and the community structure of the class on the class importance value.

Method used

Test cases are generated by parsing text information in the software user manual, determining and correcting method call diagrams based on test cases, and mapping them into class coupled diagrams. The SLPA algorithm is used to identify overlapping communities, correct the class coupling graph, and calculate the importance value of class nodes in combination with the improved PageRank algorithm, and finally filter out the key classes.

Benefits of technology

By considering method execution patterns and class community structure, the accuracy of key class identification is improved and the understanding and maintenance capabilities of core elements of the software system are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718952A_ABST
    Figure CN119718952A_ABST
Patent Text Reader

Abstract

The invention discloses a key class identification method and device, equipment, a medium and a product, and relates to the field of software development, the method comprises the following steps: analyzing text information in a software user manual, and generating a test case conforming to an actual operation process; based on the test case, according to the execution track of the software, determining a method calling graph, and correcting the method calling graph; mapping the corrected method calling graph into a class coupling graph; identifying each overlapping community in the class coupling graph by using an SLPA algorithm; according to the co-occurrence frequency of nodes at the two ends of any directed edge in the class coupling graph in the overlapping community, correcting the class coupling graph, and determining a corrected class coupling graph; calculating an importance value of each class node in the corrected class coupling graph by using an improved PageRank algorithm; and sorting all classes in the corrected class coupling graph according to the importance value, and screening out the key class based on the class sequence, thereby improving the key class identification accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software development, and in particular to a key class identification method, device, equipment, medium and product. Background Art

[0002] The increasing scale of software systems and the continuous growth of functional and performance requirements have led to a sharp increase in system complexity and high maintenance costs, which usually exceed 60% of the total cost, becoming an important factor restricting the development of the software industry. The understanding and maintenance of complex legacy systems have become a difficult problem. The fundamental reason is that there is a negative correlation between system complexity and maintenance efficiency and cost control. In view of this, the development of technologies that can improve the understandability and maintainability of software has significant theoretical and practical value.

[0003] An effective way to understand a large software system is to start with its core elements (such as packages, classes, functions, attributes, etc.), gradually expand to other related elements, and finally fully grasp the overall structure. Existing studies have tried a variety of methods to identify these core elements. Related research work includes: key class identification methods based on static class dependency graphs and HITS algorithms, key class identification methods based on class dependency graphs combined with PageRank algorithms, HITS algorithms, and graph algorithms such as betweenness centrality, and key class identification methods based on state transition models and node complexity calculations, as well as key class and key package identification methods based on class granularity and package granularity software structure graphs combined with PageRank algorithms.

[0004] However, the existing work still has the following shortcomings:

[0005] (1) Existing key class identification work is mainly based on static analysis, and there is less work based on dynamic analysis.

[0006] Key class identification based on static analysis mainly extracts software classes and the relationships between classes from the source code of the software. It is essentially a "worst case" analysis, and the class-level dependency graph it constructs will contain redundant edges (interactions between classes). Dynamic analysis is to obtain the real interaction relationships between software elements (between methods, and then between classes) by executing the software. In this respect, dynamic analysis is more accurate than static analysis.

[0007] (2) Existing techniques ignore the impact of method execution patterns and class community structures on class importance values.

[0008] Method execution information contains the patterns of method usage, which have a significant impact on the importance of methods. In addition, the community structure to which a class belongs contains information related to the functions of the class. Generally, classes belonging to the same community perform similar functions. However, existing technologies ignore the impact of method execution patterns and the community structure to which a class belongs on the importance of a class.

[0009] It can be seen that the existing key class identification method has low key class identification accuracy. Summary of the invention

[0010] The purpose of this application is to provide a key class identification method, device, equipment, medium and product to solve the problem of low accuracy of key class identification.

[0011] To achieve the above objectives, this application provides the following solutions:

[0012] In a first aspect, the present application provides a key class identification method, comprising:

[0013] Parse the text information in the software user manual and generate test cases that conform to the actual operation process;

[0014] Based on the test case, according to the execution track of the software, a method call graph is determined, and the method call graph is corrected; the method call graph includes a set of method nodes and a set of directed edges executed in real time when the software is running; wherein the set of directed edges is a call relationship between methods, the direction is from the caller to the callee, and each directed edge is assigned a weight, and the weight is the number of calls between the methods at both ends of the directed edge;

[0015] Map the corrected method call graph to a class coupling graph;

[0016] Using the SLPA algorithm, identifying overlapping communities in the class coupling graph;

[0017] According to the number of co-occurrences of nodes at both ends of any directed edge in the class coupling graph in the overlapping community, the class coupling graph is modified to determine a modified class coupling graph;

[0018] Using an improved PageRank algorithm, the importance value of each class node in the modified class coupling graph is calculated;

[0019] All classes in the modified class coupling graph are sorted according to the importance values, and key classes are screened out based on the class sequence.

[0020] In a second aspect, the present application provides a key category identification device, comprising:

[0021] Parsing module, used to parse text information in the software user manual and generate test cases that conform to the actual operation process;

[0022] A method use case diagram determination and correction module is used to determine a method call diagram based on the test case and the execution trajectory of the software, and to correct the method call diagram; the method call diagram includes a set of method nodes and a set of directed edges executed in real time when the software is running; wherein the set of directed edges is a call relationship between methods, the direction is from the caller to the callee, and each directed edge is assigned a weight, the weight being the number of calls between the methods at both ends of the directed edge;

[0023] A mapping module, used for mapping the modified method call graph into a class coupling graph;

[0024] An overlapping community identification module, used to identify overlapping communities in the class coupling graph using the SLPA algorithm;

[0025] A class coupling graph correction module, used to correct the class coupling graph according to the number of co-occurrences of nodes at both ends of any directed edge in the class coupling graph in the overlapping community, and determine a corrected class coupling graph;

[0026] An importance value determination module, used to calculate the importance value of each class node in the modified class coupling graph using an improved PageRank algorithm;

[0027] The key class identification module is used to sort all the classes in the modified class coupling diagram according to the importance values, and screen out key classes based on the class sequence.

[0028] In a third aspect, the present application provides a computer device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the key class identification methods described above.

[0029] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the key class identification methods described above.

[0030] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements any of the key class identification methods described above.

[0031] According to the specific embodiments provided in this application, this application discloses the following technical effects:

[0032] The present application captures the method execution pattern and the community structure to which the class belongs, and updates the edge weights in the Method Call Graph (MCG) and the Class Coupling Graph (CCG) through the pattern and community structure, thereby obtaining a revised Method Call Graph (UMCG) and a revised Class Coupling Graph (UCCG), and determining the importance value of each class node in the revised Class Coupling Graph to accurately identify key classes. The present application considers the impact of the method execution pattern and the class community structure on the class importance value by updating the edge weights, thereby improving the accuracy of key class identification. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0034] Figure 1 A schematic diagram of a key class identification method flow chart provided in an embodiment of the present application;

[0035] Figure 2 A schematic diagram of part of the information in a user manual provided in an embodiment of the present application;

[0036] Figure 3 A schematic diagram of part of the information of a test case provided in an embodiment of the present application;

[0037] Figure 4 A schematic diagram of execution trajectory information of a run provided by an embodiment of the present application;

[0038] Figure 5 A schematic diagram of call relationship information of an operation provided in an embodiment of the present application;

[0039] Figure 6 A schematic diagram of a constructed MCG provided in an embodiment of the present application;

[0040] Figure 7 A schematic diagram of an execution mode of a construction provided in an embodiment of the present application;

[0041] Figure 8 A schematic diagram of a UMCG constructed and provided in an embodiment of the present application and containing only one class;

[0042] Fig. 9A schematic diagram of a UMCG constructed by an embodiment of the present application and including only three classes;

[0043] Fig.10 A schematic diagram of the execution flow of the SPLA algorithm provided in one embodiment of the present application; wherein: Fig.10 (a) is a schematic diagram of node labels at the initial stage; Fig.10 (b) is a schematic diagram of node labels after the first update; Fig.10 (c) in the figure is a schematic diagram of node labels after the second update; Fig.10 (d) is a schematic diagram of node labels after the third update; Fig.10 (e) is a schematic diagram of node labels after the fourth update; Fig.10 (f) is a schematic diagram of node labels after the fifth update; Fig.10 (g) in FIG. 5 is a schematic diagram of node labels after the sixth update. DETAILED DESCRIPTION

[0044] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0045] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0046] The embodiment of the present application provides a key class identification method, which is executed by a computer device, and can be specifically executed by a computer device such as a terminal or a server alone, or can be executed by a terminal and a server together. In the embodiment of the present application, Figure 1 As shown, the method includes the following steps.

[0047] S1: Parse the text information in the software user manual and generate test cases that conform to the actual operation process.

[0048] S2: Based on the test case and the execution trajectory of the software, determine the method call graph and correct the method call graph; the method call graph includes a set of method nodes and a set of directed edges that are executed in real time when the software is running; wherein the set of directed edges is a calling relationship between methods, with a direction from the caller to the callee, and each directed edge is assigned a weight, which is the number of calls between the methods at both ends of the directed edge.

[0049] S3: Map the corrected method call graph into a class coupling graph.

[0050] S4: Using the SLPA algorithm, identifying overlapping communities in the class coupling graph.

[0051] S5: According to the co-occurrence times of the nodes at both ends of any directed edge in the class coupling graph in the overlapping communities, the class coupling graph is modified to determine a modified class coupling graph.

[0052] S6: Using the improved PageRank algorithm, calculate the importance value of each class node in the modified class coupling graph.

[0053] S7: Sort all classes in the modified class coupling graph according to the importance values, and screen out key classes based on the class sequence.

[0054] In an exemplary embodiment, S1 may be replaced by the following steps.

[0055] S11: Parse the text information in the software user manual, extract the subject-object structure related to the software operation (i.e., the verb representing the operation and the noun representing the operation object), and automatically generate test cases that conform to the actual operation process.

[0056] In order to obtain the execution trace of the software, this application will automatically generate test cases from the software user manual. The automatic generation of test cases in S11 specifically includes the following sub-steps:

[0057] (1.1) Use the Stanford Parser tool to preprocess the sentences in the user manual, split them into multiple clauses, and annotate the part of speech (such as verb, noun, adjective, etc.) for each clause word by word.

[0058] (1.2) Parse and construct the sentence dependency tree based on the dependency relationship, and clarify the core elements such as subject, object, verb and their relationships in the sentence structure. This application mainly focuses on key dependency relationships such as "nsubj" (subject), "dobj" (direct object), and "amod" (adjective modifier).

[0059] (1.3) The extracted operation verbs, subjects, objects and other information are used as a test case structure, and the parsing results are output as a structured text file. Each line in the file includes: operation behavior (operation verb), operation object (noun) and related descriptive information.

[0060] In an exemplary embodiment, S2 may be replaced by the following steps.

[0061] S21: Based on the test case, run the software to determine the execution trajectory of the software.

[0062] S22: Based on the execution trajectory, the calling relationship between methods during software runtime is abstracted into a method calling graph.

[0063] S23: Determine to divide the method call graph into a plurality of method call subgraphs according to the methods called when executing the test case and the calling relationship between the methods; the method call subgraphs are execution modes corresponding to the test case.

[0064] S24: Count the number of co-occurrences of the methods at both ends of each directed edge in the method use case diagram in all execution modes.

[0065] S25: Modifying the weights in the method call graph according to the number of co-occurrences, and determining a modified method call graph.

[0066] In another exemplary embodiment, S2 may be replaced by the following steps.

[0067] (1) Run the software according to the test case and obtain the execution trace of the software.

[0068] Step (1) specifically includes:

[0069] Based on the AspectJ framework, a script is developed to collect software execution traces and embedded into the source code of the software, thereby achieving real-time monitoring of the software runtime behavior (such as monitoring method calls, message passing, and resource usage).

[0070] According to the generated test cases, the software is operated and the execution trace is tracked, captured and recorded using the tools developed above and the records are saved in a log file in .dat format.

[0071] (2) Based on the execution trace, the calling relationship between methods in the Java software runtime is abstracted into a method call graph MCG = (N, L). Among them, N is the set of method nodes actually executed during the software runtime; L is the set of directed edges, which represents the calling relationship between methods, with the direction from the caller to the callee; each edge is assigned a weight, which represents the number of calls between the methods at both ends of the directed edge.

[0072] The methods, calling relationships between methods, and calling times between methods in step (2) are the methods actually executed during the execution of the test case, and the calls (times) between the methods actually generated. It is a dynamic analysis (information can only be collected during the software operation process), rather than a static analysis based on the source code (information obtained by analyzing the source code without running the software). At the same time, there are huge differences between this application and the analysis method based on the software operation log. The method based on the operation log collects information during the daily software operation process, reflecting the user's usage preferences, while the method of this application is based on the operation manual and collects the methods and method calls (times) required to implement all the functions of the software.

[0073] (3) Based on the execution trace, the method call pattern is analyzed, and the MCG is modified based on the obtained pattern to construct the modified MCG, UMCG = (N, L). N and L of UMCG are the same as those of MCG. The main difference is that UMCG modifies the edge weights in MCG.

[0074] In step (3), correcting the edge weight according to the method calling mode specifically includes the following sub-steps:

[0075] The MCG of step (2) is constructed by executing the test case in step (1). Therefore, the methods obtained when executing a specific test case and the calling relationships between methods will constitute a subgraph of MCG. This application regards the subgraph of MCG corresponding to the execution of a test case as the execution mode corresponding to this test case.

[0076] Count the number of co-occurrences of the methods at both ends of each directed edge in MCG in all execution modes, and add the number of co-occurrences to the weight of this edge as the new edge weight, that is, new edge weight = old edge weight + co-occurrence count. Here, the old edge weight refers to the total number of calls of the edge in all modes, and the co-occurrence count refers to the number of execution modes in which the directed edge appears.

[0077] In an exemplary embodiment, S3 may be replaced by the following steps.

[0078] S31: parsing the class name to which each method name in the revised method call graph belongs.

[0079] S32: constructing a node of the class coupling graph according to the class name; the node is a class node.

[0080] S33: Constructing directed edges of the class coupling graph according to the relationship between the classes to which the methods belong in the modified method call graph.

[0081] S34: Based on the directed edges of the class coupling graph, determine the directed edge weights of the class coupling graph according to the weights of all directed edges in the direction of the directed edge in the corrected method call node of all method nodes contained in the class nodes at both ends of any directed edge.

[0082] S35: Construct the class coupling graph according to the nodes, directed edges and directed edge weights of the class coupling graph.

[0083] Furthermore, S31-S32 is node construction: based on the constructed UMCG, the class name to which each method belongs is parsed from the full name of each method in the UMCG, and the node in the CCG is constructed according to the class name (one class corresponds to one node). For example: if there is a node package.class1.method1 in the UMCG, and the class name to which it belongs is package.class1, then a node is created in the CCG, and its name is package.class1. If there is another node, package.class1.method2, whose class name is the same as package.class1.method1, no new class node is created.

[0084] S33 is the construction of directed edges: the edges in CCG are constructed according to the relationship between the classes to which the nodes belong in UMCG, that is, the edges between two method nodes that do not belong to the same class establish the edges between the corresponding classes in CCG. For example, if there is a directed edge between the node pairs package.class1.method1 and package.class2.method2 in UMCG (method1 points to method2). Because package.class1.method1 belongs to the class package.class1, and package.class2.method2 belongs to the class package.class2, they belong to different classes, so an edge will be established between the corresponding classes of these two methods, package.class1 and package.class2, with the direction from class1 to class2.

[0085] S34 is the construction of edge weights: the edge weight in CCG is equal to the sum of the weights of all the method nodes contained in the classes at both ends of this edge in the direction of this edge in UMCG. For example, if there is a directed edge between the node pair package.class1.method1 and package.class2.method2 in UMCG (method1 points to method2), its edge weight is 2; there is a directed edge between the node pair package.class1.method5 and package.class2.method6 (method5 points to method6), its edge weight is 4; there is a directed edge between the node pair package.class2.method9 and package.class1.method11 (method9 points to method11), its edge weight is 5. These three directed edges will establish two directed edges in CCG: the directed edge package.class1->package.class2, its edge weight is 6 (i.e.: 6=2+4); the directed edge package.class2->package.class1, its edge weight is 5.

[0086] In an exemplary embodiment, S4 may be replaced by the following steps.

[0087] S41: Initialize all class nodes in the class coupling graph as labels; the labels are community labels, and the same label corresponds to class nodes in the same community.

[0088] S42: Use the current class node as a listener and the neighbor class node of the current class node as a speaker, traverse all neighbor class nodes of the current class node, use the label of the neighbor class node with the highest frequency as the new label propagated in this iteration, and store the new label in the candidate label memory of the current class node.

[0089] S43: traverse neighboring class nodes of all class nodes, determine the label storage of each class node, and update the label of each class node.

[0090] S44: Determine overlapping communities based on the labels of each class node.

[0091] Furthermore, S4 can be replaced by the following steps.

[0092] (1) All class nodes in CCG are initialized with unique labels (belonging to a single community).

[0093] (2) Traverse all class nodes and update labels.

[0094] (2.1) The current class node acts as a listener, and the neighbor node of the current node acts as a speaker.

[0095] (2.2) Traverse every neighbor of the current class node and pass the neighbor's label to the candidate label memory (2.2.1) Calculate the probability of all labels appearing in the label memory of the current neighbor class node: If there are 5 labels L1, L2, L1, L1, L3 in the label memory, and label L1 appears 3 times, its probability is 3 / 5=60%; similarly, L2 probability = 1 / 5=20%, L3 probability = 1 / 5=20%.

[0096] (2.2.2) Select a label in proportion to the probability: randomly generate a probability value, if the value is 20% < 30% < 60%, then L1 is selected.

[0097] (2.2.3) Store the L1 label in the candidate label memory.

[0098] (2.3) Select the label with the highest frequency from the label information set propagated by the neighboring class nodes (the labels re-stored in the candidate label memory) as the new label propagated in this iteration, and store it in the label memory of the current class node.

[0099] (3) Continue to iterate step (2) until the algorithm converges or the number of iterations reaches the specified number.

[0100] (4) Select the three most frequently appearing labels in the node label memory as the labels of the current class node (i.e., community number).

[0101] In an exemplary embodiment, S5 may be replaced by the following steps.

[0102] S51: According to the division result of the overlapping communities, counting the number of co-occurrences of the class nodes at both ends of each directed edge in the class coupling graph in the overlapping communities.

[0103] S52: Correcting the weights in the class coupling graph according to the number of co-occurrences, and determining a corrected class coupling graph.

[0104] Further, S52 can be replaced by the following steps.

[0105] The number of co-occurrences is added to the weight of this edge as the new edge weight, that is, the new edge weight = old edge weight + co-occurrence number. Here, the old edge weight refers to the weight of the edge in CCG (obtained by the accumulation of the number of method calls in the same direction), and the co-occurrence number refers to the number of overlapping communities in which the two end nodes of the directed edge co-appear.

[0106] In an exemplary embodiment, S6 may be replaced by the following steps.

[0107] S61: Initialize the initial importance value of each class node in the modified class coupling graph. The initial importance value is 1 / N, where N is the number of class nodes in UCCG.

[0108] S62: Using formula Update the initial importance value, and use the updated importance value as the importance value of each class node in the modified class coupling graph; where PR(u) is the importance value of class node u; wd(u) is the weighted degree of class node u; wdSum is the weighted degree sum of all class nodes; w(v,u) ...<v,u> The edge weight on the node; wod(v) is the weighted out-degree of the node v; in(u) is the neighbor on the incoming edge of the node u; d is the attenuation factor.

[0109] S62 is continuously iterated until convergence to obtain the PR value of each class node.

[0110] Compared with the traditional PageRank algorithm, this application and We further consider the impact of operating mode and community structure on class importance. This part is very different from the traditional (1-d) / N (N represents the number of nodes in the graph).

[0111] The traditional PageRank algorithm uses the following formula iteration (the meaning of the characters in the formula is the same as above):

[0112]

[0113] Where N represents the number of nodes in UCCG.

[0114] Therefore, compared with the traditional PageRank algorithm, this application adopts a guided strategy, namely use Therefore, it tends to The large u node, instead of the uniform strategy, that is, (1-d) / N uses 1 / N, so it does not tend to favor any node.

[0115] The following uses a specific software operation as an example to illustrate the key category identification method provided by this application.

[0116] The specific steps are as follows:

[0117] (1) Parse the text information in the software user manual and extract the relevant subject-object structure to generate test cases.

[0118] like Figure 2Part of the user manual shown. This information shows that the software interface has three buttons, namely, Addition button, Subtraction button, and FiveAddition button. When the user clicks the Addition button, the number will increase by 1; when the user clicks the Subtraction button, the number will decrease by 1; when the user clicks the FiveAddition button, the number will increase by 5. This user manual information is parsed using the Stanford Parser tool. First, the part of speech is marked for each clause word by word, such as "NN" for common nouns, "VB" for verbs, and "VBG" for the present participle form of verbs. Secondly, the core elements such as subject, object, and verb in the sentence structure and their mutual relationships are clarified. Here, we mainly focus on key dependencies such as "nsubj" (subject), "dobj" (direct object), and "amod" (adjective modifier).

[0119] by Figure 2 Take the second sentence in the example, "user" is the subject of the sentence, indicating the person who performs the action; "click" is the main verb of the sentence, indicating the action to be performed; "AdditionButton" is the direct object of "click", indicating the object clicked by the user. Finally, the extracted subject ("user"), operation verb-operation object pair ("click"-"AdditionButton") and other information are used as a test case structure and output to a text file. The results after parsing and extracting part of the information in the above user manual are as follows Figure 3 shown.

[0120] Each line consists of three parts. The first part indicates the subject role that performs the action, the second part indicates the action verb-action object pair, and the third part records the detailed description of the object or target. Here we focus on the second part and use it as a test case. There are 4 test cases obtained from the above extraction results. The first one asks the user to run the application, the second one asks the user to click the "Addition" button, the third one asks the user to click the "Subtraction" button, and the fourth one asks the user to click the "FiveAddition" button.

[0121] (2) First, the script for collecting software execution traces developed based on the AspectJ framework is embedded into the software source code file. The Java software source code is shown below.

[0122]

[0123]

[0124] Next, according to the test case obtained in step (1), the corresponding operation is performed on the software interface. In the above code, the manual method call is used to replace the actual interface operation such as clicking a button.

[0125] According to the Java source code of the above code, when the software is run, the main function is executed first, and then the user clicks the "Addition" button, the onAddClick function is called once, and the add function is called once through the onAddClick function; next, the user clicks the "Subtraction" button, the onSubClick function is executed once, and the add function is called once and the sub function is called twice through the onSubClick function; next, the user clicks the "FiveAddition" button, the onAddFiveClick function is executed once, and the add function is called 5 times and the onAddClick function is called once through the onAddFiveClick function, and then the add function is called once through the onAddClick function. After all the test cases are executed, the execution trajectory is as follows Figure 4 shown.

[0126] Each line in the file corresponds to a record, and each record represents a method call. Each record consists of ten fields, and each field is separated by a semicolon ";". Here we mainly focus on the third value indicating the class and method being called, the ninth value is the execution order index (eoi), and the tenth value indicates the stack depth (ess).

[0127] (3) Based on the execution trace results obtained in step (2), the calling relationship between methods is analyzed, such as Figure 5 As shown in the figure, each line indicates that the former method calls the latter method once. Then, the calling relationship is abstracted as Figure 6 The method call graph MCG shown is (N, L). N = {main, onAddClick, onSubClick, onAddFiveClick, add, sub} represents the set of method nodes actually executed when the software is running; L = {(main, onAddClick), (onAddClick, add), (main, onSubClick), (onSubClick, add), (onSubClick, sub), (main, onAddFiveClick), (onAddFiveClick, add), (onAddFiveClick, onAddClick)} represents the set of calling relationships between methods, and the direction is that the former calls the latter.

[0128] (4) Each call relationship obtained by executing each test case corresponds to a subgraph of MCG, that is, an execution mode. According to the call relationship of each test case obtained in step (3), three execution modes are obtained, such as Figure 7 As shown in Figure 1, the number of times the call relationship appears in the execution mode is used as the edge weight. Next, the edge weight is modified according to the execution mode, the number of co-occurrences of the methods at both ends of each directed edge in all execution modes is counted, and the number of co-occurrences is accumulated to the weight of the edge as the new edge weight. Figure 7 The onAddClick function calls the add function in both execution mode 1 and execution mode 3, so the co-occurrence count of (onAddClick, add) is 2, and the modified edge weight of (onAddClick, add) is 2+2=4. (main, onAddClick) only appears in execution mode 1, so the co-occurrence count of (main, onAddClick) is 1, and the modified edge weight of (main, onAddClick) is 1+1=2. The modification process of other edge weights is similar. The modified UMCG diagram is shown in the figure below: Figure 8 For the convenience of subsequent description, all nodes will be labeled with letters from A to F.

[0129] (5) Map the UMCG constructed in step (4) into a class coupling graph CCG. Because, Figure 8 The example in has only one class, and its mapped CCG contains only one node and no edges. To explain the process more clearly, assume Fig. 9 (The lower part) is a UMCG built from another actual code; Fig. 9 (The upper part) is its corresponding CCG. Fig. 9 Explain. Fig. 9 The UMCG (lower part) is mapped to the class coupling diagram CCG including:

[0130] (5.1)Node construction: based on Fig. 9 (lower part) of the UMCG, the present application parses the class name of each method from the full name of the UMCG, that is, the class corresponding to p1.classX.a(), p1.classX.v(), p1.classX.b(), and p1.classX.c() is p1.classX. Similarly, the class corresponding to p2.classY.d() is p2.classY, and the class corresponding to p2.classZ.e() is p2.classZ. Therefore, the present application can construct three nodes in CCG, named after these three types (such as Fig. 9 shown in the upper part).

[0131] (5.2) Directed edge construction: The edges in CCG are constructed based on the relationship between the classes to which the nodes belong in UMCG, that is, the edge between two method nodes that do not belong to the same class is established as the edge between the corresponding classes in CCG.<p2.classY.d(),p1.classX.v()> The nodes at both ends belong to classes p2.classY and p1.classX respectively, which are different classes. Therefore, a directed edge can be established in CCG.<p2.classY,p1.classX> . Similarly, this application can be constructed<p2.classZ,p2.classY> .

[0132] (5.3) Construction of edge weight: The weight of an edge in CCG is equal to the sum of the weights of all method nodes contained in the classes at both ends of this edge in the direction of this edge in UMCG.<p2.classY,p1.classX> The classes p2.classY at both ends only contain the method p2.classY.d(), and p1.classX contains the methods p1.classX.a(), p1.classX.v(), p1.classX.b(), and p1.classX.c(), but only p2.classY.d() calls p1.classX.a(), so<p2.classY,p1.classX> The edge weight of is 4. Similarly, we can get<p2.classZ,p2.classY> The weight of is 5.

[0133] (6) Use the SLPA algorithm to identify overlapping communities in the class coupling graph, including:

[0134] (6.1) All class nodes in CCG are initialized with unique labels. Fig. 9 In the CCG shown in Figure 1, each node is assigned a unique label, namely: {t1}, {t2} or {t3}, such as Fig.10 (a) in .

[0135] (6.2) Traverse all nodes and update labels.

[0136] (6.2.1) The current class node acts as a listener, and the neighbor node of the current node acts as a speaker. In the embodiment, if the current node is p1.classX, it acts as a listener; the neighbor node of the current node, p2.classY, acts as a speaker.

[0137] (6.2.2) Traverse each neighbor of the current node and pass the neighbor's label to the candidate label storage.

[0138] (6.2.2.1) Calculate the probability of all labels appearing in the current neighbor node label storage. In the embodiment, the label of neighbor p2.classY is {t2}, then its probability is 1 / 1=100%.

[0139] (6.2.2.2) Select a label in proportion to the probability: randomly generate a probability value, if the value is 20% < 100%, then t2 is selected.

[0140] (6.2.2.3) Store {t2} in the tag memory of p1.classX, such as Fig.10 (b) in .

[0141] (6.2.3) Select the label with the highest frequency from the label information set propagated by the neighbor node (the labels re-stored in the candidate label memory) as the new label propagated in this iteration, and store it in the label memory of the current node. In the embodiment, there is only one neighbor, so there is only one label to be transmitted.

[0142] (6.3) The algorithm continues to iterate (step (6.2)) until the algorithm converges or the iteration reaches the specified number of times, such as Fig.10 Medium (c) to Fig.10 (f) in.

[0143] (6.4) Select the two labels with the highest recurrence frequency in the node label memory as the labels of the node. Fig.10 The algorithm stops at (g) in the figure. The top ranking labels are {t2, t1}, {t2, t3}, and {t2, t3}.

[0144] (7) The class coupling graph UCCG is modified according to the co-occurrence times of the nodes at both ends of the edges in the overlapping communities in the class coupling graph CCG.

[0145] (7.1) Based on the overlapping community division results obtained in step (6), count the number of co-occurrences of the class nodes at both ends of each edge in the CCG in the overlapping community. In the embodiment, p1.classX and p2.classY co-occur once in t2, and p2.classY and p2.classZ co-occur twice in t2 and t3.

[0146] (7.2) The number of co-occurrences is added to the weight of this edge as the new edge weight, that is, the new edge weight = the old edge weight + the number of co-occurrences. In the embodiment,<p1.classX,p2.classY> The edge weight of is 5 (i.e. 4+1),<p2.classY,p2.classZ> The edge weight is 7 (i.e. 5+2).

[0147] (8) Use the improved PageRank algorithm to calculate the importance PR of each node in the corrected class coupling graph.

[0148] (8.1) Initialize the initial importance value of each class of nodes in UCCG to 1 / N (N is the number of nodes in UCCG). In the embodiment, PR(p1.classX)=1 / 3, PR(p2.classY)=1 / 3, PR(p2.classZ)=1 / 3.

[0149] (8.2) Traverse all nodes in UCCG and update the importance value of the node. The importance value of the current class node u is updated according to the following formula

[0150]

[0151] Among them, wd(u) represents the weighted degree of u, that is, the sum of the weights of all edges directly connected to node u; wdSum is the sum of the weighted degrees of all nodes; w(v,u) is the sum of the weighted degrees of edges.<v,u> The edge weight on node v; wod(v) is the weighted out-degree of node v; in(u) is the neighbor on the incoming edge of node u. d is the attenuation factor, which takes the default value of 0.85. In the embodiment, if the current node is p1.classX, then wd(p1.classX)=5, wdSum=5+(5+7)+7=24, in(p1.classX)={p2.classY}, then PR(p1.classX)=(0.15*5 / 24)+0.85*(1*5 / (5*3))=0.03125+0.283333=0.3145833.

[0152] (8.3) The algorithm is iterated continuously (step (8.2)) until the algorithm converges to obtain the PR value of each class node. In the embodiment, it can be obtained that PR(p1.classX)=0.126609375, PR(p2.classY)=0.1121875, PR(p2.classZ)=0.04375.

[0153] (9) Arrange the classes in descending order according to their PR values ​​in UCCG, and consider the classes ranked in the top-15% (a threshold recognized in the neighborhood) as key classes. 15% is a threshold recognized in the neighborhood. In the embodiment, the result of descending sorting is: p1.classX, p2.classY, p2.classZ. The embodiment has a total of 3 method nodes, and the top 15%, i.e. 3*15%=0.45, is rounded to 1, so the top 1 class p1.classX in the sorting result is taken as the key class.

[0154] Based on the same inventive concept, the embodiment of the present application also provides a key class identification device for implementing the key class identification method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more key class identification device embodiments provided below can refer to the limitations on the key class identification method above, and will not be repeated here.

[0155] In an exemplary embodiment, a key category identification device is provided, comprising:

[0156] The parsing module is used to parse the text information in the software user manual and generate test cases that conform to the actual operation process.

[0157] A method use case diagram determination and correction module is used to determine the method call diagram based on the test case and the execution trajectory of the software, and to correct the method call diagram; the method call diagram includes a set of method nodes and a set of directed edges executed in real time when the software is running; wherein the set of directed edges is the calling relationship between methods, the direction is from the caller to the callee, and each directed edge is assigned a weight, and the weight is the number of calls between the methods at both ends of the directed edge.

[0158] A mapping module is used to map the corrected method call graph into a class coupling graph.

[0159] The overlapping community identification module is used to identify each overlapping community in the class coupling graph by using the SLPA algorithm.

[0160] The class coupling graph correction module is used to correct the class coupling graph according to the number of co-occurrences of the nodes at both ends of any directed edge in the class coupling graph in the overlapping community, and determine the corrected class coupling graph.

[0161] The importance value determination module is used to calculate the importance value of each class node in the modified class coupling graph by using an improved PageRank algorithm.

[0162] The key class identification module is used to sort all the classes in the modified class coupling diagram according to the importance values, and screen out key classes based on the class sequence.

[0163] (1) This application combines dynamic analysis and community detection to identify key classes, thereby simultaneously considering the impact of the actual behavioral characteristics of the software and the community structure (function) of the class on the importance of the class, providing a new perspective for identifying key classes.

[0164] (2) In this application, the software is run using test cases extracted from the operation manual, which provides a new idea for extracting the execution trace of the software. Compared with the dynamic analysis method based on the software operation log, the strategy used in this application is more general and can be used to obtain the execution trace of more software.

[0165] (3) This application corrects the method call graph through execution pattern mining, and then obtains the class coupling graph, and corrects the class coupling graph through the community to which the class belongs. Compared with the class coupling graph obtained directly through static analysis, this application can further consider the impact of software operation mode and community structure on class importance.

[0166] (4) This application improves the iterative formula of the PageRank algorithm, thereby taking into account the impact of method execution patterns and class community structures on class importance, and improving the accuracy of key class identification, which is of great significance for improving the efficiency of code understanding and maintenance.

[0167] In an exemplary embodiment, a computer device is provided, which may be a server or a terminal. The computer device includes a processor, a memory, an input / output interface (I / O for short) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store key class identification data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a key class identification method is implemented.

[0168] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the above method is implemented when the processor executes the computer program.

[0169] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the above method when executed by a processor.

[0170] In an exemplary embodiment, a computer program product is provided, including a computer program, which implements the above method when executed by a processor.

[0171] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ReadOnlyMemory, ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (Magnetoresistive RandomAccess Memory, MRAM), ferroelectric random access memory (Ferroelectric RandomAccess Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. Volatile memory can include random access memory (RandomAccess Memory, RAM) or external cache memory, etc. By way of illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0172] In this application, all actions to obtain signals, information or data are carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.

[0173] The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but is not limited thereto.

[0174] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0175] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.

Claims

1. A key class identification method, characterized in that: The key class identification method comprises: Parse the text information in the software user manual and generate test cases that conform to the actual operation process; Based on the test case, according to the execution track of the software, a method call graph is determined, and the method call graph is corrected; the method call graph includes a set of method nodes and a set of directed edges executed in real time when the software is running; wherein the set of directed edges is a call relationship between methods, the direction is from the caller to the callee, and each directed edge is assigned a weight, and the weight is the number of calls between the methods at both ends of the directed edge; Map the corrected method call graph to a class coupling graph; Using the SLPA algorithm, identifying overlapping communities in the class coupling graph; According to the number of co-occurrences of nodes at both ends of any directed edge in the class coupling graph in the overlapping community, the class coupling graph is modified to determine a modified class coupling graph; Using an improved PageRank algorithm, the importance value of each class node in the modified class coupling graph is calculated; All classes in the modified class coupling graph are sorted according to the importance values, and key classes are screened out based on the class sequence.

2. The key class identification method according to claim 1, characterized in that: Based on the test case and according to the execution track of the software, determining a method call graph and correcting the method call graph specifically includes: Based on the test case, running the software to determine the execution trajectory of the software; Based on the execution trajectory, the calling relationship between the methods at software runtime is abstracted into a method calling graph; According to the methods called when executing the test case and the calling relationship between the methods, determining to divide the method call graph into a plurality of method call subgraphs; the method call subgraphs are the execution modes corresponding to the test case; Count the number of co-occurrences of the methods at both ends of each directed edge in the method use case diagram in all execution modes; The weights in the method call graph are modified according to the number of co-occurrences to determine a modified method call graph.

3. The key class identification method according to claim 1, characterized in that: Map the corrected method call graph to a class coupling graph, including: Parsing the class name to which each method name in the modified method call graph belongs; According to the class name, construct a node of the class coupling graph; the node is a class node; According to the relationship between the classes to which the methods belong in the modified method call graph, constructing the directed edges of the class coupling graph; Based on the directed edges of the class coupling graph, determine the directed edge weights of the class coupling graph according to the weights of all directed edges in the direction of the directed edge in the corrected method call node of all method nodes contained in the class nodes at both ends of any directed edge; The class coupling graph is constructed according to the nodes, directed edges and directed edge weights of the class coupling graph.

4. The key class identification method according to claim 1, characterized in that: Using the SLPA algorithm, the overlapping communities in the class coupling graph are identified, specifically including: Initialize all class nodes in the class coupling graph as labels; the labels are community labels, and the same label corresponds to class nodes in the same community; Take the current class node as the listener, take the neighbor class node of the current class node as the speaker, traverse all the neighbor class nodes of the current class node, take the label with the highest frequency of the neighbor class node as the new label propagated in this iteration, and store the new label in the candidate label storage of the current class node; Traverse the neighboring class nodes of all class nodes, determine the label storage of each class node, and update the label of each class node; Overlapping communities are determined based on the labels of each class node.

5. The key class identification method according to claim 1, characterized in that: According to the co-occurrence times of the nodes at both ends of any directed edge in the class coupling graph in the overlapping community, the class coupling graph is modified to determine the modified class coupling graph, specifically including: According to the division result of the overlapping communities, counting the number of co-occurrences of the class nodes at both ends of each directed edge in the class coupling graph in the overlapping communities; The weights in the class coupling graph are modified according to the number of co-occurrences to determine a modified class coupling graph.

6. The key class identification method according to claim 1, characterized in that: The improved PageRank algorithm is used to calculate the importance value of each class node in the modified class coupling graph, specifically including: Initializing the initial importance value of each class node in the modified class coupling graph; Using the formula Update the initial importance value, and use the updated importance value as the importance value of each class node in the modified class coupling graph; where PR(u) is the importance value of class node u; wd(u) is the weighted degree of class node u; wdSum is the weighted degree sum of all class nodes; w(v,u) ...<v,u> The edge weight on the node; wod(v) is the weighted out-degree of the node v; in(u) is the neighbor on the incoming edge of the node u; d is the attenuation factor.

7. A key category identification device, characterized in that: The key category identification device comprises: Parsing module, used to parse text information in the software user manual and generate test cases that conform to the actual operation process; A method use case diagram determination and correction module is used to determine a method call diagram based on the test case and the execution trajectory of the software, and to correct the method call diagram; the method call diagram includes a set of method nodes and a set of directed edges executed in real time when the software is running; wherein the set of directed edges is a call relationship between methods, the direction is from the caller to the callee, and each directed edge is assigned a weight, and the weight is the number of calls between the methods at both ends of the directed edge; A mapping module, used for mapping the modified method call graph into a class coupling graph; An overlapping community identification module, used to identify overlapping communities in the class coupling graph using the SLPA algorithm; A class coupling graph correction module, used to correct the class coupling graph according to the number of co-occurrences of nodes at both ends of any directed edge in the class coupling graph in the overlapping community, and determine a corrected class coupling graph; An importance value determination module, used to calculate the importance value of each class node in the modified class coupling graph using an improved PageRank algorithm; The key class identification module is used to sort all the classes in the modified class coupling diagram according to the importance values, and screen out key classes based on the class sequence.

8. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the key class identification method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the key class identification method described in any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the key class identification method described in any one of claims 1 to 6 is implemented.