Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -257,15 +257,23 @@ with gr.Blocks(title="Power Distance Checker") as demo:
|
|
| 257 |
"""
|
| 258 |
)
|
| 259 |
|
| 260 |
-
|
| 261 |
with gr.Row():
|
| 262 |
-
input_box = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
|
| 264 |
run_btn = gr.Button("分析语气与权力距离")
|
| 265 |
|
|
|
|
| 266 |
with gr.Row():
|
| 267 |
output_en = gr.Textbox(label="英文翻译", lines=6)
|
| 268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
with gr.Row():
|
| 270 |
zh_json = gr.JSON(label="中文侧语气指标(0–1)")
|
| 271 |
en_json = gr.JSON(label="英文侧语气指标(0–1)")
|
|
@@ -278,22 +286,21 @@ with gr.Blocks(title="Power Distance Checker") as demo:
|
|
| 278 |
bar_plot = gr.Plot(label="Bar Chart:Chinese vs English")
|
| 279 |
radar_plot = gr.Plot(label="Radar Chart:Stylistic Profile")
|
| 280 |
|
|
|
|
| 281 |
run_btn.click(
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
)
|
| 296 |
-
|
| 297 |
|
| 298 |
if __name__ == "__main__":
|
| 299 |
demo.launch()
|
|
|
|
| 257 |
"""
|
| 258 |
)
|
| 259 |
|
|
|
|
| 260 |
with gr.Row():
|
| 261 |
+
input_box = gr.Textbox(
|
| 262 |
+
label="输入中文信件",
|
| 263 |
+
lines=6,
|
| 264 |
+
placeholder="例如:您好,我想向您反馈近期的项目进度,如有不妥之处,还请您多多指正。"
|
| 265 |
+
)
|
| 266 |
|
| 267 |
run_btn = gr.Button("分析语气与权力距离")
|
| 268 |
|
| 269 |
+
# 原始英文翻译
|
| 270 |
with gr.Row():
|
| 271 |
output_en = gr.Textbox(label="英文翻译", lines=6)
|
| 272 |
|
| 273 |
+
# ✅ 新增:更礼貌的英文版本(单独一行声明组件)
|
| 274 |
+
with gr.Row():
|
| 275 |
+
polite_output = gr.Textbox(label="更礼貌的(增强版)英文", lines=6)
|
| 276 |
+
|
| 277 |
with gr.Row():
|
| 278 |
zh_json = gr.JSON(label="中文侧语气指标(0–1)")
|
| 279 |
en_json = gr.JSON(label="英文侧语气指标(0–1)")
|
|
|
|
| 286 |
bar_plot = gr.Plot(label="Bar Chart:Chinese vs English")
|
| 287 |
radar_plot = gr.Plot(label="Radar Chart:Stylistic Profile")
|
| 288 |
|
| 289 |
+
# 按钮绑定:注意 outputs 里只写变量名,不要写“=”
|
| 290 |
run_btn.click(
|
| 291 |
+
fn=analyze_letter,
|
| 292 |
+
inputs=[input_box],
|
| 293 |
+
outputs=[
|
| 294 |
+
output_en, # 1 原始英译
|
| 295 |
+
polite_output, # 2 更礼貌英译
|
| 296 |
+
zh_json, # 3 中文语气
|
| 297 |
+
en_json, # 4 英文语气
|
| 298 |
+
pd_label, # 5 PD 等级
|
| 299 |
+
pd_score, # 6 PD 分数
|
| 300 |
+
bar_plot, # 7 柱状图
|
| 301 |
+
radar_plot # 8 雷达图
|
| 302 |
+
],
|
| 303 |
+
)
|
|
|
|
|
|
|
| 304 |
|
| 305 |
if __name__ == "__main__":
|
| 306 |
demo.launch()
|