Skip to content

Bit-Maximum/Simple-Code-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Simple Code Generator

en ru

Lab work for the course “Modern Programming Languages”

A simple tool that generates code in Python or C++ based on natural language requests. Demonstrates the use of the Levenshtein distance algorithm for matching user queries to predefined templates.


📌 Project Goal

To demonstrate the ability to match user input in natural language to predefined templates and generate corresponding source code in the selected programming language (Python or C++).


🧩 How It Works

  1. The user enters a request in natural language Example: Напапечатай все строки длины 20 из нулей и единиц скриптом на языке C++

  2. The program compares the request to a set of templates using Levenshtein distance
    It selects the closest matching template

  3. The appropriate code is generated The target language (Python or C++) is determined by keywords (e.g., "Python", "C++")

  4. The result is saved in output.txt


🔧 Example Usage

Введите ваш запрос:
Выведи через пробел все простые числа от 5 до 100 на языке Python

Output in generated_code.txt:

[print(x, end=' ') for x in range(2, 100) if all(x % i != 0 for i in range(2, int(x**0.5) + 1)) and x > 5]

🛠️ How to Run

  1. Clone the repository:
git clone https://github.com/Bit-Maximum/Simple-Code-Generator.git
cd Simple-Code-Generator
  1. Install dependencies (if needed):
pip install -r requirements.txt
  1. Run the program:
python main.py

© Author

Maksim Merkurev, 2024 Laboratory work. Further development as a small-scale project with extended functionality is possible.

About

A simple tool that generates code in Python or C++ based on natural language requests. Demonstrates the use of the Levenshtein distance algorithm for matching user queries to predefined templates.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages