Bor Hodošček commited on
Commit
3d692b2
·
unverified ·
1 Parent(s): 63c91a0

fix: diff rendering and stop criterion; docs

Browse files
Files changed (2) hide show
  1. app.py +26 -17
  2. development.md +6 -0
app.py CHANGED
@@ -57,19 +57,21 @@ def _(mo):
57
  8. トークンマッチ結果を可視化する。
58
  9. 係り受け(依存)関係マッチング用パターンを定義する(アプリの場合は編集不可)。
59
  10. 係り受け関係マッチ結果を可視化する。
60
-
61
- {
62
- mo.callout('''
63
- By default, this demo uses Natsume Soseki's _‘Wagahai wa neko de aru’_
64
-
65
- ファイルをアップロードしない場合は、デフォルトで夏目漱石『吾輩は猫である』が使用されます。
66
- ''')
67
- }
68
  """
69
  )
70
  return
71
 
72
 
 
 
 
 
 
 
 
 
 
 
73
  @app.cell
74
  def _():
75
  import re
@@ -426,9 +428,9 @@ def _():
426
  )
427
  # equal → skip entirely (we want only changes)
428
 
429
- rendered = HTML(f'<div style="{WRAP_STYLE}">{"".join(html_chunks)}</div>')
430
  if auto_display:
431
- display(rendered)
432
  return rendered
433
 
434
  return (diff_changes,)
@@ -453,13 +455,11 @@ def compare_preprocessed_vs_old(
453
  Compare our cleaned text against the original Aozora‐processed text.
454
  """
455
 
456
- diff_result = None
457
 
458
- if run_diff.value:
459
- # run the expensive diff only when checked
460
- diff_result = diff_changes(
461
- cleaned_text, aozora_xhtml_processed_text, auto_display=False
462
- )
463
 
464
  mo.md(f"""
465
  - 赤: 正規表現版のみにある文字列
@@ -491,7 +491,16 @@ def _(mo):
491
 
492
 
493
  @app.cell
494
- def process_aozora_text(Doc, cleaned_text, mo, nlp, re):
 
 
 
 
 
 
 
 
 
495
  """
496
  Turn each paragraph into one Doc. If any paragraph > MAX_BYTES,
497
  fall back to sentence‐splitting, then raw‐byte‐splitting, and only
 
57
  8. トークンマッチ結果を可視化する。
58
  9. 係り受け(依存)関係マッチング用パターンを定義する(アプリの場合は編集不可)。
59
  10. 係り受け関係マッチ結果を可視化する。
 
 
 
 
 
 
 
 
60
  """
61
  )
62
  return
63
 
64
 
65
+ @app.cell
66
+ def _(mo):
67
+ mo.md('''
68
+ - By default, this demo uses Natsume Soseki's _‘Wagahai wa neko de aru’_
69
+
70
+ - ファイルをアップロードしない場合は、デフォルトで夏目漱石『吾輩は猫である』が使用されます。
71
+ ''').callout(kind="info")
72
+ return
73
+
74
+
75
  @app.cell
76
  def _():
77
  import re
 
428
  )
429
  # equal → skip entirely (we want only changes)
430
 
431
+ rendered = f'<div style="{WRAP_STYLE}">{"".join(html_chunks)}</div>'
432
  if auto_display:
433
+ display(HTML(rendered))
434
  return rendered
435
 
436
  return (diff_changes,)
 
455
  Compare our cleaned text against the original Aozora‐processed text.
456
  """
457
 
458
+ mo.stop(not run_diff.value)
459
 
460
+ diff_result = diff_changes(
461
+ cleaned_text, aozora_xhtml_processed_text, auto_display=False
462
+ )
 
 
463
 
464
  mo.md(f"""
465
  - 赤: 正規表現版のみにある文字列
 
491
 
492
 
493
  @app.cell
494
+ def _(mo):
495
+ run_spacy = mo.ui.switch(label="spaCyで解析する", value=False)
496
+ run_spacy
497
+ return (run_spacy,)
498
+
499
+
500
+ @app.cell
501
+ def process_aozora_text(Doc, cleaned_text, mo, nlp, re, run_spacy):
502
+ mo.stop(not run_spacy.value)
503
+
504
  """
505
  Turn each paragraph into one Doc. If any paragraph > MAX_BYTES,
506
  fall back to sentence‐splitting, then raw‐byte‐splitting, and only
development.md CHANGED
@@ -6,3 +6,9 @@
6
  docker build -t marimo-app .
7
  docker run -it --rm -p 7860:7860 marimo-app
8
  ```
 
 
 
 
 
 
 
6
  docker build -t marimo-app .
7
  docker run -it --rm -p 7860:7860 marimo-app
8
  ```
9
+
10
+ ## Nix setup
11
+
12
+ ```bash
13
+ nix-shell -p libxml2 -p libxslt -p libz
14
+ ```