Spaces:
Sleeping
Sleeping
Update to shoshan v0.3.1: repin to release tag, HebArabNlpProject links, gender-slash alignment
Browse files- README.md +2 -2
- app.py +12 -5
- requirements.txt +7 -1
README.md
CHANGED
|
@@ -10,7 +10,7 @@ app_file: app.py
|
|
| 10 |
pinned: false
|
| 11 |
license: mit
|
| 12 |
models:
|
| 13 |
-
-
|
| 14 |
---
|
| 15 |
|
| 16 |
# Shoshan โ Hebrew lemmatizer
|
|
@@ -19,4 +19,4 @@ Paste Hebrew text and get each word's lemma (dictionary form). Shoshan retrieves
|
|
| 19 |
the lemma from a fixed bank and, for unknown words, derives it by editing the
|
| 20 |
word itself โ so it never invents a word.
|
| 21 |
|
| 22 |
-
Code: <https://github.com/ivrit/shoshan> ยท Weights: <https://huggingface.co/
|
|
|
|
| 10 |
pinned: false
|
| 11 |
license: mit
|
| 12 |
models:
|
| 13 |
+
- HebArabNlpProject/shoshan
|
| 14 |
---
|
| 15 |
|
| 16 |
# Shoshan โ Hebrew lemmatizer
|
|
|
|
| 19 |
the lemma from a fixed bank and, for unknown words, derives it by editing the
|
| 20 |
word itself โ so it never invents a word.
|
| 21 |
|
| 22 |
+
Code: <https://github.com/ivrit/shoshan> ยท Weights: <https://huggingface.co/HebArabNlpProject/shoshan>
|
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import html as H
|
| 2 |
import gradio as gr
|
| 3 |
from shoshan import Lemmatizer
|
| 4 |
-
from shoshan.text import
|
| 5 |
|
| 6 |
DEFAULT = "ืืื ื ืืกื ืืืฆืื ืืช ืืืคืชืืืช ืืืืืืื ืืชืืช ืืืืฉื ืื ืื."
|
| 7 |
BLUE, ORANGE = "#2f6f9f", "#b5651d"
|
|
@@ -49,7 +49,14 @@ def _table(sh_rows, d_map):
|
|
| 49 |
form = r["form"]
|
| 50 |
sh_color = BLUE if r["source"] == "retrieved" else ORANGE
|
| 51 |
sh = H.escape(r["lemma"]) if r["lemma"] else "โ"
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
d_cell = (f"<b style='color:{ORANGE}'>{H.escape(d)}</b>" if d
|
| 54 |
else "<span style='color:#bbb'>โ</span>")
|
| 55 |
trs.append(
|
|
@@ -96,15 +103,15 @@ with gr.Blocks(title="Shoshan vs DictaBERT-lex") as demo:
|
|
| 96 |
gr.Examples(
|
| 97 |
examples=[
|
| 98 |
["ืืื ื ืืกื ืืืฆืื ืืช ืืืคืชืืืช ืืืืืืื ืืชืืช ืืืืฉื ืื ืื."],
|
| 99 |
-
["ืื'ืืื
|
| 100 |
["ืืืืจื ืคืืชืื ืืื ืืืืืื ืืืฉื ืืืืืกื ืืื ืืืืฉืงืืขืื."],
|
| 101 |
],
|
| 102 |
inputs=inp, label="Examples (click to load, then press Lemmatize)")
|
| 103 |
out = gr.HTML(label="Shoshan vs DictaBERT-lex")
|
| 104 |
gr.Markdown(
|
| 105 |
"Shoshan: [code](https://github.com/ivrit/shoshan) ยท "
|
| 106 |
-
"[weights](https://huggingface.co/
|
| 107 |
-
"[data](https://huggingface.co/datasets/
|
| 108 |
"DictaBERT-lex: [dicta-il/dictabert-lex](https://huggingface.co/dicta-il/dictabert-lex).")
|
| 109 |
btn.click(run, inp, out, api_name="predict")
|
| 110 |
inp.submit(run, inp, out, api_name=False)
|
|
|
|
| 1 |
import html as H
|
| 2 |
import gradio as gr
|
| 3 |
from shoshan import Lemmatizer
|
| 4 |
+
from shoshan.text import collapse_gender_slash
|
| 5 |
|
| 6 |
DEFAULT = "ืืื ื ืืกื ืืืฆืื ืืช ืืืคืชืืืช ืืืืืืื ืืชืืช ืืืืฉื ืื ืื."
|
| 7 |
BLUE, ORANGE = "#2f6f9f", "#b5651d"
|
|
|
|
| 49 |
form = r["form"]
|
| 50 |
sh_color = BLUE if r["source"] == "retrieved" else ORANGE
|
| 51 |
sh = H.escape(r["lemma"]) if r["lemma"] else "โ"
|
| 52 |
+
# Shoshan reports a gender-slash form whole (ืืืชื/ืช); DictaBERT-lex splits it into
|
| 53 |
+
# ืืืชื + / + ืช, so its map is keyed by the base. Fall back to the base, otherwise
|
| 54 |
+
# the comparison column shows a false "โ" as if DictaBERT had produced nothing.
|
| 55 |
+
d = None
|
| 56 |
+
if d_map is not None:
|
| 57 |
+
d = d_map.get(form)
|
| 58 |
+
if d is None:
|
| 59 |
+
d = d_map.get(collapse_gender_slash(form))
|
| 60 |
d_cell = (f"<b style='color:{ORANGE}'>{H.escape(d)}</b>" if d
|
| 61 |
else "<span style='color:#bbb'>โ</span>")
|
| 62 |
trs.append(
|
|
|
|
| 103 |
gr.Examples(
|
| 104 |
examples=[
|
| 105 |
["ืืื ื ืืกื ืืืฆืื ืืช ืืืคืชืืืช ืืืืืืื ืืชืืช ืืืืฉื ืื ืื."],
|
| 106 |
+
["ืื'ืืื ืื ืืฃ ืืช ืืืืืืกืืืืจ ืืืืืจ ืฉืื ืขื ืืืื."],
|
| 107 |
["ืืืืจื ืคืืชืื ืืื ืืืืืื ืืืฉื ืืืืืกื ืืื ืืืืฉืงืืขืื."],
|
| 108 |
],
|
| 109 |
inputs=inp, label="Examples (click to load, then press Lemmatize)")
|
| 110 |
out = gr.HTML(label="Shoshan vs DictaBERT-lex")
|
| 111 |
gr.Markdown(
|
| 112 |
"Shoshan: [code](https://github.com/ivrit/shoshan) ยท "
|
| 113 |
+
"[weights](https://huggingface.co/HebArabNlpProject/shoshan) ยท "
|
| 114 |
+
"[data](https://huggingface.co/datasets/HebArabNlpProject/shoshan-data). "
|
| 115 |
"DictaBERT-lex: [dicta-il/dictabert-lex](https://huggingface.co/dicta-il/dictabert-lex).")
|
| 116 |
btn.click(run, inp, out, api_name="predict")
|
| 117 |
inp.submit(run, inp, out, api_name=False)
|
requirements.txt
CHANGED
|
@@ -3,4 +3,10 @@ transformers
|
|
| 3 |
numpy
|
| 4 |
pandas
|
| 5 |
huggingface_hub
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
numpy
|
| 4 |
pandas
|
| 5 |
huggingface_hub
|
| 6 |
+
# Pinned to a release TAG, not a commit SHA, on purpose. This repo's history has been
|
| 7 |
+
# rewritten more than once (see "repin after history purge" / "prior pin invalidated by
|
| 8 |
+
# history rewrite" in the log), and each rewrite orphans a SHA pin โ the old commit then
|
| 9 |
+
# survives only as an unreachable object GitHub happens to retain. A tag is a named ref
|
| 10 |
+
# that is recreated by the rewrite, so it keeps resolving. Bump this on each release and
|
| 11 |
+
# redeploy the Space.
|
| 12 |
+
git+https://github.com/ivrit/shoshan.git@v0.3.1
|