Patent ID: 11934815
Assignee: TATA CONSULTANCY SERVICES LIMITED
Field: Computer technology (Electrical engineering)
Classification: CPC G | IPC G

Claim 4:
5. A system for translation of codes based on a semantic similarity, the system comprises:
a user interface for providing a source code for translation as an input and a target language in which the source code needs to be translated;
one or more hardware processors;
a memory in communication with the one or more hardware processors, wherein the one or more first hardware processors are configured to execute programmed instructions stored in the one or more first memories, to:
parse the source code using a parser;
create a program flow graph using the parsed source code, wherein the program flow graph is used to establish a set of relations between a plurality of statements present in the source code;
create a matrix of the established set of relations between the plurality of statements;
split the source code into a plurality of blocks using the created matrix, wherein the statements in one block out of the plurality of blocks are closer to each other as compared to other statements irrespective of their physical presence in the source code;
vectorize the plurality of blocks to get a plurality of vectorized blocks;
train a semantically enhanced encoder with a context of a semantic equivalence between the plurality of blocks of the source code irrespective of a manner in which the plurality of blocks is syntactically coded;
identify semantically similar statements out of the plurality of blocks using the trained model;
select a target language in which the source code needs to be translated; and

translate the source code into the target language using a decoder based on the identified semantically similar statements, wherein the decoder is a pretrained machine learning model, wherein the pretrained machine learning model is fine-tuned on a supervised data set to generate one or more vectors that are similar in nature and wherein the pretrained machine learning model understands and encapsulates code semantics and translates a semantic equivalent code, and wherein an attention mechanism in a transformer model learns patterns to produce one or more mathematically closer vectors; and
eliminate at least one of unused and duplicate codes from the source code using the set of relations and removing technical debt and the duplicate codes by semantic equivalence analysis.