Compilable Code Generation from Uncompilable Input via N-Gram Correction

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current automated systems for testing coding skills and providing feedback fail to address code that does not compile, resulting in programmers missing out on feedback and potential job opportunities.

Innovation Solution

A computer-implemented method generates compilable code from uncompilable code by identifying and correcting syntax errors and using an n-gram based token prediction model, along with a machine learning model that recognizes patterns and provides semantic feedback on logical correctness and programming style.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If automated testing systems evaluate code using traditional methods (test cases or rubrics), then they can provide grades on logical correctness, but they cannot handle code that does not compile and provide actionable feedback

Engineering Contradiction:
Improveability to handle uncompilable codeVSAvoidactionable feedback provision
Core Design Contradiction:
Adaptability or versatilityVSEase of operation

Solution Approach 1:

The system segments the code evaluation process into distinct phases: syntax error detection, n-gram based token prediction for correction, parse tree generation, and machine learning-based pattern recognition. This segmentation allows the system to handle uncompilable code by processing it through multiple specialized components rather than requiring a single comprehensive evaluator.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system introduces an intermediary correction mechanism that uses n-gram based token prediction to generate corrected versions of uncompilable code. This intermediary process bridges the gap between uncompilable input and compilable analysis, enabling the system to provide feedback on code that would otherwise be rejected by traditional compilers.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Loss of information

If programmers submit uncompilable code, then they demonstrate algorithmic thinking, but they receive no feedback and miss out on grades or job opportunities

Engineering Contradiction:
Improvefeedback lossVSAvoidassessment capability
Core Design Contradiction:
Loss of informationVSProductivity

Solution Approach 1:

The system performs preliminary syntax error identification and correction attempts before full evaluation. By pre-processing the uncompilable code through syntax analysis and n-gram based correction, the system prepares the code for subsequent evaluation phases, ensuring that no potential feedback is lost due to compilation failures.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system implements a comprehensive feedback mechanism that provides actionable recommendations to programmers. The feedback includes syntax error locations, suggested corrections based on n-gram predictions, and machine learning-based assessments of logical correctness, ensuring that programmers receive constructive guidance even when their code does not compile.

Inventive Principle:
Principle #23Feedback

3Measurement precision

If the system uses multiple machine learning models for code correction and analysis, then it can provide comprehensive feedback, but the system complexity increases

Engineering Contradiction:
Improvecode analysis accuracyVSAvoidsystem structure
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The system merges multiple machine learning models into a unified evaluation framework. The syntax error detector, n-gram based correction model, parse tree generator, and pattern recognition model are integrated to work together sequentially, combining their individual capabilities to provide comprehensive code analysis while presenting a unified interface to users.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The machine learning models are designed with universal applicability across different programming languages and code structures. The n-gram based token prediction model and pattern recognition system can handle various syntax errors and code patterns, making the complex multi-model system versatile rather than language-specific.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS10963226B2Generating compilable code from uncompilable code
Publication Date: 2021.03.30 SHL INDIA PTE LTD
  • US10963226B2 patent drawing
  • US10963226B2 patent drawing
  • US10963226B2 patent drawing

AI summary

A method to generate compilable code from uncompilable code. The method includes receiving uncompilable code. The method further includes generating compilable code by one or more of (1) identifying and correcting syntax errors in the uncompilable code and (2) using an n-gram based token prediction model. The method further includes extracting features from the compilable code. The method further includes generating a machine learning model that recognizes patterns from extracted features in the compilable code.