Api intelligent recommendation method and system based on semantic knowledge graph
By constructing an API intelligent recommendation method based on semantic knowledge graphs, and combining multi-source data and user behavior analysis, the problem of accurate recommendation for API management in microservice architecture is solved, improving development efficiency and system maintainability.
Patent Information
- Application Number
- CN202511714266.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2045-11-21
AI Technical Summary
In a microservice architecture, existing API management methods struggle to achieve accurate and intelligent recommendations, resulting in low development efficiency and poor system maintainability. Existing technologies lack a deep understanding of microservice functions, business semantics, and contextual relationships.
We employ a semantic knowledge graph-based approach. By constructing an initial semantic knowledge graph and combining it with semantic similarity algorithms, user behavior analysis, and collaborative filtering algorithms, we generate an accurate intelligent API recommendation list. We also introduce a service popularity adjustment mechanism to ensure the personalization and practicality of the recommendation results.
It enables accurate and personalized recommendations for microservices/APIs, improving development efficiency and service reusability, reducing development complexity, and enhancing the accuracy and usability of recommendations.
Smart Images

Figure CN121166190B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of cloud computing, in particular to an API intelligent recommendation method and system based on a semantic knowledge graph. BACKGROUND
[0002] With the popularity of cloud native concept, microservice architecture has become the mainstream way to build modern application software. In this architecture, application programs are split into a group of small, loosely coupled services, and communicate and integrate through application programming interfaces (APIs). API gateway, as the core component of microservice architecture, undertakes important responsibilities such as request routing, combination and security control.
[0003] However, with the rapid growth of enterprise microservices, the size and complexity of APIs have also increased, posing serious challenges to development and management. Currently, the management of microservices and APIs relies heavily on manual maintenance by development teams, resulting in inconsistent management standards and quality standards across different projects. This situation makes it difficult to implement unified and platform-based management of microservices and APIs, which in turn leads to a series of problems, including: first, it is difficult to discover, understand and reuse microservices and APIs, making it difficult for developers to quickly locate services that meet their functional requirements and are reliable in quality, leading to a lot of repeated development and reducing research and development efficiency; second, the dependency relationship between services is unclear, and the maintainability and evolvability of system architecture are poor. Existing recommendation techniques, such as keyword-based search or simple collaborative filtering, lack a deep understanding of the functionality, business semantics and contextual relationships of microservices, making it difficult to achieve accurate and intelligent recommendations. SUMMARY
[0004] Therefore, it is necessary to provide an API intelligent recommendation method and system based on a semantic knowledge graph that can achieve accurate and intelligent recommendations.
[0005] In a first aspect, an API intelligent recommendation method based on a semantic knowledge graph is provided, the method comprising:
[0006] According to the target scenario, a data crawling mechanism is determined, first target data of the API is collected based on the data crawling mechanism, and first preprocessing is performed on the first target data to obtain second target data;
[0007] A metadata model is determined, a target parser is determined based on the metadata model, and API key data is extracted from the second target data based on the target parser to generate structured metadata;
[0008] Determine domain ontology and the association relationship between the domain ontology, construct an initial semantic knowledge graph based on the domain ontology and the association relationship between the domain ontology, and the domain ontology is used to describe the standardized relationship rules established in the micro-service and API management field;
[0009] Based on the structured metadata, determine an entity, and perform a second preprocessing on the entity, map the second preprocessing result to the initial semantic knowledge graph, generate a target semantic knowledge graph, and the entity is a basic unit constituting the knowledge graph;
[0010] According to the target semantic knowledge graph, an initial API intelligent recommendation list is generated by combining a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, and the target API intelligent recommendation list is obtained by adjusting the initial API intelligent recommendation list based on service popularity.
[0011] Optionally, according to a target scenario, a data crawling mechanism is determined, and based on the data crawling mechanism, first target data of an API is collected, including:
[0012] Obtain relevant information of the target scenario, and the relevant information includes at least one of the following: data source type, update frequency and data volume;
[0013] Weighted fusion is performed on the relevant information, and a data crawling mechanism is determined according to the weighted fusion result, and the data crawling mechanism includes automatic crawling and manual crawling;
[0014] In response to the data crawling mechanism being automatic crawling, a target data source is accessed and parsed based on a preset parsing program to collect the first target data of the API;
[0015] In response to the data crawling mechanism being manual crawling, the first target data of the API input by a user is received based on a user interface;
[0016] The first target data at least includes the name, description, endpoint URL and request method of the API.
[0017] Optionally, the first target data is preprocessed to obtain second target data, including:
[0018] Data cleaning is performed on the first target data to remove outliers and duplicate data in the first target data;
[0019] The first target data after data cleaning is subjected to format uniform processing, and the format uniform processing includes data consistency processing and data type conversion;
[0020] Based on the first target data after the format unification processing, the preset structured attribute data is extracted through rule matching, and the structured attribute data is normalized to generate the second target data.
[0021] Optionally, a metadata model is determined, and based on the metadata model, a target parser is determined to include:
[0022] The metadata model is determined, and the metadata model is used to describe structured fields required by microservices or APIs, and includes at least one of the following: basic information, endpoint information, authentication information, a data model, and a document link;
[0023] Based on the metadata model, a plurality of target data sources are analyzed to establish a mapping relationship between fields of the metadata model and information bearing positions in the target data sources;
[0024] Based on the mapping relationship, at least one target parser and a parsing rule are determined, wherein the target parser is configured to extract information from the corresponding target data source according to the parsing rule and instantiate the metadata model.
[0025] Optionally, based on the target parser, API key data is extracted from the second target data to generate structured metadata, including:
[0026] The second target data is input to the target parser;
[0027] Based on the target parser, API key data is extracted from the second target data according to the parsing rule corresponding to the target parser;
[0028] Based on the metadata model, the API key data is assembled into a structured data object;
[0029] The structured data object is serialized to generate a standard format file, and the standard format file is defined as the structured metadata.
[0030] Optionally, a domain ontology and an association relationship between the domain ontologies are determined, and based on the domain ontology and the association relationship between the domain ontologies, an initial semantic knowledge graph is constructed, including:
[0031] Based on the microservice architecture and API management requirements, the domain ontology and the association relationship between the domain ontologies are constructed;
[0032] Based on the domain ontology, specific object instances in a plurality of data sources are instantiated as entity nodes of corresponding classes, and relationship edges are established between the entity nodes according to the association relationship between the domain ontologies;
[0033] generate the initial semantic knowledge graph based on the entity nodes and the relationship edges.
[0034] Optionally, based on the structured metadata, determine entities, and perform second preprocessing on the entities, map the second preprocessing result to the initial semantic knowledge graph, and generate a target semantic knowledge graph, including:
[0035] based on the structured metadata and the initial semantic knowledge graph, determine entities to be processed;
[0036] perform entity disambiguation and semantic encoding processing on the entities to be processed;
[0037] fuse the entities after entity disambiguation and semantic encoding processing with the entities in the initial semantic knowledge graph, and based on the structured metadata and the semantic encoding result, establish static relationship edges and semantic relationship edges between entities;
[0038] based on the fusion result and the static relationship edges and the semantic relationship edges, generate the target semantic knowledge graph.
[0039] Optionally, according to the target semantic knowledge graph, combining a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, generating an initial API intelligent recommendation list includes:
[0040] receive a recommendation request, the recommendation request including a user identifier;
[0041] According to the user identifier, obtain related user behavior data and a candidate API set from the target semantic knowledge graph;
[0042] Combine the target semantic knowledge graph to execute at least one of the following algorithms for scoring the candidate API set: a semantic similarity algorithm based on a semantic vector, a user behavior analysis algorithm based on a user behavior sequence, and a collaborative filtering algorithm based on a user and service interaction matrix;
[0043] Based on the scoring result, sort the candidate API set to generate the initial API intelligent recommendation list.
[0044] Optionally, based on service heat, adjust the initial API intelligent recommendation list to obtain a target API intelligent recommendation list, including:
[0045] Obtain the initial API intelligent recommendation list, wherein the target API in the initial API intelligent recommendation list has an initial recommendation score;
[0046] Based on historical call data, determine the service heat score of the target API in the initial API intelligent recommendation list;
[0047] based on a preset heat weight coefficient, the initial recommendation score of the target API is weighted and fused with the service heat score to determine a comprehensive score;
[0048] APIs in the initial API intelligent recommendation list are reordered according to the comprehensive score to generate a target API intelligent recommendation list.
[0049] In a second aspect, an API intelligent recommendation system based on a semantic knowledge graph is provided, and the system comprises:
[0050] A data collection module is configured to determine a data crawling mechanism according to a target scenario, collect first target data of APIs based on the data crawling mechanism, and perform first preprocessing on the first target data to obtain second target data.
[0051] A data processing module is configured to determine a metadata model, determine a target parser based on the metadata model, and extract API key data from the second target data based on the target parser to generate structured metadata.
[0052] A first semantic knowledge graph construction module is configured to determine domain ontologies and association relationships between the domain ontologies, and construct an initial semantic knowledge graph based on the domain ontologies and the association relationships between the domain ontologies, wherein the domain ontologies are used to describe standardized relationship rules established in the microservice and API management field.
[0053] A second semantic knowledge graph construction module is configured to determine entities based on the structured metadata, perform second preprocessing on the entities, map a second preprocessing result to the initial semantic knowledge graph, and generate a target semantic knowledge graph, wherein the entities are basic units constituting the knowledge graph.
[0054] An intelligent recommendation module is configured to generate an initial API intelligent recommendation list according to the target semantic knowledge graph, in combination with a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, adjust the initial API intelligent recommendation list based on service heat, and obtain a target API intelligent recommendation list.
[0055] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the following steps when executing the computer program:
[0056] A data collection module is configured to determine a data crawling mechanism according to a target scenario, collect first target data of APIs based on the data crawling mechanism, and perform first preprocessing on the first target data to obtain second target data.
[0057] determining a metadata model, determining a target parser based on the metadata model, extracting API key data from the second target data based on the target parser to generate structured metadata;
[0058] determining domain ontologies and association relationships between the domain ontologies, constructing an initial semantic knowledge graph based on the domain ontologies and the association relationships between the domain ontologies, the domain ontologies being used to describe standardized relationship rules established by a microservice and an API management field;
[0059] determining an entity based on the structured metadata, performing second preprocessing on the entity, mapping a second preprocessing result to the initial semantic knowledge graph to generate a target semantic knowledge graph, the entity being a basic unit constituting the knowledge graph;
[0060] generating an initial API intelligent recommendation list according to the target semantic knowledge graph, combining a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, adjusting the initial API intelligent recommendation list based on service heat to obtain a target API intelligent recommendation list.
[0061] In a fourth aspect, a computer-readable storage medium is provided, and the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the following steps are implemented:
[0062] determining a data crawling mechanism according to a target scenario, collecting first target data of an API based on the data crawling mechanism, and performing first preprocessing on the first target data to obtain second target data;
[0063] determining a metadata model, determining a target parser based on the metadata model, extracting API key data from the second target data based on the target parser to generate structured metadata;
[0064] determining domain ontologies and association relationships between the domain ontologies, constructing an initial semantic knowledge graph based on the domain ontologies and the association relationships between the domain ontologies, the domain ontologies being used to describe standardized relationship rules established by a microservice and an API management field;
[0065] determining an entity based on the structured metadata, performing second preprocessing on the entity, mapping a second preprocessing result to the initial semantic knowledge graph to generate a target semantic knowledge graph, the entity being a basic unit constituting the knowledge graph;
[0066] According to the target semantic knowledge graph, an initial API intelligent recommendation list is generated in combination with a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, the initial API intelligent recommendation list is adjusted based on service heat, and a target API intelligent recommendation list is obtained.
[0067] In a fifth aspect, a computer program product is provided, which includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0068] According to a target scene, a data crawling mechanism is determined, first target data of an API is collected based on the data crawling mechanism, and first preprocessing is performed on the first target data to obtain second target data;
[0069] A metadata model is determined, a target parser is determined based on the metadata model, API key data is extracted from the second target data based on the target parser, and structured metadata is generated;
[0070] Domain ontologies and associated relationships between the domain ontologies are determined, an initial semantic knowledge graph is constructed based on the domain ontologies and the associated relationships between the domain ontologies, and the domain ontologies are used to describe standardized relationship rules established in the microservice and API management field;
[0071] Based on the structured metadata, an entity is determined, second preprocessing is performed on the entity, and a second preprocessing result is mapped to the initial semantic knowledge graph to generate a target semantic knowledge graph, and the entity is a basic unit constituting the knowledge graph;
[0072] According to the target semantic knowledge graph, an initial API intelligent recommendation list is generated in combination with a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, the initial API intelligent recommendation list is adjusted based on service heat, and a target API intelligent recommendation list is obtained.
[0073] The API intelligent recommendation method and system based on the semantic knowledge graph, the method comprises the following steps: determining a data crawling mechanism according to a target scene, collecting first target data of an API based on the data crawling mechanism, and performing first preprocessing on the first target data to obtain second target data; determining a metadata model, determining a target parser based on the metadata model, extracting API key data from the second target data based on the target parser to generate structured metadata; determining a domain ontology and an association relationship between the domain ontologies, constructing an initial semantic knowledge graph based on the domain ontology and the association relationship between the domain ontologies, and the domain ontology is used to describe the standardized relationship rules established in the microservice and API management field; determining an entity based on the structured metadata, performing second preprocessing on the entity, mapping the second preprocessing result to the initial semantic knowledge graph to generate a target semantic knowledge graph, and the entity is a basic unit constituting the knowledge graph; generating an initial API intelligent recommendation list according to the target semantic knowledge graph, combining a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, adjusting the initial API intelligent recommendation list based on service heat, and obtaining a target API intelligent recommendation list. Through the construction of the intelligent recommendation method integrating the semantic knowledge graph and the multi-source data, the application realizes accurate and personalized recommendation of microservices / APIs. The application can not only understand the functional requirements based on the semantic similarity, but also can improve the recommendation accuracy by combining the user behavior analysis. At the same time, the service heat adjustment mechanism is introduced to ensure that the recommendation result has both personalization and practicality, effectively reduces the development complexity, and improves the service reuse rate and development efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0074] Figure 1 An application environment diagram of the API intelligent recommendation method based on the semantic knowledge graph in one embodiment;
[0075] Figure 2 A flowchart of the API intelligent recommendation method based on the semantic knowledge graph in one embodiment;
[0076] Figure 3 Another flowchart of the API intelligent recommendation method based on the semantic knowledge graph in one embodiment;
[0077] Figure 4 A system architecture diagram of the API intelligent recommendation method based on the semantic knowledge graph in one embodiment;
[0078] Figure 5 A metadata generation flowchart of the API intelligent recommendation method based on the semantic knowledge graph in one embodiment;
[0079] Figure 6A structural block diagram of an API intelligent recommendation system based on a semantic knowledge graph in an embodiment;
[0080] Figure 7 An internal structure diagram of a computer device in an embodiment. DETAILED DESCRIPTION
[0081] For the purposes of the present application, the technical solutions and advantages thereof will be more clearly apparent from the following description of the embodiments of the present application, which will be described in conjunction with the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0082] It should be understood that, in the description of the present application, unless the context clearly requires otherwise, the terms "comprise", "comprise", and the like in the entire specification should be interpreted as inclusive meaning rather than exclusive or exhaustive meaning; that is, as "including but not limited to".
[0083] It should also be understood that the terms "first", "second", and the like are only for the purpose of description, and should not be understood as indicating or implying relative importance. In addition, in the description of the present application, unless otherwise stated, the meaning of "multiple" is two or more.
[0084] It should be noted that the terms "S1", "S2", and the like are only for the purpose of describing the steps, and do not specifically refer to the order or position, nor limit the present application. It is only for the convenience of describing the method of the present application, and should not be understood as indicating the order of the steps. In addition, the technical solutions of various embodiments can be combined with each other, but must be based on the realization of those of ordinary skill in the art. When the combination of technical solutions contradicts each other or cannot be realized, it should be considered that the combination of technical solutions does not exist, nor is it within the scope of protection required by the present application.
[0085] The API intelligent recommendation method based on the semantic knowledge graph provided by the present application can be applied to the application environment as shown in Figure 1 . Among them, the terminal 102 communicates with the data processing platform set on the server 104 through the network, wherein the terminal 102 can be but not limited to various personal computers, notebook computers, smart phones, tablet computers and portable wearable devices, and the server 104 can be realized by an independent server or a server cluster composed of multiple servers.
[0086] In an embodiment, as shown in Figures 2-4 , an API intelligent recommendation method based on a semantic knowledge graph is provided, and the method is applied toFigure 1 The terminal in the target scene is taken as an example to illustrate the method, including the following steps:
[0087] S1: According to the target scene, a data crawling mechanism is determined, based on which first target data of an API is collected, and first preprocessing is performed on the first target data to obtain second target data.
[0088] It should be noted that the API gateway is a core component in the microservice architecture, which provides an effective solution for request management and security of each service; the requirements of the target scene include data source type, update frequency, data volume, etc., and the data crawling mechanism includes two mechanisms of automatic crawling and manual input, for example, for a public API market with large amount and frequent update, automatic crawling is selected; for a private API which is not yet documented, manual input is adopted, wherein if automatic crawling is adopted, the system calls a pre-written crawler program or parser to automatically access a specified target source (such as the management interface of the API gateway, the OpenAPI document in the Git repository, the service registry center), and through parsing HTML, JSON or YAML structured data, the first target data of the API (i.e. basic registration information of the API such as name, description, endpoint URL and request method) is crawled, if manual input is adopted, the system provides a user interface (such as a form) for the user to manually fill in or copy and paste the above first target data; the first preprocessing refers to data cleaning, format unification, attribute extraction and data normalization processing.
[0089] S2: A metadata model is determined, based on which a target parser is determined, based on which API key data is extracted from the second target data to generate structured metadata.
[0090] It should be noted that the metadata model includes multiple modules, such as a basic information module (defining fields such as service name, version, description), an endpoint information module (defining fields such as API path, request method, parameter), and an authentication information module (defining fields such as authentication method, Token URL), etc., and the API key data can include a request method: POST and an API path: / users, such as extracting the request method: POST and the API path: / users from the Java source code by analyzing the @PostMapping annotation, extracting the parameter name: userId, the parameter type: integer, whether it is required: true from the parameters part of the OpenAPI document, and extracting the version number v1.2.0 from the Markdown description by using a regular expression.
[0091] S3: determine domain ontologies and association relationships between the domain ontologies, construct an initial semantic knowledge graph based on the domain ontologies and the association relationships between the domain ontologies, and the domain ontologies are used to describe standardized relationship rules established between microservices and API management domains.
[0092] It should be noted that the domain ontologies are constructed based on microservice architecture and API management requirements, and the association relationships between the domain ontologies can include a call relationship (calls) indicating a calling dependency between microservices and APIs, a containment relationship (contains) indicating a belonging relationship between microservices and APIs, and a semantic association (semanticallyRelated) indicating semantic similarity between entities based on domain knowledge. The initial semantic knowledge graph constructed includes entities as nodes and relationship edges as edges, thereby generating an initial semantic knowledge graph. For example, according to code dependency, a call relationship edge is established between "OrderService" (a microservice entity) and " / payment" (an API entity); and according to the containment relationship, a containment relationship edge is established between "UserService" (a microservice entity) and " / login" (an API entity).
[0093] S4: determine entities based on the structured metadata, perform second preprocessing on the entities, map a second preprocessing result to the initial semantic knowledge graph, and generate a target semantic knowledge graph, and the entities are basic units constituting the knowledge graph.
[0094] It should be noted that the entity determination method is to traverse the generated structured metadata (such as a JSON file), identify and extract the subject object in the class definition (such as API, Microservice) in the domain ontology according to the class definition (such as API, Microservice) in the domain ontology, and determine it as an entity that needs to be added to the graph, for example, identifying "PaymentService" and "POST / v1 / pay" two entities from a piece of metadata; the second preprocessing refers to entity disambiguation and semantic coding, entity disambiguation is to handle the problem of homonymy, for example, to judge whether the Order entity in the metadata refers to an e-commerce order or a logistics order, usually through analyzing the context description or other attributes in the metadata, by matching the preprocessed new entity with the existing entity in the graph, if it is a new entity, it will be added as a new node to the graph, if it is an existing entity (may be identified from different data sources), information merging is performed, according to the explicit dependency relationship (such as call chain) in the metadata, the static relationship (such as calls) between entities is established, the semantic similarity between entities is calculated by using the semantic vector generated in the second preprocessing, when the similarity exceeds the preset threshold, the semantic relationship (such as semanticallyRelated) edge is established, so as to discover the deep association not embodied in the initial graph, after the fusion of all new entities and the establishment of new relationships are completed, a semantic knowledge graph with more information and deeper association is obtained, which is the target semantic knowledge graph.
[0095] S5: According to the target semantic knowledge graph, combining a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, an initial API intelligent recommendation list is generated, the initial API intelligent recommendation list is adjusted based on service popularity, and a target API intelligent recommendation list is obtained.
[0096] It should be noted that the semantic similarity algorithm is to use a model such as BERT to vectorize the description text of the candidate API, calculate the cosine similarity between it and the current context or historical preferences of the user, and obtain a semantic score, which measures the relevance in function; the user behavior analysis algorithm is to use a sequence model such as LSTM to analyze the historical behavior sequence of the user (such as calling A after calling B), predict the next API that the user may be interested in, and obtain a behavior prediction score, which captures dynamic behavior patterns; the collaborative filtering algorithm is to analyze the user-service interaction matrix by matrix decomposition, find other user groups with similar preferences to the target user, recommend the APIs that the group likes but the target user has not called, and obtain a collaborative score, which uses the wisdom of the group. Based on this, the initial API intelligent recommendation list can be generated; the service popularity is to count the calling frequency of each candidate service / API in a certain period from system logs and monitoring data, and to smooth the original calling times, for example, using the formula: popularity score = log(1 + a), a is the calling times, based on this, the initial API intelligent recommendation list is adjusted to obtain the final target API intelligent recommendation list.
[0097] In some embodiments, according to the target scene, a data crawling mechanism is determined, and based on the data crawling mechanism, the first target data of the API is collected, including:
[0098] Obtaining related information of the target scene, the related information including at least one of data source type, update frequency and data volume, the related information being used to describe scene requirements;
[0099] Performing weighted fusion on the related information, and determining a data crawling mechanism according to a weighted fusion result, the data crawling mechanism including automatic crawling and manual crawling, wherein a calculation formula of the weighted fusion is K = w1s1 + w2s2 + w3s3, K represents a weighted fusion score, w1, w2 and w3 all represent weight coefficients, s1, s2 and s3 respectively represent the data source type, the update frequency and the data volume, the crawling mechanism determined based on the weighted score including automatic crawling and manual input, the automatic crawling can automatically access a webpage and crawl data on the webpage according to a program written according to requirements, and is suitable for a case where data volume is large or needs to be frequently updated, and the manual input needs a user to manually access a webpage and copy and paste required data into a system, and is suitable for a case where data volume is small or needs to be manually screened;
[0100] In response to the data crawling mechanism being automatic crawling, a target data source is accessed and parsed based on a preset parsing program to collect the first target data of the API;
[0101] In response to the data crawling mechanism being manual crawling, the first target data of the API is received based on a user interface and user input.
[0102] The first target data at least includes the name, description, endpoint URL and request method of the API.
[0103] In some embodiments, the first target data is first pre-processed to obtain second target data.
[0104] The first target data is data cleaned to remove outliers and duplicate data in the first target data.
[0105] The first target data after data cleaning is format-unified, and the format-unified processing includes data consistency processing and data type conversion.
[0106] Based on the first target data after format-unified processing, the pre-set structured attribute data is extracted by rule matching, and the structured attribute data is normalized to generate the second target data.
[0107] Specifically, the processing method mainly includes data cleaning, format-unification, attribute extraction, etc., mainly including outlier processing, duplicate data removal, data consistency processing, data type conversion, data normalization / standardization processing, etc. The data cleaning is used to identify and process outliers, errors and invalid data in the original data, for example, removing or marking API call records with non-200 status code, filtering out obviously inconsistent format URLs (such as containing illegal characters), identifying and processing API entries with empty or placeholder (such as “TODO”) descriptions, format-unification: converting data to a consistent format to ensure consistency of data processing, for example, converting all letters in the URL to lowercase, converting different “True / true / YES / 1” Boolean value representations to “true”, and converting date and time stamps to ISO 8601 standard format; attribute extraction: extracting structured attributes from unstructured text blocks, for example, using regular expressions to extract the mentioned “version number” (such as v1.2) from the “description” field of the API, and parsing the required parameter name and data type from the request example; data normalization / standardization: scaling or converting data to a uniform scale, for example, converting response time from milliseconds to seconds, and mapping different levels of status descriptions (such as success, OK, 200) to the standard code 200, based on which the second target data is generated.
[0108] In some embodiments, a metadata model is determined, and based on the metadata model, a target parser is determined.
[0109] determining the metadata model, the metadata model being used to describe structured fields required by microservices or APIs, including at least one of the following: basic information, endpoint information, authentication information, data model, and document link;
[0110] based on the metadata model, analyzing a plurality of target data sources to establish a mapping relationship between fields of the metadata model and information bearing positions in the target data sources;
[0111] based on the mapping relationship, determining at least one target parser and a parsing rule, wherein the target parser is configured to extract information from the corresponding target data source according to the parsing rule and instantiate the metadata model.
[0112] In some embodiments, based on the target parser extracting API key data from the second target data to generate structured metadata includes:
[0113] inputting the second target data into the target parser;
[0114] based on the target parser, extracting API key data from the second target data according to the parsing rule corresponding to the target parser;
[0115] based on the metadata model, assembling the API key data into a structured data object;
[0116] serializing the structured data object to generate a standard format file, and defining the standard format file as the structured metadata.
[0117] Specifically, as shown in Figure 5 The metadata model defines the specification of a certain model, that is, the elements of the model and the management between the elements, defines the 1:1 dependency relationship between entities, and instantiation is the model and metadata, which is the specification of the relationship between the elements of the model and the elements, can make the definition and connection of the model more standardized, realize the structured representation of microservice / API information, and can be completed through an automatic metadata generation method, including extracting key information from source code, documents, annotations or configuration files, and converting it into a structured metadata format, specifically:
[0118] (1) defining a metadata model.
[0119] Define a metadata model that defines the structure and content of the API information to be extracted. The metadata model can include the following main parts: basic information such as service name, version number, description, author, contact information, endpoint information such as API path, request method (GET, POST, PUT, DELETE, etc.), request parameters, response type, status code, authentication information such as authentication method (such as OAuth, API Key, Basic Auth, etc.), authentication URL, Token validity period, data model: request and response data structure, usually described using JSON Schema or OpenAPI Schema, document link: link to more detailed API documentation.
[0120] (2) Write a parser.
[0121] Write a parser to extract API information from source code or configuration files, including, comment parsing: extract information from comments in source code (such as Swagger / OpenAPI comments), document parsing: parse information from API documents in Markdown, YAML or JSON format, code analysis: use static code analysis tools to analyze source code, extract API endpoints, parameters and type information.
[0122] (3) Automatically generate metadata.
[0123] Use the information extracted by the parser to automatically generate structured metadata. You can use libraries or frameworks in programming languages such as Python, Java to handle the parsing and generation process. Specifically, read configuration files: first read configuration files that define which source code files or documents need to be parsed, parse and extract: call the parser to extract API information from the specified files, build metadata: build structured data that conforms to the metadata model based on the extracted information, output metadata: output the generated metadata in JSON, YAML or other easy-to-use and store formats.
[0124] (4) Continuous integration and update.
[0125] Integrate the metadata generation process into the CI / CD pipeline to ensure that the metadata is automatically updated whenever the code or document is updated. Specifically, code commit trigger: when code is committed to the version control system (such as Git), trigger the CI / CD pipeline, automated testing: run automated tests to ensure the correctness of the code and documents before generating metadata, metadata generation and verification: generate metadata and verify its integrity and accuracy, deployment and update: deploy the updated metadata to the corresponding system or storage.
[0126] Based on this, the structured representation of microservice / API information can be realized.
[0127] After generating the structured metadata, the method further includes using a relational database (such as MySQL) or a columnar database (such as Cassandra, HBase) to respectively store the structured metadata and the large-scale, sparse metadata, while using a file storage (such as HDFS, S3) to save the model parameters and other metadata, efficiently read and use through memory mapping, and establish a metadata registration module for registering various types of metadata in the system, ensuring consistency and accessibility; for frequently updated data such as model metadata, version management is performed to ensure that the required metadata version can be accurately obtained when the model is updated; at the same time, access to metadata is strictly controlled to prevent unauthorized access and modification.
[0128] In some embodiments, determining the domain ontology and the association relationship between the domain ontologies, and constructing an initial semantic knowledge graph based on the domain ontology and the association relationship between the domain ontologies includes:
[0129] Based on the microservice architecture and API management requirements, the domain ontology and the association relationship between the domain ontologies are constructed;
[0130] Based on the domain ontology, specific object instances in multiple data sources are instantiated as entity nodes of corresponding classes, and relationship edges are established between the entity nodes according to the association relationship between the domain ontologies;
[0131] Based on the entity nodes and the relationship edges, the initial semantic knowledge graph is generated.
[0132] In some embodiments, based on the structured metadata, an entity is determined, and the entity is subjected to a second preprocessing, the second preprocessing result is mapped to the initial semantic knowledge graph, and a target semantic knowledge graph is generated, including:
[0133] Based on the structured metadata and the initial semantic knowledge graph, a to-be-processed entity is determined;
[0134] The to-be-processed entity is subjected to entity disambiguation and semantic encoding processing;
[0135] The entity subjected to entity disambiguation and semantic encoding processing is fused with the entity in the initial semantic knowledge graph, and based on the structured metadata and the semantic encoding result, static relationship edges and semantic relationship edges are established between entities;
[0136] Based on the fusion result and the static relationship edges and the semantic relationship edges, the target semantic knowledge graph is generated.
[0137] Specifically, based on the microservice architecture and API management requirements, a domain ontology is constructed, and the following core classes and relationships are defined: (1) Core classes: Microservice class (Microservice): contains service name, version, function description, module, etc. attributes, API class (API): contains API path, request method (GET / POST, etc.), parameter type, response format, etc. attributes, entity class (Entity): contains entity objects in the data model (such as users, orders, etc.), user class (User): contains developer role, historical call record, preference tag, etc. attributes; (2) Relationship definition: call relationship (calls): represents the calling dependency between microservices and APIs, contains relationship (contains): represents the ownership relationship between microservices and APIs, semantic association (semanticallyRelated): defines the semantic similarity between entities based on domain knowledge; (3) Ontology extension mechanism: support domain term extension through custom annotation attributes (such as @domainTag), ensure that the ontology can adapt to different industry scenarios (such as finance, e-commerce, etc.); (2) Entity extraction process includes, metadata analysis: extract structured information from microservice documents, API annotations, use regular expressions and natural language processing (NLP) techniques to identify entity keywords (such as "user authentication API", "order management service"), entity disambiguation: eliminate homonym entity ambiguity (such as "order" may refer to e-commerce orders or logistics orders) through WordNet and other semantic libraries, determine the unique identifier in combination with the context, entity classification: map the extracted entity to the corresponding class in the ontology (such as API path / user / login mapped to API class), static relationship mapping: generate calls relationship by analyzing code dependencies (such as interface calls between microservices), use static code analysis tools (such as SonarQube) to extract call chains, dynamic relationship mapping: capture real-time interaction between services based on runtime logs (such as Kubernetes monitoring data), generate dynamic call relationship graph, semantic relationship construction: use BERT and other pre-trained models to calculate the semantic similarity between entities, when the similarity threshold (such as >0.7) is met, generate semanticallyRelated relationship, or, according to the fitting coefficient, determine the semantic relationship, the calculation method of the fitting coefficient is:
[0138]
[0139]
[0140] where H represents the fitting coefficient, 、 、 all represent weight coefficients for adjusting the influence degree of different parts in the formula on the fitting coefficient H, and can be optimized according to actual scenes (such as different business fields and data characteristics), represent the distance between entities (such as semantic distance, feature distance, etc.), and c represents the count type index of the entity, represent the correction coefficient, represent the size of the sliding window, B represents the fitting coefficient, and x, y, and z all represent different feature values related to the entity, such as semantic feature values, attribute values, etc. The above feature values can be fused.
[0141] When the fitting coefficient value is greater than the preset threshold, it indicates that there is an association between the two, that is, the corresponding semantic relationship can be constituted, wherein the preset threshold can be set according to the world demand, and the target semantic knowledge graph is as follows:
[0142] (user authentication service)-[:calls]->(user login API);
[0143] (order management service)-[:calls]->(order creation API);
[0144] (payment service)-[:calls]->(payment request API);
[0145] (user authentication service)-[:contains]->(user login API);
[0146] (order management service)-[:contains]->(order creation API);
[0147] (payment service)-[:contains]->(payment request API);
[0148] (user)-[:semanticallyRelated]->(user login API);
[0149] (order)-[:semanticallyRelated]->(order creation API);
[0150] (payment record)-[:semanticallyRelated]->(payment request API).
[0151] Further, after generating the target semantic knowledge graph, a hybrid architecture of graph database and distributed storage is adopted, core graph storage: the ontology structure and relationship are stored using Neo4j graph database, and its native graph index is used to optimize complex relationship query (such as multi-hop call chain query), mass metadata storage: mass data such as historical call logs and user behaviors are stored through HBase column database, the graph database node ID is associated with the HBase table, the query mechanism is Cypher query optimization: special query statements are designed for microservice recommendation scenarios, for example: MATCH (u: User)- [: uses] - (a: API)- [: belongsTo] - (ms: Microservice) WHERE u.role =“developer” AND ms.domain=“finance” RETURN ms, COUNT (a) AS apiCount ORDER BY apiCount DESC, real-time query acceleration: Redis cache is introduced to cache high-frequency query results (such as popular microservice list), so as to reduce database load, distributed query: Apache TinkerPop framework is used to realize cross-node graph query, and supports million-level node response per second.
[0152] In some embodiments, generating an initial API intelligent recommendation list according to the target semantic knowledge graph, combining a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm includes:
[0153] Receiving a recommendation request, the recommendation request including a user identifier;
[0154] According to the user identifier, obtaining relevant user behavior data and a candidate API set from the target semantic knowledge graph;
[0155] Combining the target semantic knowledge graph, at least one of the following algorithms is executed to score the candidate API set: a semantic similarity algorithm based on semantic vectors, a user behavior analysis algorithm based on user behavior sequences, and a collaborative filtering algorithm based on user and service interaction matrix;
[0156] Based on the scoring result, the candidate API set is sorted to generate the initial API intelligent recommendation list.
[0157] In some embodiments, adjusting the initial API intelligent recommendation list based on service popularity to obtain a target API intelligent recommendation list includes:
[0158] Obtaining the initial API intelligent recommendation list, wherein the target API in the initial API intelligent recommendation list has an initial recommendation score;
[0159] determine a service hotness score of a target API in the initial API intelligent recommendation list based on historical invocation data;
[0160] based on a preset hotness weight coefficient, weighting and fusing the initial recommendation score of the target API and the service hotness score to determine a comprehensive score;
[0161] reordering the APIs in the initial API intelligent recommendation list according to the comprehensive score to generate a target API intelligent recommendation list.
[0162] Specifically, the algorithm framework of the recommendation algorithm based on semantic similarity includes: (1) semantic vector construction: converting the description text of a microservice / API into a semantic vector, and adopting BERT semantic encoding and ontology embedding for construction, BERT semantic encoding: using a pre-trained BERT model to convert service description (such as "user authentication microservice, supporting OAuth2.0 protocol") into a 768-dimensional vector, ontology embedding (Ontology Embedding): mapping classes and relationships in the ontology to a low-dimensional vector space (such as using the TransE model), preserving the semantic structure; (2) calculating the semantic distance between the target service and the candidate service by using the cosine similarity formula, wherein the cosine similarity formula includes:
[0163]
[0164] wherein, , are the semantic vectors of the target service and the candidate service respectively, denotes the semantic distance between the target service and the candidate service .
[0165] (3) returning the top N recommendation results in descending order of similarity, and adjusting the weight combining the service invocation frequency (hotness), and the calculation formula is:
[0166]
[0167] wherein, a is the hotness weight coefficient, and the optimal value is 0.3-0.5, and callFreq represents the service invocation frequency.
[0168] Further, the specific process of the recommendation algorithm based on user behavior analysis includes: (1) behavior data modeling: abstracting user operations (such as API calls, document viewing, and favorite services) into triples: (user ID, operation type, target resource), for example, (u001, call, / api / order / create); (2) sequence pattern mining: using LSTM (Long Short-Term Memory Network) to capture user behavior sequence patterns, for example, input-user recent call sequence [A, B, C], output-predict the next possible call service D; (3) context-aware recommendation: adjusting the recommendation results in combination with the current operation scenario of the user (such as the development environment, the deployment stage), for example, in the development stage, test class APIs (such as / api / test / mock) are preferentially recommended; in the production environment, high-availability microservices are preferentially recommended.
[0169] Further, the specific process of the recommendation algorithm based on collaborative filtering includes: user-service interaction matrix: constructing a sparse matrix where m is the number of users, n is the number of services, represents the number of calls (or ratings) of user i to service j, matrix factorization (MF): decomposing the matrix into user latent factor matrix P and service latent factor matrix Q, and optimizing the objective function through gradient descent:
[0170]
[0171] where is a regularization coefficient to avoid overfitting, represents the latent factor vector of user i, represents the latent factor vector of service j, represents the user latent factor matrix, represents the service latent factor matrix.
[0172] Domain collaborative filtering: calculating the similarity between users / services, including: using the Pearson correlation coefficient to calculate the preference similarity between users, and the calculation formula is as follows:
[0173]
[0174] where I is the set of services called by user and user , represents the similarity between user and user , represents the number of calls (or ratings) of user to service i, represents the number of calls (or ratings) of user to service i, , respectively represent a user , a user average number of calls (or average score) to all services.
[0175] Hybrid strategy: combine the results of matrix decomposition and neighborhood collaborative filtering to improve recommendation accuracy through weighted fusion, wherein the weighted fusion is to combine a preset weight coefficient to calculate the results determined by the above algorithms to obtain an optimal result, i.e., a comprehensive score, such as comprehensive score = semantic score x 0.4 + behavior score x 0.3 + collaborative score x 0.3, reorder the APIs in the initial API intelligent recommendation list according to the comprehensive score, and generate a target API intelligent recommendation list. When the complexity of the target scene is large, such as when the data volume is greater than a certain value, the value can be set according to actual needs, a data analysis model is used to convert the results obtained by the above semantic similarity algorithm and / or user behavior analysis algorithm and / or collaborative filtering algorithm, and according to the converted results, a corresponding comprehensive score is generated to determine the final API intelligent recommendation list, wherein the data analysis model includes:
[0176]
[0177] wherein, represents a permutation result, represents a result collection period, i.e., a collection period of the results obtained by the above semantic similarity algorithm and / or user behavior analysis algorithm and / or collaborative filtering algorithm, represents a permutation coefficient, represents a permutation function, represents an average value of input feature values, i.e., an average value of the results obtained by the above semantic similarity algorithm and / or user behavior analysis algorithm and / or collaborative filtering algorithm, represents a collection frequency, represents a feature coefficient, according to the permutation result and a pre-stored mapping relationship table, a corresponding comprehensive score can be determined, and then based on the comprehensive score, a corresponding API intelligent recommendation list can be generated.
[0178] Further, when a new user behavior or service is updated, an online learning algorithm (such as FTRL) is used to dynamically update the model to avoid full retraining; distributed computing: based on the Spark GraphX framework, parallel computing of large-scale graph and recommendation algorithm is realized, for example: semantic similarity calculation-uses MapReduce to process million-level service vectors in parallel; collaborative filtering matrix decomposition-uses the ALS (alternating least squares) algorithm of Spark MLlib; cold start solution: user cold start-recommends popular services related to the field through user registration information (such as industry, technology stack); service cold start-bases on ontology semantic association, binds new services with similar existing services for recommendation.
[0179] Performance evaluation indicators include accuracy, recall, score and response time, specifically:
[0180] Accuracy (Precision): The proportion of relevant services in the recommended results:
[0181]
[0182] Recall (Recall): The proportion of recommended results covering the actual needs of users:
[0183]
[0184] Score: The combination of accuracy and recall:
[0185]
[0186] Response time: The recommendation delay under the test of 100 million node graph, requiring 95% request response time < 500ms. Based on this, the algorithm is optimized, and the corresponding performance is evaluated, so as to further improve the accuracy of API intelligent recommendation.
[0187] In the API intelligent recommendation method based on the semantic knowledge graph, the method comprises the following steps: determining a data crawling mechanism according to a target scene, collecting first target data of an API based on the data crawling mechanism, and performing first preprocessing on the first target data to obtain second target data; determining a metadata model, determining a target parser based on the metadata model, and extracting API key data from the second target data based on the target parser to generate structured metadata; determining a domain ontology and an association relationship between the domain ontologies, constructing an initial semantic knowledge graph based on the domain ontology and the association relationship between the domain ontologies, and the domain ontology is used to describe a standardized relationship rule established in a microservice and API management field; determining an entity based on the structured metadata, performing second preprocessing on the entity, mapping a second preprocessing result to the initial semantic knowledge graph, generating a target semantic knowledge graph, and the entity is a basic unit constituting the knowledge graph; generating an initial API intelligent recommendation list according to the target semantic knowledge graph, combining a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, adjusting the initial API intelligent recommendation list based on service heat, and obtaining a target API intelligent recommendation list. Through the intelligent recommendation method fusing the semantic knowledge graph and the multi-source data, the application realizes accurate and personalized recommendation of microservices / APIs. The application can not only understand functional requirements based on semantic similarity, but also improve recommendation accuracy by combining user behavior analysis. Meanwhile, a service heat adjustment mechanism is introduced to ensure that the recommendation result has both personalization and practicality, effectively reduces development complexity, and improves service reuse rate and development efficiency.
[0188] It should be understood that, although Figures 2-5 the steps in the flowcharts are shown in a sequence indicated by arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the steps are not necessarily limited in sequence, and the steps can be executed in other sequences. Moreover, Figures 2-5 at least part of the steps in the flowcharts can include multiple sub-steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times. The execution sequence of the sub-steps or stages is not necessarily sequential, but can be executed in rotation or alternation with other steps or sub-steps or stages of other steps.
[0189] In one embodiment, as shown in Figure 6 , an API intelligent recommendation device based on a semantic knowledge graph is provided, comprising a data acquisition module, a data processing module, a first semantic knowledge graph construction module, a second semantic knowledge graph construction module, and an intelligent recommendation module, wherein:
[0190] The data collection module is configured to determine a data collection mechanism according to a target scene, collect first target data of an API based on the data collection mechanism, and perform first preprocessing on the first target data to obtain second target data.
[0191] The data processing module is configured to determine a metadata model, determine a target parser based on the metadata model, and extract API key data from the second target data based on the target parser to generate structured metadata.
[0192] The first semantic knowledge graph construction module is configured to determine domain ontologies and association relationships between the domain ontologies, and construct an initial semantic knowledge graph based on the domain ontologies and the association relationships between the domain ontologies, wherein the domain ontologies are used to describe standardized relationship rules established in the microservice and API management field.
[0193] The second semantic knowledge graph construction module is configured to determine entities based on the structured metadata, perform second preprocessing on the entities, map a second preprocessing result to the initial semantic knowledge graph, and generate a target semantic knowledge graph, wherein the entities are basic units of the knowledge graph.
[0194] The intelligent recommendation module is configured to generate an initial API intelligent recommendation list according to the target semantic knowledge graph, in combination with a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, adjust the initial API intelligent recommendation list based on service popularity, and obtain a target API intelligent recommendation list.
[0195] As a preferred implementation, in the embodiment of the present application, the data collection module is specifically configured to:
[0196] Obtain relevant information of the target scene, wherein the relevant information includes at least one of a data source type, an update frequency, and a data volume.
[0197] Perform weighted fusion on the relevant information, and determine a data collection mechanism according to a weighted fusion result, wherein the data collection mechanism includes automatic collection and manual collection.
[0198] In response to the data collection mechanism being automatic collection, access and parse a target data source based on a preset parsing program to collect the first target data of the API.
[0199] In response to the data collection mechanism being manual collection, receive the first target data of the API input by a user based on a user interface.
[0200] The first target data at least includes a name, a description, an endpoint URL, and a request method of the API.
[0201] As a preferred implementation, in the embodiment of the present application, the data collection module is further used for:
[0202] performing data cleaning on the first target data to remove outliers and repeated data in the first target data;
[0203] performing format uniform processing on the first target data after data cleaning, the format uniform processing including data consistency processing and data type conversion;
[0204] based on the first target data after format uniform processing, extracting pre-set structured attribute data through rule matching, and performing normalization processing on the structured attribute data to generate the second target data.
[0205] As a preferred implementation, in the embodiment of the present application, the data processing module is specifically used for:
[0206] determining the metadata model, the metadata model being used to describe structured fields required by microservices or APIs, including at least one of the following: basic information, endpoint information, authentication information, data model and document link;
[0207] based on the metadata model, analyzing a plurality of target data sources to establish a mapping relationship between fields of the metadata model and information bearing positions in the target data sources;
[0208] based on the mapping relationship, determining at least one target parser and a parsing rule, wherein the target parser is configured to extract information from the corresponding target data source according to the parsing rule and instantiate the metadata model.
[0209] As a preferred implementation, in the embodiment of the present application, the data processing module is further used for:
[0210] inputting the second target data into the target parser;
[0211] based on the target parser, extracting API key data from the second target data according to the parsing rule corresponding to the target parser;
[0212] based on the metadata model, assembling the API key data into a structured data object;
[0213] performing serialization processing on the structured data object to generate a file in a standard format, and defining the file in the standard format as the structured metadata.
[0214] As a preferred implementation, in the embodiment of the present application, the first semantic knowledge graph construction module is specifically used for:
[0215] constructing a domain ontology and an association relationship between the domain ontologies based on a micro-service architecture and API management requirements;
[0216] instantiating specific object in a plurality of data sources as entity nodes of corresponding classes based on the domain ontology, and establishing relationship edges between the entity nodes according to the association relationship between the domain ontologies;
[0217] generating the initial semantic knowledge graph based on the entity nodes and the relationship edges.
[0218] As a more preferred embodiment, in the embodiment of the present application, the second semantic knowledge graph construction module is specifically configured to:
[0219] determining an entity to be processed based on the structured metadata and the initial semantic knowledge graph;
[0220] performing entity disambiguation and semantic encoding processing on the entity to be processed;
[0221] fusing the entity after the entity disambiguation and semantic encoding processing with the entity in the initial semantic knowledge graph, and establishing static relationship edges and semantic relationship edges between entities based on the structured metadata and the semantic encoding result;
[0222] generating the target semantic knowledge graph based on the fusion result and the static relationship edges and the semantic relationship edges.
[0223] As a more preferred embodiment, in the embodiment of the present application, the intelligent recommendation module is specifically configured to:
[0224] receiving a recommendation request, the recommendation request including a user identifier;
[0225] obtaining relevant user behavior data and a candidate API set from the target semantic knowledge graph according to the user identifier;
[0226] performing at least one of the following algorithms for scoring the candidate API set in combination with the target semantic knowledge graph: a semantic similarity algorithm based on semantic vectors, a user behavior analysis algorithm based on user behavior sequences, and a collaborative filtering algorithm based on a user and service interaction matrix;
[0227] sorting the candidate API set based on the scoring result to generate an initial API intelligent recommendation list.
[0228] As a more preferred embodiment, in the embodiment of the present application, the intelligent recommendation module is specifically further configured to:
[0229] obtain the initial API intelligent recommendation list, wherein a target API in the initial API intelligent recommendation list has an initial recommendation score;
[0230] based on historical calling data, determine a service heat score of a target API in the initial API intelligent recommendation list;
[0231] based on a preset heat weight coefficient, weight and fuse the initial recommendation score and the service heat score of the target API to determine a comprehensive score;
[0232] reorder the APIs in the initial API intelligent recommendation list according to the comprehensive score to generate a target API intelligent recommendation list.
[0233] The specific limitations of the API intelligent recommendation device based on the semantic knowledge graph can be referred to the limitations of the API intelligent recommendation method based on the semantic knowledge graph in the foregoing, and will not be described here. Each module in the API intelligent recommendation device based on the semantic knowledge graph can be realized by software, hardware and a combination thereof in whole or in part. Each module can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each module.
[0234] In one embodiment, a computer device, which can be a terminal, has an internal structure diagram as shown in Figure 7 The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The network interface of the computer device is configured to communicate with external terminals through network connection. The computer program is executed by the processor to implement an API intelligent recommendation method based on a semantic knowledge graph. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.
[0235] Those skilled in the art can understand that Figure 7The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0236] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
[0237] S1: determining a data crawling mechanism according to a target scenario, collecting first target data of an API based on the data crawling mechanism, and performing first preprocessing on the first target data to obtain second target data;
[0238] S2: determining a metadata model, determining a target parser based on the metadata model, and extracting API key data from the second target data based on the target parser to generate structured metadata;
[0239] S3: determining domain ontologies and association relationships between the domain ontologies, constructing an initial semantic knowledge graph based on the domain ontologies and the association relationships between the domain ontologies, the domain ontologies being used to describe standardized relationship rules established in the microservice and API management domain;
[0240] S4: determining an entity based on the structured metadata, performing second preprocessing on the entity, mapping a second preprocessing result to the initial semantic knowledge graph, and generating a target semantic knowledge graph, the entity being a basic unit constituting the knowledge graph;
[0241] S5: generating an initial API intelligent recommendation list according to the target semantic knowledge graph, combining a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, adjusting the initial API intelligent recommendation list based on service heat, and obtaining a target API intelligent recommendation list.
[0242] In one embodiment, a computer readable storage medium is provided, having a computer program stored thereon, the computer program being executed by a processor to implement the following steps:
[0243] S1: determining a data crawling mechanism according to a target scenario, collecting first target data of an API based on the data crawling mechanism, and performing first preprocessing on the first target data to obtain second target data;
[0244] S2: determine a metadata model, determine a target parser based on the metadata model, extract API key data from the second target data based on the target parser to generate structured metadata;
[0245] S3: determine a domain ontology and a correlation relationship between the domain ontologies, construct an initial semantic knowledge graph based on the domain ontology and the correlation relationship between the domain ontologies, the domain ontology is used to describe a standardized relationship rule established by a micro service and an API management field;
[0246] S4: determine an entity based on the structured metadata, perform a second preprocessing on the entity, map a second preprocessing result to the initial semantic knowledge graph to generate a target semantic knowledge graph, the entity is a basic unit constituting a knowledge graph;
[0247] S5: generate an initial API intelligent recommendation list according to the target semantic knowledge graph, combine a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, adjust the initial API intelligent recommendation list based on service heat to obtain a target API intelligent recommendation list.
[0248] In one embodiment, a computer program product is provided, the computer program product comprising a computer program, the computer program being executed by a processor to implement the following steps:
[0249] S1: determine a data crawling mechanism according to a target scenario, collect first target data of an API based on the data crawling mechanism, and perform a first preprocessing on the first target data to obtain second target data;
[0250] S2: determine a metadata model, determine a target parser based on the metadata model, extract API key data from the second target data based on the target parser to generate structured metadata;
[0251] S3: determine a domain ontology and a correlation relationship between the domain ontologies, construct an initial semantic knowledge graph based on the domain ontology and the correlation relationship between the domain ontologies, the domain ontology is used to describe a standardized relationship rule established by a micro service and an API management field;
[0252] S4: determine an entity based on the structured metadata, perform a second preprocessing on the entity, map a second preprocessing result to the initial semantic knowledge graph to generate a target semantic knowledge graph, the entity is a basic unit constituting a knowledge graph;
[0253] S5: generating an initial API intelligent recommendation list according to the target semantic knowledge graph, combining a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, adjusting the initial API intelligent recommendation list based on service heat to obtain a target API intelligent recommendation list.
[0254] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing related hardware, and the computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. Any reference to memory, storage, database or other medium used in the embodiments provided by the present 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. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0255] The technical features of the above embodiments can be combined in any way. To make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not contradict, they should be considered within the scope of the present disclosure.
[0256] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, some modifications and improvements can be made, which are within the scope of the present application.
Claims
1. A method for intelligent API recommendation based on a semantic knowledge graph, characterized in that, The method comprises: According to the target scene, determine the data grabbing mechanism, based on the data grabbing mechanism, collect the first target data of API, and perform first preprocessing on the first target data to obtain second target data; Determine the metadata model, determine the target parser based on the metadata model, extract the API key data from the second target data based on the target parser to generate structured metadata; Determine the domain ontology and the association relationship between the domain ontologies, construct an initial semantic knowledge graph based on the domain ontology and the association relationship between the domain ontologies, and the domain ontology is used to describe the standardized relationship rule established in the micro-service and API management field; Based on the structured metadata, determine the entity, and perform second preprocessing on the entity, map the second preprocessing result to the initial semantic knowledge graph to generate a target semantic knowledge graph, and the entity is a basic unit constituting the knowledge graph; According to the target semantic knowledge graph, combine the semantic similarity algorithm and / or user behavior analysis algorithm and / or collaborative filtering algorithm to generate an initial API intelligent recommendation list, adjust the initial API intelligent recommendation list based on service heat to obtain a target API intelligent recommendation list; According to the target scene, determine the data grabbing mechanism, based on the data grabbing mechanism, collect the first target data of API, and perform first preprocessing on the first target data to obtain second target data; Obtain relevant information of the target scene, the relevant information including at least one of the following: data source type, update frequency and data volume; Weighted fusion is performed on the relevant information, and the data grabbing mechanism is determined according to the weighted fusion result, the data grabbing mechanism including automatic grabbing and manual grabbing; In response to the data grabbing mechanism being automatic grabbing, access and parse the target data source based on the preset parsing program to collect the first target data of the API; In response to the data grabbing mechanism being manual grabbing, receive the first target data of the API input by the user based on the user interface; Wherein, the first target data at least includes the name, description, endpoint URL and request method of API; Based on the structured metadata, determine the entity, and perform second preprocessing on the entity, map the second preprocessing result to the initial semantic knowledge graph to generate a target semantic knowledge graph, and the entity is a basic unit constituting the knowledge graph; Based on the structured metadata and the initial semantic knowledge graph, determine the entity to be processed; Perform entity disambiguation and semantic coding processing on the entity to be processed; Fuse the entity after entity disambiguation and semantic coding processing with the entity in the initial semantic knowledge graph, and based on the structured metadata and the semantic coding result, establish static relationship edges and semantic relationship edges between entities; Based on the fusion result and the static relationship edges and the semantic relationship edges, generate the target semantic knowledge graph. 2.The semantic knowledge graph based API intelligent recommendation method according to claim 1, characterized in that, The first preprocessing on the first target data includes: Data cleaning is performed on the first target data to remove outliers and duplicate data in the first target data; The first target data after data cleaning is subjected to format uniform processing, and the format uniform processing includes data consistency processing and data type conversion; Based on the first target data after format uniform processing, the pre-set structured attribute data is extracted through rule matching, and the structured attribute data is normalized to generate the second target data. 3.The method of claim 2, wherein, Determine the metadata model, and determine the target parser based on the metadata model, including: Determine the metadata model, which is used to describe the structured fields required by microservices or APIs, including at least one of the following: basic information, endpoint information, authentication information, data model and document link; Based on the metadata model, analyze a plurality of target data sources to establish a mapping relationship between the fields of the metadata model and the information bearing positions in the target data sources; Based on the mapping relationship, determine at least one target parser and parsing rule, wherein the target parser is configured to extract information from the corresponding target data source according to the parsing rule and instantiate the metadata model. 4.The method of claim 3, wherein, Based on the target parser, extract API key data from the second target data to generate structured metadata, including: Input the second target data into the target parser; Based on the target parser, extract API key data from the second target data according to the parsing rule corresponding to the target parser; Based on the metadata model, assemble the API key data into a structured data object; Serializing the structured data object generates a standard format file, and the standard format file is defined as the structured metadata. 5.The method of claim 4, wherein, Determine the domain ontology and the association relationship between the domain ontologies, and construct an initial semantic knowledge graph based on the domain ontology and the association relationship between the domain ontologies, including: Based on the microservice architecture and API management requirements, construct the domain ontology and the association relationship between the domain ontologies; Based on the domain ontology, instantiate specific object instances in multiple data sources into entity nodes of corresponding classes, and establish relationship edges between the entity nodes according to the association relationship between the domain ontologies; Based on the entity nodes and the relationship edges, generate the initial semantic knowledge graph. 6.The method of claim 5, wherein, According to the target semantic knowledge graph, combine the semantic similarity algorithm and / or user behavior analysis algorithm and / or collaborative filtering algorithm to generate an initial API intelligent recommendation list, including: Receive a recommendation request, and the recommendation request includes a user identifier; According to the user identifier, obtain related user behavior data and a candidate API set from the target semantic knowledge graph; Combine the target semantic knowledge graph to score the candidate API set by at least one of the following algorithms: semantic similarity algorithm based on semantic vector, user behavior analysis algorithm based on user behavior sequence, and collaborative filtering algorithm based on user and service interaction matrix; Based on the scoring result, sort the candidate API set to generate the initial API intelligent recommendation list. 7.The method of claim 6, wherein, The initial API intelligent recommendation list is adjusted based on service heat to obtain a target API intelligent recommendation list, which comprises: An initial API intelligent recommendation list is obtained, wherein a target API in the initial API intelligent recommendation list has an initial recommendation score; Based on historical calling data, a service heat score of the target API in the initial API intelligent recommendation list is determined; Based on a preset heat weight coefficient, the initial recommendation score and the service heat score of the target API are weighted and fused to determine a comprehensive score; The APIs in the initial API intelligent recommendation list are reordered according to the comprehensive score to generate a target API intelligent recommendation list.
8. A semantic knowledge graph-based API intelligent recommendation system for implementing the semantic knowledge graph-based API intelligent recommendation method of claim 1. The system comprises: A data acquisition module configured to determine a data crawling mechanism according to a target scenario, acquire first target data of an API based on the data crawling mechanism, and perform first preprocessing on the first target data to obtain second target data; A data processing module configured to determine a metadata model, determine a target parser based on the metadata model, and extract API key data from the second target data based on the target parser to generate structured metadata; A first semantic knowledge graph construction module configured to determine domain ontologies and associated relationships between the domain ontologies, construct an initial semantic knowledge graph based on the domain ontologies and the associated relationships between the domain ontologies, and use the domain ontologies to describe standardized relationship rules established in the microservice and API management field; A second semantic knowledge graph construction module configured to determine entities based on the structured metadata, perform second preprocessing on the entities, map a second preprocessing result to the initial semantic knowledge graph, and generate a target semantic knowledge graph, wherein the entities are basic units of the knowledge graph; An intelligent recommendation module configured to generate an initial API intelligent recommendation list according to the target semantic knowledge graph, combine a semantic similarity algorithm and / or a user behavior analysis algorithm and / or a collaborative filtering algorithm, and adjust the initial API intelligent recommendation list based on service heat to obtain a target API intelligent recommendation list.
Citation Information
Patent Citations
Web API recommendation method and system based on knowledge graph
CN115268995A
API recommendation method and device, equipment and storage medium
CN117093204A