Predictive natural language rule generation
AssigneeInternational Business Machines Corporation
InventorYan Luo
Life of this patent
Estimating the term…
Abstract
In an approach to generating natural language rules based on detected code snippets, one or more computer processors detect a code snippet. The one or more computer processors extract code information from the detected code snippet. The one or more computer processors feed the extracted code information into a cognitive model, wherein the cognitive model utilizes one or more historical code snippets based on the extracted code information and one or more natural language rules based on the extracted code information. The one or more computer processors generate, based on one or more calculations by the cognitive model, a natural language rule for the code snippet.
Claims20
A method comprising:
- responsive to a user inputting a code snippet into an integrated development environment, extracting, by one or more computer processors, code information from the code snippet;
- determining, by one or more computer processors, a programing language associated with the code snippet based on the extracted code information, wherein determining the programming language comprises generating a relevancy score based on the code snippet and one or more programming languages each associated with one or more conventions;
- retrieving, by one or more computer processors, a code corpus specific to the determined programing language;
- training, by one or more computer processors, a cognitive model utilizing the retrieved code corpus;
- feeding, by one or more computer processors, the extracted code information into the cognitive model, wherein the cognitive model utilizes one or more historical code snippets based on the extracted code information and one or more natural language rules based on the extracted code information;
- and
- generating, by one or more computer processors, based on one or more calculations by the cognitive model, a natural language rule for the code snippet, wherein generating the natural language rule comprises:
- responsive to a generated natural language word not exceeding a predetermined probability threshold, prompting, by one or more computer processors, a user for a selection from a list of predicted words with respective calculated probabilities;
- and
- responsive to a user selection from the list of predicted words, appending, by one or more computer processors, the selection to the natural language rule.
A computer program product comprising:
- one or more computer readable storage media and program instructions stored on the one or more computer readable storage media, the program instructions comprising:
- program instructions to detect a code snippet;
- program instructions to extract code information from the detected code snippet;
- program instructions to feed the extracted code information into a cognitive model, wherein the cognitive model utilizes one or more historical code snippets based on the extracted code information and one or more natural language rules based on the extracted code information;
- and
- program instructions to generate, based on one or more calculations by the cognitive model, a natural language rule for the code snippet, wherein program instructions to generate the natural language rule comprise:
- program instructions to responsive to a generated natural language word not exceeding a predetermined probability threshold, prompt a user for a selection from a list of predicted words with respective calculated probabilities;
- and
- program instructions to responsive to a user selection from the list of predicted words, append the selection to the natural language rule.
A computer system comprising:
- one or more computer processors;
- one or more computer readable storage media;
- and
- program instructions stored on the computer readable storage media for execution by at least one of the one or more processors, the program instructions comprising:
- program instructions to detect a code snippet;
- program instructions to extract code information from the detected code snippet;
- program instructions to feed the extracted code information into a cognitive model, wherein the cognitive model utilizes one or more historical code snippets based on the extracted code information and one or more natural language rules based on the extracted code information;
- and
- program instructions to generate, based on one or more calculations by the cognitive model, a natural language rule for the code snippet, wherein program instructions to generate the natural language rule comprise:
- program instructions to responsive to a generated natural language word not exceeding a predetermined probability threshold, prompt a user for a selection from a list of predicted words with respective calculated probabilities;
- and
- program instructions to responsive to a user selection from the list of predicted words, append the selection to the natural language rule.
Dependencies are inferred from the claim text.