File size: 1,068 Bytes
f1953a3
 
 
62c36a7
f1953a3
c60844b
f1953a3
62c36a7
 
 
 
 
 
 
a567382
62c36a7
a567382
c60844b
f1953a3
605c319
f1953a3
62c36a7
 
f1953a3
 
c60844b
3a54228
f1953a3
 
 
 
c60844b
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
27
28
29
30
31
32
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()