SyntaxMorph is a Python module that enables code conversion between different programming languages
Project description
SyntaxMorph SyntaxMorph
SyntaxMorph is a module that aims to facilitate the conversion between programming languages by utilizing OpenAI.
- Free software: GPLv3 license
- Github: https://github.com/Enderjua/SyntaxMorph
Features
- Determining which programming language a given code belongs to.
- Identifying the general structure of the given code.
- Converting the given code to the desired programming language.
- Aiming to collect a comprehensive dataset.
- Eliminating the dependency on OpenAI.
Versions
========
1.0.5
- Folder error resolved and published
1.0.4
- Folder error resolved and published
1.0.3
- Folder error resolved and published
1.0.2
- Published.
Developer
- Marijua @
enderjua gmail com
Quick Tutorial
import openai
openai.api_key = "YOUR_API_KEY"
from morph import formatCode
from morph import columDetect
from morph import languageDetect
Language Detection
code = " print('hello world') "
languageDetection = languageDetect.languageDetect(code)
print("Language Detected: "+languageDetection) # Python
Language Detected: Python
Colum Detection
~~~~~~~~~~~~
code = " def main(a, b, c):
d = a+b+c
print(d)
main(5,7,9)"
columDetection = columDetect.columDetect(code)
print("Colum Detected: "+columDetection) # Function && Fonksiyon
Colum Detected: Fonksiyon
print(columDetect.columDetect(code))
Function && Fonksiyon
Language translation
code = " print('hello world') "
newCode = formatCode.formatDetected(languageDetection, code, 1, C++, columDetection)
print(newCode)
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
Create a function for Flask API
main.py:
import openai
openai.api_key = "YOUR_API_KEY"
from morph import formatCode as f
from morph import languageDetect as l
from morph import columDetect as c
def morphApi(code, lang):
language = l.languageDetect(code)
colum = c.columDetect(code)
newCode = f.formatDetected(language, code, 1, lang, colum)
return newCode
# code = morphApi("print('hello')", "C++")
# print(code)
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
Create a Flask API
~~~~~~~~~~~~~~~~~~~~
from flask import Flask, jsonify
from flask_cors import CORS
from urllib.parse import unqoute
app = Flask(__name__)
CORS(app)
@app.route('/translateAPI/<string:language>/<path:code>', methods=['GET'])
def translating(language2, code):
from main import morphApi
code = morphApi(code, language2)
return code
if __name__ = '__main__':
app.run(debug=True)
localhost:5000/translateAPI/C++/print('hello world')
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
Future
~~~~~~~~
- We have set out on the process of training our own AI.
- We will share our AI for free here as a result of the AI training.
- We will ensure the independence of OpenAI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
SyntaxMorph-1.0.5.tar.gz
(8.1 kB
view details)
File details
Details for the file SyntaxMorph-1.0.5.tar.gz
.
File metadata
- Download URL: SyntaxMorph-1.0.5.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a579fbf29b9c13da4ede2cc917409cade35392867540337d4f495f6d5b7e8a73 |
|
MD5 | 308da7fea2a0596431ebd180f5135275 |
|
BLAKE2b-256 | 9efa18b9eaabbba5766255c857e9eaa432834ef1949cf6cbcca92f20ff04d3f1 |