An API combination recommendation method and device, a computer device, and a storage medium
By constructing a novel API association graph and using optimal Steiner tree search, combined with Simhash and Hamming distance algorithms, the problems of poor accuracy and high redundancy in existing API recommendation methods are solved. This achieves efficient and diverse API combination recommendations, improving the popularity and diversity of recommendation results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- QUFU NORMAL UNIV
- Filing Date
- 2021-12-03
- Publication Date
- 2026-04-21
AI Technical Summary
Existing API recommendation methods suffer from poor accuracy and high redundancy, failing to effectively consider the popularity and diversity of APIs.
By constructing a novel association graph based on API functional keyword elements and historical call counts, and combining optimal Steiner tree search and Simhash algorithms, the API combinations with the highest compatibility and popularity are recommended. The degree of diversity is calculated using Hamming distance to select the optimal API combination.
It improves the accuracy and efficiency of API recommendations, reduces redundancy, broadens developers' choices, and enhances developer satisfaction.
Smart Images

Figure CN114139028B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer technology, and in particular relates to an API combination recommendation method, apparatus, computer device, and storage medium. Background Technology
[0002] Application Programming Interfaces (APIs) are fundamental components for app developers. Because of their composability, programmability, and flexibility, choosing the right API can make app development more convenient and efficient. Typically, app developers search for desired APIs by inputting keywords into API sharing platforms. However, in recent years, the number and complexity of APIs have increased dramatically, making it a major challenge for recommendation systems to recommend suitable APIs to app developers.
[0003] Currently, popular API recommendation methods include keyword-based Steiner tree search algorithms (K-CAR and WARtext) and the ATD algorithm. The K-CAR algorithm first builds an API relationship graph, then performs a Steiner search based on the keywords input by app developers to find the most compatible set of APIs to recommend to users. However, this method ignores API popularity and diversity. The WARtext algorithm considers compatibility and the number of APIs, but similarly neglects popularity and diversity. The ATD algorithm considers both API compatibility and diversity, but it ignores popularity and is less accurate than Steiner tree search. Summary of the Invention
[0004] The purpose of this invention is to provide an API combination recommendation method, which aims to solve the problems of poor accuracy and high redundancy in existing API recommendation methods.
[0005] This invention is implemented as follows: an API combination recommendation method includes:
[0006] Receive user-inputted function keyword information, wherein the function keyword information contains at least one function keyword element;
[0007] Candidate API combinations are determined based on the functional keyword elements and the preset API association diagram; the preset API association diagram is constructed based on the functional keyword elements and historical call counts of the APIs.
[0008] Calculate the degree of diversity among the candidate API combinations, and recommend the API combination with the highest degree of diversity within a preset number of recommendations to the user.
[0009] Another objective of this invention is an API combination recommendation device, comprising:
[0010] A function keyword information receiving unit is used to receive function keyword information input by a user, wherein the function keyword information contains at least one function keyword element;
[0011] The candidate API combination determination unit is used to determine candidate API combinations based on the functional keyword elements and a preset API association diagram; the preset API association diagram is constructed based on the functional keyword elements and historical call counts of the APIs; and
[0012] The recommendation unit is used to calculate the degree of diversity among the candidate API combinations and recommend the API combination with the highest degree of diversity within a preset number of recommendations to the user.
[0013] Another object of the present invention is a computer device including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor causes the processor to perform the steps of the API combination recommendation method.
[0014] Another object of the present invention is a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to perform the steps of the API combination recommendation method.
[0015] The API combination recommendation method provided in this invention constructs a novel API association graph based on API functional keyword elements and historical call counts. In the process of recommending APIs to users, in addition to considering compatibility, it also focuses on popularity factors, making the recommended APIs highly efficient and usable. In addition, the API combinations recommended by this invention have a high degree of diversity, which helps to broaden the choice space for developers, improve developers' satisfaction, and reduce the redundancy of recommendation results. Attached Figure Description
[0016] Figure 1 A flowchart illustrating the implementation of the API combination recommendation method provided in this embodiment of the invention;
[0017] Figure 2 The API association graph and optimal Steiner tree search graph provided for embodiments of the present invention;
[0018] Figure 3 This is a diagram illustrating the steps involved in constructing an API association graph according to an embodiment of the present invention.
[0019] Figure 4A preferred diagram illustrating the construction steps of an API association graph provided in an embodiment of the present invention;
[0020] Figure 5 A flowchart illustrating the implementation of a preferred API combination recommendation method provided in an embodiment of the present invention;
[0021] Figure 6 A flowchart illustrating the implementation of another preferred API combination recommendation method provided in this embodiment of the invention;
[0022] Figure 7 A bar chart showing the average popularity of API combinations in the recommendation results provided in this embodiment of the invention;
[0023] Figure 8 A bar chart showing the average diversity of API combinations in the recommendation results provided in this embodiment of the invention;
[0024] Figure 9 A coverage curve of functional keywords included in the API combinations in the recommendation results provided by the embodiments of the present invention;
[0025] Figure 10 A redundancy curve of functional keywords contained in API combinations in the recommendation results provided by the embodiments of the present invention;
[0026] Figure 11 This is a structural block diagram of the API combination recommendation device provided in an embodiment of the present invention;
[0027] Figure 12 This is a structural block diagram of the candidate API combination determination unit in the API combination recommendation device provided in an embodiment of the present invention;
[0028] Figure 13 This is a structural block diagram of the recommendation unit in the API combination recommendation device provided in an embodiment of the present invention;
[0029] Figure 14 This is a block diagram of the internal structure of a computer device in one embodiment. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0031] It is understood that the terms "first," "second," etc., used in this application may be used herein to describe various elements, but unless otherwise specified, these elements are not limited by these terms. These terms are used only to distinguish one element from another. For example, without departing from the scope of this application, a first script may be referred to as a second script, and similarly, a second script may be referred to as a first script.
[0032] To address the issues of poor accuracy and high redundancy in existing API recommendation methods, this invention provides an API combination recommendation method. This method constructs a novel API association graph based on API functional keywords and historical call counts. In recommending APIs to users, it considers not only compatibility but also popularity, resulting in highly efficient and usable recommended APIs. Furthermore, the API combinations recommended by this invention offer significant diversity, broadening developers' choices, increasing developer satisfaction, and reducing redundancy in the recommendation results.
[0033] Figure 1 The following is a detailed flowchart of the implementation of an API combination recommendation method provided in an embodiment of the present invention.
[0034] Step S101: Receive function keyword information input by the user, wherein the function keyword information contains at least one function keyword element.
[0035] Step S102: Determine candidate API combinations based on the functional keyword elements and the preset API association diagram.
[0036] In this embodiment of the invention, the preset API association graph is constructed based on the functional keyword elements of the APIs and their historical call counts. Specifically, a new API association graph with compatibility and popularity information is established based on historical API usage records. Compatibility represents the degree of cooperation between APIs (the higher the better), while popularity represents the number of times an API is called, reflecting API quality (the higher the better). By establishing this new API association graph and performing an optimal Steiner tree search based on the requirement keywords input by the APP developers, this invention can obtain candidate API combinations.
[0037] In embodiments of the present invention, such as Figure 2(a) is an API relationship graph. Creating a relationship graph essentially involves formalizing the information already existing in the database. Currently, the database contains: various APIs; the functional categories of each API; and records of previous API calls by the app. Each API is considered a point v, and each API's functional category is considered its functional keyword. For example, in the left diagram of (a), the functional keyword (element) of the API considered as point v1 is k1.
[0038] In this embodiment of the invention, the specific steps for constructing the preset API association graph are as follows: Figure 3 As shown, it includes the following steps:
[0039] Step S301: Statistically analyze the historical call counts of each API for each APP to obtain edge weights and vertex weights.
[0040] In embodiments of the present invention, such as Figure 4 As shown, step S301 includes:
[0041] Step S401: Obtain the number of times any two APIs are called simultaneously by the same APP to get the edge weights.
[0042] In this embodiment of the invention, if any two APIs have been called by the same app, then there is an undirected edge connecting their corresponding nodes, representing their cooperativeness and compatibility. The number of times any two APIs have been called by the same app represents their degree of compatibility, presented as edge weights in the API association graph, for example... Figure 2 In the left figure (a), there is an edge connecting points v1 and v2, which means that the two APIs are compatible. The weight of the edge is 5, which means that the two APIs have been called by the same APP 5 times.
[0043] Step S402: Count the number of calls to each API corresponding to each APP, and sum the number of calls to obtain the point weight.
[0044] In this embodiment of the invention, the total number of times each API is called by all apps is used as the popularity value of that API, and it is presented as a point weight value in the association graph, for example in... Figure 2 In the left figure (a), the weight value of point v1 is 1, which means that it is called a total of 1 time by all apps.
[0045] Step S302: Normalize the edge weights and point weights.
[0046] In an embodiment of the present invention, Figure 2(a) The left figure is a well-constructed API association graph with compatibility and popularity information. To normalize the data, the reciprocal of all weights in the graph is taken. Figure 2 (a) Right figure.
[0047] Step S303: Based on the functional keyword elements of each API, as well as the edge weights and node weights, construct an API association graph with each API as a node.
[0048] The API combination recommendation method provided in this invention establishes a novel API association graph. This graph not only reflects the functional keywords of each API, but also reflects the compatibility and popularity information of the APIs. Whether APIs are compatible, the degree of compatibility, and the popularity of each API can all be clearly seen from the graph, and it provides the premise and foundation for the implementation of the following steps.
[0049] In this embodiment of the invention, based on the requirement keywords input by the APP developers, the optimal Steiner tree search technique is used in the API association graph to find candidate API combinations with high compatibility and popularity. Figure 2 The Steiner tree search process mainly involves tree growth and merging. Growth involves adding neighboring nodes of the root node to the tree, making the newly added node the new root node, and merging the function keywords of the newly added node into the new tree's key set. Merging occurs when two trees share the same root node, their key sets intersect (which is empty), and their union has more elements than either key set. In this case, the root nodes of the two trees are merged into a single root node, and the two trees are combined into one tree.
[0050] In a preferred embodiment of the present invention, such as Figure 5 As shown, step S102 specifically includes:
[0051] Step S501: Determine the API combination that contains any of the aforementioned functional keyword elements in the preset API association diagram.
[0052] Step S502: Obtain the set of functional keyword elements corresponding to the API combination, as well as the sum of edge weights and vertex weights.
[0053] Step S503: Determine candidate API combinations based on the set of functional keyword elements corresponding to the API combination and the sum of edge weights and vertex weights.
[0054] In this embodiment of the invention, with Figure 2For example, suppose an app developer inputs the requirement keywords MK = {k1,k2,k3}. This invention first needs to find nodes v1, v3, v4, v5 in the function keyword set that contain elements from MK, and then use these nodes as the root nodes of the tree to perform a tree growth and merging process. In this invention, MK' is defined as the requirement keyword set of the tree, and MK' only contains elements from the keyword set of this tree that exist in MK. Let M be the sum of the edge weights and vertex weights of this tree, which is also the sum of compatibility and popularity. It is a comprehensive value for evaluating the compatibility and popularity of this tree (because of the normalization of the values, the smaller the value of M, the better). Figure 2 (c) represents the growth result of (b). This invention places all trees into a priority queue, updating the queue after each growth or merging process. For trees with the same root node and identical MK', this invention retains only the tree with the smallest M value, deleting the others. If M values are the same, and a tree with the same node has already been retained, this invention also deletes that tree. For example, in... Figure 2 In (c), two trees have the same root node v4 and MK' equal to {k2,k3}. Therefore, this invention deletes the tree with M=1.7 (cross), because M=1.6 is the tree with the smallest M value. During the iterative growth and merging process, if a tree's MK' equals MK, this invention adds this tree to the result queue as one of the candidate results (checkmark). Specifically, this invention deletes the first tree in (f) because a tree with the same root node, the same MK' and M, and identical nodes has already been retained. Finally, all trees with checkmarks are candidate trees selected by this invention in the result queue for use in the next step.
[0055] The API combination recommendation method provided in this embodiment of the invention, in the process of performing the optimal Steiner tree search, not only considers the optimal compatibility, but also adds the objective of optimal popularity, and filters out all API combinations that meet the keywords required by developers and have the best compatibility and popularity.
[0056] Step S103: Calculate the diversity level among the candidate API combinations, and recommend the API combination with the highest diversity level within the preset recommendation number to the user.
[0057] In this embodiment of the invention, the Simhash algorithm and Hamming distance can be used to calculate the dissimilarity between two documents. Here, this invention is used to calculate the functional dissimilarity between two trees. For example, suppose the set of functional keywords of a tree (the union of all API keywords in this tree) is {k1, k2}. The methods of Simhash and Hamming distance are explained below. Figure 6 As shown, step S103 specifically includes:
[0058] Step S601: Perform hash function processing on each functional keyword element corresponding to each candidate API combination to obtain the hash value of each functional keyword element.
[0059] In this embodiment of the invention, the first step of Simhash is to segment the document into words. Here, the invention uses the elements in the functional keyword set of each tree as the segmentation result; then, the hash function is used to hash each keyword and obtain a binary hash value (hash value) of the same number of bits. It is assumed that the hash values of k1 and k2 obtained by this invention are 1010 and 0110, respectively.
[0060] Step S602: Convert the hash value into a hash vector and assign weights to each functional keyword element to obtain a weight vector for each keyword element.
[0061] In this embodiment of the invention, each hash value is transformed into a hash vector, with 1 becoming 1 and 0 becoming -1. Then, each keyword is assigned a weight, resulting in a final weight vector for each keyword. For example, the hash vectors of k1 and k2 are (1, -1, 1, -1) and (-1, 1, 1, -1), respectively. Assuming k1 and k2 are assigned the same weight of 1, their weight vectors are (1, -1, 1, -1)*1 = (1, -1, 1, -1) and (-1, 1, 1, -1)*1 = (-1, 1, 1, -1), respectively.
[0062] Step S603: The weight vector of each keyword element is accumulated to obtain the merging result, and the dimensionality reduction process is performed on the merging result to obtain the dimensionality reduction result of each candidate API combination.
[0063] In this embodiment of the invention, since the weight vectors of all keywords have the same number of bits, the weight values at the same bits are accumulated to obtain a merged result. For example, the merged result of k1 and k2 is (0, 0, 2, -2). Then, the merged result is subjected to dimensionality reduction processing. The principle of dimensionality reduction is that a bit greater than 0 is recorded as 1, and a bit less than or equal to 0 is recorded as 0. Then the dimensionality reduction result of this tree is (0, 0, 1, 0).
[0064] Step S604: Based on the dimensionality reduction result of the candidate API combinations, calculate the Hamming distance between any two candidate API combinations, and recommend the API combination with the largest Hamming distance within the preset recommendation limit to the user.
[0065] In this embodiment of the invention, the above describes the entire process of Simhash for a tree. Then, for the Simhash results of any two trees, the invention uses Hamming distance to calculate their dissimilarity. Hamming distance represents the number of corresponding positions that differ between two strings of the same length. For example, in the example above, the Simhash result of this tree is (0, 0, 1, 0). Assuming the Simhash result of another tree is (1, 0, 0, 1), the Hamming distance between the two trees is 3, which can also represent a dissimilarity of 3 between the two trees. The invention ultimately recommends k API combinations, i.e., k trees, to developers. Therefore, the invention arranges and combines the trees in the result queue to form multiple sets containing k trees. For each set, the dissimilarity between trees is calculated to represent its diversity. Finally, the k trees from the set with the best diversity, i.e., the k API combinations, are recommended to developers.
[0066] The API combination recommendation method provided in this embodiment of the invention uses the Simhash algorithm and Hamming distance to calculate the diversity between API combinations, and selects the k API combinations with the highest diversity to recommend to APP developers.
[0067] Furthermore, this invention crawled data from the API sharing platform ProgrammableWeb.com and conducted experiments. Extensive comparative experiments with K-CAR and WARtext demonstrated that the technology of this invention has significant advantages in terms of the popularity and diversity of API combination recommendations. Let K-CAR be A, WARtext be B, and the technology of this invention be C (see...). Figure 7-10 (And assuming the app developers input 2-6 keywords, and ultimately recommend 5 API combinations to the user, after 30 experiments, this invention uses the average values of various metrics for comparison.) Figure 7-10 List.
[0068] like Figure 7 As shown, the comparison is the average popularity of API combinations in the recommendation results. Since the vertical axis is the reciprocal of the popularity, the lower the value, the better the popularity. It can be seen from the figure that the technology of this invention achieves the best popularity of recommended API combinations when the number of demand keywords ranges from 2 to 6.
[0069] like Figure 8 As shown, the comparison is the average diversity of API combinations in the recommendation results. This invention uses Hamming distance to represent the dissimilarity of API combinations, i.e., diversity. Therefore, the higher the value, the better the diversity. As can be seen from the figure, the technology of this invention has the best average diversity of recommended API combinations when the number of demand keywords ranges from 2 to 6.
[0070] like Figure 9 As shown, the comparison focuses on the coverage of functional keywords included in the recommended API combinations. Under the premise of meeting user needs, the more functional keywords included in the API combinations recommended by this invention, the better; that is, the higher the coverage value, the better. The figure shows that the technology of this invention achieves the best average coverage of the recommended API combinations when the number of required keywords ranges from 2 to 6. This is because the technology of this invention emphasizes increasing diversity, thus increasing the coverage accordingly.
[0071] like Figure 10 As shown, the comparison focuses on the redundancy of functional keywords in the recommended API combinations. Under the premise of meeting user needs, the more different the functional keywords in the recommended API combinations are, the better. This is because similar functional keywords can only provide similar functions, leading to unnecessary redundancy. Therefore, a lower redundancy value is better. The figure shows that the technology of this invention achieves the lowest average redundancy in recommended API combinations when the number of required keywords ranges from 2 to 6. This is because the technology of this invention emphasizes the diversity of recommended results; greater dissimilarity between them naturally results in lower redundancy.
[0072] Figure 11 A structural block diagram of an API combination recommendation device provided in an embodiment of the present invention is described in detail below:
[0073] In this embodiment of the invention, the API combination recommendation device includes:
[0074] The function keyword information receiving unit 1110 is used to receive function keyword information input by the user, wherein the function keyword information contains at least one function keyword element.
[0075] The candidate API combination determination unit 1120 is used to determine candidate API combinations based on the functional keyword elements and a preset API association diagram; the preset API association diagram is constructed based on the functional keyword elements and historical call counts of the APIs.
[0076] In embodiments of the present invention, such as Figure 12 As shown, the candidate API combination determination unit 1120 includes:
[0077] The first determining module 1121 is used to determine, in a preset API association diagram, an API combination that contains any of the aforementioned functional keyword elements.
[0078] The acquisition module 1122 is used to acquire the set of functional keyword elements corresponding to the API combination, as well as the sum of edge weights and point weights.
[0079] The second determining module 1123 is used to determine the candidate API combination based on the set of functional keyword elements corresponding to the API combination and the sum of edge weights and point weights.
[0080] The recommendation unit 1130 is used to calculate the degree of diversity among the candidate API combinations and recommend the API combination with the highest degree of diversity within a preset number of recommendations to the user.
[0081] In embodiments of the present invention, such as Figure 13 As shown, the recommendation unit 1130 includes:
[0082] The hash value determination module 1131 is used to perform hash function processing on each functional key element corresponding to each candidate API combination to obtain the hash value of each functional key element.
[0083] The weight vector determination module 1132 is used to transform the hash value into a hash vector and assign weights to each functional keyword element to obtain the weight vector of each keyword element.
[0084] The dimensionality reduction result determination module 1133 is used to accumulate the weight vector of each keyword element to obtain the merging result, and to perform dimensionality reduction processing on the merging result to obtain the dimensionality reduction result of each candidate API combination.
[0085] The recommendation module 1134 is used to calculate the Hamming distance between any two candidate API combinations based on the dimensionality reduction result of the candidate API combinations, and recommend the API combination with the largest Hamming distance within a preset number of recommendations to the user.
[0086] Figure 14 An internal structural diagram of a computer device in one embodiment is shown. Figure 14 As shown, the computer device includes a processor, memory, network interface, input device, and display screen connected via a system bus. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores an operating system and may also store computer programs. When executed by the processor, these computer programs enable the processor to implement the API combination recommendation method. The internal memory may also store computer programs, which, when executed by the processor, enable the processor to execute the API combination recommendation method. The display screen can be an LCD screen or an e-ink screen. The input device can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0087] Those skilled in the art will understand that Figure 14The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0088] In one embodiment, the API combination recommendation device provided in this application can be implemented as a computer program, which can be implemented as follows: Figure 14 It runs on the computer device shown. The computer device's memory can store the various program modules that make up the API combination recommendation device, for example, Figure 11 The functional keyword information receiving unit 1110, candidate API combination determination unit 1120, and recommendation unit 1130 are shown. The computer program, comprised of these program modules, causes the processor to execute the steps in the API combination recommendation methods of the various embodiments of this application described in this specification.
[0089] For example, Figure 14 The computer equipment shown can be used as follows Figure 11 The functional keyword information receiving unit 1110 in the API combination recommendation device shown executes step S101. The computer device can execute step S102 through the candidate API combination determination unit 1120. The computer device can execute step S103 through the recommendation unit 1130.
[0090] In one embodiment, a computer device is provided, the computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, performs the following steps:
[0091] The system receives user-inputted function keyword information, which includes at least one function keyword element.
[0092] Candidate API combinations are determined based on the functional keyword elements and the preset API association diagram; the preset API association diagram is constructed based on the functional keyword elements and historical call counts of the APIs.
[0093] Calculate the degree of diversity among the candidate API combinations, and recommend the API combination with the highest degree of diversity within a preset number of recommendations to the user.
[0094] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, causes the processor to perform the following steps:
[0095] The system receives user-inputted function keyword information, which includes at least one function keyword element.
[0096] Candidate API combinations are determined based on the functional keyword elements and the preset API association diagram; the preset API association diagram is constructed based on the functional keyword elements and historical call counts of the APIs.
[0097] Calculate the degree of diversity among the candidate API combinations, and recommend the API combination with the highest degree of diversity within a preset number of recommendations to the user.
[0098] It should be understood that although the steps in the flowcharts of the various embodiments of the present invention are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the various embodiments may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.
[0099] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0100] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.
[0101] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
[0102] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. An API combination recommendation method, characterized by, include: Receive user-inputted function keyword information, wherein the function keyword information contains at least one function keyword element; Based on the functional keyword elements and the preset API association diagram, determine the candidate API combinations; The preset API association diagram is constructed based on the API's functional keyword elements and historical call counts; Calculate the degree of diversity among the candidate API combinations, and recommend the API combination with the highest degree of diversity within a preset number of recommendations to the user; The step of determining candidate API combinations based on the functional keyword elements and the preset API association diagram includes: In the preset API association diagram, identify API combinations that contain any of the aforementioned functional keyword elements; Obtain the set of functional keyword elements corresponding to the API combination, as well as the sum of edge weights and vertex weights; Candidate API combinations are determined based on the set of functional keyword elements corresponding to the API combination and the sum of edge weights and vertex weights. The steps for constructing the preset API association graph include: The historical call counts of each API for each corresponding APP are statistically analyzed to obtain the edge weights and vertex weights; The edge weights and vertex weights are normalized. Based on the functional keyword elements of each API, as well as the edge weights and vertex weights, construct an API association graph with each API as a node. The step of statistically analyzing the historical call counts of each API for each APP to obtain edge weights and vertex weights includes: Get the edge weight by obtaining the number of times any two APIs are called simultaneously by the same app; The number of times each API is called by each APP is counted, and the number of calls is summed to obtain the point weight; The step of calculating the diversity among the candidate API combinations and recommending the API combination with the highest diversity within a preset number of recommendations to the user includes: For each functional keyword element corresponding to each candidate API combination, perform a hash function to obtain the hash value of each functional keyword element; The hash value is transformed into a hash vector and a weight is assigned to each functional keyword element to obtain a weight vector for each keyword element; The weight vectors of each keyword element are summed to obtain the merged result, and the merged result is then subjected to dimensionality reduction processing to obtain the dimensionality reduction result of each candidate API combination. Based on the dimensionality reduction result of the candidate API combinations, calculate the Hamming distance between any two candidate API combinations, and recommend the API combination with the largest Hamming distance within a preset number of recommendations to the user.
2. An API combination recommendation apparatus characterized by comprising: include: A function keyword information receiving unit is used to receive function keyword information input by a user, wherein the function keyword information contains at least one function keyword element; The candidate API combination determination unit is used to determine candidate API combinations based on the functional keyword elements and a preset API association diagram; the preset API association diagram is constructed based on the functional keyword elements and historical call counts of the APIs. as well as The recommendation unit is used to calculate the degree of diversity among the candidate API combinations and recommend the API combination with the highest degree of diversity within a preset number of recommendations to the user. The candidate API combination determination unit includes: The first determining module is used to determine, in a preset API association diagram, an API combination that contains any of the aforementioned functional keyword elements; The acquisition module is used to acquire the set of functional keyword elements corresponding to the API combination, as well as the sum of edge weights and vertex weights; and The second determining module is used to determine candidate API combinations based on the set of functional keyword elements corresponding to the API combination and the sum of edge weights and vertex weights. The recommendation unit includes: The hash value determination module is used to perform hash function processing on each functional key element corresponding to each candidate API combination to obtain the hash value of each functional key element; The weight vector determination module is used to transform the hash value into a hash vector and assign weights to each functional keyword element to obtain the weight vector of each keyword element. The dimensionality reduction result determination module is used to accumulate the weight vectors of each keyword element to obtain a merged result, and then perform dimensionality reduction processing on the merged result to obtain the dimensionality reduction result for each candidate API combination; and The recommendation module is used to calculate the Hamming distance between any two candidate API combinations based on the dimensionality reduction result of the candidate API combinations, and recommend the API combination with the largest Hamming distance within a preset number of recommendations to the user. The steps for constructing the preset API association graph include: The historical call counts of each API for each corresponding APP are statistically analyzed to obtain the edge weights and vertex weights; The edge weights and vertex weights are normalized. Based on the functional keyword elements of each API, as well as the edge weights and vertex weights, construct an API association graph with each API as a node. The step of statistically analyzing the historical call counts of each API for each APP to obtain edge weights and vertex weights includes: Get the edge weight by obtaining the number of times any two APIs are called simultaneously by the same app; The number of times each API is called by each APP is counted, and the number of calls is summed to obtain the point weight.
3. A computer device, comprising: It includes a memory and a processor, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of the API combination recommendation method of any one of claims 1.
4. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the steps of the API combination recommendation method of any one of claims 1.