File size: 748 Bytes
8869cd6 7892846 52c35bb 7892846 df6f1ac 7892846 df6f1ac 7892846 aa6ea14 7892846 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
from transformers import pipeline
import pyflakes.api
from io import StringIO
import sys
# Análisis semántico con modelo Hugging Face
model = pipeline("text2text-generation", model="Salesforce/codet5-base")
def analizar_codigo(code):
# Análisis de sintaxis
buffer = StringIO()
sys.stderr = buffer
pyflakes.api.check(code, "análisis")
errores = buffer.getvalue()
sys.stderr = sys.__stderr__
if errores:
return f"Errores de sintaxis:\n{errores}"
# Análisis semántico
resultado = model(code, max_length=256, do_sample=False)
return f"Análisis semántico:\n{resultado[0]['generated_text']}"
gr.Interface(fn=analizar_codigo, inputs="text", outputs="text").launch()
|