WO2024082983A1 - 一种代码推荐方法、装置及相关设备 - Google Patents

一种代码推荐方法、装置及相关设备 Download PDF

Info

Publication number
WO2024082983A1
WO2024082983A1 PCT/CN2023/123468 CN2023123468W WO2024082983A1 WO 2024082983 A1 WO2024082983 A1 WO 2024082983A1 CN 2023123468 W CN2023123468 W CN 2023123468W WO 2024082983 A1 WO2024082983 A1 WO 2024082983A1
Authority
WO
WIPO (PCT)
Prior art keywords
party
api
code
target
party api
Prior art date
Application number
PCT/CN2023/123468
Other languages
English (en)
French (fr)
Inventor
谷祖兴
梁晶晶
程啸
梁广泰
Original Assignee
华为云计算技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN202310376402.0A external-priority patent/CN117931146A/zh
Application filed by 华为云计算技术有限公司 filed Critical 华为云计算技术有限公司
Publication of WO2024082983A1 publication Critical patent/WO2024082983A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Definitions

  • the present application relates to the field of computer technology, and in particular to a code recommendation method, device and related equipment.
  • API Application Programming Interface
  • IDE Integrated development environments
  • the present application provides a code recommendation method that can improve the efficiency of API selection during user code development, thereby improving code development efficiency.
  • the present application also provides a corresponding code recommendation device, system, computing device cluster, computer-readable storage medium, and computer program product.
  • the present application provides a code recommendation method.
  • the method includes: obtaining a knowledge graph of a third-party application program interface API; receiving an object entered by a user during the code development process; recommending multiple third-party APIs belonging to the object based on the knowledge graph of the third-party application program interface API and the context code where the object is located; providing a code recommendation window, presenting the above multiple third-party APIs and the explanation content of the target third-party API in the above multiple third-party APIs to the user through the code recommendation window; receiving the user's selection of the target third-party API; and adding the target third-party API.
  • This method makes real-time API recommendations based on the code context of the object and provides explainable reasons for each recommended API. It helps developers quickly understand the functions and usage constraints of the recommended APIs and automatically generates code snippets that match the developer's current code context. This can improve the efficiency of API selection and the overall efficiency of code development during user code development.
  • the method also includes: generating a knowledge graph of a third-party application programming interface API based on one or more knowledge sources.
  • the knowledge sources include: a third-party library of the third-party API, a code library of the third-party API, and a document library of the third-party API;
  • the knowledge graph of the third-party application programming interface API includes an association relationship between at least two kinds of knowledge, and the knowledge includes: type knowledge of the third-party API, functional knowledge of the third-party API, constraint knowledge of the third-party API, parameter knowledge of the third-party API, and code use cases of the third-party API;.
  • the method further includes: generating explanation content of the target third-party API based on the knowledge graph of the third-party application program interface API, wherein the explanation content of the target third-party API includes one or more of the following: type description of the target third-party API, function description of the target third-party API, constraint description of the target third-party API, parameter description of the target third-party API, and code use case of the target third-party API.
  • the method further includes: when the target third-party API switches to a new third-party API recommended among the multiple third-party APIs, presenting explanation content of the new third-party API to the user through a code recommendation window.
  • presenting the multiple third-party APIs specifically includes: arranging and presenting the multiple third-party APIs in order of recommendation priority.
  • adding a target third-party API includes: adding parameters of the target third-party API.
  • the parameters of the target third-party API may be added in combination with the context code where the object is located.
  • the method further includes: replacing the parameters of the added target third-party API with the parameters entered by the user.
  • the method further includes: adding a target third-party API that lacks one or more parameters, and using the parameters entered by the user as parameters of the target third-party API.
  • the method further comprises: presenting to the user one or more third-party codes belonging to the object that are not recommended through a code recommendation window. API.
  • the present application provides a code recommendation device, the device comprising:
  • An acquisition unit used to acquire the knowledge graph of a third-party application programming interface (API);
  • a receiving unit used to receive objects entered by users during the code development process
  • a recommendation unit used to recommend multiple third-party APIs belonging to the object based on the knowledge graph of the third-party application programming interface API and the context code of the object;
  • a presenting unit configured to provide a code recommendation window, and present the plurality of third-party APIs and explanation contents of a target third-party API among the plurality of third-party APIs to a user through the code recommendation window;
  • the receiving unit is further used to receive a user's selection of a target third-party API
  • Add unit used to add target third-party API.
  • the code recommendation device may further include a knowledge graph generation unit and an explanation content generation unit, wherein:
  • a knowledge graph generation unit used to generate a knowledge graph of a third-party application program interface API based on one or more knowledge sources, wherein the knowledge sources include: a third-party library of the third-party API, a code library of the third-party API, and a document library of the third-party API, and the knowledge graph of the third-party application program interface API includes an association relationship between at least two kinds of knowledge, and the knowledge includes: type knowledge of the third-party API, function knowledge of the third-party API, constraint knowledge of the third-party API, parameter knowledge of the third-party API, and code use cases of the third-party API;
  • An explanation content generation unit is used to generate explanation content of a target third-party API for presentation to a user based on a knowledge graph of a third-party application programming interface (API), wherein the explanation content of the target third-party API includes one or more of the following: a type description of the target third-party API, a functional description of the target third-party API, a constraint description of the target third-party API, a parameter description of the target third-party API, and a code usage case of the target third-party API.
  • API application programming interface
  • the presenting unit is further configured to present the explanation content of the new third-party API to the user through the code recommendation window when the target third-party API switches to a new third-party API recommended among the multiple third-party APIs.
  • the presentation unit is further configured to arrange and present the plurality of third-party APIs in order of recommended priority.
  • the adding unit is further used to add parameters of the target third-party API.
  • the adding unit is used to add parameters of the target third-party API in combination with the context code where the object is located.
  • the adding unit is further configured to replace the parameters of the added target third-party API with the parameters entered by the user.
  • the adding unit is further configured to add a target third-party API that lacks one or more parameters, and use the parameters entered by the user as parameters of the target third-party API.
  • the presenting unit is further configured to present one or more third-party APIs that are not recommended and belong to the object to the user through a code recommendation window.
  • the code recommendation device provided in the present application is deployed in an integrated development environment IDE.
  • the present application provides a code recommendation system, the system comprising:
  • a code development device is used to: obtain a knowledge graph of a third-party application program interface API from a knowledge graph device; receive an object entered by a user during a code development process; recommend multiple third-party APIs belonging to the object based on the knowledge graph of the third-party application program interface API and the context code where the object is located; provide a code recommendation window, and present the multiple third-party APIs and explanation contents of a target third-party API among the multiple third-party APIs to the user through the code recommendation window; receive a user's selection of a target third-party API; and add a target third-party API.
  • Knowledge graph device used to store knowledge graphs of third-party application programming interfaces (APIs).
  • APIs application programming interfaces
  • the knowledge graph device is also used to generate a knowledge graph of a third-party application programming interface (API) based on one or more knowledge sources, wherein the knowledge sources include: a third-party library of the third-party API, a code library of the third-party API, and a document library of the third-party API; the knowledge graph of the third-party application programming interface (API) includes an association relationship between at least two types of knowledge, and the knowledge includes: type knowledge of the third-party API, functional knowledge of the third-party API, constraint knowledge of the third-party API, parameter knowledge of the third-party API, and code usage cases of the third-party API.
  • API application programming interface
  • the code development device is further used to generate explanation content of the target third-party API for presentation to the user based on the knowledge graph of the third-party application program interface API.
  • the explanation content of the target third-party API includes one or more of the following: a type description of the target third-party API, a functional description of the target third-party API, a constraint description of the target third-party API, a parameter description of the target third-party API, and a code use case of the target third-party API.
  • the code development device is further configured to: when the target third-party API is switched to a new third-party API recommended among the plurality of third-party APIs, present the explanation content of the new third-party API to the user through the code recommendation window.
  • the code development device is further used to arrange and present the multiple third-party APIs in a recommended priority order.
  • the code development device is also used to add parameters of the target third-party API.
  • Context code to add parameters for the target third-party API.
  • the code development device is further used to replace the parameters of the added target third-party API with the parameters entered by the user.
  • the code development device is further used to add a target third-party API that lacks one or more parameters, and use the parameters entered by the user as parameters of the target third-party API.
  • the code development device is further configured to present one or more third-party APIs that are not recommended and belong to the object to the user through a code recommendation window.
  • the code development device and the knowledge graph device can both be deployed in the cloud; or, the code development device is deployed locally and the knowledge graph device is deployed in the cloud; or, the code development device and the knowledge graph device can both be deployed locally.
  • the present application provides a computing device cluster, comprising at least one computing device, each computing device comprising a processor and a memory; the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes a code recommendation method provided by the first aspect or any possible implementation of the first aspect.
  • the present application provides a computer program product comprising instructions, which, when executed by a computing device cluster, enables the computing device cluster to execute a code recommendation method as provided in the first aspect or any possible implementation of the first aspect.
  • FIG1( a ) is one of the schematic diagrams of a code development scenario provided in an embodiment of the present application.
  • FIG1( b ) is a second schematic diagram of a code development scenario provided in an embodiment of the present application.
  • FIG2 is a flow chart of a code recommendation method provided in an embodiment of the present application.
  • FIG. 3 is a schematic diagram of a scenario of step 201 in a code recommendation method provided in an embodiment of the present application.
  • FIG. 4 is a flowchart of step 204 in a code recommendation method provided in an embodiment of the present application.
  • FIG. 5 is one of schematic diagrams of a code recommendation window in a code recommendation method provided in an embodiment of the present application.
  • FIG. 6 is a second schematic diagram of a code recommendation window in a code recommendation method provided in an embodiment of the present application.
  • FIG. 7 is a schematic diagram of an execution result of step 208 in a code recommendation method provided in an embodiment of the present application.
  • FIG. 8 is another schematic diagram of the execution result of step 208 in a code recommendation method provided in an embodiment of the present application.
  • FIG. 9 is a schematic diagram of the structure of a code recommendation device provided in an embodiment of the present application.
  • FIG10 is a schematic diagram of the structure of a code recommendation system provided in an embodiment of the present application.
  • FIG. 11 is a schematic diagram of a computing device cluster provided in an embodiment of the present application.
  • FIG. 12 is a schematic diagram of an implementation method of a computing device cluster provided in an embodiment of the present application.
  • API Application Programming Interface
  • API is an interface for code developers to access a piece of already written code that can implement a specific function. Developers can use the API interface for programming and development, and can directly reuse the functions of the code encapsulated by the API interface without accessing the source code or understanding the internal details of the code, which can improve development efficiency.
  • the API from the third-party library is further referred to as the third-party API.
  • IDE Integrated Development Environment
  • An application program that provides a program development environment. It generally includes tools such as code editors, compilers, debuggers, and graphical user interfaces. It integrates code writing, analysis, compilation, and debugging functions into an integrated development software service suite. All software or software suites (groups) with this feature can be called an IDE. Examples include Microsoft's Visual Studio series, Borland's C++Builder, and Delphi series. The program can run independently or in conjunction with other programs.
  • Object refers to an instance object in an object-oriented programming language that calls a specific API through an object instance, such as "TypeReceiver.”, "client.”, etc.
  • Third-party Library A reusable software component developed and released by an entity other than the developer who calls the software platform.
  • the application scenarios shown in FIG1(a) and FIG1(b) are scenarios in which a user uses the code development function on a terminal device to perform code development.
  • the terminal device can be any device with a code development function, such as a personal computer or a notebook computer, etc.
  • the code development function can be implemented by a code development application (such as a code editor) that comes with the terminal device. It can also be implemented by an integrated development environment IDE (such as Visual Studio, C++Builder, Delphi, etc.) provided by a third party installed on the terminal device, which is not specifically limited here. Developers can develop or maintain software through the code development function on the terminal device.
  • IDE such as Visual Studio, C++Builder, Delphi, etc.
  • IDEs application programming interfaces
  • FIG. 1(a) when the developer enters the object "client.”, the integrated development environment (IDE) will pop up an API recommendation floating box, which recommends multiple APIs that can be called by the object "client.”
  • Prior art solution 2 When the user enters an object of the form "client.” in the code development interface, the integrated development environment IDE will further rank the more likely API candidate sets in the front position for the developer to choose based on the user code or the internal logic of the tool.
  • the recommended results only include the signature information of the API, such as the API name ("codePointAt"), parameter type and name ("int index”), and return value type ("int”), but no information about the function or usage constraints of this API is given. This means that when developers are not familiar with the recommended APIs, they need to leave the development environment and conduct a secondary search. The probability of developers selecting a suitable API through the prior art solution 2 is still relatively low, which in turn reduces the efficiency of the entire code development.
  • the present application provides a code recommendation method that can make API recommendations in real time based on the context of the user's current code, and provide explainable recommendation reasons for the recommended APIs, helping developers quickly understand the functions and usage constraints of the recommended APIs, and automatically generate code snippets that conform to the developer's current context.
  • This method can improve the efficiency of API selection during user code development, thereby improving the overall efficiency of code development.
  • the present application also provides corresponding code recommendation devices, code recommendation systems, and computing device clusters.
  • the code recommendation method provided by the present application is described in detail below in conjunction with the flowchart shown in FIG. 2 .
  • the method includes the following steps 201 to 208 .
  • Step 201 Generate a knowledge graph of a third-party application programming interface (API) based on one or more knowledge sources.
  • API application programming interface
  • the knowledge graph of the third-party API is an important basis for providing explainable reasons for the recommendation of the recommended third-party API.
  • the knowledge graph of the third-party API contains multiple types of information that reflect how the third-party API is used and the associations between the multiple types of information. These information that reflect how the third-party API is used can be called the knowledge of the third-party API. For example, when a developer calls a third-party API, he can more quickly select a suitable third-party API based on the type of the third-party API, the function of the third-party API, the usage constraints of the third-party API, etc.
  • the information that can reflect the type of the third-party API, the function of the third-party API, and the usage constraints of the third-party API can be called the type knowledge of the third-party API, the functional knowledge of the third-party API, and the constraint knowledge of the third-party API, respectively.
  • the knowledge graph of the third-party API may include the type knowledge of the third-party API, the functional knowledge of the third-party API, the constraint knowledge of the third-party API, the parameter knowledge of the third-party API, and the association relationship between at least two kinds of knowledge in the code usage cases of the third-party API.
  • this application does not limit the types of third-party API knowledge contained in the knowledge graph of the third-party API. As long as the information is helpful for developers to understand how to use the third-party API, it can be considered to be included in the knowledge graph of the third-party API. For example, in actual applications, several third-party APIs that are often used together can form a third-party API combination, so the information about the third-party API combination that is often used together (i.e., the combination knowledge of the third-party API) can also be used to construct the knowledge graph.
  • the knowledge graph of the third-party API includes the relationship between the type knowledge of the third-party API, the functional knowledge of the third-party API, the constraint knowledge of the third-party API, and the combination knowledge of the third-party API.
  • the knowledge of the third-party API can come from the third-party library of the third-party API, or the code library of the third-party API, or the document library of the third-party API. Therefore, the knowledge graph of the third-party API can be based on the third-party library of the third-party API, the code library of the third-party API, or the document library of the third-party API. and one or more knowledge sources in the documentation library of third-party APIs.
  • this application does not limit the types and number of knowledge sources used to generate the knowledge graph of the third-party API. For example, when relevant technicians need to increase or decrease the types of knowledge included in the knowledge graph of the third-party API according to their own recommendations, the knowledge sources corresponding to the knowledge of the third-party API can be increased or decreased accordingly.
  • the knowledge graph of the third-party API includes the type knowledge of the third-party API, the function knowledge of the third-party API, the constraint knowledge of the third-party API, the parameter knowledge of the third-party API, and the association relationship between the code use cases of the third-party API.
  • the following describes the specific process of generating the knowledge graph of the third-party API based on the third-party library of the third-party API and the code library of the third-party API.
  • Each API has its own unique type signature.
  • the structure of the API type signature is like "package name. class name. method name. parameter type”.
  • the API type signature contains the type knowledge of the API, which can reflect which type of object the API belongs to and which type of object can call it.
  • the type signature of the API named "executeMethod" is:
  • the type knowledge of the third-party API based on the type signature of the third-party API can be extracted from the third-party library of the third-party API.
  • the type knowledge of the third-party API can be used as an identifier of the third-party API type to determine the candidate set of all available third-party APIs for a certain type of object; on the other hand, the type knowledge of the third-party API can be used as an index of the knowledge of various third-party APIs in the knowledge graph of the third-party API.
  • the third-party library of the third-party API also contains instructions for using each third-party API for developers to learn and understand the API. Therefore, in a possible implementation, the functional knowledge of the third-party API based on the instructions for using the third-party API can be extracted from the third-party library of the third-party API, and the functional knowledge of the third-party API is used to illustrate the functions of the third-party API. For example, the functional description of the third-party API named "executeMethod" in the third-party library of the third-party API is "Executes the given HttpMethod HTTP method.”
  • API constraint knowledge is used to explain the parameter constraints, return value constraints, timing constraints, etc. that need to be met when using the API.
  • usage instructions of the third-party API published in the third-party library of the third-party API will contain a natural language description of the usage constraints of the third-party API.
  • the description of the parameter constraints of the third-party API named "executeMethod” in the usage instructions of the third-party API is "HttpMethod parameter may not be null.”
  • HttpMethod parameter may not be null.
  • a natural language description of the usage constraints of the third-party API can be first extracted from the third-party library of the third-party API, and a code snippet for performing constraint checks on the third-party API in the sample code where the third-party API is located can be extracted from the code library of the third-party API. Then, the natural language description of the usage constraints of the third-party API and the code snippet for performing constraint checks on the third-party API can be integrated to obtain the constraint knowledge of the third-party API in the knowledge graph of the third-party API.
  • the parameter knowledge of the third-party API based on the type signature of the third-party API can be extracted from the third-party library of the third-party API.
  • the sample codes of the third-party API can be extracted from the code base of the third-party API, and after classifying and labeling the sample codes based on the type of the third-party API, the code usage cases of the third-party API in the knowledge graph of the third-party API can be obtained.
  • third-party API type knowledge After obtaining the third-party API type knowledge, third-party API function knowledge, third-party API constraint knowledge, third-party API parameter knowledge, and third-party API code usage cases from the third-party API's third-party library and third-party API's code library, these five types of knowledge are further standardized and represented in a unified manner. Then, the five types of knowledge are associated using the association relationship mining algorithm to generate a knowledge graph of the third-party API.
  • the knowledge sources corresponding to the knowledge of a certain third-party API may be diverse, and this application does not limit the correspondence between the knowledge of third-party APIs and the knowledge sources.
  • a document library of the third-party API may be established based on various documents on the Internet that describe the usage scenarios of third-party APIs, and then the functional knowledge of the third-party API may be extracted from the third-party library of the third-party API and the document library of the third-party API.
  • various documents on the Internet that describe the usage scenarios of third-party APIs may also contain sample code for using third-party APIs.
  • the functional knowledge of the third-party API may be extracted from the code library of the third-party API and the document library of the third-party API. Sample code for third-party APIs. After integrating the above two parts of sample code, we can obtain the code usage cases of third-party APIs in the knowledge graph of third-party APIs.
  • Step 202 Obtain the knowledge graph of the third-party application programming interface API.
  • Step 203 Receive the object entered by the user during the code development process.
  • the API recommendation mechanism is triggered.
  • the object entered by the user is "client.”
  • the API recommendation mechanism begins to be made for the object "client.”.
  • Step 204 Based on the knowledge graph of the third-party application programming interface API and the context code where the object is located, recommend multiple third-party APIs belonging to the object.
  • the context code of the object is first collected, and then personalized API recommendations are made for the user based on the context code.
  • the specific process of recommending multiple third-party APIs belonging to the object includes the following steps 2041 to 2043.
  • Step 2041 Construct an intermediate expression of the context code where the object is located.
  • the context code Before using the API recommendation algorithm to recommend APIs, the context code needs to be converted into an intermediate representation such as a graph representation or vector representation that can be used as input for the API recommendation algorithm. Specifically, the context code where the object is located is first marked with complete type information for analyzing the type of the object, and then the lexical and grammatical analysis results of the context code are constructed in sequence, and then various graph representations and vector representations of the context code are constructed.
  • Step 2042 Get a candidate set of all third-party APIs belonging to the object.
  • all third-party APIs that can be called by the object can be obtained, that is, the candidate set of all third-party APIs belonging to the object.
  • Step 2043 The API recommendation algorithm gives a third-party API recommendation result based on the intermediate expression of the context code and the candidate set of third-party APIs.
  • a possible implementation method of using an API recommendation algorithm to give a third-party API recommendation result is: first, the API recommendation engine schedules a registration mechanism for multiple API recommendation algorithms to register. When a third-party API recommendation is required, the API recommendation engine will distribute the intermediate expression of the context code where the object is located and the candidate set of all third-party APIs belonging to the object to each algorithm. Each algorithm combines the intermediate expression of the context code and the candidate set of all third-party APIs belonging to the object to recommend a third-party API for the object, and returns the third-party API recommendation result. After obtaining the third-party API recommendation results of each algorithm, all third-party API recommendation results are standardized and analyzed, and all recommended third-party APIs are comprehensively ranked to give the final third-party API recommendation result.
  • Step 205 Based on the knowledge graph of the third-party application programming interface API, generate explanation content of the above-mentioned multiple third-party APIs.
  • the explanation content of the third-party API includes one or more of the following: type description of the third-party API, function description of the third-party API, constraint description of the third-party API, parameter description of the third-party API, and code usage case of the third-party API.
  • the knowledge of the third-party API in the third-party API knowledge graph is used to construct explanation content for each recommended third-party API.
  • the type description of the third-party API in the explanation content of the third-party API is generated based on the type knowledge of the third-party API in the third-party API knowledge graph
  • the function description of the third-party API in the explanation content of the third-party API is generated based on the function knowledge of the third-party API in the third-party API knowledge graph
  • the constraint description of the third-party API in the explanation content of the third-party API is generated based on the constraint knowledge of the third-party API in the third-party API knowledge graph.
  • Step 206 Provide a code recommendation window, and present the multiple third-party APIs and explanation contents of the target third-party API among the multiple third-party APIs to the user through the code recommendation window.
  • the explanation content of the target third-party API includes one or more of the following: type description of the third-party API, function description of the third-party API, constraint description of the third-party API, parameter description of the third-party API, and code usage case of the third-party API.
  • FIG5 exemplarily shows a code recommendation window provided in an embodiment of the present application, wherein the code recommendation window includes an API display window on the left and an API explanation content display window on the right.
  • the upper part of the API display window displays four third-party APIs recommended for the object “client”, and the four third-party APIs are displayed in order of recommendation priority.
  • the third-party API named “executeMethod” ranked first is the most suitable for the current code context of the object “client” among the four recommended third-party APIs, and is most likely to be the third-party API required by the user. high.
  • the lower portion of the API display window may display multiple other third-party APIs that can be called by the object "client" but are not recommended.
  • the API explanation content display window presents the type description of the third-party API, the function description of the third-party API, the constraint description of the third-party API, the parameter description of the third-party API, and the code usage case of the third-party API.
  • These explanation contents can help users understand the functions, usage constraints and other information of the recommended third-party API, so that users can quickly select a suitable third-party API from multiple recommended third-party APIs.
  • the type description of the third-party API can present the type signature of the third-party API;
  • the functional description of the third-party API can be a sentence describing the function of the third-party API;
  • the constraint description of the third-party API can include natural language describing the usage constraints of the third-party API and code form for constraint checking;
  • the parameter description of the third-party API can explain the types of parameters in the third-party API;
  • the code usage case of the third-party API can include multiple sections of sample code containing the third-party API in the code library of the third-party API, thereby providing guidance for users to write code after calling the third-party API, thereby improving user development efficiency.
  • sample codes in the code use cases of the third-party API can be displayed in order of recommended priority. As shown in Figure 5, the recommended priority of sample code 1 is the first, the recommended priority of sample code 2 is the second, and the recommended priority of sample code 3 is the third.
  • users can use the up and down keys on the keyboard to select and view the explanation content of a third-party API in real time from multiple recommended third-party APIs.
  • the third-party API whose explanation content is viewed by the user is the target third-party API.
  • the target third-party API column can be highlighted to distinguish other recommended third-party APIs. Specifically, when the target third-party API switches to a new third-party API among multiple recommended third-party APIs, the explanation content display window displays the explanation content of the new third-party API.
  • the user selects a third-party API named "executeMethod” in the API display window on the left, and the explanation content display window of the API on the right displays the explanation content of the third-party API named "executeMethod”; in the code recommendation window shown in Figure 6, the user selects a third-party API named "setHostConfiguration" in the API display window on the left, and the explanation content display window of the API on the right is switched to display the explanation content of the third-party API named "setHostConfiguration”.
  • Step 207 Receive the user's selection of a target third-party API.
  • the user When the user selects the target third-party API as the API to be finally inserted into the code according to the explanation content of the target third-party API, the user can complete the selection of the target third-party API by clicking the target third-party API with the mouse or by selecting the target third-party API and pressing the Enter key on the keyboard.
  • Step 208 Add the target third-party API.
  • the target third-party API After receiving the user's selection of the target third-party API, the target third-party API will be inserted into the current code according to the user's current coding style.
  • adding the target third-party API not only includes adding the method name of the target third-party API, but also includes adding the parameters of the target third-party API in combination with the context code where the object is located.
  • the context code will first be analyzed based on the type of the context code and the third-party API where the object is located. Then, according to the type information of the target third-party API and the program structure information of the context code, the candidate variables in the context code that meet the parameter type requirements of the target third-party API will be marked. Finally, when adding the target third-party API, the variable with the highest matching degree among the marked candidate variables can be automatically added as the parameter of the target third-party API.
  • the parameters entered by the user themselves may be used to replace the parameters of the added target third-party API.
  • the target third-party API has more than one parameter.
  • the target third-party API can be added by adding the target third-party API that lacks one or more parameters, and then directly using the parameters entered by the user as the parameters of the target third-party API.
  • the constraint satisfiability solution will be performed based on the semantics of the context code where the object is located and the usage constraints of the third-party API. Specifically, when adding a target third-party API to the current code, if the code after inserting the target third-party API does not satisfy the usage constraints of the target third-party API: on the one hand, the target third-party API in the code will be marked It is a special color to remind developers. On the other hand, it will combine the grammatical and semantic forms of the unsatisfied constraints to provide users with the code for performing corresponding constraint checks as part of the target third-party API and insert it into the current code. The coding format of the code for performing corresponding constraint checks will be adjusted to conform to the coding style of the user's current code project.
  • the usage constraint of the target third-party API named "executeMethod” is that the parameter is not null.
  • the parameter "status” is created in advance, and there is no need to perform a constraint check on the parameter being not null, so when adding the target third-party API, only "executeMethod(status)" needs to be added; while in the scenario shown in Figure 8, the parameter "method” is passed in from outside, so when adding the target third-party API, a piece of code for checking the parameter "method” is also added.
  • step 201 in the above code recommendation method can be executed by a knowledge graph device
  • steps 201 to 208 can be executed by a code development device.
  • the code development device and the knowledge graph device here are only used to distinguish the steps executed by the device, and do not mean that the code development device and the knowledge graph device can only be different device entities.
  • steps 201 to 208 are all executed by the same device entity such as a computer or the same server, this device entity is both a code development device and a knowledge graph device.
  • the code development device is deployed locally.
  • the code development device can be a personal computer or a laptop, etc.
  • the user performs code development on the local code development device, and the knowledge graph device used to generate and store the knowledge graph of the third-party API is deployed in the cloud.
  • the knowledge graph of the third-party API is obtained from the cloud.
  • both the code development device and the knowledge graph device are deployed in the cloud.
  • the code development device and the knowledge graph device can be the server where the cloud service is located or a virtual machine on the cloud. Users develop code in the cloud, and the knowledge graph is also stored in the cloud. The knowledge graph of the third-party API is called directly in the cloud before making API recommendations for users.
  • both the code development device and the knowledge graph device are deployed locally.
  • both the code development device and the knowledge graph device can be a personal computer or a laptop, etc.
  • the user does code development locally, and the knowledge graph is also stored locally.
  • the local third-party API knowledge graph is directly called before making API recommendations for the user.
  • step 201 and step 202 can be swapped. Specifically, after receiving the object entered by the user during the code development process, the knowledge graph of the third-party API can be obtained in real time. In addition, in a possible implementation, it is also possible to obtain only the knowledge graph of the third-party API belonging to the entered object, so as to achieve on-demand acquisition and reduce the occupation of the knowledge graph on the storage resources of the code development device.
  • the present application also provides a code recommendation device for implementing the code recommendation method in the above method embodiment, and Figure 9 shows a schematic diagram of the structure of the device.
  • the code recommendation device includes an acquisition unit, a receiving unit, a recommendation unit, a presentation unit, and an adding unit, wherein:
  • An acquisition unit used to acquire the knowledge graph of a third-party application programming interface (API);
  • a receiving unit used to receive objects entered by users during the code development process
  • a recommendation unit used to recommend multiple third-party APIs belonging to the object based on the knowledge graph of the third-party application programming interface API and the context code of the object;
  • a presenting unit configured to provide a code recommendation window, and present the plurality of third-party APIs and explanation contents of a target third-party API among the plurality of third-party APIs to a user through the code recommendation window;
  • the receiving unit is further used to receive a user's selection of a target third-party API
  • Add unit used to add target third-party API.
  • the code recommendation device may further include a knowledge graph generation unit and an explanation content generation unit, wherein:
  • a knowledge graph generation unit used to generate a knowledge graph of a third-party application program interface API based on one or more knowledge sources, wherein the knowledge sources include: a third-party library of the third-party API, a code library of the third-party API, and a document library of the third-party API, and the knowledge graph of the third-party application program interface API includes an association relationship between at least two kinds of knowledge, and the knowledge includes: type knowledge of the third-party API, function knowledge of the third-party API, constraint knowledge of the third-party API, parameter knowledge of the third-party API, and code use cases of the third-party API;
  • An explanation content generation unit is used to generate explanation content of a target third-party API for presentation to a user based on a knowledge graph of a third-party application programming interface (API), wherein the explanation content of the target third-party API includes one or more of the following: a type description of the target third-party API, a functional description of the target third-party API, a constraint description of the target third-party API, a parameter description of the target third-party API, and a code usage case of the target third-party API.
  • API application programming interface
  • the presenting unit is further configured to present the explanation content of the new third-party API to the user through the code recommendation window when the target third-party API switches to a new third-party API recommended among the multiple third-party APIs.
  • the presentation unit is further configured to arrange and present the plurality of third-party APIs in order of recommended priority.
  • the adding unit is further used to add parameters of the target third-party API.
  • Context code to add parameters for the target third-party API.
  • the adding unit is further configured to replace the parameters of the added target third-party API with the parameters entered by the user.
  • the adding unit is further configured to add a target third-party API that lacks one or more parameters, and use the parameters entered by the user as parameters of the target third-party API.
  • the presenting unit is further configured to present one or more third-party APIs that are not recommended and belong to the object to the user through a code recommendation window.
  • the code recommendation device provided in the present application is deployed in an integrated development environment IDE.
  • each unit in the above code recommendation device can be implemented by software or hardware.
  • the following takes the recommendation unit as an example to introduce the specific implementation of the recommendation unit.
  • the implementation of the acquisition unit, the receiving unit, the presentation unit, the adding unit, the knowledge graph generation unit and the explanation content generation unit can refer to the implementation of the recommendation unit.
  • the recommended unit may include code running on a computing instance.
  • the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more.
  • the recommended unit may include code running on multiple hosts/virtual machines/containers. It should be noted that the multiple hosts/virtual machines/containers used to run the code can be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts/virtual machines/containers used to run the code can be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple data centers with close geographical locations. Among them, usually a region can include multiple AZs.
  • AZ availability zone
  • VPC virtual private cloud
  • multiple hosts/virtual machines/containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs.
  • VPC virtual private cloud
  • a VPC is set up in a region.
  • a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
  • the recommended unit may include at least one computing device, such as a server, etc.
  • the recommended unit may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD).
  • ASIC application-specific integrated circuit
  • PLD programmable logic device
  • the PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
  • CPLD complex programmable logical device
  • FPGA field-programmable gate array
  • GAL generic array logic
  • the multiple computing devices included in the recommendation unit can be distributed in the same region or in different regions.
  • the multiple computing devices included in the recommendation unit can be distributed in the same AZ or in different AZs.
  • the multiple computing devices included in the recommendation unit can be distributed in the same VPC or in multiple VPCs.
  • the multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
  • FIG10 shows a structural diagram of the code recommendation system, which includes a code development device and a knowledge graph device, wherein:
  • a code development device is used to: obtain a knowledge graph of a third-party application program interface API from a knowledge graph device; receive an object entered by a user during a code development process; recommend multiple third-party APIs belonging to the object based on the knowledge graph of the third-party application program interface API and the context code where the object is located; provide a code recommendation window, and present the multiple third-party APIs and explanation contents of a target third-party API among the multiple third-party APIs to the user through the code recommendation window; receive a user's selection of a target third-party API; and add a target third-party API.
  • Knowledge graph device used to store knowledge graphs of third-party application programming interfaces (APIs).
  • APIs application programming interfaces
  • the knowledge graph device is also used to generate a knowledge graph of a third-party application programming interface (API) based on one or more knowledge sources, wherein the knowledge sources include: a third-party library of the third-party API, a code library of the third-party API, and a document library of the third-party API; the knowledge graph of the third-party application programming interface (API) includes an association relationship between at least two types of knowledge, and the knowledge includes: type knowledge of the third-party API, functional knowledge of the third-party API, constraint knowledge of the third-party API, parameter knowledge of the third-party API, and code usage cases of the third-party API.
  • API application programming interface
  • the code development device is further used to generate explanation content of the target third-party API for presentation to the user based on the knowledge graph of the third-party application program interface API.
  • the explanation content of the target third-party API includes one or more of the following: a type description of the target third-party API, a functional description of the target third-party API, a constraint description of the target third-party API, a parameter description of the target third-party API, and a code use case of the target third-party API.
  • the code development device is further used for: when the target third-party API is switched to a new third-party API recommended by the plurality of third-party APIs When the code is recommended, the user is presented with explanations of the new third-party API.
  • the code development device is further used to arrange and present the multiple third-party APIs in a recommended priority order.
  • the code development device is also used to add parameters of the target third-party API.
  • the code development device is used to add parameters of the target third-party API in combination with the context code where the object is located.
  • the code development device is further used to replace the parameters of the added target third-party API with the parameters entered by the user.
  • the code development device is further used to add a target third-party API that lacks one or more parameters, and use the parameters entered by the user as parameters of the target third-party API.
  • the code development device is further configured to present one or more third-party APIs that are not recommended and belong to the object to the user through a code recommendation window.
  • the code development device in the code recommendation system is deployed locally.
  • the code development device in this case can be a personal computer or a laptop computer, etc.
  • the knowledge graph device used to generate and store the knowledge graph of the third-party API is deployed in the cloud.
  • the knowledge graph device in this case can be the server where the cloud service is located or a virtual machine on the cloud.
  • the code recommendation system using the above deployment method executes the code recommendation method, the user can go to the cloud to obtain the knowledge graph of the third-party API before making an API recommendation on the local code development device, thereby reducing the occupation of the storage resources of the code development device when the knowledge graph exists directly locally.
  • the knowledge graph of the third-party API can be stored in the knowledge graph device in the cloud in the form of a cloud database or OBS (object storage service), which is not specifically limited in this application.
  • OBS object storage service
  • users develop code on the cloud.
  • both the code development device and the knowledge graph device are deployed on the cloud.
  • Both the code development device and the knowledge graph device can be the server where the cloud service is located or a virtual machine on the cloud.
  • the code recommendation system using the above deployment method executes the code recommendation method, the knowledge graph is also stored in the cloud. Users can directly call the knowledge graph of the third-party API on the cloud before making API recommendations.
  • the user develops code locally and the knowledge graph is also stored locally.
  • the code development device and the knowledge graph device are both deployed locally, and both the code development device and the knowledge graph device can be a personal computer or a laptop, etc.
  • the code recommendation system using the above deployment method executes the code recommendation method, the user can directly call the local third-party API knowledge graph before making API recommendations.
  • the specific implementation method of the code development device or the knowledge graph device in the code recommendation system can refer to the implementation method of the recommendation unit in the code recommendation device, which will not be repeated here.
  • FIG11 is a schematic diagram of the structure of the computing device cluster, which can implement the code recommendation method in the above embodiment.
  • the computing device cluster includes at least one computing device 500, which can be a server, such as a central server, an edge server, or a local server in a local data center.
  • the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
  • Each computing device 500 includes: a bus 502, a processor 504, a memory 506, and a communication interface 508.
  • the processor 504, the memory 506, and the communication interface 508 communicate with each other through the bus 502.
  • the computing device 500 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 500.
  • the bus 502 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc.
  • the bus may be divided into an address bus, a data bus, a control bus, etc.
  • FIG. 5 is represented by only one line, but does not mean that there is only one bus or one type of bus.
  • the bus 502 may include a path for transmitting information between various components of the computing device 500 (e.g., the memory 506, the processor 504, and the communication interface 508).
  • Processor 504 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
  • CPU central processing unit
  • GPU graphics processing unit
  • MP microprocessor
  • DSP digital signal processor
  • the memory 506 may include a volatile memory (volatile memory), such as a random access memory (RAM).
  • volatile memory such as a random access memory (RAM).
  • RAM random access memory
  • non-volatile memory non-volatile memory
  • ROM read-only memory
  • flash memory flash memory
  • HDD hard disk drive
  • SSD solid state drive
  • the memory 506 stores executable program codes, and the processor 504 executes the executable program codes to implement the aforementioned code recommendation method. That is, the memory 506 stores instructions for executing the code recommendation method.
  • the communication interface 508 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 500 and other devices or a communication network.
  • a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 500 and other devices or a communication network.
  • the memory 506 of one or more computing devices 500 in the computing device cluster may also be respectively Some instructions for executing the code recommendation method are stored.
  • the combination of one or more computing devices 500 can jointly execute the instructions for executing the code recommendation method.
  • the memory 506 in different computing devices 500 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the code recommendation device or the code recommendation system. That is, the instructions stored in the memory 506 in different computing devices 500 can implement the functions of one or more units of the multiple units of the code recommendation device, or the instructions stored in the memory 506 in different computing devices 500 can implement the functions of the code development device and the knowledge graph device in the code recommendation system.
  • one or more computing devices in a computing device cluster may be connected via a network.
  • the network may be a wide area network or a local area network, etc.
  • FIG. 12 shows a possible implementation. As shown in FIG. 12 , two computing devices 500A and 500B are connected via a network. Specifically, the network is connected via a communication interface in each computing device.
  • the memory 506 in the computing device 500A stores instructions for executing the functions of a code development device of a code recommendation system.
  • the memory 506 in the computing device 500B stores instructions for executing the functions of a knowledge graph device of a code recommendation system.
  • connection method between the computing device clusters shown in Figure 12 can be considered that the knowledge graph device in the code recommendation method provided in this application needs to store a large amount of data, so it is considered to hand over the functions implemented by the knowledge graph device to the computing device 500B for execution.
  • the functions of the computing device 500A shown in FIG12 may also be completed by multiple computing devices 500.
  • the functions of the computing device 500B may also be completed by multiple computing devices 500.
  • the present application also provides a computer program product comprising instructions.
  • the computer program product may be software or a program product comprising instructions that can be run on a computing device or stored in any available medium.
  • the at least one computing device executes the code recommendation method.
  • the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium may be any available medium that can be stored by a computing device or a data storage device such as a data center that includes one or more available media.
  • the available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk).
  • the computer-readable storage medium includes instructions that instruct a computing device to execute a code recommendation method, or instructs a computing device to execute a code recommendation method.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

本申请提供了一种代码推荐方法、装置及相关设备,属于计算机技术领域。该方法通过根据对象所在的代码上下文实时进行API推荐,并为每一个被推荐的API提供可解释的推荐原因,帮助开发者快速理解被推荐的API的功能和使用约束等信息,并自动生成符合开发者当前代码上下文的代码片段,能够提高用户代码开发过程中API的选择效率和代码开发的整体效率。

Description

一种代码推荐方法、装置及相关设备
本申请要求于2022年10月17日提交中国国家知识产权局、申请号为202211264591.4、发明名称为“API推荐方法、装置、服务器及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请要求于2023年04月10日提交中国国家知识产权局、申请号为202310376402.0、发明名称为“一种代码推荐方法、装置及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及一种代码推荐方法、装置以及相关设备。
背景技术
应用程序接口(Application Programming Interface,简称:API),又称为应用编程接口,是用于代码开发者访问一段已经写好的、可实现某一具体功能的代码的接口。开发人员通过使用API接口进行编程开发,可直接复用API接口所封装的那段代码的功能,而无需访问源码或理解代码的内部细节,可提高开发效率。在面向对象编程的代码开发过程中,为了提高代码开发效率,用户多利用已经存在的应用编程接口API进行代码的功能复用,快速完成需求。随着API规模的增加,用户无法记住可被某个对象调用的、属于该对象的所有API的候选集合,集成开发环境IDE通常会提供代码推荐功能,给用户提供实时的API联想结果供用户选择合适的API。因此,如何提高API推荐结果的准确性、并帮助开发人员更好理解推荐结果以从推荐结果中快速选出所需的API,是代码开发领域需要解决的一个重要技术问题。
发明内容
本申请提供了一种代码推荐方法,能够提高用户代码开发过程中API的选择效率,从而提高代码开发效率。本申请还提供了对应的代码推荐装置、系统、计算设备集群、计算机可读存储介质以及计算机程序产品。
第一方面,本申请提供了一种代码推荐方法。该方法包括:获取第三方应用程序接口API的知识图谱;接收用户在代码开发过程中录入的对象;基于第三方应用程序接口API的知识图谱和对象所在的上下文代码,推荐属于对象的多个第三方API;提供代码推荐窗口,通过代码推荐窗口向用户呈现上述多个第三方API和上述多个第三方API中的目标第三方API的解释内容;接收用户对目标第三方API的选择;添加目标第三方API。
该方法通过根据对象所在的代码上下文实时进行API推荐,并为每一个被推荐的API提供可解释的推荐原因,帮助开发者快速理解被推荐的API的功能和使用约束等信息,并自动生成符合开发者当前代码上下文的代码片段,能够提高用户代码开发过程中API的选择效率和代码开发的整体效率。
该方法还包括:基于一种或多种知识来源生成第三方应用程序接口API的知识图谱。其中,所述知识来源包括:第三方API的第三方库、第三方API的代码库以及第三方API的文档库;第三方应用程序接口API的知识图谱包括至少两种知识之间的关联关系,所述知识包括:第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、第三方API的代码使用案例;。
该方法还包括:基于第三方应用程序接口API的知识图谱,生成目标第三方API的解释内容。其中,目标第三方API的解释内容包括如下的一种或多种:目标第三方API的类型描述、目标第三方API的功能描述、目标第三方API的约束描述、目标第三方API的参数描述、目标第三方API的代码使用案例。
一种可能的实现方式中,该方法还包括:当目标第三方API切换到所述多个第三方API中推荐的新第三方API时,通过代码推荐窗口向用户呈现新第三方API的解释内容。
一种可能的实现方式中,呈现所述多个第三方API,具体包括:按照推荐的优先级顺序,排列呈现所述多个第三方API。
一种可能的实现方式中,添加目标第三方API,包括:添加目标第三方API的参数。具体地,可结合对象所在的上下文代码添加目标第三方API的参数。
可选地,该方法还包括:使用用户自己录入的参数替换已添加的目标第三方API的参数。
可选地,该方法还包括:添加缺少一个或多个参数的目标第三方API,并使用用户录入的参数作为目标第三方API的参数。
可选地,该方法还包括:通过代码推荐窗口向用户呈现属于所述对象的未被推荐的一个或多个第三方 API。
第二方面,本申请提供了一种代码推荐装置,该装置包括:
获取单元,用于获取第三方应用程序接口API的知识图谱;
接收单元,用于接收用户在代码开发过程中录入的对象;
推荐单元,用于基于第三方应用程序接口API的知识图谱和该对象所在的上下文代码,推荐属于该对象的多个第三方API;
呈现单元,用于提供代码推荐窗口,通过代码推荐窗口向用户呈现上述多个第三方API和上述多个第三方API中的目标第三方API的解释内容;
所述接收单元,还用于接收用户对目标第三方API的选择;
添加单元,用于添加目标第三方API。
该代码推荐装置进一步还可包括知识图谱生成单元和解释内容生成单元,其中:
知识图谱生成单元,用于基于一种或多种知识来源生成第三方应用程序接口API的知识图谱,其中,所述知识来源包括:第三方API的第三方库、第三方API的代码库以及第三方API的文档库,所述第三方应用程序接口API的知识图谱包括至少两种知识之间的关联关系,所述知识包括:第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、第三方API的代码使用案例;
解释内容生成单元,用于基于第三方应用程序接口API的知识图谱,生成用于向用户呈现的目标第三方API的解释内容,其中,目标第三方API的解释内容包括如下的一种或多种:目标第三方API的类型描述、目标第三方API的功能描述、目标第三方API的约束描述、目标第三方API的参数描述、目标第三方API的代码使用案例。
可选地,所述呈现单元还用于当目标第三方API切换到所述多个第三方API中推荐的新第三方API时,通过所述代码推荐窗口向所述用户呈现所述新第三方API的解释内容。
可选地,所述呈现单元还用于按照推荐的优先级顺序,排列呈现所述多个第三方API。
可选地,所述添加单元还用于添加目标第三方API的参数。具体地,所述添加单元用于结合对象所在的上下文代码,添加目标第三方API的参数。
可选地,所述添加单元还用于使用用户录入的参数,替换已添加的目标第三方API的参数。
可选地,所述添加单元还用于添加缺少一个或多个参数的目标第三方API,并使用用户录入的参数,作为目标第三方API的参数。
可选地,所述呈现单元还用于通过代码推荐窗口向用户呈现属于所述对象的未被推荐的一个或多个第三方API。
一种可能的实现方式中,本申请提供的代码推荐装置部署在集成开发环境IDE。
第三方面,本申请提供了一种代码推荐系统,该系统包括:
代码开发设备,用于:从知识图谱设备,获取第三方应用程序接口API的知识图谱;接收用户在代码开发过程中录入的对象;基于第三方应用程序接口API的知识图谱和所述对象所在的上下文代码,推荐属于所述对象的多个第三方API;提供代码推荐窗口,通过所述代码推荐窗口向用户呈现所述多个第三方API和所述多个第三方API中的目标第三方API的解释内容;接收用户对目标第三方API的选择;添加目标第三方API。
知识图谱设备,用于存储第三方应用程序接口API的知识图谱。
可选地,知识图谱设备还用于基于一种或多种知识来源生成第三方应用程序接口API的知识图谱,其中,所述知识来源包括:第三方API的第三方库、第三方API的代码库以及第三方API的文档库;第三方应用程序接口API的知识图谱包括至少两种知识之间的关联关系,所述知识包括:第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、第三方API的代码使用案例。
可选地,代码开发设备还用于基于第三方应用程序接口API的知识图谱,生成用于向用户呈现的目标第三方API的解释内容。其中,目标第三方API的解释内容包括如下的一种或多种:目标第三方API的类型描述、目标第三方API的功能描述、目标第三方API的约束描述、目标第三方API的参数描述、目标第三方API的代码使用案例。
可选地,代码开发设备还用于:当目标第三方API切换到所述多个第三方API中推荐的新第三方API时,通过代码推荐窗口向用户呈现新第三方API的解释内容。
可选地,代码开发设备还用于按照推荐的优先级顺序,排列呈现所述多个第三方API。
可选地,代码开发设备还用于添加目标第三方API的参数。具体地,代码开发设备用于结合对象所在 的上下文代码,添加目标第三方API的参数。
可选地,代码开发设备还用于使用用户录入的参数,替换已添加的目标第三方API的参数。
可选地,代码开发设备还用于添加缺少一个或多个参数的目标第三方API,并使用用户录入的参数,作为目标第三方API的参数。
可选地,代码开发设备还用于通过代码推荐窗口向用户呈现属于所述对象的未被推荐的一个或多个第三方API。
本申请提供的代码推荐系统中,代码开发设备和知识图谱设备可以都部署在云端;或者,代码开发设备部署在本地,知识图谱设备部署在云端;或者,代码开发设备和知识图谱设备可以都部署在本地。
第四方面,本申请提供了一种计算设备集群,包括至少一个计算设备,每个计算设备包括处理器和存储器;该至少一个计算设备的处理器用于执行该至少一个计算设备的存储器中存储的指令,以使得该计算设备集群执行如上述第一方面或第一方面中任一种可能的实现方所提供的代码推荐方法。
第五方面,本申请提供了一种包含指令的计算机程序产品,当该指令被计算设备集群运行时,使得该计算设备集群执行如上述第一方面或第一方面中任一种可能的实现方式所提供的代码推荐方法。
附图说明
图1(a)是本申请实施例提供的一种代码开发场景的示意图之一。
图1(b)是本申请实施例提供的一种代码开发场景的示意图之二。
图2是本申请实施例提供的一种代码推荐方法的流程图。
图3是本申请实施例提供的一种代码推荐方法中步骤201的场景示意图。
图4是本申请实施例提供的一种代码推荐方法中步骤204的流程图。
图5是本申请实施例提供的一种代码推荐方法中代码推荐窗口的示意图之一。
图6是本申请实施例提供的一种代码推荐方法中代码推荐窗口的示意图之二。
图7是本申请实施例提供的一种代码推荐方法中步骤208的一种执行结果示意图。
图8是本申请实施例提供的一种代码推荐方法中步骤208的另一种执行结果示意图。
图9是本申请实施例提供的一种代码推荐装置的结构示意图。
图10是本申请实施例提供的一种代码推荐系统的结构示意图。
图11是本申请实施例提供的一种计算设备集群的示意图。
图12是本申请实施例提供的一种计算设备集群的实现方式示意图。
具体实施方式
下面将结合附图,对本申请提供的技术方案进行详细描述。
为了使本申请提供的技术方案更清晰,在具体描述本申请提供的技术方案之前,首先进行本申请提供的技术方案中所用相关术语的解释。
(1)应用程序接口(Application Programming Interface,API):又称为应用编程接口,是用于代码开发者访问一段已经写好的、可实现某一具体功能的代码的接口。开发人员通过使用API接口进行编程开发,可直接复用API接口所封装的那段代码的功能,而无需访问源码或理解代码的内部细节,可提高开发效率。本申请实施例中,来自第三方库的API进一步被称为第三方API。
(2)集成开发环境(Integrated Development Environment,IDE):是用于提供程序开发环境的应用程序,一般包括代码编辑器、编译器、调试器和图形用户界面等工具,集成了代码编写功能、分析功能、编译功能、调试功能等一体化的开发软件服务套,所有具备这一特性的软件或者软件套(组)都可以叫集成开发环境。如微软的Visual Studio系列,Borland的C++Builder、Delphi系列等。该程序可以独立运行,也可以和其它程序并用。
(3)对象:是指面向对象编程语言中,通过对象实例来调用具体API的实例对象,形如“TypeReceiver.”、“client.”等。
(4)第三方库(Third-party Library):由调用软件平台的开发者以外的实体开发、发布的可重用软件组件。
下面对本申请实施例涉及的应用场景进行简要说明。
图1(a)和图1(b)所示的应用场景是用户利用终端设备上的代码开发功能进行代码开发的场景。在图1(a)和图1(b)所示的应用场景中,终端设备可以为任何具有代码开发功能的设备,如个人计算机或者笔记本电脑等,其具有的代码开发功能可以是终端设备自带的代码开发应用(如代码编辑器)实现, 也可以是终端设备上安装的第三方提供的集成开发环境IDE(如Visual Studio、C++Builder、Delphi等)实现,此处不作具体限定。开发人员通过终端设备上的代码开发功能可以实现对软件的开发或者维护。
在面向对象编程的代码开发过程中,为了提高代码开发效率,用户多利用已经存在的应用编程接口API进行代码的功能复用,快速完成需求。随着API规模的增加,开发者无法记住可被某个对象调用的、属于该对象的所有API的候选集合。集成开发环境IDE通常会提供代码推荐功能,给用户提供实时的API联想结果供用户选择合适的API。如图1(a)所示,当开发者输入了“client.”这个对象后,集成开发环境IDE便会弹出API推荐悬浮框,在该悬浮框中推荐可被“client.”这个对象调用的多个API。
因此,如何提高API推荐结果的准确性、并帮助开发人员更好地理解推荐结果以从推荐结果中更加高效地选到所需的API,是代码开发领域需要解决的一个重要技术问题。现有技术中有以下两种代码推荐方案:
现有技术方案一:当用户在代码开发界面输入形如“client.”的对象后,集成开发环境IDE会推荐这个对象所有可用的API供开发者选择,且这些API推荐结果会根据字母顺序排序。基于字母顺序的推荐能够帮助开发者获知属于某个对象的所有API的候选序列,但开发者需要进行繁琐的选择或者键盘敲击才能找到所需的API,开发者通过上述推荐方法选中合适API的效率比较低,进而会降低整个代码开发的效率。
现有技术方案二:当用户在代码开发界面输入形如“client.”的对象后,集成开发环境IDE会进一步根据用户代码或者工具内部逻辑,将可能性更高的API候选集排在靠前的位置供开发者选择。该方案虽相比现有技术方案一有所改进,但该方案中,推荐的结果只有API的签名信息,例如API的名字(“codePointAt”)、参数类型与名字(“int index”)和返回值类型(“int”),却没有给出任何关于这个API的功能或使用约束的信息。这就导致当开发者不熟悉被推荐的这些API的时候,需要离开开发环境,进行二次搜索,开发者通过现有技术方案二选中合适API的还是比较低,进而会降低整个代码开发的效率。
此外,在开发者选中某个API后,上述两种现有技术方案都只是将该API的名字插入到编辑器中,并没有对API的参数进行自动填充。例如图1(b)所示,补全的结果是将函数名“executeMethod()”加入到编辑器中,但是并没有将两行之前的“status”变量加入到参数位置。因此,开发者还需要根据自己代码的情况进行二次编辑。
针对上述问题,本申请提供了一种代码推荐方法,能够根据用户当前代码的上下文实时进行API推荐,并为被推荐的API提供可解释的推荐原因,帮助开发者快速理解被推荐的API的功能和使用约束等信息,并自动生成符合开发者当前上下文的代码片段。该方法能够提高用户代码开发过程中API的选择效率,进而提高代码开发的整体效率。本申请还提供了对应的代码推荐装置、代码推荐系统和计算设备集群。
下面,结合图2所示的流程示意图详细描述本申请提供的代码推荐方法,该方法包括以下步骤201至步骤208。
步骤201:基于一种或多种知识来源生成第三方应用程序接口API的知识图谱。
在本申请提供的代码推荐方法中,进行第三方API推荐时,第三方API的知识图谱是为被推荐的第三方API提供可解释的推荐原因的重要依据,第三方API的知识图谱内包含了反应第三方API如何使用的多类信息及多类信息之间的关联关系,这些反应第三方API如何使用的信息都可以称为第三方API的知识。例如,开发者在调用第三方API的时候,可以根据第三方API所属的类型、第三方API的功能、第三方API的使用约束等来更加快速地选择出合适的第三方API,能够反应第三方API所属的类型、第三方API的功能、第三方API的使用约束的信息分别可以称为第三方API的类型知识、第三方API的功能知识、第三方API的约束知识。
本申请实施例中,第三方API的知识图谱可以包括第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、第三方API的代码使用案例中至少两种知识之间的关联关系。
需要说明的是,本申请并不对第三方API的知识图谱中包含的第三方API的知识的种类作限定,只要是有助于开发者理解第三方API如何使用的信息都可以被考虑包含在第三方API的知识图谱内。例如,实际应用中,经常被一起使用的某几个第三方API可以形成一个第三方API组合,那么关于经常一同使用的第三方API组合的信息(即第三方API的组合知识)也可以被用于知识图谱的构建。例如,其它可能的一种实施方式中,第三方API的知识图谱包括第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的组合知识之间的关联关系。
具体地,第三方API的知识可以来源于第三方API的第三方库、或者第三方API的代码库、或者第三方API的文档库,因此,第三方API的知识图谱可以基于第三方API的第三方库、第三方API的代码库 以及第三方API的文档库中的一种或多种知识来源而生成。
同样需要说明的是,本申请亦不对生成第三方API的知识图谱时所依据的知识来源的类型和种类数作限定。例如,当相关技术人员根据自身推荐需要增加或减少第三方API的知识图谱中包含的知识种类时,相应地可以增加或减少第三方API的知识对应的知识来源。
一种可能的实施方式中,第三方API的知识图谱包括第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、以及第三方API的代码使用案例之间的关联关系。下面介绍基于第三方API的第三方库和第三方API的代码库生成上述第三方API的知识图谱的具体过程。
每个API会有自己独特的类型签名,API的类型签名的结构形如“包名.类名.方法名.参数类型”,API的类型签名中便包含了API的类型知识,可以反应出API属于哪一类对象、可被哪一类对象调用。例如,名称为“executeMethod”的API的类型签名为:
“org.apache.commons.httpclient.HttpClient.executeMethod(org.apache.commons.httpclient.HttpMethod)”,其中,“HttpClient”是名称为“executeMethod”的这个API的类名,这表示名称为“executeMethod”的这个API属于可以被“client”这类对象调用的API。
由于第三方API的第三方库中会记录有所有第三方API的类型签名,所以,一种可能的实施方式中,可以从第三方API的第三方库中提取基于第三方API的类型签名的第三方API的类型知识。一方面,第三方API的类型知识可以作为第三方API类型的标识,用于确定某一类对象所有可用的第三方API的候选集合;另一方面,第三方API的类型知识可以作为第三方API的知识图谱中各种第三方API的知识的索引。
第三方API的第三方库中除了记录有所有第三方API的类型签名,还会包含关于每一个第三方API的使用说明以供开发者学习和理解API。所以,一种可能的实施方式中,可以从第三方API的第三方库中提取基于第三方API的使用说明的第三方API的功能知识,这些第三方API的功能知识用于说明第三方API的功能。例如,第三方API的第三方库中关于名称为“executeMethod”的第三方API的功能说明为“Executes the given HttpMethod HTTP method.”
API在被调用时需要满足一些使用约束,包括但不限于:API的参数约束、返回值约束、时序约束等。API的约束知识便是用于说明API使用时需要满足的参数约束、返回值约束、时序约束等约束。一方面,第三方API的第三方库中发布的第三方API的使用说明中会包含关于第三方API的使用约束的自然语言描述,例如,第三方API的使用说明中关于名称为“executeMethod”的第三方API的参数约束的说明为“HttpMethod parameter may not be null.”。另一方面,在使用需要满足一定约束的第三方API的时候,有时需要在代码的上下文中提供一些进行约束检查的代码,这些对第三方API进行约束检查的代码可以从第三方API的代码库中调用了第三方API的示例代码获得。例如,在调用名称为“executeMethod”的第三方API时,前文代码中会有形如“if(method!=null)”的代码语句用于进行参数不为空的约束检查。因此,一种可能的实施方式中,可以首先从第三方API的第三方库提取关于第三方API的使用约束的自然语言描述,并从第三方API的代码库提取第三方API所在的示例代码中对第三方API进行约束检查的代码片段,之后将上述关于第三方API的使用约束的自然语言描述和对第三方API进行约束检查的代码片段进行整合,从而得到第三方API的知识图谱中的第三方API的约束知识。
由于API的类型签名中包含了API的参数类型,所以,一种可能的实施方式中,可以从第三方API的第三方库中提取基于第三方API的类型签名的第三方API的参数知识。
由于第三方API的代码库中拥有大量使用了第三方API的示例代码,所以,一种可能的实施方式中,可以从第三方API的代码库中提取第三方API的示例代码,并在基于第三方API的类型将上述示例代码进行分类标记后,得到第三方API的知识图谱中的第三方API的代码使用案例。
在从第三方API的第三方库和第三方API的代码库中获取到第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、以及第三方API的代码使用案例后,进一步将这5种知识标准化并统一表示,之后利用关联关系挖掘算法对这5种知识进行关联以生成第三方API的知识图谱。
需要指出的是,实际应用中,从知识来源获取第三方API的知识时,某一种第三方API的知识对应的知识来源可以是多样的,本申请并不对第三方API的知识和知识来源的对应关系做限定。例如,互联网上会有各种描述第三方API使用场景的文档,另一种可能的实施方式中,可以先基于互联网上各种描述第三方API使用场景的文档建立第三方API的文档库,之后从第三方API的第三方库和第三方API的文档库提取第三方API的功能知识。再例如,互联网上各种描述第三方API使用场景的文档中也会包含使用第三方API的示例代码,另一种可能的实施方式中,可以从第三方API的代码库和第三方API的文档库中提取 第三方API的示例代码,将上述两部分示例代码整合后得到第三方API的知识图谱中第三方API的代码使用案例。
步骤202:获取第三方应用程序接口API的知识图谱。
在为用户(即开发者)进行第三方API推荐之前,首先需要根据用户当前代码开发项目中使用的第三方库,获取用户当前使用的第三方库中的第三方API的知识图谱,为第三方API推荐做准备。
步骤203:接收用户在代码开发过程中录入的对象。
具体地,在用户编写程序的过程中,实时监测用户在编辑器中输入的内容,当自动检测到用户输入了形如“TypeReceiver.”的对象时,触发API推荐机制。如图3示例的一种代码开发场景中,用户输入的对象为“client.”,接收到用户在代码开发过程中录入的对象“client.”之后,便开始为对象“client.”进行API推荐。
步骤204:基于第三方应用程序接口API的知识图谱和对象所在的上下文代码,推荐属于对象的多个第三方API。
在接收到用户输入的对象并触发API推荐机制后,首先会收集对象所在的上下文代码,从而结合上下文代码为用户进行个性化的API推荐。
一种可能的实施方式中,基于第三方应用程序接口API的知识图谱和对象所在的上下文代码,推荐属于对象的多个第三方API的具体过程包括以下步骤2041至步骤2043。
步骤2041:构建对象所在上下文代码的中间表达。
在采用API推荐算法进行API推荐之前,需要先将上下文代码转成可作为API推荐算法输入的图表示或向量化表示等中间表达。具体地,首先对对象所在的上下文代码进行完整的类型信息标记以用于分析对象的类型,接着依次构建上下文代码的词法、语法分析结果,之后构建上下文代码的各种图表示与向量化表示。
步骤2042:获取属于该对象的所有第三方API的候选集合。
具体地,根据分析出的用户录入的对象的类型和第三方API的知识图谱中第三方API的类型知识,便可获得可被该对象调用的所有第三方API,即属于该对象的所有第三方API的候选集合。
步骤2043:API推荐算法基于上下文代码的中间表达和第三方API的候选集合,给出第三方API推荐结果。
考虑到不同的推荐算法针对于不同的代码场景有差异化表现,本申请实施例中,采用API推荐算法给出第三方API推荐结果的一种可能的实现方式为:首先由API推荐引擎调度提供一种注册机制,供多种API推荐算法进行注册。当需要进行第三方API推荐时,API推荐引擎会将对象所在上下文代码的中间表达和属于该对象的所有第三方API的候选集合分发给各个算法,各个算法结合上下文代码的中间表达和属于该对象的所有第三方API的候选集合为该对象进行第三方API推荐,并将第三方API推荐结果返回。在获得各个算法的第三方API推荐结果之后,对所有的第三方API推荐结果进行标准化分析,并对所有被推荐的第三方API进行综合排序,从而给出最终的第三方API推荐结果。
步骤205:基于第三方应用程序接口API的知识图谱,生成上述多个第三方API的解释内容。
其中,第三方API的解释内容包括如下的一种或多种:第三方API的类型描述、第三方API的功能描述、第三方API的约束描述、第三方API的参数描述、第三方API的代码使用案例。
具体地,在获得API推荐算法提供的第三方API推荐结果后,利用第三方API的知识图谱中的第三方API的知识为每一个被推荐的第三方API构建解释内容。例如,基于第三方API的知识图谱中第三方API的类型知识生成第三方API的解释内容中第三方API的类型描述;基于第三方API的知识图谱中第三方API的功能知识生成第三方API的解释内容中第三方API的功能描述;基于第三方API的知识图谱中第三方API的约束知识生成第三方API的解释内容中第三方API的约束描述。
步骤206:提供代码推荐窗口,通过代码推荐窗口向用户呈现上述多个第三方API和上述多个第三方API中的目标第三方API的解释内容。
其中,目标第三方API的解释内容包括如下的一种或多种:第三方API的类型描述、第三方API的功能描述、第三方API的约束描述、第三方API的参数描述、第三方API的代码使用案例。
图5示例性给出了本申请实施例提供的一种代码推荐窗口,该代码推荐窗口包括左侧的API展示窗口和右侧的API的解释内容展示窗口。
如图5所示,在API展示窗口的上部分展示了为对象“client”推荐的4个第三方API,且这4个第三方API按照推荐的优先级顺序排列展示,其中,排在第一位的名称为“executeMethod”的第三方API在4个被推荐的第三方API中最符合对象“client”当前所在的代码上下文,刚好是用户所需的第三方API的可能性最 高。
一种可能的实施方式中,API展示窗口的下部分可以展示其它多个可被对象“client”调用但未被推荐的第三方API。
如图5所示,API的解释内容展示窗口中呈现了第三方API的类型描述、第三方API的功能描述、第三方API的约束描述、第三方API的参数描述、以及第三方API的代码使用案例,这些解释内容可以帮助用户理解被推荐的第三方API的功能、使用约束等信息,从而使用户能从被推荐的多个第三方API中快速选出合适的第三方API。
具体地,第三方API的类型描述可以呈现第三方API的类型签名;第三方API的功能描述可以是描述第三方API功能的一句话;第三方API的约束描述可以包括描述第三方API使用约束的自然语言和进行约束检查的代码形式;第三方API的参数描述可以对第三方API中参数的类型进行说明;第三方API的代码使用案例可以包括第三方API的代码库中含有该第三方API的多段示例代码,从而可以为用户在调用了该第三方API之后编写代码提供指导,提高用户开发效率。
此外,第三方API的代码使用案例中的示例代码可以按照被推荐的优先级顺序排列展示。如图5所示,示例代码1被推荐的优先级顺序是第一,示例代码2被推荐的优先级顺序是第二,示例代码3被推荐的优先级顺序是第三。一种可能的实施方式中,示例代码所关联的第三方API的第三方库与用户当前代码项目使用的第三方API的第三方库的相似度越高,该示例代码被推荐的优先级越高,在多个示例代码中越先被展示;另一种可能的实施方式中,示例代码和对象所在的上下文代码的相似度越高,该示例代码被推荐的优先级越高,在多个示例代码中越先被展示;另一种可能的实施方式中,示例代码所在代码项目的受欢迎程度越高,该示例代码被推荐的优先级越高,在多个示例代码中越先被展示。
实际应用中,用户可以通过键盘上下键在被推荐的多个第三方API中实时选择查看某一个第三方API的解释内容,被用户查看解释内容的那一个第三方API便是目标第三方API。一种可能的实施方式中,目标第三方API一栏可以被高亮显示以区分其它被推荐的第三方API。具体地,当目标第三方API切换到被推荐的多个第三方API中的新第三方API时,解释内容展示窗口展示该新第三方API的解释内容。例如,在图5所示的代码推荐窗口中,用户在左侧的API展示窗口选中了名称为“executeMethod”的第三方API,则右侧的API的解释内容展示窗口便展示名称为“executeMethod”的第三方API的解释内容;在图6所示的代码推荐窗口中,用户在左侧的API展示窗口选中了名称为“setHostConfiguration”的第三方API,则此时右侧的API的解释内容展示窗口便转为展示名称为“setHostConfiguration”的第三方API的解释内容。
步骤207:接收用户对目标第三方API的选择。
当用户根据目标第三方API的解释内容,选择将目标第三方API作为最终被插入代码的API时,用户可以通过鼠标点击目标第三方API或选中目标第三方API后敲击键盘回车键完成对目标第三方API的选择。
步骤208:添加目标第三方API。
在接收到用户对目标第三方API的选择后,会根据用户当前的编码风格将目标第三方API插入到当前代码中。
本申请实施例中,添加目标第三方API不仅包括添加目标第三方API的方法名,还包括结合对象所在的上下文代码添加目标第三方API的参数。
具体地,首先会基于对象所在上下文代码和第三方API的类型,对上下文代码进行程序分析,之后根据目标第三方API的类型信息和上下文代码的程序结构信息,对上下文代码中满足目标第三方API参数类型要求的候选变量进行标记,最后在添加目标第三方API的时候,能够自动将被标记的候选变量中匹配度最高的变量添加为目标第三方API的参数。
例如图7所示的场景中,通过对对象“client”所在的上下文代码分析,当前上下文代码中只有唯一的变量“status”符合名称为“executeMethod”的目标第三方API的参数类型要求,所以最终添加的是包含参数“status”的第三方API。
一种可能的实施方式中,基于上下文代码分析自动补全的参数不符合用户要求,这时可以使用用户自己录入的参数替换已添加的目标第三方API的参数。
另一种可能的实施方式中,目标第三方API的参数不止一个,添加目标第三方API的方式可以是添加缺少一个或多个参数的目标第三方API,之后直接使用用户录入的参数,作为目标第三方API的参数。
此外,在本申请实施例中,对于具有使用约束的第三方API,会根据对象所在上下文代码的语义和第三方API的使用约束进行约束可满足性求解。具体地,在向当前代码中添加目标第三方API时,如果插入目标第三方API后的代码不满足目标第三方API的使用约束:一方面,会将代码中的目标第三方API标记 为特殊颜色,以提醒开发者;另一方面,会结合不满足的约束的语法语义形式,为用户提供进行相应约束检查的代码作为目标第三方API的一部分一同插入当前代码,并对进行相应约束检查的代码进行编码格式的调整以符合用户当前代码项目的编码风格。
例如,名称为“executeMethod”的目标第三方API的使用约束为参数不为空。在图7所示的场景中,参数“status”是提前创建的,不需要进行参数不为空的约束检查,所以在添加目标第三方API时只需添加“executeMethod(status)”即可;而在图8所示的场景中,参数“method”为外部传入的,所以在添加目标第三方API时还同时添加了一段对参数“method”进行非空检查的代码。
本申请实施例中,上述代码推荐方法中的步骤201可以由知识图谱设备执行,步骤201至步骤208则可以由代码开发设备执行。需要说明的是,这里的代码开发设备和知识图谱设备仅是为了区分设备执行的步骤,并不代表代码开发设备和知识图谱设备只能是不同的设备实体,例如,当步骤201至步骤208全部由同一个设备实体如同一台计算机或同一台服务器执行时,这一个设备实体既是代码开发设备也是知识图谱设备。
一种可能的应用场景中,代码开发设备部署在本地,此时的代码开发设备可以是个人计算机或笔记本电脑等,用户在本地的代码开发设备上做代码开发,而用于生成并存储第三方API的知识图谱的知识图谱设备部署在云端,在为用户进行API推荐之前先去云端获取第三方API的知识图谱。
另一种可能的应用场景中,代码开发设备和知识图谱设备均部署在云端,此时的代码开发设备和知识图谱设备可以是云服务所在的服务器或云上的虚拟机,用户在云上做代码开发,同时知识图谱也存储在云端,在为用户进行API推荐之前直接在云上调用第三方API的知识图谱。
另一种可能的应用场景中,代码开发设备和知识图谱设备均部署在本地,此时的代码开发设备和知识图谱设备均可以是个人计算机或笔记本电脑等,用户在本地做代码开发,同时知识图谱也存储在本地,在为用户进行API推荐之前直接调用本地的第三方API的知识图谱。
除了上述方法实施例外,在其它可能的实施例中,步骤201和步骤202的执行顺序可调换。具体地,可以在接收到用户在代码开发过程中录入的对象后,实时去获取第三方API的知识图谱。此外,一种可能的实施方式中,还可以针对录入的对象,只获取属于该对象的第三方API的知识图谱,以实现按需获取、减少知识图谱对代码开发设备存储资源的占用。
本申请还提供一种用于实现上述方法实施例中的代码推荐方法的代码推荐装置,图9给出了该装置的结构示意图。如图9所示,该代码推荐装置包括获取单元、接收单元、推荐单元、呈现单元和添加单元,其中:
获取单元,用于获取第三方应用程序接口API的知识图谱;
接收单元,用于接收用户在代码开发过程中录入的对象;
推荐单元,用于基于第三方应用程序接口API的知识图谱和该对象所在的上下文代码,推荐属于该对象的多个第三方API;
呈现单元,用于提供代码推荐窗口,通过代码推荐窗口向用户呈现上述多个第三方API和上述多个第三方API中的目标第三方API的解释内容;
所述接收单元,还用于接收用户对目标第三方API的选择;
添加单元,用于添加目标第三方API。
如图9所示,该代码推荐装置进一步还可包括知识图谱生成单元和解释内容生成单元,其中:
知识图谱生成单元,用于基于一种或多种知识来源生成第三方应用程序接口API的知识图谱,其中,所述知识来源包括:第三方API的第三方库、第三方API的代码库以及第三方API的文档库,所述第三方应用程序接口API的知识图谱包括至少两种知识之间的关联关系,所述知识包括:第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、第三方API的代码使用案例;
解释内容生成单元,用于基于第三方应用程序接口API的知识图谱,生成用于向用户呈现的目标第三方API的解释内容,其中,目标第三方API的解释内容包括如下的一种或多种:目标第三方API的类型描述、目标第三方API的功能描述、目标第三方API的约束描述、目标第三方API的参数描述、目标第三方API的代码使用案例。
可选地,所述呈现单元还用于当目标第三方API切换到所述多个第三方API中推荐的新第三方API时,通过所述代码推荐窗口向所述用户呈现所述新第三方API的解释内容。
可选地,所述呈现单元还用于按照推荐的优先级顺序,排列呈现所述多个第三方API。
可选地,所述添加单元还用于添加目标第三方API的参数。具体地,所述添加单元用于结合对象所在 的上下文代码,添加目标第三方API的参数。
可选地,所述添加单元还用于使用用户录入的参数,替换已添加的目标第三方API的参数。
可选地,所述添加单元还用于添加缺少一个或多个参数的目标第三方API,并使用用户录入的参数,作为目标第三方API的参数。
可选地,所述呈现单元还用于通过代码推荐窗口向用户呈现属于所述对象的未被推荐的一个或多个第三方API。
此外,上述代码推荐装置执行上述代码推荐方法的各步骤的具体实现过程,可参照上述方法实施例中相关内容的描述,此处不再赘述。
一种可能的实现方式中,本申请提供的代码推荐装置部署在集成开发环境IDE。
需要说明的是,上述代码推荐装置中的各个单元均可以通过软件实现,也可以通过硬件实现。示例性的,下面以推荐单元为例,介绍推荐单元的具体实现方式,类似的,获取单元、接收单元、呈现单元、添加单元、知识图谱生成单元和解释内容生成单元的实现方式可参考推荐单元的实现方式。
单元作为软件功能单元的一种举例,推荐单元可以包括运行在计算实例上的代码。其中,计算实例可以包括物理主机(计算设备)、虚拟机、容器中的至少一种。进一步地,上述计算实例可以是一台或者多台。例如,推荐单元可以包括运行在多个主机/虚拟机/容器上的代码。需要说明的是,用于运行该代码的多个主机/虚拟机/容器可以分布在相同的区域(region)中,也可以分布在不同的region中。进一步地,用于运行该代码的多个主机/虚拟机/容器可以分布在相同的可用区(availability zone,AZ)中,也可以分布在不同的AZ中,每个AZ包括一个数据中心或多个地理位置相近的数据中心。其中,通常一个region可以包括多个AZ。
同样,用于运行该代码的多个主机/虚拟机/容器可以分布在同一个虚拟私有云(virtual private cloud,VPC)中,也可以分布在多个VPC中。其中,通常一个VPC设置在一个region内,同一region内两个VPC之间,以及不同region的VPC之间跨区通信需在每个VPC内设置通信网关,经通信网关实现VPC之间的互连。
单元作为硬件功能单元的一种举例,推荐单元可以包括至少一个计算设备,如服务器等。或者,推荐单元也可以是利用专用集成电路(application-specific integrated circuit,ASIC)实现、或可编程逻辑器件(programmable logic device,PLD)实现的设备等。其中,上述PLD可以是复杂程序逻辑器件(complex programmable logical device,CPLD)、现场可编程门阵列(field-programmable gate array,FPGA)、通用阵列逻辑(generic array logic,GAL)或其任意组合实现。
推荐单元包括的多个计算设备可以分布在相同的region中,也可以分布在不同的region中。推荐单元包括的多个计算设备可以分布在相同的AZ中,也可以分布在不同的AZ中。同样,推荐单元包括的多个计算设备可以分布在同一个VPC中,也可以分布在多个VPC中。其中,所述多个计算设备可以是服务器、ASIC、PLD、CPLD、FPGA和GAL等计算设备的任意组合。
本申请还提供一种用于实现上述方法实施例中的代码推荐方法的代码推荐系统,图10给出了该代码推荐系统的一种结构示意图,该系统包括代码开发设备和知识图谱设备,其中:
代码开发设备,用于:从知识图谱设备,获取第三方应用程序接口API的知识图谱;接收用户在代码开发过程中录入的对象;基于第三方应用程序接口API的知识图谱和所述对象所在的上下文代码,推荐属于所述对象的多个第三方API;提供代码推荐窗口,通过所述代码推荐窗口向用户呈现所述多个第三方API和所述多个第三方API中的目标第三方API的解释内容;接收用户对目标第三方API的选择;添加目标第三方API。
知识图谱设备,用于存储第三方应用程序接口API的知识图谱。
可选地,知识图谱设备还用于基于一种或多种知识来源生成第三方应用程序接口API的知识图谱,其中,所述知识来源包括:第三方API的第三方库、第三方API的代码库以及第三方API的文档库;第三方应用程序接口API的知识图谱包括至少两种知识之间的关联关系,所述知识包括:第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、第三方API的代码使用案例。
可选地,代码开发设备还用于基于第三方应用程序接口API的知识图谱,生成用于向用户呈现的目标第三方API的解释内容。其中,目标第三方API的解释内容包括如下的一种或多种:目标第三方API的类型描述、目标第三方API的功能描述、目标第三方API的约束描述、目标第三方API的参数描述、目标第三方API的代码使用案例。
可选地,代码开发设备还用于:当目标第三方API切换到所述多个第三方API中推荐的新第三方API 时,通过代码推荐窗口向用户呈现新第三方API的解释内容。
可选地,代码开发设备还用于按照推荐的优先级顺序,排列呈现所述多个第三方API。
可选地,代码开发设备还用于添加目标第三方API的参数。具体地,代码开发设备用于结合对象所在的上下文代码,添加目标第三方API的参数。
可选地,代码开发设备还用于使用用户录入的参数,替换已添加的目标第三方API的参数。
可选地,代码开发设备还用于添加缺少一个或多个参数的目标第三方API,并使用用户录入的参数,作为目标第三方API的参数。
可选地,代码开发设备还用于通过代码推荐窗口向用户呈现属于所述对象的未被推荐的一个或多个第三方API。
此外,上述代码推荐系统执行上述代码推荐方法的各步骤的具体实现过程,可参照上述方法实施例中相关内容的描述,此处不再赘述。
如图10所示的实施方式中,该代码推荐系统中的代码开发设备部署在本地,此时的代码开发设备可以是个人计算机或笔记本电脑等,而用于生成并存储第三方API的知识图谱的知识图谱设备部署在云端,此时的知识图谱设备可以是云服务所在的服务器或云上的虚拟机。采用上述部署方式的代码推荐系统在执行代码推荐方法时,用户在本地的代码开发设备上进行API推荐之前,可以先去云端获取第三方API的知识图谱,减少了知识图谱直接存在本地时对代码开发设备存储资源的占用。具体地,第三方API的知识图谱可以以云数据库或OBS(对象存储服务)等形式被存储在云端的知识图谱设备,本申请不作具体限定。
其它可能的实施方式中,用户在云上做代码开发,此时代码开发设备和知识图谱设备均部署在云端,代码开发设备和知识图谱设备均可以是云服务所在的服务器或云上的虚拟机。采用上述部署方式的代码推荐系统在执行代码推荐方法时,知识图谱也存储在云端,用户在进行API推荐之前可直接在云上调用第三方API的知识图谱。
另一种可能的实施方式中,用户在本地做代码开发,同时知识图谱也存储在本地,此时代码开发设备和知识图谱设备均部署在本地,代码开发设备和知识图谱设备均可以是个人计算机或笔记本电脑等。采用上述部署方式的代码推荐系统在执行代码推荐方法时,用户在进行API推荐之前可直接调用本地的第三方API的知识图谱。
此外,代码推荐系统中代码开发设备或知识图谱设备的具体实现方式可参照代码推荐装置中推荐单元的实现方式,此处不再赘述。
本申请还提供一种计算设备集群,图11是该计算设备集群的结构示意图,该计算设备集群可以实现上述实施例中的代码推荐方法。如图11所示,该计算设备集群包括至少一个计算设备500,该计算设备500可以是服务器,例如是中心服务器、边缘服务器,或者是本地数据中心中的本地服务器。在一些实施例中,计算设备也可以是台式机、笔记本电脑或者智能手机等终端设备。
每个计算设备500包括:总线502、处理器504、存储器506和通信接口508。处理器504、存储器506和通信接口508之间通过总线502通信。计算设备500可以是服务器或终端设备。应理解,本申请不限定计算设备500中的处理器和存储器的个数。
总线502可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图5中仅用一条线表示,但并不表示仅有一根总线或一种类型的总线。总线502可包括在计算设备500各个部件(例如,存储器506、处理器504、通信接口508)之间传送信息的通路。
处理器504可以包括中央处理器(central processing unit,CPU)、图形处理器(graphics processing unit,GPU)、微处理器(micro processor,MP)或者数字信号处理器(digital signal processor,DSP)等处理器中的任意一种或多种。
存储器506可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM)。存储器506还可以包括非易失性存储器(non-volatile memory),例如只读存储器(read-only memory,ROM),快闪存储器,机械硬盘(hard disk drive,HDD)或固态硬盘(solid state drive,SSD)。
存储器506中存储有可执行的程序代码,处理器504执行该可执行的程序代码以实现前述代码推荐方法。也即,存储器506上存有用于执行代码推荐方法的指令。
通信接口508使用例如但不限于网络接口卡、收发器一类的收发模块,来实现计算设备500与其他设备或通信网络之间的通信。
在一些可能的实现方式中,该计算设备集群中的一个或多个计算设备500的存储器506中也可以分别 存有用于执行代码推荐方法的部分指令。换言之,一个或多个计算设备500的组合可以共同执行用于执行代码推荐方法的指令。
需要说明的是,计算设备集群中的不同的计算设备500中的存储器506可以存储不同的指令,分别用于执行代码推荐装置或代码推荐系统的部分功能。也即,不同的计算设备500中的存储器506存储的指令可以实现代码推荐装置的多个单元中的一个或多个单元的功能,或者不同的计算设备500中的存储器506存储的指令可以实现代码推荐系统中代码开发设备和知识图谱设备的功能。
在一些可能的实现方式中,计算设备集群中的一个或多个计算设备可以通过网络连接。其中,所述网络可以是广域网或局域网等等。图12示出了一种可能的实现方式。如图12所示,两个计算设备500A和500B之间通过网络进行连接。具体地,通过各个计算设备中的通信接口与所述网络进行连接。在这一类可能的实现方式中,计算设备500A中的存储器506中存有执行代码推荐系统的代码开发设备的功能的指令。同时,计算设备500B中的存储器506中存有执行代码推荐系统的知识图谱设备的功能的指令。
图12所示的计算设备集群之间的连接方式可以是考虑到本申请提供的代码推荐方法中知识图谱设备需要大量地存储数据,因此考虑将知识图谱设备实现的功能交由计算设备500B执行。
应理解,图12中示出的计算设备500A的功能也可以由多个计算设备500完成。同样,计算设备500B的功能也可以由多个计算设备500完成。
本申请还提供了一种包含指令的计算机程序产品。所述计算机程序产品可以是包含指令的,能够运行在计算设备上或被储存在任何可用介质中的软件或程序产品。当所述计算机程序产品在至少一个计算设备上运行时,使得至少一个计算设备执行代码推荐方法。
本申请还提供了一种计算机可读存储介质。所述计算机可读存储介质可以是计算设备能够存储的任何可用介质或者是包含一个或多个可用介质的数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘)等。该计算机可读存储介质包括指令,所述指令指示计算设备执行代码推荐方法,或指示计算设备执行代码推荐方法。
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的保护范围。

Claims (35)

  1. 一种代码推荐方法,其特征在于,所述方法包括:
    代码开发设备从知识图谱设备,获取第三方应用程序接口API的知识图谱;
    所述代码开发设备接收用户在代码开发过程中录入的对象;
    所述代码开发设备基于所述第三方应用程序接口API的知识图谱和所述对象所在的上下文代码,推荐属于所述对象的多个第三方API;
    所述代码开发设备提供代码推荐窗口,通过所述代码推荐窗口向所述用户呈现所述多个第三方API和所述多个第三方API中的目标第三方API的解释内容;
    所述代码开发设备接收所述用户对所述目标第三方API的选择;
    所述代码开发设备添加所述目标第三方API。
  2. 根据权利要求1所述的方法,其特征在于,所述方法包括:
    所述知识图谱设备基于一种或多种知识来源生成所述第三方应用程序接口API的知识图谱,其中,所述知识来源包括:第三方API的第三方库、第三方API的代码库以及第三方API的代码库,所述第三方应用程序接口API的知识图谱包括至少两种知识之间的关联关系,所述知识包括:第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、第三方API的代码使用案例;
    所述代码开发设备基于所述第三方应用程序接口API的知识图谱,生成用于向所述用户呈现的所述目标第三方API的解释内容。
  3. 根据权利要求1或2所述的方法,其特征在于,所述目标第三方API的解释内容包括如下的一种或多种:
    所述目标第三方API的类型描述;
    所述目标第三方API的功能描述;
    所述目标第三方API的约束描述;
    所述目标第三方API的参数描述;
    所述目标第三方API的代码使用案例。
  4. 根据权利要求1至3中任一项所述的方法,其特征在于,所述方法包括:
    当所述目标第三方API切换到所述多个第三方API中推荐的新第三方API时,所述代码开发设备通过所述代码推荐窗口向所述用户呈现所述新第三方API的解释内容。
  5. 根据权利要求1至4中任一项所述的方法,其特征在于,所述呈现所述多个第三方API,包括:
    所述代码开发设备按照推荐的优先级顺序,排列呈现所述多个第三方API。
  6. 根据权利要求1至5中任一项所述的方法,其特征在于,所述代码开发设备添加所述目标第三方API,包括:
    所述代码开发设备添加所述目标第三方API的参数。
  7. 根据权利要求6所述的方法,其特征在于,所述代码开发设备添加所述目标第三方API的参数,包括:
    所述代码开发设备结合所述对象所在的上下文代码,添加所述目标第三方API的参数。
  8. 根据权利要求6或7所述的方法,其特征在于,所述方法包括:
    所述代码开发设备使用所述用户录入的参数,替换已添加的所述目标第三方API的参数。
  9. 根据权利要求1至5中任一项所述的方法,其特征在于,
    所述代码开发设备添加所述目标第三方API,包括:所述代码开发设备添加缺少一个或多个参数的所述目标第三方API;
    所述方法包括:所述代码开发设备使用所述用户录入的参数,作为所述目标第三方API的参数。
  10. 根据权利要求1至9中任一项所述的方法,其特征在于,所述方法包括:
    所述代码开发设备通过所述代码推荐窗口向所述用户呈现属于所述对象的未被推荐的第三方API。
  11. 根据权利要求1至10中任一项所述的方法,其特征在于,
    所述代码开发设备和所述知识图谱设备部署在云端;或者,
    所述代码开发设备部署在本地,所述知识图谱设备部署在云端;或者,
    所述代码开发设备和所述知识图谱设备部署在本地。
  12. 一种代码推荐装置,其特征在于,所述装置包括:
    获取单元,用于获取第三方应用程序接口API的知识图谱;
    接收单元,用于接收用户在代码开发过程中录入的对象;
    推荐单元,用于基于所述第三方应用程序接口API的知识图谱和所述对象所在的上下文代码,推荐属于所述对象的多个第三方API;
    呈现单元,用于提供代码推荐窗口,通过所述代码推荐窗口向所述用户呈现所述多个第三方API和所述多个第三方API中的目标第三方API的解释内容;
    所述接收单元,用于接收所述用户对所述目标第三方API的选择;
    添加单元,用于添加所述目标第三方API。
  13. 根据权利要求12所述的装置,其特征在于,所述装置包括:
    知识图谱生成单元,用于基于一种或多种知识来源生成所述第三方应用程序接口API的知识图谱,其中,所述知识来源包括:第三方API的第三方库、第三方API的代码库以及第三方API的文档库,所述第三方应用程序接口API的知识图谱包括至少两种知识之间的关联关系,所述知识包括:第三方API的类型知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、第三方API的代码使用案例;
    解释内容生成单元,用于基于所述第三方应用程序接口API的知识图谱,生成用于向所述用户呈现的所述目标第三方API的解释内容。
  14. 根据权利要求12或13所述的装置,其特征在于,所述目标第三方API的解释内容包括如下的一种或多种:
    所述目标第三方API的类型描述;
    所述目标第三方API的功能描述;
    所述目标第三方API的约束描述;
    所述目标第三方API的参数描述;
    所述目标第三方API的代码使用案例。
  15. 根据权利要求12至14中任一项所述的装置,其特征在于,
    所述呈现单元,用于当所述目标第三方API切换到所述多个第三方API中推荐的新第三方API时,通过所述代码推荐窗口向所述用户呈现所述新第三方API的解释内容。
  16. 根据权利要求12至15中任一项所述的装置,其特征在于,
    所述呈现单元,用于按照推荐的优先级顺序,排列呈现所述多个第三方API。
  17. 根据权利要求12至16中任一项所述的装置,其特征在于,
    所述添加单元,用于添加所述目标第三方API的参数。
  18. 根据权利要求17所述的装置,其特征在于,
    所述添加单元,用于结合所述对象所在的上下文代码,添加所述目标第三方API的参数。
  19. 根据权利要求17或18所述的装置,其特征在于,
    所述添加单元,用于使用所述用户录入的参数,替换已添加的所述目标第三方API的参数。
  20. 根据权利要求12至16中任一项所述的装置,其特征在于,
    所述添加单元,用于:添加缺少一个或多个参数的所述目标第三方API;使用所述用户录入的参数,作为所述目标第三方API的参数。
  21. 根据权利要求12至20中任一项所述的装置,其特征在于,
    所述呈现单元,用于通过所述代码推荐窗口向所述用户呈现属于所述对象的未被推荐的第三方API。
  22. 一种代码推荐系统,其特征在于,所述系统包括:
    代码开发设备,用于:从知识图谱设备,获取第三方应用程序接口API的知识图谱;接收用户在代码开发过程中录入的对象;基于所述第三方应用程序接口API的知识图谱和所述对象所在的上下文代码,推荐属于所述对象的多个第三方API;提供代码推荐窗口,通过所述代码推荐窗口向所述用户呈现所述多个第三方API和所述多个第三方API中的目标第三方API的解释内容;接收所述用户对所述目标第三方API的选择;添加所述目标第三方API;
    知识图谱设备,用于存储所述第三方应用程序接口API的知识图谱。
  23. 根据权利要求22所述的系统,其特征在于,所述系统包括:
    所述知识图谱设备,用于基于一种或多种知识来源生成所述第三方应用程序接口API的知识图谱,其中,所述知识来源包括:第三方API的第三方库、第三方API的代码库以及第三方API的文档库,所述第三方应用程序接口API的知识图谱包括至少两种知识之间的关联关系,所述知识包括:第三方API的类型 知识、第三方API的功能知识、第三方API的约束知识、第三方API的参数知识、第三方API的代码使用案例;
    所述代码开发设备,用于基于所述第三方应用程序接口API的知识图谱,生成用于向所述用户呈现的所述目标第三方API的解释内容。
  24. 根据权利要求22或23所述系统,其特征在于,所述目标第三方API的解释内容包括如下的一种或多种:
    所述目标第三方API的类型描述;
    所述目标第三方API的功能描述;
    所述目标第三方API的约束描述;
    所述目标第三方API的参数描述;
    所述目标第三方API的代码使用案例。
  25. 根据权利要求22至24中任一项所述的系统,其特征在于,
    所述代码开发设备,用于当所述目标第三方API切换到所述多个第三方API中推荐的新第三方API时,通过所述代码推荐窗口向所述用户呈现所述新第三方API的解释内容。
  26. 根据权利要求22至25中任一项所述的系统,其特征在于,
    所述代码开发设备,用于按照推荐的优先级顺序,排列呈现所述多个第三方API。
  27. 根据权利要求22至26中任一项所述的系统,其特征在于,
    所述代码开发设备,用于添加所述目标第三方API的参数。
  28. 根据权利要求27所述的系统,其特征在于,
    所述代码开发设备,用于结合所述对象所在的上下文代码,添加所述目标第三方API的参数。
  29. 根据权利要求27或28所述的系统,其特征在于,
    所述代码开发设备,用于使用所述用户录入的参数,替换已添加的所述目标第三方API的参数。
  30. 根据权利要求22至26中任一项所述的系统,其特征在于,
    所述代码开发设备,用于:添加缺少一个或多个参数的所述目标第三方API;使用所述用户录入的参数,作为所述目标第三方API的参数。
  31. 根据权利要求22至30中任一项所述的系统,其特征在于,
    所述代码开发设备,用于通过所述代码推荐窗口向所述用户呈现属于所述对象的未被推荐的第三方API。
  32. 根据权利要求22至31中任一项所述的系统,其特征在于,
    所述代码开发设备和所述知识图谱设备部署在云端;或者,
    所述代码开发设备部署在本地,所述知识图谱设备部署在云端;或者,
    所述代码开发设备和所述知识图谱设备部署在本地。
  33. 一种计算设备集群,其特征在于,包括至少一个计算设备,每个计算设备包括处理器和存储器;
    所述至少一个计算设备的处理器用于执行所述至少一个计算设备的存储器中存储的指令,以使得所述计算设备集群执行如权利要求1至11任一项所述的方法。
  34. 一种包含指令的计算机程序产品,其特征在于,当所述指令被计算设备集群运行时,使得所述计算设备集群执行如权利要求1至11任一项所述的方法。
  35. 一种计算机可读存储介质,其特征在于,包括计算机程序指令,当所述计算机程序指令由计算设备集群执行时,所述计算设备集群执行如权利要求1至11任一项所述的方法。
PCT/CN2023/123468 2022-10-17 2023-10-09 一种代码推荐方法、装置及相关设备 WO2024082983A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202211264591.4 2022-10-17
CN202211264591 2022-10-17
CN202310376402.0A CN117931146A (zh) 2022-10-17 2023-04-10 一种代码推荐方法、装置及相关设备
CN202310376402.0 2023-04-10

Publications (1)

Publication Number Publication Date
WO2024082983A1 true WO2024082983A1 (zh) 2024-04-25

Family

ID=90736900

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/123468 WO2024082983A1 (zh) 2022-10-17 2023-10-09 一种代码推荐方法、装置及相关设备

Country Status (1)

Country Link
WO (1) WO2024082983A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030131069A1 (en) * 2001-03-14 2003-07-10 Lucovsky Mark H. Schema-based context service
CN111966817A (zh) * 2020-07-24 2020-11-20 复旦大学 基于深度学习及代码上下文结构和文本信息的api推荐方法
CN112329964A (zh) * 2020-11-24 2021-02-05 北京百度网讯科技有限公司 用于推送信息的方法、装置、设备以及存储介质
CN112650482A (zh) * 2020-12-25 2021-04-13 浙江蓝卓工业互联网信息技术有限公司 一种逻辑组件的推荐方法及相关装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030131069A1 (en) * 2001-03-14 2003-07-10 Lucovsky Mark H. Schema-based context service
CN111966817A (zh) * 2020-07-24 2020-11-20 复旦大学 基于深度学习及代码上下文结构和文本信息的api推荐方法
CN112329964A (zh) * 2020-11-24 2021-02-05 北京百度网讯科技有限公司 用于推送信息的方法、装置、设备以及存储介质
CN112650482A (zh) * 2020-12-25 2021-04-13 浙江蓝卓工业互联网信息技术有限公司 一种逻辑组件的推荐方法及相关装置

Similar Documents

Publication Publication Date Title
US10169471B2 (en) Generating and executing query language statements from natural language
US9772890B2 (en) Sophisticated run-time system for graph processing
US11687579B2 (en) Dictionary editing system integrated with text mining
US9400700B2 (en) Optimized system for analytics (graphs and sparse matrices) operations
US20060026559A1 (en) Automatic content completion of valid values for method argument variables
US9626432B2 (en) Defect record classification
Gu et al. Codekernel: A graph kernel based approach to the selection of API usage examples
US11144437B2 (en) Pre-populating continuous delivery test cases
US11354108B2 (en) Assisting dependency migration
CN111736840A (zh) 小程序应用的编译方法、运行方法、存储介质及电子设备
CN111324833A (zh) 页面展示方法、装置、电子设计及计算机可读介质
CN116406459A (zh) 一种代码处理方法、装置、设备及介质
CN110688111A (zh) 业务流程的配置方法、装置、服务器和存储介质
US11500619B1 (en) Indexing and accessing source code snippets contained in documents
EP3667547B1 (en) User interface (ui) design compliance determination
WO2024082983A1 (zh) 一种代码推荐方法、装置及相关设备
CN110852050A (zh) 一种配置报表生成系统的方法、装置和电子设备
CN115794858A (zh) 查询语句处理方法、装置、设备及存储介质
US11947966B2 (en) Identifying computer instructions enclosed by macros and conflicting macros at build time
CN110727428B (zh) 一种转换业务逻辑层代码的方法、装置和电子设备
US10902046B2 (en) Breaking down a high-level business problem statement in a natural language and generating a solution from a catalog of assets
US11163833B2 (en) Discovering and displaying business artifact and term relationships
CN117931146A (zh) 一种代码推荐方法、装置及相关设备
WO2024031983A1 (zh) 一种代码管理方法及相关设备
WO2024078472A1 (zh) 一种调试云服务应用程序接口api的方法、装置以及相关设备