import gradio as gr import pandas as pd import re import csv def calculate_correlations(file_obj): try: with open(file_obj.name, 'r', encoding='utf-8') as csvfile: dialect = csv.Sniffer().sniff(csvfile.read(1024)) # Определяем разделитель csvfile.seek(0) # Возвращаемся в начало файла reader = csv.reader(csvfile, dialect=dialect) header = next(reader) data = list(reader) df = pd.DataFrame(data, columns=header) # ... (остальной код для расчета корреляций - без изменений) except Exception as e: return {"error": f"Неизвестная ошибка: {e}"} iface = gr.Interface( fn=calculate_correlations, inputs=gr.File(type="filepath", label="CSV файл с отзывами"), outputs=gr.JSON(), title="Корреляционный анализ отзывов", description="Загрузите CSV файл с отзывами." ) iface.launch()