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.
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++).
-
The user enters a request in natural language Example:
Напапечатай все строки длины 20 из нулей и единиц скриптом на языке C++ -
The program compares the request to a set of templates using Levenshtein distance
It selects the closest matching template -
The appropriate code is generated The target language (Python or C++) is determined by keywords (e.g., "Python", "C++")
-
The result is saved in
output.txt
Введите ваш запрос:
Выведи через пробел все простые числа от 5 до 100 на языке PythonOutput 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]- Clone the repository:
git clone https://github.com/Bit-Maximum/Simple-Code-Generator.git
cd Simple-Code-Generator- Install dependencies (if needed):
pip install -r requirements.txt- Run the program:
python main.pyMaksim Merkurev, 2024 Laboratory work. Further development as a small-scale project with extended functionality is possible.