# US 12,008,365 B2 · Systems and method for automated code analysis and tagging

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,008,365 B2
- Document ID: US12008365B2
- Status: Granted
- Kind: B2
- Application number: 17/651,005
- Filed: 2022-02-14
- Published: 2023-08-17
- Granted: 2024-06-11
- Earliest claimed: 2021-06-28
- Assignees: JPMorgan Chase Bank, N.A.
- Applicants: Jpmorgan Chase Bank , N.A.
- Inventors: Sean Moran; Sanat Saha; Gaurav Singh; Fanny Silavong; Antonios Georgiadis; Ganesh Chandrasekar; Andy Alexander; Rob Otter; Brett Sanford
- Web page: https://patentgrep.com/patent/US12008365B2

## CPC

- G06F 8/75: Structural analysis for program understanding
- G06F 8/427: {Parsing}
- G06F 17/16: Matrix or vector computation {, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization (matrix transposition G06F7/78)}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Systems and methods for automated code analysis and tagging are disclosed. In one embodiment, a method for automated code analysis and tagging may include: (1) receiving, by a code annotation computer program executed by a computer processor, a training code snippet from a training codebase; (2) parsing, by the code annotation computer program, the training code snippet into a data structure; (3) quantifying, by the code annotation computer program, the data structure, (4) parsing, by the code annotation computer program, a docstring associated with the training code snippet into a plurality of keywords; (5) quantifying, by the code annotation computer program, the plurality of keywords; and (6) training, by the code annotation computer program, a code annotation model based on a similarity between the quantified data structure and a smoothing parameter for a Dirichlet prior smoothing estimate.

## Claims

### Claim 1

A method for automated code analysis and tagging, comprising:
receiving, by a code annotation computer program executed by a computer processor, a training code snippet from a training codebase;
parsing, by the code annotation computer program, the training code snippet into a data structure;
quantifying, by the code annotation computer program, the data structure,
parsing, by the code annotation computer program, a docstring associated with the training code snippet into a plurality of keywords;
quantifying, by the code annotation computer program, the plurality of keywords;
training, by the code annotation computer program, a code annotation model based on a similarity between the quantified data structure and a smoothing parameter for a Dirichlet prior smoothing estimate; and
generating an annotation for the training code snippet by matrix multiplication of a test code-training probability matrix and a training code-word probability matrix, the test code-training code probability matrix computed from a Gaussian kernel density estimate between each test code snippet and each training code snippet from the training codebase.

### Claim 2 (depends on 1)

The method of claim 1, wherein the data structure comprises an Abstract Syntax Tree (“AST”).

### Claim 3 (depends on 1)

The method of claim 1, wherein the data structure comprises a Simplified Parse Tree (“SPT”).

### Claim 4 (depends on 1)

The method of claim 1, wherein the data structure is quantified into a feature vector.

### Claim 5 (depends on 1)

The method of claim 1, further comprising:
extracting, by the code annotation computer program, structural features for a relationship between two nodes in the data structure.

### Claim 6 (depends on 1)

The method of claim 1, further comprising:
determining, by the code annotation computer program, a number of occurrences of the keyword in the docstring;
comparing, by the code annotation computer program, the number of occurrences of the keyword in the docstring to a number of occurrences of the keyword in the training codebase; and
applying, by the code annotation computer program, term frequency inverse document frequency to weight the keyword.

### Claim 7 (depends on 1)

The method of claim 1, wherein the step of training the code annotation model based on a similarity between the quantified data structures and the quantified keywords comprises:
tuning, by the code annotation computer program, a bandwidth of a Gaussian kernel to compute the similarity between the quantified data structures and a smoothing parameter for a Dirichlet prior smoothing estimate.

### Claim 8 (depends on 1)

The method of claim 1, wherein the code annotation model comprises a probabilistic generative model.

### Claim 9

A method for automated code analysis and tagging, comprising:
receiving, by a code annotation computer program executed by a computer processor, a training code snippet from a training codebase;
parsing, by the code annotation computer program, the training code snippet into a data structure;
quantifying, by the code annotation computer program, the data structure,
parsing, by the code annotation computer program, a docstring associated with the training code snippet into a plurality of keywords;
quantifying, by the code annotation computer program, the plurality of keywords; and
tuning, by the code annotation computer program, a bandwidth of a Gaussian kernel to compute a similarity between the quantified data structures and a smoothing parameter for a Dirichlet prior smoothing estimate,
wherein annotations for the training code snippet is generated by matrix multiplication of a test code-training code probability matrix and a training code-word probability matrix, wherein the test code-training code probability matrix is computed from a Gaussian kernel density estimate between each test code snippet and each training code snippet.

### Claim 10

A method for automated code analysis and tagging, comprising:
parsing, by a code annotation computer program executed by a computer processor, an unannotated code snippet into a data structure;
quantifying, by the code annotation computer program, the data structure;
quantifying, by the code annotation computer program, keywords for a plurality of training code snippets by matrix multiplication of a test code-training code probability matrix and a training code-word probability matrix, wherein the test code-training code probability matrix is computed from a Gaussian kernel density estimate between each test code snippet and each of the plurality of training code snippets;
computing, by the code annotation computer program, conditional probabilities of the unannotated code snippet occurring in each of the plurality of training code snippets;
computing, by the code annotation computer program, a conditional probability of each of the keywords in the training code snippets for the unannotated code snippet;
selecting, by the code annotation computer program, a plurality of the keywords based on the conditional probability for each keyword; and
annotating, by the code annotation computer program, the unannotated code snippet with the selected keywords.

### Claim 11 (depends on 10)

The method of claim 10, wherein the data structure comprises an Abstract Syntax Tree (“AST”).

### Claim 12 (depends on 10)

The method of claim 10, wherein the data structure comprises a Simplified Parse Tree (“SPT”).

### Claim 13 (depends on 10)

The method of claim 10, wherein the data structure is quantified into a feature vector.

### Claim 14 (depends on 10)

The method of claim 10, wherein the keywords are quantified using a Dirchlet prior estimator.

### Claim 15 (depends on 10)

The method of claim 10, wherein the conditional probabilities are computed using a Gaussian kernel density estimator.

### Claim 16 (depends on 10)

The method of claim 10, further comprising:
computing, by the code annotation computer program, a prior probability of each training code snippet.

### Claim 17 (depends on 10)

The method of claim 10, further comprising:
determining, by the code annotation computer program, that a prior probability of each training code snippet is constant.

### Claim 18 (depends on 10)

The method of claim 10, wherein the step of annotating the unannotated code snippet with the selected keywords comprises:
storing, by the code annotation computer program, the selected keywords; and
associating, by the code annotation computer program, the stored selected keywords with the unannotated code snippet.
