IP Library › Granted Patent US 11,573,790
Granted Patent B2
US 11,573,790 · App. 16/704,098 · Granted Feb 7, 2023

Generation of knowledge graphs based on repositories of code

Inventors: Julian Timothy Dolby (Bronx, NY); Kavitha Srinivas (Rye, NY)
Assignee: International Business Machines Corporation
G06F8/75G06N5/02
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,573,790
App. No.
16/704,098
Granted
Feb 7, 2023
Kind
B2
Abstract

Techniques for code analysis are provided. User code is received, and an import statement is identified in the user code. A first empty object is generated based on the import statement, and the first empty object is named based on the name of an import reference included in the import statement. A knowledge graph is generated based at least in part on the first empty object.

Claims (62)

1. A method comprising:

receiving user code;

identifying an import statement in the user code to import an application programming interface (API);

generating a first empty object representing the API based on the import statement;

naming the first empty object to match a name of an import reference included in the import statement;

identifying a first control call in the user code;

determining an invocation of the first control call on the first empty object;

generating a second empty object based on the invocation of the first control call;

naming the second empty object based on a name of the first empty object and a name of the first control call; and

generating a knowledge graph based at least in part on the first empty object and the second empty object to indicate relationships and patterns in usage of a plurality of APIs.

2. The method of claim 1 , wherein the first control call is a function call or a method call.

3. The method of claim 1 , wherein the first empty object and the second empty object do not include any code statement.

4. The method of claim 1 , further comprising:

identifying an argument passed as a parameter in a second control call;

resolving the argument to an existing empty object;

determining an invocation of a third control call on the existing empty object;

generating a third empty object based on the invocation of the third control call; and

naming the third empty object based on a name of the existing empty object and a name of the third control call.

5. The method of claim 4 , wherein the third control call is a function call or method call, and wherein the existing empty object and the third empty object do not include any code statement.

6. The method of claim 1 , wherein the knowledge graph includes code data from at least one of: (i) a code comment embedded in the user code, (ii) a code comment embedded in a first code module referenced by the import statement, (iii) a code usage document external to the user code, (iv) an internet forum, (iv) a class hierarchy depicted in a second code module.

7. A non-transitory computer-readable medium containing computer program code that, when executed on one or more computer processors, performs an operation configured to:

receive user code;

identify an import statement in the user code to import an application programming interface (API);

generate a first empty object representing the API based on the import statement;

name the first empty object to match a name of an import reference included in the import statement;

identify a first control call in the user code;

determine an invocation of the first control call on the first empty object;

generate a second empty object based on the invocation of the first control call; and

name the second empty object based on a name of the first empty object and a name of the first control call; and

generate a knowledge graph based at least in part on the first empty object and the second empty object to indicate relationships and patterns in usage of a plurality of APIs.

8. The non-transitory computer-readable medium of claim 7 , wherein the first control call is a function call or a method call.

9. The non-transitory computer-readable medium of claim 7 , wherein the first empty object and the second empty object do not include any code statement.

10. The non-transitory computer-readable medium of claim 7 , the operation further configured to:

identify an argument passed as a parameter in a second control call;

resolve the argument to an existing empty object;

determine an invocation of a third control call on the existing empty object;

generate a third empty object based on the invocation of the third control call; and

name the third empty object based on a name of the existing empty object and a name of the third control call.

11. The non-transitory computer-readable medium of claim 10 , wherein the third control call is a function call or method call, and wherein the existing empty object and the third empty object do not include any code statement.

12. The non-transitory computer-readable medium of claim 7 , wherein the knowledge graph includes code data from at least one of: (i) a code comment embedded in the user code, (ii) a code comment embedded in a first code module referenced by the import statement, (iii) a code usage document external to the user code, (iv) an internet forum, (iv) a class hierarchy depicted in a second code module.

13. A system comprising:

a processor; and

memory, the memory including computer program code that, when executed by the processor, performs an operation, the operation comprising:

receiving user code;

identifying an import statement in the user code to import an application programming interface (API);

generating a first empty object representing the API based on the import statement;

naming the first empty object to match a name of an import reference included in the import statement;

identifying a first control call in the user code;

determining an invocation of the first control call on the first empty object;

generating a second empty object based on the invocation of the first control call; and

naming the second empty object based on a name of the first empty object and a name of the first control call; and

generating a knowledge graph based at least in part on the first empty object and the second empty object to indicate relationships and patterns in usage of a plurality of APIs.

14. The system of claim 13 , wherein the first control call is a function call or a method call.

15. The system of claim 13 , wherein the first empty object and the second empty object do not include any code statement.

16. The system of claim 13 , the operation further comprising:

identifying an argument passed as a parameter in a second control call;

resolving the argument to an existing empty object;

determining an invocation of a third control call on the existing empty object;

generating a third empty object based on the invocation of the third control call; and

naming the third empty object based on a name of the existing empty object and a name of the third control call.

17. The system of claim 16 , wherein the third control call is a function call or method call, and wherein the existing empty object and the third empty object do not include any code statement.

18. The system of claim 13 , wherein the knowledge graph includes code data from at least one of: (i) a code comment embedded in the user code, (ii) a code comment embedded in a first code module referenced by the import statement, (iii) a code usage document external to the user code, (iv) an internet forum, (iv) a class hierarchy depicted in a second code module.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 5, 2019
From: DOLBY, JULIAN TIMOTHY; SRINIVAS, KAVITHA
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 051188/0545 →
Continuity (1)
Related Publication 20210173641A1 · Jun 10, 2021