Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,9 +45,17 @@ def coref_learning_pipeline(user_input):
|
|
| 45 |
if has_chinese:
|
| 46 |
working_text = GoogleTranslator(source='zh-CN', target='en').translate(user_input)
|
| 47 |
mode_notice = "中文輸入模式(已啟動 AI 跨語言橋接)"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
else:
|
| 49 |
working_text = user_input
|
| 50 |
mode_notice = "英文原語模式"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
# B. 執行 AI 指代消解運算
|
| 53 |
preds = model.predict(texts=[working_text])
|
|
@@ -60,6 +68,10 @@ def coref_learning_pipeline(user_input):
|
|
| 60 |
vocab_output = ""
|
| 61 |
doc = nlp(working_text)
|
| 62 |
extracted_words = set()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
for token in doc:
|
| 65 |
# 只抓普通名詞 (NOUN),排除專有名詞/人名 (PROPN) 與代名詞 (PRON)
|
|
|
|
| 45 |
if has_chinese:
|
| 46 |
working_text = GoogleTranslator(source='zh-CN', target='en').translate(user_input)
|
| 47 |
mode_notice = "中文輸入模式(已啟動 AI 跨語言橋接)"
|
| 48 |
+
|
| 49 |
+
# 💥 關鍵修正:如果原本輸入中文,這裡就輸出對應的「英文化語意空間」
|
| 50 |
+
translation_text = working_text
|
| 51 |
+
translation_label = "📖 完整文本翻譯 (中 ➔ 英)"
|
| 52 |
else:
|
| 53 |
working_text = user_input
|
| 54 |
mode_notice = "英文原語模式"
|
| 55 |
+
|
| 56 |
+
# 如果原本輸入英文,這裡維持「英翻中」
|
| 57 |
+
translation_text = GoogleTranslator(source='en', target='zh-TW').translate(working_text)
|
| 58 |
+
translation_label = "📖 完整文本翻譯 (英 ➔ 中)"
|
| 59 |
|
| 60 |
# B. 執行 AI 指代消解運算
|
| 61 |
preds = model.predict(texts=[working_text])
|
|
|
|
| 68 |
vocab_output = ""
|
| 69 |
doc = nlp(working_text)
|
| 70 |
extracted_words = set()
|
| 71 |
+
|
| 72 |
+
# E. 欄位三:生成「AI 語意共指報告」
|
| 73 |
+
report_text = f"✨ 系統狀態:{mode_notice}\n"
|
| 74 |
+
report_text += f"📝 英文運算空間: {working_text}\n"
|
| 75 |
|
| 76 |
for token in doc:
|
| 77 |
# 只抓普通名詞 (NOUN),排除專有名詞/人名 (PROPN) 與代名詞 (PRON)
|