Suhsiung Claude Opus 4.8 commited on
Commit
4c2d4b7
·
1 Parent(s): 8ed7cbb

修正研討回饋 7 項

Browse files

- 修正 boxplot labels 參數(matplotlib 3.9 棄用)致統計分析失敗、無 LLM 報告
- 標題改為三行(含 II 語料淬煉 CorpusRefinery)
- 消除對話視窗重複滾軸
- metadata 表單出現/消失時自動捲動
- 子分頁「其他」更名為「下載」
- 語言指標分析大標題置中

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Files changed (1) hide show
  1. app_agent.py +47 -10
app_agent.py CHANGED
@@ -943,7 +943,9 @@ def run_statistical_analysis(csv_path: Path, output_dir: Path):
943
  for i, col in enumerate(sig_cols):
944
  ax = axes[i]
945
  pd_data = [df.loc[df[GROUP_COL]==g, col].dropna().values for g in groups]
946
- ax.boxplot(pd_data, labels=groups)
 
 
947
  pv = diff_df.loc[diff_df['指標']==col, 'p值'].values
948
  pv_str = f"p={pv[0]:.4f}" if len(pv)>0 else ""
949
  ax.set_title(f"{col}\n({pv_str})", fontsize=8)
@@ -1743,7 +1745,20 @@ _CUSTOM_CSS = """
1743
  }
1744
  .app-header .subtitle {
1745
  font-size: 1.1rem !important;
1746
- line-height: 1.7 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
1747
  background: linear-gradient(130deg, #38bdf8 0%, #818cf8 55%, #c084fc 100%) !important;
1748
  -webkit-background-clip: text !important;
1749
  -webkit-text-fill-color: transparent !important;
@@ -1837,6 +1852,8 @@ _CUSTOM_CSS = """
1837
  background: rgba(14,165,233,.07) !important;
1838
  }
1839
  .tabitem { padding: 1.5rem 1.25rem !important; }
 
 
1840
  /* 巢狀子分頁(統計比較分析內)維持原字級 */
1841
  .tabitem .tabs > .tab-nav > button { font-size: 0.80rem !important; }
1842
 
@@ -1856,6 +1873,15 @@ _CUSTOM_CSS = """
1856
  .main-chat div[role="log"] {
1857
  background: #0f172a !important;
1858
  }
 
 
 
 
 
 
 
 
 
1859
 
1860
  /* 訊息從頂部開始排列,消除空白 */
1861
  div[role="log"].bubble-wrap,
@@ -2381,6 +2407,20 @@ def create_app():
2381
  var root = document.querySelector('.main-chat');
2382
  if (root) mo.observe(root, { childList: true, subtree: true, attributes: true });
2383
  }, 500);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2384
  }""",
2385
  ) as demo:
2386
 
@@ -2388,11 +2428,8 @@ def create_app():
2388
  gr.HTML(
2389
  '<div class="app-header">'
2390
  ' <h1>譯彩紛呈:重譯文本分析系統</h1>'
2391
- ' <p class="subtitle">'
2392
- ' TransPrism: An Analytical Framework for Retranslation II'
2393
- ' &nbsp;&nbsp;|&nbsp;&nbsp;'
2394
- ' 分析引擎 Spectra Engine'
2395
- ' </p>'
2396
  ' <div class="steps">'
2397
  ' <span class="step-pill"><span class="step-num">1</span>情境選擇</span>'
2398
  ' <span class="step-pill"><span class="step-num">2</span>上傳引導</span>'
@@ -2451,7 +2488,7 @@ def create_app():
2451
  upload_btn = gr.Button("確認上傳", scale=2, variant="primary")
2452
 
2453
  # ── 語料 Metadata 說明表單(上傳後、分析前)──────────────────
2454
- with gr.Column(visible=False, elem_classes=["metadata-zone"]) as metadata_row:
2455
  gr.Markdown("### 📑 語料 Metadata 說明\n請於正式分析前說明語料來源、範圍與比較結構,將寫入研究報告。")
2456
 
2457
  gr.Markdown("**一、原文資訊**")
@@ -2503,7 +2540,7 @@ def create_app():
2503
  # 結果分頁:初始隱藏,分析完成後顯示
2504
  # ══════════════════════════════════════════════════════════════
2505
  with gr.Tab("📊 語言指標分析", visible=False) as tab2:
2506
- tab_idx_md = gr.Markdown(_EMPTY_HINT)
2507
  tab_idx_df = gr.Dataframe(
2508
  label="指標計算結果",
2509
  interactive=False, visible=False,
@@ -2555,7 +2592,7 @@ def create_app():
2555
  interactive=False, visible=False,
2556
  )
2557
  # 子分頁 5:其他
2558
- with gr.Tab("5. 其他"):
2559
  tab_stats_file = gr.File(
2560
  label="下載統計檔案",
2561
  file_count="multiple", interactive=False, visible=False,
 
943
  for i, col in enumerate(sig_cols):
944
  ax = axes[i]
945
  pd_data = [df.loc[df[GROUP_COL]==g, col].dropna().values for g in groups]
946
+ ax.boxplot(pd_data)
947
+ ax.set_xticks(range(1, len(groups) + 1))
948
+ ax.set_xticklabels(list(groups))
949
  pv = diff_df.loc[diff_df['指標']==col, 'p值'].values
950
  pv_str = f"p={pv[0]:.4f}" if len(pv)>0 else ""
951
  ax.set_title(f"{col}\n({pv_str})", fontsize=8)
 
1745
  }
1746
  .app-header .subtitle {
1747
  font-size: 1.1rem !important;
1748
+ line-height: 1.5 !important;
1749
+ margin: 0 0 .25rem !important;
1750
+ background: linear-gradient(130deg, #38bdf8 0%, #818cf8 55%, #c084fc 100%) !important;
1751
+ -webkit-background-clip: text !important;
1752
+ -webkit-text-fill-color: transparent !important;
1753
+ background-clip: text !important;
1754
+ color: transparent !important;
1755
+ }
1756
+ /* 第三排:字型比第二排大、比主標題小 */
1757
+ .app-header .subtitle-3 {
1758
+ font-size: 1.5rem !important;
1759
+ font-weight: 700 !important;
1760
+ line-height: 1.4 !important;
1761
+ margin: 0 !important;
1762
  background: linear-gradient(130deg, #38bdf8 0%, #818cf8 55%, #c084fc 100%) !important;
1763
  -webkit-background-clip: text !important;
1764
  -webkit-text-fill-color: transparent !important;
 
1852
  background: rgba(14,165,233,.07) !important;
1853
  }
1854
  .tabitem { padding: 1.5rem 1.25rem !important; }
1855
+ /* #7 語言指標分析等結果大標題置中 */
1856
+ .result-md h1, .result-md h2, .result-md h3 { text-align: center !important; }
1857
  /* 巢狀子分頁(統計比較分析內)維持原字級 */
1858
  .tabitem .tabs > .tab-nav > button { font-size: 0.80rem !important; }
1859
 
 
1873
  .main-chat div[role="log"] {
1874
  background: #0f172a !important;
1875
  }
1876
+ /* #2 消除重複滾軸:只讓 bubble-wrap 捲動,外層不捲 */
1877
+ .main-chat [class*="wrapper"],
1878
+ .main-chat > div > div:not([role="log"]) {
1879
+ overflow: hidden !important;
1880
+ }
1881
+ .main-chat div[role="log"].bubble-wrap {
1882
+ overflow-y: auto !important;
1883
+ overflow-x: hidden !important;
1884
+ }
1885
 
1886
  /* 訊息從頂部開始排列,消除空白 */
1887
  div[role="log"].bubble-wrap,
 
2407
  var root = document.querySelector('.main-chat');
2408
  if (root) mo.observe(root, { childList: true, subtree: true, attributes: true });
2409
  }, 500);
2410
+
2411
+ /* metadata 表單:出現時自動捲入視野;消失時捲回頂部 */
2412
+ var metaWasVisible = false;
2413
+ function watchMetadata() {
2414
+ var zone = document.getElementById('metadata_zone');
2415
+ var visible = !!(zone && zone.offsetParent !== null);
2416
+ if (visible && !metaWasVisible) {
2417
+ zone.scrollIntoView({ behavior: 'smooth', block: 'center' });
2418
+ } else if (!visible && metaWasVisible) {
2419
+ window.scrollTo({ top: 0, behavior: 'smooth' });
2420
+ }
2421
+ metaWasVisible = visible;
2422
+ }
2423
+ setInterval(watchMetadata, 400);
2424
  }""",
2425
  ) as demo:
2426
 
 
2428
  gr.HTML(
2429
  '<div class="app-header">'
2430
  ' <h1>譯彩紛呈:重譯文本分析系統</h1>'
2431
+ ' <p class="subtitle">TransPrism: An Analytical Framework for Retranslation</p>'
2432
+ ' <p class="subtitle-3">II 語料淬煉 CorpusRefinery</p>'
 
 
 
2433
  ' <div class="steps">'
2434
  ' <span class="step-pill"><span class="step-num">1</span>情境選擇</span>'
2435
  ' <span class="step-pill"><span class="step-num">2</span>上傳引導</span>'
 
2488
  upload_btn = gr.Button("確認上傳", scale=2, variant="primary")
2489
 
2490
  # ── 語料 Metadata 說明表單(上傳後、分析前)──────────────────
2491
+ with gr.Column(visible=False, elem_id="metadata_zone", elem_classes=["metadata-zone"]) as metadata_row:
2492
  gr.Markdown("### 📑 語料 Metadata 說明\n請於正式分析前說明語料來源、範圍與比較結構,將寫入研究報告。")
2493
 
2494
  gr.Markdown("**一、原文資訊**")
 
2540
  # 結果分頁:初始隱藏,分析完成後顯示
2541
  # ══════════════════════════════════════════════════════════════
2542
  with gr.Tab("📊 語言指標分析", visible=False) as tab2:
2543
+ tab_idx_md = gr.Markdown(_EMPTY_HINT, elem_classes=["result-md"])
2544
  tab_idx_df = gr.Dataframe(
2545
  label="指標計算結果",
2546
  interactive=False, visible=False,
 
2592
  interactive=False, visible=False,
2593
  )
2594
  # 子分頁 5:其他
2595
+ with gr.Tab("5. 下載"):
2596
  tab_stats_file = gr.File(
2597
  label="下載統計檔案",
2598
  file_count="multiple", interactive=False, visible=False,