Intent clarification method based on knowledge graph driven path optimization for API recommendation
Through the driver path optimization intention clarification method based on knowledge graph, the problem of intent clarification in existing API search technology is solved, and the API recommendations of efficient, diverse and interpretable are achieved, meeting the developers' needs for practical APIs .
Patent Information
- Application Number
- CN202310757316.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-26
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2043-06-26
AI Technical Summary
Existing API search technology is difficult to effectively clarify the developers' vague problem intentions, resulting in a single query result and an inefficient query process, which cannot meet developers' API recommendation needs for inspiration, diversity and interpretability.
Using a knowledge graph-based driver path optimization intent clarification method, the relationship categories between entities are enriched by extracting API actions, events, objects and constraints from the initial API document, and the knowledge graph is used as a carrier to store these entities and relationships. Based on this, an efficient dialogue process is generated, and user needs are clarified through subgraph search and decision tree algorithms, and APIs are expanded to provide interpretability.
It realizes efficient API recommendation and knowledge discovery, provides diversified, inspiring and interpretable API recommendations, significantly improving the efficiency of the query process, and meeting developers' needs for practical APIs.
Smart Images

Figure CN116860991B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of application programming interface (API) recommendation, and in particular to an intent clarification method based on knowledge graph-driven path optimization for API recommendation. Background Art
[0002] Developers' demands for application programming interfaces (APIs) have gone beyond simply looking for the so-called best API for a specific programming task. To minimize the misuse of APIs, they must consider multiple aspects, such as the specific usage context of the API, the relationship with the cooperating API, and the confusion between similar APIs with minor differences. Therefore, API search technology should aim to guide developers to clarify ambiguous problem intentions, provide diverse and inspiring APIs for different needs, explain search results, and expand other potentially useful API knowledge. This expectation reveals some practical API requirements, namely, seeking API recommendations and knowledge discovery that are revealing, explainable, and extensible, rather than just presenting the so-called best API. Meeting these practical API requirements not only helps developers choose the ideal API for their needs, but also stimulates and expands their thinking, such as exploring alternative or better solutions and discovering previously unknown API knowledge.
[0003] Mainstream API search technologies use API query statements to directly search for APIs, which can be roughly divided into the following two categories:
[0004] (1) Keyword matching-based methods. This type of method uses fuzzy keyword matching to retrieve APIs that match the literal meaning of the keywords (such as API names, requirement descriptions, and tags). However, this method is limited by the semantic relationship between keywords.
[0005] (2) Methods based on deep learning. This type of method requires the query to contain enough keywords to accurately reflect the user's needs. However, in practice, due to the lack of keywords in the query, the developer's intention is not fully expressed, which seriously reduces the effectiveness of deep learning methods.
[0006] In order to solve the problem of insufficient keywords in the initial query, methods based on intent clarification have been proposed, which are mainly divided into the following two categories:
[0007] (1) Methods based on query expansion. Query expansion methods retrieve query-related expansion keywords from the knowledge base and modify or add them to the initial query statement. However, these methods may bring negative expansion effects, because it is difficult to fully express the user's expansion needs with the keywords in the initial query statement alone. If the knowledge base lacks correct expansion keywords, the effect of knowledge recommendation will be greatly reduced.
[0008] (2) Methods based on query clarification. These methods accurately express user needs by asking clarifying questions, providing options for interaction with users, and adjusting query statements based on user responses. However, the performance of such methods depends on the diversity and scale of training data. If the correct expansion keywords are missing in the training data, the query results will be monotonous. Even if expansion keywords are present in the information, these methods may require multiple rounds of query clarification to accurately capture the user's intentions and obtain the correct expansion keywords, which greatly reduces the efficiency of the query clarification process.
[0009] In summary, we summarize two limitations of existing methods.
[0010] Limitation 1: The query results are single; the knowledge recommendation of existing methods is limited to recommending the so-called best APIs, but lacks inspiring, diverse and explainable recommendation knowledge, thus failing to meet the needs of developers for practical APIs.
[0011] Limitation 2: Inefficient query process: Existing methods lack efficient query clarification guidance for query statements with unclear requirements or unspecified details, resulting in too many query rounds and redundant information in the query process, making it impossible to recommend accurate and practical API knowledge in the shortest time. Summary of the invention
[0012] The purpose of the present invention is to provide an intent clarification method based on knowledge graph-driven path optimization for API recommendation in view of the deficiencies of the prior art, so as to solve the problems existing in the above-mentioned prior art.
[0013] To achieve the above objectives, on the one hand, the present invention provides an intent clarification method based on knowledge graph driven path optimization for API recommendation, comprising the following steps:
[0014] Step S1: extract entities that embody API actions, events, objects, and constraints from the initial API document, enrich the relationship categories between entities, including API functional relationships and API semantic relationships, and use the knowledge graph as a carrier to store the extracted entities and relationships with rich types;
[0015] Step S2: Based on the API knowledge graph, an efficient dialogue process is generated to clarify the user's needs, search for subgraphs from the knowledge graph according to the query statement input by the user, and design an efficient guidance mechanism and decision tree algorithm to generate a human-computer dialogue process according to the subgraph content;
[0016] Step S3: Expand the API and provide explainability, expand to obtain other APIs that have semantic relationships with the initial API, realize the mapping from the dialogue process to the knowledge graph, obtain the best clarification path for each API, and provide explanations.
[0017] In the above step S1, entities that embody API actions, events, objects, and constraints are extracted from the initial API document, and the relationship categories between entities are enriched, including API functional relationships and API semantic relationships. The extracted entities and relationships with rich types are stored in the knowledge graph as a carrier. The process is as follows:
[0018] Step S11: design sentence screening rules to extract API description sentences related to API behaviors from the API document;
[0019] Step S12: designing grammatical and semantic labels and annotation rules, and designing grammatical role annotation and semantic role annotation for API description statements accordingly;
[0020] Step S13, combining the grammatical role and the semantic role according to the rules to form an entity;
[0021] Step S14: Design entity relationships that reflect API behaviors to organize entities into triples;
[0022] Step S15: Use the knowledge graph as a carrier to store all triples to form an API behavior knowledge graph.
[0023] Furthermore, the design performs grammatical role annotation and semantic role annotation on the API description statements. There are 6 types of grammatical roles obtained through annotation, namely: verb, direct object, direct object modifier, preposition, preposition object, preposition object modifier; there are 9 types of semantic roles obtained through annotation, namely: position constraint, direction constraint, method constraint, scope constraint, time constraint, target constraint, purpose constraint, result constraint and condition constraint semantic roles.
[0024] 10. The relationship categories between the enriched entities in step S1, there are 6 types of enriched entities, including application program interface API, action Action, event Event, object Object, object constraint Object Constraint, event constraint Event Constraint; the relationship categories include event function relationship, constraint function relationship and semantic relationship;
[0025] The event function relationship is used to organize four types of entities: API, Action, Event, and Object, including API event API Has Event, action event Act Has Event, direct object Has Direct Object, and indirect object HasPreposition Object.
[0026] The constraint function relationship is used to organize four types of entities, namely, Event, Object, and Object Constraint, including 11 types, namely, Status Has Status, Type Has Type, Location Has Location, Direction Has Direction, Manner Has Manner, Range Has Extent, Time Has Temporal, Goal Has Goal, Purpose Has Purpose, Result Has Result, and Condition Has Condition.
[0027] The semantic relationships are used to organize different API entities, including seven categories: Function Similarity, Function Opposite, Function Replace, Function Collaboration, Logic Constraint, Behavior Difference, and Efficiency Comparison.
[0028] The search subgraph in step S2 is closely related to the user query statement. The search subgraph content includes the API entity and other entities and relationships related to the API entity. The entire efficient guidance mechanism process includes:
[0029] Step S21, converting entities and relationships in the subgraph into Aspects and their options, and designing an attribute table to store them;
[0030] Step S22, design a decision tree algorithm to select the best Aspect from the attribute table and narrow the subgraph range, the Aspect is used as a node of the decision tree, and the options corresponding to the Aspect are used as edges of the node;
[0031] Step S23, repeating steps S21 and S22 to generate a complete decision tree;
[0032] Step S24: design a clarification question template according to the decision tree, and finally form a human-computer dialogue process.
[0033] Furthermore, the decision tree algorithm is an information gain algorithm, which preferentially selects the Aspect with the largest information gain. The specific calculation formula is as follows:
[0034] Gain(aspect)=I(API1,...,API m )-E(aspect) (1)
[0035]
[0036]
[0037] In the above formula, Gain(aspect) represents information gain; (I(API1,…,API m )) represents the information entropy of all APIs; (E(aspect)) represents the information entropy of the current Aspect.
[0038] Furthermore, the human-computer dialogue process includes multiple rounds of human-computer interaction. Each round of human-computer interaction includes clarification questions and options generated by the system and options selected by the user. In the last round, the system will give a recommended API list. There are fourteen clarification question templates, corresponding to the 14 types of nodes in the decision tree, and all edges of each node are used as options.
[0039] The expansion in step S3 obtains other APIs that have a semantic relationship with the initial API, realizes the mapping from the dialogue process to the knowledge graph, and obtains the best clarification path for each API. The process of obtaining the clarification path includes:
[0040] Convert the conversation process into a path in a decision tree. This path is the most efficient path from the head node to the recommended API. The starting point of the path is the head node of the decision tree, and the end point is the recommended API list.
[0041] Mapping from the path in the decision tree to the knowledge graph, the nodes and edges in the path are restored to entities and relationships in the knowledge graph. These entities and relationships are connected in the knowledge graph and constitute the best clarification path.
[0042] On the other hand, the present invention also provides an intention clarification system using the above intention clarification method, including a diversified knowledge composition form construction module, a knowledge efficient guidance strategy module and a recommendation result expansion and interpretation module;
[0043] The knowledge form construction module is used to take the API description statements in the API document as input, extract API behavior knowledge, and output various entities and entity relationships, and store them in the API behavior knowledge graph;
[0044] The knowledge efficient guidance strategy module is used to receive the initial query statement input by the user, use the subgraph search algorithm to search for a subgraph from the API behavior knowledge graph, and then use the subgraph as input to build a decision tree using the decision tree algorithm, generate each round of clarification questions and options based on the decision tree, and return them to the user; and update the decision tree according to the options selected by the user, generate a new round of clarification questions and options, and repeat this process until the user chooses to stop the conversation and output the recommended result API;
[0045] The recommendation result expansion and explanation module is used to take the result API as input, use the API expansion strategy, obtain the expansion API, and then obtain the optimal clarification path corresponding to each result API and the expansion API.
[0046] Compared with the prior art, the present invention has the following beneficial effects:
[0047] 1. The present invention provides an efficient query clarification method based on knowledge graph (KG)-driven path optimization for API recommendation, and designs a novel knowledge-aware artificial intelligence dialogue agent KAHAID, which combines the instant response capability of API research with the interaction, clarification, explanation and scalability capabilities of social technical information search; the present invention transforms API search from simply looking for the best API to enhancing the entire query process by providing potentially useful and inspiring knowledge, thereby achieving interactive, inspiring, explainable and scalable exploratory discovery.
[0048] 2. The present invention mines meaningful API behavior knowledge, including API operations, objects, constraints, and functional / semantic relationships, and organizes this knowledge into an API behavior knowledge graph KG; this comprehensive knowledge graph not only helps to clarify problems efficiently, but also enables users to navigate and understand API functions more effectively.
[0049] 3. Based on the basic knowledge graph, the present invention designs an efficient knowledge guidance strategy based on the decision tree algorithm to prioritize the best question aspects, reduce the rounds of question answering, and gradually guide developers to clarify ambiguous question intentions. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 It is a flow chart of the intent clarification method based on knowledge graph driven path optimization for API recommendation of the present invention;
[0051] Figure 2 It is a design diagram of a new knowledge organization form in an embodiment of the present invention;
[0052] Figure 3 is a flow chart of the knowledge extraction method in an embodiment of the present invention;
[0053] Figure 4It is a flow chart of the method for generating human-computer dialogue in an embodiment of the present invention. DETAILED DESCRIPTION
[0054] In order to make the technical concept and advantages of the invention more clearly understood, the technical solution of the invention is further described in detail below in conjunction with the accompanying drawings. It should be understood that the following embodiments are only used to explain and illustrate the preferred implementation methods of the invention and should not constitute a limitation on the scope of the patent protection required by the invention.
[0055] Example 1
[0056] like Figure 1 As shown, the present invention provides an intent clarification method based on knowledge graph driven path optimization for API recommendation, comprising:
[0057] Step S1: extract entities that embody API actions, events, objects, and constraints from the initial API document, enrich the relationship categories between entities, including API functional relationships and API semantic relationships, and use the knowledge graph as a carrier to store the extracted entities and relationships with rich types;
[0058] Step S2: Based on the API knowledge graph, an efficient dialogue process is generated to clarify the user's needs, search for subgraphs from the knowledge graph according to the query statement input by the user, and design an efficient guidance mechanism and decision tree algorithm to generate a human-computer dialogue process according to the subgraph content;
[0059] Step S3: Expand the API and provide explainability, expand to obtain other APIs that have semantic relationships with the initial API, realize the mapping from the dialogue process to the knowledge graph, obtain the best clarification path for each API, and provide explanations.
[0060] In order to meet the needs of practical APIs, the present invention designs a new knowledge organization form that is accurate, diverse, inspiring and explanatory; it uses the knowledge graph as a carrier to organize rich entities and entity relationships.
[0061] like Figure 2 As shown, in this embodiment, 6 types of entities are designed through processing and researching the API documents, and these entities are organized through 22 types of entity relationships.
[0062] There are 6 types of entities, including API, Action, Event, Object, Object Constraint, and Event Constraint. The Event entity includes two types of entities: Action and Object.
[0063] Entity relationships are designed from three aspects: event function relationship, constraint function relationship, and semantic relationship:
[0064] (1) The event function relationship is responsible for organizing the four types of entities: API, Action, Event, and Object, including the following four types: APIHasEvent, ActHasEvent, HasDirectObject, and HasPrepositionObject;
[0065] (2) Constraint relations are responsible for organizing the four types of entities: Event, Object, and Object Constraint, including object constraint relations and event constraint relations. Object constraint relations include two types: Has Status and Has Type. Event constraint relations include nine types: Has Location relation, Has Direction relation, Has Manner relation, Has Extent relation, Has Temporal relation, Has Goal relation, Has Purpose relation, Has Result relation, and Has Condition relation.
[0066] (3) Semantic relationships are responsible for organizing different API entities, including seven categories such as function replacement relationships and performance comparison relationships; they are: Function Similarity, Function Opposite, Function Replace, Function Collaboration, Logic Constraint, Behavior Difference, and Efficiency Comparison.
[0067] like Figure 3 As shown, the sub-process of extracting entities embodying API actions, events, objects and constraints from the initial API document in step S1 includes:
[0068] Step S11: design sentence screening rules to extract API description sentences related to API behaviors from the API document;
[0069] Step S12, designing grammatical and semantic labels and annotation rules, and designing grammatical role annotation and semantic role annotation for API description statements according to the grammatical labels and annotation rules; there are 6 types of grammatical roles obtained through annotation, namely verb, direct object, direct object modifier, preposition, preposition object, preposition objectmodifier; there are 9 types of semantic roles obtained through annotation, such as time constraint, location constraint, purpose constraint, aspect constraint and other constraint semantic roles;
[0070] Step S13, combining the grammatical role and the semantic role according to the rules to form an entity;
[0071] Step S14: Design entity relationships that reflect API behaviors to organize entities into triples;
[0072] Step S15: Use the knowledge graph as a carrier to store all triples to form an API behavior knowledge graph.
[0073] by Figure 3 For example, after receiving the initial input API description sentence "converts a path string, or asequence of strings that when joined form a path string, to a path", use NLP tools (including ALLenNLP, ChatGPT, etc.) to annotate the sentence components with multiple different labels (such as V, ARG1, ARGM-TMP and ARG2). Based on these labels, the various grammatical roles and semantic roles of the sentence are extracted. For example, the verb "convert" in the grammatical role is extracted according to the position of the V label, and the semantic role "time constraint" is extracted according to the label ARGM-TMP, which represents the time limitation of the entire event. Subsequently, these sentence components are combined to form entities. In this case, the verb, direct object and prepositional object are combined to form an Event entity, such as "convert a path string to a nonempty path". As the entities are formed, the relationships between them naturally emerge. All extracted entities and functional relationships are organized into triples. For example, the Action entity and the Event entity can form a "HasEvent" relationship, resulting in the triple <"convert", Act Has Event, "convert a path string to anonempty path">.
[0074] Finally, the Neo4j graph database is used to store the above triples to construct the API behavior knowledge graph.
[0075] In this embodiment, the performance of the above method is evaluated by experiments:
[0076] The accuracy of triples is verified through experiments; because triples contain entities and relations, their accuracy can effectively reflect the performance of knowledge extraction methods.
[0077] The experimental results show that the average accuracy of the triples is over 90%, and the minimum accuracy is 85%, which indicates that the triples constructed in this embodiment have high accuracy, and the method described in step S1 can efficiently extract accurate knowledge.
[0078] like Figure 4 The flowchart of the method for generating a human-computer dialogue in step 3 is shown, and the process includes the following four steps:
[0079] 1. Organize each API and functional relationship into a property table, such as Figure 4 -a to Figure 4 -b, constructing an attribute table is a key step in building a decision tree. This step converts the API and functional relationships into a two-dimensional form, which facilitates comparison of different aspects and helps to determine the most critical aspects that need to be clarified in the query; in this embodiment, the API entity and its functional relationship are referred to as API{<e1,r,e2> , ...}, and then convert it into a property table with an API column and multiple aspect columns. The first column of the property table is the API column, which contains the ID numbers of all matched APIs. The columns after the first column are aspect columns. Functional relationship<e1,r,e2> In the example, "e1#r" is selected as the column name, and "e2" is selected as the column value. Note that if<e1,r,e2> The r in the column represents the "Action Has Event" relationship, so use "action#Has Event" as the column name instead of "e1#r".
[0080] 2. Select key clarification aspects according to the attribute table and split the subgraph to obtain a sub-dataset. Selecting the best key clarification aspects helps minimize the height of the decision tree, thereby improving the efficiency of the question-answering process. In this embodiment, the decision tree algorithm ID3 based on information gain is used to select the aspect column with the highest information gain. A higher information gain indicates that there are more options or APIs related to the question, which helps reduce the number of conversation turns and guide users to quickly clarify their intentions.
[0081] Specifically, the decision tree algorithm calculation formula is as follows
[0082] Gain(aspect)=I(API1,...,API m)-E(aspect) (1)
[0083] The information gain of each attribute column can be calculated by formula (1), which is the difference between the information entropy I(API1, ..., APIm) of all APIs and the information entropy E(aspect) of the current attribute column. Entropy measures the uncertainty of random variables and characterizes the degree of impurity of the example. The higher the entropy, the greater the amount of information.
[0084]
[0085] The information entropy of all APIs I(API1, ..., APIm) is calculated by formula (2), where m is the number of APIs and Pi represents the probability of the i-th API appearing in all APIs;
[0086]
[0087] The information entropy E(aspect) of the current attribute column is calculated by formula (3), where k is the number of column value types in the attribute column, and “API_{1j}, ..., API_{mj}” represents the m APIs associated with the jth column value.
[0088] Based on the above calculation, the attribute column with the highest information gain can be determined from the attribute table. The attribute of this column will be used as the current node in the decision tree, and different column values (including null values) will be connected to the current node as edges. In order to generate sub-nodes for each edge of the decision tree, the subgraph needs to be divided. In this embodiment, the API {<e1,r,e2> , ...} grouping to form sub-datasets, in this way, the construction of one layer of nodes and edges in the decision tree is completed.
[0089] 3. Recursively repeat steps 1 and 2 to build a complete decision tree that supports the query clarification process. The result is as follows: Figure 4 -b to Figure 4 -c.
[0090] In order to build a complete decision tree, for each sub-data set, in this embodiment, steps 1 and 2 are recursively repeated to build child nodes until the following stopping criteria are met:
[0091] a. The sub-dataset contains only one API;
[0092] The bb subdataset contains multiple APIs with the same functionality;
[0093] When the stopping criterion is met, all APIs in the current sub-dataset are called current nodes and set as leaf nodes in the decision tree. It should be noted that when building a new attribute table, the selected aspects will be deleted to avoid generating redundant clarification questions.
[0094] 4. Generate query clarification process based on decision tree, such as Figure 4 -c to Figure 4 -d as shown.
[0095] In this embodiment, the current node of the decision tree and all its edges are used to generate clarification questions and diverse options. According to different aspects of the current node, the following template can be used to generate clarification questions: after the user selects an option, the decision tree will be pruned, leaving only the subtree of the branch selected by the user; if the subtree has only one node, the answer will be recommended directly; otherwise, a new round of clarifications and options will be generated; during the conversation, the user can manually stop generating a new round of clarifications and options at any time; in this case, all APIs contained in the subtree are regarded as recommended API sequences.
[0096] Finally, this example evaluates the performance of the intent clarification method based on knowledge graph-driven path optimization for API recommendation through experiments, mainly from three aspects: conversation efficiency, API recommendation, and knowledge expansion.
[0097] In terms of dialogue efficiency, the method of the present invention successfully generated efficient semantically diverse question options (the average diversity between any two options was 74.9%) and effectively reduced dialogue turns (the average number of turns required for a query was no more than three), proving that the method of the present invention has powerful capabilities in API recommendation and knowledge expansion.
[0098] For API recommendation, the proposed method achieves mean reciprocal rank (MRR) and mean average precision (MAP) of 0.769 and 0.794 respectively, which is superior to two state-of-the-art API search methods, BIKER and CLEAR, with MRR improved by at least 47% and MAP improved by 226.7%.
[0099] In terms of knowledge expansion, the MRR and MAP of the proposed method are 0.815 and 0.864 respectively, which exceeds the most advanced dialogue-based code search method ZaCQ, with MRR improved by at least 42% and MAP improved by 45.2%.
[0100] The above specifically describes the preferred implementation method of the present invention, but the invention is not limited to the described embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.
Claims
1. A method for clarifying intent based on knowledge graph-driven path optimization for API recommendation, characterized in that: The following steps are involved: Step S1: extract entities that embody API actions, events, objects, and constraints from the initial API document, enrich the relationship categories between entities, including API functional relationships and API semantic relationships, and use the knowledge graph as a carrier to store the extracted entities and relationships with rich types; Step S11: design sentence screening rules to extract API description sentences related to API behaviors from the API document; Step S12: designing grammatical and semantic labels and annotation rules, and designing grammatical role annotation and semantic role annotation for API description statements accordingly; Step S13, combining the grammatical role and the semantic role according to the rules to form an entity; Step S14: Design entity relationships that reflect API behaviors to organize entities into triples; Step S15: All triples are stored using the knowledge graph as a carrier to form an API behavior knowledge graph; Step S2: Based on the API knowledge graph, an efficient dialogue process is generated to clarify the user's needs, search for subgraphs from the knowledge graph according to the query statement input by the user, and design an efficient guidance mechanism and decision tree algorithm to generate a human-computer dialogue process according to the subgraph content; The entire efficient guidance mechanism process includes: Step S21, converting entities and relationships in the subgraph into Aspects and their options, and designing an attribute table to store them; Step S22, design a decision tree algorithm to select the best Aspect from the attribute table and narrow the subgraph range, the Aspect is used as a node of the decision tree, and the options corresponding to the Aspect are used as edges of the node; Step S23, repeating steps S21 and S22 to generate a complete decision tree; Step S24, designing a clarification question template according to the decision tree, and finally forming a human-computer dialogue process; Step S3: Expand the API and provide explainability, expand to obtain other APIs that have semantic relationships with the initial API, realize the mapping from the conversation process to the knowledge graph, obtain the best clarification path for each API, and provide explanations; The process of obtaining a clarified path includes: Convert the conversation process into a path in a decision tree. This path is the most efficient path from the head node to the recommended API. The starting point of the path is the head node of the decision tree, and the end point is the recommended API list. Mapping from the path in the decision tree to the knowledge graph, the nodes and edges in the path are restored to entities and relationships in the knowledge graph. These entities and relationships are connected in the knowledge graph and constitute the best clarification path.
2. According to claim 1, the method for clarifying intent based on knowledge graph-driven path optimization for API recommendation is characterized in that: The design performs grammatical role annotation and semantic role annotation on the API description statements. There are 6 types of grammatical roles obtained through annotation, namely: verb, direct object, direct object modifier, preposition, preposition object, preposition object modifier; there are 9 types of semantic roles obtained through annotation, namely: position constraint, direction constraint, method constraint, scope constraint, time constraint, target constraint, purpose constraint, result constraint and condition constraint semantic roles.
3. The method for clarifying intent based on knowledge graph-driven path optimization for API recommendation according to claim 1, characterized in that: The relationship categories between the enriched entities in step S1 include 6 types of enriched entities, including API, Action, Event, Object, Object Constraint, and Event Constraint; the relationship categories include event function relationship, constraint function relationship, and semantic relationship; The event function relationship is used to organize four types of entities: API, Action, Event, and Object, including API event API Has Event, action event Act Has Event, direct object Has Direct Object, and indirect object HasPreposition Object. The constraint function relationship is used to organize four types of entities, namely, Event, Object, and Object Constraint, including 11 types, namely, Status Has Status, Type Has Type, Location Has Location, Direction Has Direction, Manner Has Manner, Range Has Extent, Time Has Temporal, Goal Has Goal, Purpose Has Purpose, Result Has Result, and Condition Has Condition. The semantic relationships are used to organize different API entities, including seven categories: Function Similarity, Function Opposite, Function Replace, Function Collaboration, Logic Constraint, Behavior Difference, and Efficiency Comparison.
4. The method for clarifying intent based on knowledge graph-driven path optimization for API recommendation according to claim 1, characterized in that: The decision tree algorithm is an information gain algorithm, which gives priority to selecting the aspect with the largest information gain. The specific calculation formula is as follows: Gain(aspect)=I(API1,...,APA m )-E(aspect) (1) In the above formula, Gain(aspect) represents information gain; (I(API1,…,API m )) represents the information entropy of all APIs; (E(aspect)) represents the information entropy of the current Aspect; m represents the number of APIs; Pi represents the probability of the i-th API appearing in all APIs; k represents the number of column value types in the attribute column; API_{1j}, ..., API_{mj} represent the m APIs associated with the j-th column value.
5. The method for clarifying intent based on knowledge graph-driven path optimization for API recommendation according to claim 1, characterized in that: The human-computer dialogue process includes multiple rounds of human-computer interaction. Each round of human-computer interaction includes clarification questions and options generated by the system and options selected by the user. In the last round, the system will give a recommended API list. There are fourteen clarification question templates, corresponding to the 14 types of nodes in the decision tree, and all edges of each node are used as options.
6. An intention clarification system using the intention clarification method according to any one of claims 1 to 5, characterized in that: It includes a diversified knowledge composition form construction module, a knowledge efficient guidance strategy module, and a recommendation result expansion and interpretation module; The diversified knowledge composition form construction module is used to take the API description statements in the API document as input, extract API behavior knowledge, and output various entities and entity relationships, and store them in the API behavior knowledge graph; The knowledge efficient guidance strategy module is used to receive the initial query statement input by the user, use the subgraph search algorithm to search for a subgraph from the API behavior knowledge graph, and then use the subgraph as input to build a decision tree using the decision tree algorithm, generate each round of clarification questions and options based on the decision tree, and return them to the user; and update the decision tree according to the options selected by the user, generate a new round of clarification questions and options, and repeat this process until the user chooses to stop the conversation and output the recommended result API; The recommendation result expansion and explanation module is used to take the result API as input, use the API expansion strategy, obtain the expansion API, and then obtain the optimal clarification path corresponding to each result API and the expansion API.
Citation Information
Patent Citations
API recommendation method based on knowledge graph and collaborative filtering
CN113407731A
Knowledge graph-based intention representation system and method
CN114138930A
