API aggregation method and device, electronic equipment and storage medium
By building the initial API tree and aggregating child nodes in the API aggregation method, the problem of difficulty in judging complex parameter nodes in the existing technology is solved, and more accurate and efficient API aggregation is achieved, which is suitable for the processing of complex URLs.
Patent Information
- Application Number
- CN202311754131.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-19
- Publication Date
- 2025-06-20
AI Technical Summary
Existing API aggregation methods are difficult to determine nodes with node names as complex parameters, resulting in the inability to effectively aggregate the API.
By determining the confidence of each URL node in the URL to be processed corresponding to the API, an initial API tree is built, and sub-nodes are aggregated when the specific threshold conditions are met to form a target API tree, thereby realizing the judgment and aggregation of complex parameter nodes.
This method can accurately judge complex parameter nodes, improve the accuracy and efficiency of API aggregation, and save storage space through the storage form of API tree, which is suitable for the processing of extended and new URLs.
Smart Images

Figure CN120179757A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computers, and in particular, to an API aggregation method, device, electronic device, and storage medium. Background Art
[0002] Existing API (Application Programming Interface) aggregation methods mainly aggregate based on rule matching. This rule-based matching method can only simply judge relatively single parameters such as numbers, time and dates, IP (Internet Protocol Address), hash strings, etc. on a single traffic. For example, when there is a data of a type such as time and date, IP, hash string, etc. in a node of the URL (Uniform Resource Locator) of the traffic log, it is considered that the node of the URL is a variable node, and a variable node is a node with an unfixed node name. However, the existing API aggregation method can only be applied to identify variable nodes with relatively single parameters such as numbers, time and dates, IP, hash strings, etc. for the node name, and it is difficult to judge nodes with complex parameters for the node name. Summary of the Invention
[0003] The present application provides an API aggregation method, device, electronic device, and storage medium to solve the problem that it is difficult to judge nodes with complex parameters for the node name in the prior art.
[0004] In a first aspect, the present application provides an API aggregation method, including: determining the confidence of each URL node in the to-be-processed URL corresponding to the API, and constructing an initial API tree; the confidence represents the probability that the corresponding URL node is a variable node; each path from the root node to the leaf node in the initial API tree corresponds to a to-be-processed URL, and the nodes in each path include all URL nodes of the corresponding to-be-processed URL; wherein, the domain names of all to-be-processed URLs used to construct the initial API tree are the same, and the root node of the initial API tree is the URL node representing the domain name; in the case that the number of child nodes of a node in the initial API tree is greater than a first preset child node threshold, aggregating all child nodes with a confidence greater than a preset confidence threshold among the child nodes of the node into a new child node to obtain a target API tree; traversing all paths of the target API tree to obtain all aggregated APIs included in the target API tree.
[0005] In the embodiment of the present application, after constructing the initial API tree, if the number of child nodes of a node is greater than the preset child node threshold, it indicates that the child nodes of this node may be variable nodes. Then, the confidence of the child nodes is further used for judgment. Since the confidence represents the probability that the URL node is a variable node, therefore, the possibility that the child nodes are variable nodes can be determined through the confidence of the child nodes. If it is determined that the child nodes are variable nodes, all the child nodes determined to be variable nodes are aggregated, and then all APIs can be obtained according to the aggregated target API tree. This solution can combine different URLs to judge variable nodes, and the basis for judging whether it is a variable node in this solution includes the confidence of the nodes. Compared with the method in the prior art that can only judge according to the data type of the node name, this solution can realize the judgment of relatively complex node names. Moreover, in this solution, the APIs are stored in the form of an API tree, which can save the storage space required for storing the APIs, and even if a new URL to be processed is received subsequently, it can be further extended on the original target API tree, improving the application scope of this solution.
[0006] Combined with the technical solution described in the first aspect above, in some possible implementation manners, determining the confidence of each URL node in each URL to be processed includes: for each URL node in each URL to be processed: performing word segmentation processing on the URL node to obtain a plurality of word segments; and obtaining the confidence of the URL node based on the plurality of word segments and a preset confidence determination rule.
[0007] In the embodiment of the present application, by performing word segmentation processing on the URL node and then determining the confidence based on each word segment, it is more accurate than the method of determining the confidence for the entire URL node.
[0008] Combined with the technical solution described in the first aspect above, in some possible implementation manners, before performing word segmentation processing on the URL node, the method further includes: determining whether the URL node is preset type data; correspondingly, performing word segmentation processing on the URL node includes: in the case where the URL node is not preset type data, performing word segmentation processing on the URL node.
[0009] Combined with the technical solution described in the first aspect above, in some possible implementation manners, the method further includes: in the case where the URL node belongs to preset type data, obtaining the confidence of the URL node based on the corresponding relationship between the preset type data and the confidence.
[0010] In the embodiments of the present application, by first determining whether the URL node is pre-set type data, when the URL node belongs to the pre-set type data, the confidence level of the URL node can be directly obtained based on the corresponding relationship between the pre-set type data and the confidence level. When the URL node does not belong to the pre-set type data, the URL node is then subjected to word segmentation processing. Thus, when the URL node is pre-set type data, word segmentation processing can be avoided, reducing the amount of calculation.
[0011] Combined with the technical solution described in the first aspect above, in some possible implementation manners, the pre-set type data includes at least one of UUID (Universally Unique Identifier), number, hash string, IP, date and time, ID card number, and Chinese.
[0012] Combined with the technical solution described in the first aspect above, in some possible implementation manners, obtaining the confidence level of the URL node based on the multiple word segments and the pre-set confidence level determination rule includes: performing statistical processing on the multiple word segments to obtain the total number of word segments and the proportion of the word segment lengths; wherein, the proportion of the word segment lengths represents the ratio of the total number of word segments of each length in the multiple word segments to the total number of word segments; and obtaining the confidence level of the URL node based on the multiple word segments, the total number of word segments, the proportion of the word segment lengths, and the pre-set confidence level determination rule.
[0013] In the embodiments of the present application, by performing statistical processing on the multiple word segments to obtain the total number of word segments and the proportion of the word segment lengths, the confidence level of the URL node can then be determined according to the multiple word segments, the total number of word segments, and the proportion of the word segment lengths. Since there are more types of parameters for determining the confidence level, the accuracy of the finally determined confidence level is relatively higher.
[0014] Combined with the technical solution described in the first aspect above, in some possible implementation manners, the confidence level determination rule includes multiple sub-rules, and each sub-rule corresponds to a confidence level increment respectively, and the confidence level increment is used to represent the confidence level score when the URL node meets the corresponding sub-rule. Obtaining the confidence level of the URL node based on the multiple word segments, the total number of word segments, the proportion of the word segment lengths, and the pre-set confidence level determination rule includes: determining all the sub-rules that the URL node meets based on the multiple word segments, the total number of word segments, and the proportion of the word segment lengths; and adding up the confidence level increments corresponding to each sub-rule that the URL node meets to obtain the confidence level of the URL node.
[0015] In the embodiments of the present application, since each sub-rule corresponds to a confidence increment, by determining all the sub-rules satisfied by the URL node, the confidence increments corresponding to each sub-rule satisfied by the URL node can be added together to obtain the confidence of the URL node. As a result, the obtained confidence fully takes into account each sub-rule satisfied by the URL node, thereby improving the accuracy of the finally obtained confidence.
[0016] Combined with the technical solution described in the first aspect above, in some possible implementation manners, the preset confidence determination rule includes: the total number of word segments is greater than a first preset threshold; the total number of word segments is within a first preset word segment quantity range, and the number of word segments that are numbers among all word segments is greater than a second preset threshold; the total number of word segments is within a second preset word segment quantity range, and the length of the word segments that are numbers is greater than a third preset threshold; all word segments are numbers; there are more than two word segments that are numbers, and the ratio of the number of word segments that are numbers to the total number of word segments is greater than at least one sub-rule of a fourth preset threshold.
[0017] Combined with the technical solution described in the first aspect above, in some possible implementation manners, the first-layer nodes of the initial API tree represent the number of URL nodes; the first-layer nodes are the child nodes of the root node; correspondingly, by traversing all paths of the target API tree, all APIs included in the target API tree are obtained, including: for each path of the target API tree, the URL nodes included in all nodes except the first-layer nodes in this path are spliced in the order from the root node to the leaf node according to the hierarchical relationship between the nodes to obtain the API.
[0018] In the embodiments of the present application, since the number of nodes of different URLs corresponding to the same API must be the same, the first-layer nodes of the initial API tree are set as the number of URL nodes, so as to ensure that the number of nodes of all URLs corresponding to each first-layer node is the same, thereby preventing the situation of incorrect aggregation caused by aggregating URLs of different lengths.
[0019] Combined with the technical solution described in the first aspect above, in some possible implementation manners, aggregating all child nodes with confidence greater than a preset confidence threshold among the child nodes of this node into a new child node includes: judging whether the number of all child nodes with confidence greater than a preset confidence threshold among the child nodes of this node is greater than or equal to a second preset child node threshold; wherein, the second preset child node threshold is less than or equal to the first preset child node threshold; if it is greater than or equal to the second preset child node threshold, aggregate all child nodes with confidence greater than a preset confidence threshold among the child nodes of this node into a new child node.
[0020] In a second aspect, the present application provides an API aggregation device, including: a determination module and a processing module. The determination module is configured to determine the confidence of each URL node in the to-be-processed URL corresponding to the API, and construct an initial API tree; the confidence represents the probability that the corresponding URL node is a variable node; each path from the root node to the leaf node in the initial API tree corresponds to a to-be-processed URL, and the nodes in each path include all URL nodes of the corresponding to-be-processed URL; wherein, all the to-be-processed URLs used to construct the initial API tree have the same domain name, and the root node of the initial API tree is the URL node representing the domain name; the processing module is configured to, when the number of child nodes of a node in the initial API tree is greater than a first preset child node threshold, aggregate all child nodes with a confidence greater than a preset confidence threshold among the child nodes of the node into a new child node to obtain a target API tree; the processing module is further configured to traverse all paths of the target API tree to obtain all aggregated APIs included in the target API tree.
[0021] In a third aspect, the present application provides an electronic device, including: a memory and a processor, the memory is connected to the processor; the memory is configured to store a program; the processor is configured to call the program stored in the memory to execute the API aggregation method according to the first aspect and / or any possible implementation manner in combination with the first aspect.
[0022] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a computer, it executes the API aggregation method according to the first aspect and / or any possible implementation manner in combination with the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required to be used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application, and thus should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0024] Figure 1 It is a schematic flowchart of the API aggregation method shown in the embodiments of the present application;
[0025] Figure 2 It is a schematic structural diagram of the first initial API tree shown in the embodiments of the present application;
[0026] Figure 3 It is a schematic structural diagram of the second initial API tree shown in the embodiments of the present application;
[0027] Figure 4 It is a schematic structural diagram of the target API tree shown in the embodiments of the present application;
[0028] Figure 5 It is a structural block diagram of the API aggregation device shown in the embodiments of the present application;
[0029] Figure 6 It is a structural block diagram of the electronic device shown in the embodiments of the present application. Detailed implementation manners
[0030] Next, the technical solutions in the embodiments of the present application will be described with reference to the accompanying drawings in the embodiments of the present application.
[0031] It should be noted that: similar reference numerals and letters denote similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of the present application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover a non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not expressly listed, or elements inherent to such process, method, article or device.
[0032] Next, the technical solutions of the present application will be described in detail with reference to the drawings.
[0033] Please refer to Figure 1 , Figure 1 which is an API aggregation method shown in the embodiments of the present application. Next, the steps it includes will be described with reference to Figure 1 and explained.
[0034] S100: Determine the confidence of each URL node in the to-be-processed URL corresponding to the API, and construct an initial API tree.
[0035] The confidence represents the probability that the corresponding URL node is a variable node; each path from the root node to the leaf node in the initial API tree corresponds to a to-be-processed URL, and the nodes in each path include all URL nodes of the corresponding to-be-processed URL. Among them, the domain names of all to-be-processed URLs used to construct the initial API tree are the same, and the root node of the initial API tree is the URL node representing the domain name.
[0036] Among them, it can be that the higher the confidence, the greater the probability that the corresponding URL node is a variable node.
[0037] To facilitate the understanding of URL nodes, take the URL to be processed http: / / t.com / a / b / c / 1 / g / 9 as an example for illustration. The URL nodes of this URL to be processed include seven nodes: t.com, a, b, c, 1, g, and 9. This example is only for ease of explanation and should not be regarded as a limitation of this application.
[0038] Optionally, before determining the confidence of each URL node in each URL to be processed, the URL to be processed can also be segmented by nodes to obtain multiple URL nodes.
[0039] In one implementation, the specific method for determining the confidence of each URL node in each URL to be processed can be: for each URL node in each URL to be processed: perform word segmentation on the URL node to obtain multiple words. Then, based on the multiple words and a preset confidence determination rule, obtain the confidence of the URL node.
[0040] By performing word segmentation on the URL node and then determining the confidence based on each word, it is more accurate than the method of determining the confidence for the entire URL node.
[0041] Performing word segmentation on the URL node can be to perform word segmentation on the URL node using methods such as natural language processing (NLP). The specific methods for performing word segmentation on the URL node include, but are not limited to, the above natural language processing.
[0042] In one implementation, the specific method for obtaining the confidence of the URL node based on multiple words and a preset confidence determination rule can be: match each word with each matching condition in the confidence determination rule, and take the sum of the confidences corresponding to all the matching conditions that match successfully as the confidence of the URL node.
[0043] For example, if the confidence determination rule includes Rule 1, Rule 2, and Rule 3, and the confidence corresponding to Rule 1 is a, the confidence corresponding to Rule 2 is b, and the confidence corresponding to Rule 3 is c; the words corresponding to the target URL node include Word 1 and Word 2. If Word 1 matches Rule 1 successfully and Word 2 matches Rule 1 and Rule 2 successfully, then the confidence of the target URL node is a + a + b. This example is only for ease of understanding and should not be regarded as a limitation of this application.
[0044] Optionally, based on multiple word segments and a preset confidence determination rule, the specific method for obtaining the confidence of this URL node may be: performing statistical processing on multiple word segments to obtain the total number of word segments and the proportion of word segment lengths; where the proportion of word segment lengths represents the ratio of the total number of word segments of each length to the total number of word segments among multiple word segments. Then, based on multiple word segments, the total number of word segments, the proportion of word segment lengths, and the preset confidence determination rule, the confidence of this URL node is obtained.
[0045] To facilitate the understanding of the above total number of word segments and the proportion of word segment lengths, take the URL node "abgetuser1001" as an example for illustration. If, after performing word segment processing on "abgetuser1001", the obtained word segments include 5 word segments: a, b, get, user, and 1001, then the total number of word segments is 5. The proportion of word segment lengths includes: the proportion of word segments with a length of 1 is 2÷5×100% = 40%; the proportion of word segments with a length of 3 is 1÷5×100% = 20%; the proportion of word segments with a length of 4 is 2÷5×100% = 40%. The example here is only for easy understanding and should not be regarded as a limitation to this application.
[0046] Optionally, the confidence determination rule may include multiple sub-rules, and each sub-rule corresponds to a confidence increment respectively, where the confidence increment is used to represent the confidence score when the URL node meets the corresponding sub-rule. In this case, the specific method for obtaining the confidence of this URL node based on multiple word segments, the total number of word segments, the proportion of word segment lengths, and the preset confidence determination rule may be: first, based on multiple word segments, the total number of word segments, and the proportion of word segment lengths, determine all the sub-rules that this URL node meets. Then, add up the confidence increments corresponding to each sub-rule that this URL node meets to obtain the confidence of this URL node.
[0047] Optionally, an initial confidence may also be preset for the URL node. Correspondingly, when obtaining the confidence of this URL node, add up the initial confidence of this URL node and the confidence increments corresponding to each sub-rule that this URL node meets to obtain the confidence of this URL node.
[0048] Among them, the specific value of the initial confidence can be set according to actual needs, and the initial confidences of different URL nodes can be the same, or at least some of the initial confidences of different URL nodes can be different.
[0049] In one implementation, the preset confidence determination rules may include at least one of the following sub-rules: the total number of word segments is greater than the first preset threshold; the total number of word segments is within the first preset range of the number of word segments, and the number of word segments that are numbers among all word segments is greater than the second preset threshold; the total number of word segments is within the second preset range of the number of word segments, and the length of the word segments that are numbers is greater than the third preset threshold; all word segments are numbers; there are more than two word segments that are numbers, and the ratio of the number of word segments that are numbers to the total number of word segments is greater than the fourth preset threshold.
[0050] In addition to the parts exemplified above, the confidence determination rules may further include other types of rules. For example, they may further include: the URL node starts with a preset string, and the preset string may be strings such as get, query, list, etc.; each word segment can be translated by a preset dictionary, and the length of each word segment is greater than the fifth preset threshold, and other conditions.
[0051] The first preset range of the number of word segments may be an interval including multiple values, or may only include one value. Among them, the first preset threshold, the first preset range of the number of word segments, the second preset threshold, the second preset range of the number of word segments, the third preset threshold, the fourth preset threshold, and the fifth preset threshold can be set according to actual needs. For example, the first preset threshold may be 20, the first preset range of the number of word segments may be greater than or equal to 10 and less than 20, the second preset threshold may be 3, the second preset range of the number of word segments may be 2, the third preset threshold may be 5, the fourth preset threshold may be 50%, and the fifth preset threshold may be 3. The examples here are only for easy understanding and should not be construed as a limitation of this application.
[0052] Optionally, the confidence increments corresponding to different rules included in the confidence determination rules may be different. For example, if the total number of word segments is greater than the first preset threshold, the confidence increment is +1; if the total number of word segments is within the first preset range of the number of word segments, and the number of word segments that are numbers among all word segments is greater than the second preset threshold, the confidence increment is +2; if the total number of word segments is within the second preset range of the number of word segments, and the length of the word segments that are numbers is greater than the third preset threshold, the confidence increment is +3; if all word segments are numbers, the confidence increment is +3; if there are more than two word segments that are numbers, and the ratio of the number of word segments that are numbers to the total number of word segments is greater than the fourth preset threshold, the confidence increment is +4. If the URL node starts with a preset string, and the preset string may be strings such as get, query, list, etc., the confidence increment is +5; if each word segment can be translated by a preset dictionary, and the length of each word segment is greater than the fifth preset threshold, and other conditions, the confidence increment is +6.
[0053] The confidence level of the URL node is: the sum of the confidences corresponding to all the conditions that match in the confidence matching rules for multiple word segments, the total number of word segments, and the proportion of word segment lengths of the URL node.
[0054] Alternatively, when the URL node has a preset initial confidence level, the confidence level of the URL node is: the initial confidence level of the URL node, plus the sum of the confidences corresponding to all the conditions that match in the confidence matching rules for multiple word segments, the total number of word segments, and the proportion of word segment lengths of the URL node.
[0055] To facilitate the understanding of the calculation method of the confidence level of the URL node, take the following three conditions for the multiple word segments, the total number of word segments, and the proportion of word segment lengths of the target URL node: the total number of word segments is greater than the first preset threshold (confidence increment is +1); the total number of word segments is within the second preset range of the number of word segments, and the length of the word segment that is a number is greater than the third preset threshold (confidence increment is +3); the URL node starts with a preset string, and the preset string can be strings such as get, query, list, etc. (confidence increment is +5). Then the confidence level of the target URL node is 1 + 3 + 5 = 9. The example here is only for easy understanding and should not be used as a limitation to this application.
[0056] If the target URL node has a preset initial confidence level and the initial confidence level is 1, then the confidence level of the target URL node is 1 + 1 + 3 + 5 = 10. The example here is only for easy understanding and should not be used as a limitation to this application.
[0057] In one implementation, before performing word segmentation on the URL node, it is also possible to first determine whether the URL node is preset type data.
[0058] Correspondingly, the specific method of performing word segmentation on the URL node can be: when the URL node is not preset type data, perform word segmentation on the URL node.
[0059] Among them, the specific method of performing word segmentation on the URL node has been clearly described above. For a brief description, it will not be elaborated here.
[0060] When the URL node belongs to preset type data, based on the corresponding relationship between the preset preset type data and the confidence level, obtain the confidence level of the URL node.
[0061] Optionally, the preset type data includes at least one of UUID, number, hash string, IP, date and time, ID number, Chinese. In addition to the data types exemplified above, the preset type data can also include other types of data.
[0062] For the confidence levels corresponding to different types of data in the preset type data, they can be the same or different. For example, the confidence levels corresponding to UUID, numbers, and hash strings can be 8, and the confidence levels corresponding to IP, date and time, ID card numbers, and Chinese can be 9. The examples here are only for easy understanding and should not be regarded as a limitation to this application.
[0063] In one implementation, the way to construct the initial API tree can be to use the node representing the domain name in the URL to be processed as the root node of the initial API tree. Then, the other nodes of the URL to be processed are added to the initial API tree in sequence. Among them, each path from the root node to the leaf node in the initial API tree corresponds to a URL to be processed, and the nodes in each path include all the URL nodes of the corresponding URL to be processed.
[0064] For easy understanding, taking the URLs to be processed including http: / / t.com / v1 / api / user / 1001 / show_img / 2b34bc3, http: / / t.com / v1 / api / user / 1001 / save_img, http: / / t.com / v1 / api / user / 1001 / download_img / 2b34bc3, http: / / t.com / v1 / api / user / 1002 / info, http: / / t.com / v1 / api / user / 1002 / article, http: / / t.com / v1 / api / user / 1002 / blog, http: / / t.com / api / 45ferer53 / dtth75532de, http: / / t.com / api / ui3445w / 73eu23, http: / / t.com / api / dfv434 / 23erg55, http: / / t.com / api / we23235e / wer231324 as examples, the constructed initial API tree is as Figure 2 shown.
[0065] Optionally, since the number of nodes of different URLs corresponding to the same API must be the same, therefore, the number of URL nodes can also be used as the first-layer nodes of the initial API tree, so as to ensure that the number of nodes of all URLs corresponding to each first-layer node is the same.
[0066] For ease of understanding, taking the URLs to be processed including http: / / t.com / v1 / api / user / 1001 / show_img / 2b34bc3, http: / / t.com / v1 / api / user / 1001 / save_img, http: / / t.com / v1 / api / user / 1001 / download_img / 2b34bc3, http: / / t.com / v1 / api / user / 1002 / info, http: / / t.com / v1 / api / user / 1002 / article, http: / / t.com / v1 / api / user / 1002 / blog, http: / / t.com / api / 45ferer53 / dtth75532de, http: / / t.com / api / ui3445w / 73eu23, http: / / t.com / api / dfv434 / 23erg55, http: / / t.com / api / we23235e / wer231324 as examples, the constructed initial API tree is as Figure 3 shown.
[0067] Optionally, each node of the initial API tree can also store the confidence level of the URL node corresponding to this node.
[0068] Optionally, each node of the initial API tree can also store the number of times the URL node corresponding to this node appears.
[0069] S200: When the number of child nodes of a node in the initial API tree is greater than the first preset child node threshold, aggregate all child nodes with a confidence level greater than the preset confidence threshold among the child nodes of this node into a new child node to obtain the target API tree.
[0070] The newly aggregated child node can be named with a common name. The specific content of the common name can be set according to actual needs, as long as it can be distinguished from other nodes and the common name represents a variable node. The specific content of the common name is not limited here.
[0071] For ease of understanding, taking Figure 3 the initial API tree shown, with the first preset child node threshold being 1 as an example for illustration.
[0072] Figure 3The node "user" on the left has two child nodes. Therefore, it is determined whether the confidence levels of the two child nodes "1001" and "1002" of "user" are greater than the preset confidence threshold. Since the confidence levels of the child nodes "1001" and "1002" are both greater than the preset confidence threshold, the child nodes "1001" and "1002" are aggregated, and the aggregated node is named with the common name "param". The child nodes of the child nodes "1001" and "1002" are both mounted under the new child node "param".
[0073] The aggregated node "param" has 4 child nodes. Therefore, it is determined whether the confidence levels of the four child nodes "save_img", "blog", "article", and "info" of "param" are greater than the preset confidence threshold. Since the confidence levels of the child nodes "save_img", "blog", "article", and "info" are all less than the preset confidence threshold, the child nodes "save_img", "blog", "article", and "info" do not need to be aggregated.
[0074] Figure 3 The confidence levels of the two child nodes "show_img" and "download_img" of the middle node "1001" are both less than the preset confidence threshold. Therefore, the child nodes "show_img" and "download_img" do not need to be aggregated.
[0075] Figure 3 The node "api" on the right has four child nodes "45ferer53", "ui3445w", "dfv434", and "we231324". The confidence levels of the nodes "45ferer53", "ui3445w", "dfv434", and "we231324" are all greater than the preset confidence threshold. Therefore, the nodes "45ferer53", "ui3445w", "dfv434", and "we231324" are aggregated, and the aggregated node is named with the common name "param". The aggregated node "param" has 4 child nodes "dtth75532de", "73eu23", "23erg55", and "wer231324". The confidence levels of the nodes "dtth75532de", "73eu23", "23erg55", and "wer231324" are all greater than the preset confidence threshold. Therefore, the nodes "dtth75532de", "73eu23", "23erg55", and "wer231324" are aggregated, and the aggregated node is named with the common name "param".
[0076] Based on the above processing, the target API tree is obtained as Figure 4 shown below.
[0077] In one implementation, the specific method of aggregating all child nodes with confidence greater than the preset confidence threshold among the child nodes of this node into a new child node can be: determining whether the number of all child nodes with confidence greater than the preset confidence threshold among the child nodes of this node is greater than or equal to the second preset child node threshold; where the second preset child node threshold is less than or equal to the first preset child node threshold. If it is greater than or equal to the second preset child node threshold, aggregate all child nodes with confidence greater than the preset confidence threshold among the child nodes of this node into a new child node.
[0078] If the number of all child nodes with confidence greater than the preset confidence threshold among the child nodes of this node is less than the second preset child node threshold, no aggregation processing is performed.
[0079] Among them, the second preset child node threshold can be set according to actual needs. For example, it can be 1, 2, 3, 4, 5, 6, 7, 8, 9, etc. The specific value is not limited here.
[0080] The specific implementation method of aggregating all child nodes with confidence greater than the preset confidence threshold among the child nodes of this node into a new child node has been described clearly above. For the sake of brief description, it will not be elaborated here.
[0081] S300: Traverse all paths of the target API tree to obtain all aggregated APIs included in the target API tree.
[0082] In one implementation, when the number of URL nodes is represented by the first-layer nodes in the initial API tree; in the case where the first-layer nodes are the child nodes of the root node, the specific method of traversing all paths of the target API tree to obtain all APIs included in the target API tree can be: for each path of the target API tree, splice the URL nodes included in all nodes except the first-layer nodes in this path in the order from the root node to the leaf node according to the hierarchical relationship between the nodes to obtain the API.
[0083] For ease of understanding, take the Figure 4 target API tree shown below as an example for illustration.
[0084] Take Figure 4In each path of the target API tree shown, for nodes other than the first-layer nodes, they are concatenated in the order from the root node to the leaf node, and the following can be obtained: http: / / t.com / v1 / api / user / {param} / save_img; http: / / t.com / v1 / api / user / {param} / info; http: / / t.com / v1 / api / user / {param} / article; http: / / t.com / v1 / api / user / {param} / blog; http: / / t.com / v1 / api / user / {param} / show_img / 2b34bc3; http: / / t.com / v1 / api / user / {param} / download_img / 2b34bc3; http: / / t.com / api / {param} / {param}.
[0085] Among them, "{param}" in the obtained API is a variable node.
[0086] Based on the same technical concept, the present application also provides an API aggregation device, as Figure 5 shown, the API aggregation device 100 includes a determination module 110 and a processing module 120.
[0087] The determination module 110 is configured to determine the confidence of each URL node in the to-be-processed URL corresponding to the API, and construct an initial API tree; the confidence represents the probability that the corresponding URL node is a variable node; each path from the root node to the leaf node in the initial API tree corresponds to a to-be-processed URL, and the nodes in each path include all URL nodes of the corresponding to-be-processed URL; among them, all the to-be-processed URLs used to construct the initial API tree have the same domain name, and the root node of the initial API tree is the URL node representing the domain name.
[0088] The processing module 120 is configured to, when the number of child nodes of a node in the initial API tree is greater than a first preset child node threshold, aggregate all child nodes with a confidence greater than a preset confidence threshold among the child nodes of this node into a new child node to obtain a target API tree.
[0089] The processing module 120 is further configured to traverse all paths of the target API tree to obtain all aggregated APIs included in the target API tree.
[0090] The determination module 110 is specifically configured to, for each URL node in each URL to be processed: perform word segmentation on the URL node to obtain a plurality of word segments; and obtain the confidence level of the URL node based on the plurality of word segments and a preset confidence level determination rule.
[0091] The determination module 110 is further configured to determine whether the URL node is preset type data before performing word segmentation on the URL node; and perform word segmentation on the URL node when the URL node is not preset type data.
[0092] The determination module 110 is further configured to, when the URL node belongs to preset type data, obtain the confidence level of the URL node based on the corresponding relationship between the preset type data and the confidence level.
[0093] In one implementation, the preset type data includes at least one of UUID, number, hash string, IP, date and time, ID number, and Chinese.
[0094] The determination module 110 is specifically configured to perform statistical processing on the plurality of word segments to obtain the total number of word segments and the proportion of the length of the word segments; wherein the proportion of the length of the word segments represents the ratio of the total number of word segments of each length in the plurality of word segments to the total number of word segments; and obtain the confidence level of the URL node based on the plurality of word segments, the total number of word segments, the proportion of the length of the word segments, and a preset confidence level determination rule.
[0095] The confidence level determination rule includes multiple sub-rules, and each sub-rule corresponds to a confidence level increment respectively. The confidence level increment is used to represent the confidence level score when the URL node meets the corresponding sub-rule. The determination module 110 is specifically configured to determine all sub-rules that the URL node meets based on the plurality of word segments, the total number of word segments, and the proportion of the length of the word segments; and add the confidence level increments corresponding to each sub-rule that the URL node meets to obtain the confidence level of the URL node.
[0096] In one implementation, the preset confidence level determination rule includes at least one of the following sub-rules: the total number of word segments is greater than a first preset threshold; the total number of word segments is within a first preset word segment number range, and the number of word segments that are numbers among all word segments is greater than a second preset threshold; the total number of word segments is within a second preset word segment number range, and the length of the word segments that are numbers is greater than a third preset threshold; all word segments are numbers; there are more than two word segments that are numbers, and the ratio of the number of word segments that are numbers to the total number of word segments is greater than a fourth preset threshold.
[0097] In one implementation, the first-layer nodes of the initial API tree represent the number of URL nodes; the first-layer nodes are the child nodes of the root node; the processing module 120 is specifically configured to, for each path of the target API tree, splice the URL nodes included in all nodes except the first-layer nodes in this path in the order from the root node to the leaf node according to the hierarchical relationship between the nodes, so as to obtain the API.
[0098] The processing module 120 is specifically configured to determine whether the number of all child nodes with a confidence level greater than a preset confidence threshold in the child nodes of this node is greater than or equal to a second preset child node threshold; wherein, the second preset child node threshold is less than or equal to the first preset child node threshold; if it is greater than or equal to the second preset child node threshold, aggregate all child nodes with a confidence level greater than the preset confidence threshold in the child nodes of this node into a new child node.
[0099] The API aggregation device 100 provided by the embodiments of the present application has the same implementation principle and the same technical effects as those of the foregoing API aggregation method embodiments. For the sake of brief description, for the parts not mentioned in the device embodiments, reference may be made to the corresponding contents in the foregoing API aggregation method embodiments.
[0100] Please refer to Figure 6 , which is an electronic device 200 provided by the embodiments of the present application. The electronic device 200 includes: a processor 210 and a memory 220.
[0101] The memory 220 and the processor 210 are directly or indirectly electrically connected to each other to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines. Among them, the memory 220 is used to store computer programs, such as storing Figure 5The software function module shown in is the API aggregation device 100. The API aggregation device 100 includes at least one software function module that can be stored in the memory 220 in the form of software or firmware or fixed in the operating system (OS) of the electronic device 200. The processor 210 is used to execute the executable module stored in the memory 220, such as the software function module or computer program included in the API aggregation device 100. At this time, the processor 210 is used to determine the confidence of each URL node in the to-be-processed URL corresponding to the API, and to construct an initial API tree; the confidence represents the probability that the corresponding URL node is a variable node; each path from the root node to the leaf node in the initial API tree corresponds to a to-be-processed URL, and the nodes in each path include all URL nodes of the corresponding to-be-processed URL; wherein, the domain names of all the to-be-processed URLs used to construct the initial API tree are the same, and the root node of the initial API tree is the URL node representing the domain name; when there is a node in the initial API tree whose number of child nodes is greater than a first preset child node threshold, all child nodes in the child nodes of the node whose confidence is greater than the preset confidence threshold are aggregated into a new child node to obtain a target API tree; all paths of the target API tree are traversed to obtain all aggregated APIs included in the target API tree.
[0102] Among them, the memory 220 can be, but is not limited to, RAM (Random Access Memory), ROM (Read Only Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.
[0103] The processor 210 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), etc.; it may also be a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or the processor 210 may also be any conventional processor, etc.
[0104] Among them, the above-mentioned electronic device 200 includes, but is not limited to, a personal computer, a server, etc.
[0105] The embodiments of the present application also provide a computer-readable storage medium (hereinafter referred to as the storage medium). A computer program is stored on the storage medium. When the computer program is run by a computer such as the above-mentioned electronic device 200, it executes the API aggregation method shown above. The computer-readable storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk, or an optical disc.
[0106] The foregoing is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. An API aggregation method, characterized in that, including: determining the confidence of each URL node in the to-be-processed URL corresponding to the API, and constructing an initial API tree; the confidence represents the probability that the corresponding URL node is a variable node; each path from the root node to the leaf node in the initial API tree corresponds to a to-be-processed URL, and the nodes in each path include all URL nodes of the corresponding to-be-processed URL; wherein, all the to-be-processed URLs used to construct the initial API tree have the same domain name, and the root node of the initial API tree is the URL node representing the domain name; in the case that the number of child nodes of a node in the initial API tree is greater than the first preset child node threshold, aggregating all child nodes with confidence greater than the preset confidence threshold among the child nodes of this node into a new child node to obtain a target API tree; traversing all paths of the target API tree to obtain all aggregated APIs included in the target API tree.
2. The method according to claim 1, characterized in that, Determining the confidence of each URL node in each to-be-processed URL includes: for each URL node in each to-be-processed URL: performing word segmentation on this URL node to obtain multiple word segments; based on the multiple word segments and a preset confidence determination rule, obtaining the confidence of this URL node.
3. The method according to claim 2, characterized in that, Before performing word segmentation on this URL node, the method further includes: determining whether this URL node is pre-set type data; correspondingly, performing word segmentation on this URL node includes: in the case that this URL node is not pre-set type data, performing word segmentation on this URL node.
4. The method according to claim 3, characterized in that, The method further includes: in the case that this URL node belongs to pre-set type data, obtaining the confidence of this URL node based on the corresponding relationship between the pre-set type data and the confidence.
5. The method according to claim 3, characterized in that, The pre-set type data includes at least one of UUID, number, hash string, IP, date and time, ID number, Chinese.
6. The method according to claim 2, characterized in that, Based on the multiple word segments and a preset confidence determination rule, obtaining the confidence of this URL node includes: performing statistical processing on the multiple word segments to obtain the total number of word segments and the word segment length ratio of the multiple word segments; wherein, the word segment length ratio represents the ratio of the total number of word segments of each length among the multiple word segments to the total number of word segments; based on the multiple word segments, the total number of word segments, the word segment length ratio and a preset confidence determination rule, obtaining the confidence of this URL node.
7. The method according to claim 6, characterized in that, The confidence determination rule includes multiple sub-rules, and each sub-rule corresponds to a confidence increment respectively. The confidence increment is used to represent the confidence score when the URL node meets the corresponding sub-rule. Based on the multiple word segments, the total number of word segments, the word segment length ratio and a preset confidence determination rule, obtaining the confidence of this URL node includes: based on the multiple word segments, the total number of word segments, the word segment length ratio, determining all sub-rules that this URL node meets; adding up the confidence increments corresponding to each sub-rule that this URL node meets to obtain the confidence of this URL node.
8. The method according to claim 7, characterized in that, The preset confidence determination rules include at least one of the following sub - rules: the total number of word segments is greater than a first preset threshold; the total number of word segments is within a first preset word - segment quantity range, and the number of word segments that are numbers among all word segments is greater than a second preset threshold; the total number of word segments is within a second preset word - segment quantity range, and the length of the word segments that are numbers is greater than a third preset threshold; all word segments are numbers; there are more than two word segments that are numbers, and the ratio of the number of word segments that are numbers to the total number of word segments is greater than a fourth preset threshold.
9. The method according to any one of claims 1 - 8, characterized in that, The first - layer nodes of the initial API tree represent the number of URL nodes; the first - layer nodes are the child nodes of the root node; Correspondingly, traversing all paths of the target API tree to obtain all APIs included in the target API tree includes: For each path of the target API tree, splicing the URL nodes included in all nodes except the first - layer node in this path in the order from the root node to the leaf node according to the hierarchical relationship between the nodes to obtain the API.
10. The method according to any one of claims 1 - 9, characterized in that, Aggregating all child nodes with confidence greater than a preset confidence threshold among the child nodes of this node into a new child node includes: Judging whether the number of all child nodes with confidence greater than a preset confidence threshold among the child nodes of this node is greater than or equal to a second preset child - node threshold; wherein, the second preset child - node threshold is less than or equal to the first preset child - node threshold; If it is greater than or equal to the second preset child - node threshold, aggregating all child nodes with confidence greater than a preset confidence threshold among the child nodes of this node into a new child node.
11. An API aggregation device, characterized in that,Including: A determination module, configured to determine the confidence of each URL node in the to - be - processed URL corresponding to the API and construct an initial API tree; The confidence represents the probability that the corresponding URL node is a variable node; Each path from the root node to the leaf node in the initial API tree corresponds to a to - be - processed URL, and the nodes in each path include all URL nodes of the corresponding to - be - processed URL; wherein, all the to - be - processed URLs used to construct the initial API tree have the same domain name, and the root node of the initial API tree is the URL node representing the domain name; A processing module, configured to, when the number of child nodes of a node in the initial API tree is greater than a first preset child - node threshold, aggregate all child nodes with confidence greater than a preset confidence threshold among the child nodes of this node into a new child node to obtain a target API tree; The processing module is further configured to traverse all paths of the target API tree to obtain all aggregated APIs included in the target API tree.
12. An electronic device, characterized in that, Including: A memory and a processor, the memory is connected to the processor; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 1 - 10.
13. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and when the computer program is run by the computer, it executes the method according to any one of claims 1 - 10.