Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,12 +16,16 @@ sentiment_model = pipeline(
|
|
16 |
|
17 |
# 2️⃣ 主處理流程
|
18 |
def full_pipeline(file, num_clusters):
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
|
26 |
# 向量化並聚類
|
27 |
texts = df["text"].astype(str).tolist()
|
|
|
16 |
|
17 |
# 2️⃣ 主處理流程
|
18 |
def full_pipeline(file, num_clusters):
|
19 |
+
try:
|
20 |
+
df = pd.read_csv(file, encoding="utf-8")
|
21 |
+
except UnicodeDecodeError:
|
22 |
+
try:
|
23 |
+
df = pd.read_csv(file, encoding="utf-8-sig")
|
24 |
+
except UnicodeDecodeError:
|
25 |
+
try:
|
26 |
+
df = pd.read_csv(file, encoding="big5")
|
27 |
+
except Exception as e:
|
28 |
+
return f"❌ 無法讀取 CSV 檔案,錯誤原因:{str(e)}"
|
29 |
|
30 |
# 向量化並聚類
|
31 |
texts = df["text"].astype(str).tolist()
|