Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ from inseq import FeatureAttributionOutput
|
|
6 |
st.set_page_config(layout="wide")
|
7 |
|
8 |
dataset = load_dataset("GroNLP/divemt")
|
9 |
-
attribution_path = "https://huggingface.co/datasets/inseq/divemt_attributions/resolve/main/divemt-attributions/it/{idx}
|
10 |
df = dataset["train"].to_pandas()
|
11 |
unique_src = df[["item_id", "src_text"]].drop_duplicates(subset="item_id")
|
12 |
langs = list(df["lang_id"].unique())
|
@@ -80,9 +80,9 @@ for lang in langs:
|
|
80 |
st.markdown(f"<b>Aligned edits</b>:", unsafe_allow_html=True)
|
81 |
if dic["aligned_edit"] is not None:
|
82 |
aligned_edit = dic["aligned_edit"]
|
83 |
-
if lang == 'ara' and len(dic["aligned_edit"].split("EVAL: ")) == 2:
|
84 |
-
|
85 |
-
|
86 |
aligned_edit = aligned_edit.replace("\\n", "\n").replace("REF:", "MT :").replace("HYP:", "PE :")
|
87 |
st.text(aligned_edit)
|
88 |
else:
|
@@ -94,10 +94,10 @@ for lang in langs:
|
|
94 |
st.markdown(f"<b>Attributions</b>:", unsafe_allow_html=True)
|
95 |
st.text("Click on checkboxes to show/hide the respective attributions computed with mBART 1-to-50.")
|
96 |
for sentence_type in ["mt", "pe", "diff"]:
|
97 |
-
url = attribution_path.format(idx=item_id, setting=setting, sentence_type=sentence_type)
|
98 |
try:
|
99 |
g = urllib.request.urlopen(url)
|
100 |
-
fpath = f"attr_{sentence_type}.json.gz"
|
101 |
with open(fpath, 'b+w') as f:
|
102 |
f.write(g.read())
|
103 |
attr = FeatureAttributionOutput.load(fpath, decompress=True)
|
|
|
6 |
st.set_page_config(layout="wide")
|
7 |
|
8 |
dataset = load_dataset("GroNLP/divemt")
|
9 |
+
attribution_path = "https://huggingface.co/datasets/inseq/divemt_attributions/resolve/main/divemt-attributions/it/{idx}_{lang}_gradl2_{setting}_{sentence_type}.json.gz"
|
10 |
df = dataset["train"].to_pandas()
|
11 |
unique_src = df[["item_id", "src_text"]].drop_duplicates(subset="item_id")
|
12 |
langs = list(df["lang_id"].unique())
|
|
|
80 |
st.markdown(f"<b>Aligned edits</b>:", unsafe_allow_html=True)
|
81 |
if dic["aligned_edit"] is not None:
|
82 |
aligned_edit = dic["aligned_edit"]
|
83 |
+
#if lang == 'ara' and len(dic["aligned_edit"].split("EVAL: ")) == 2:
|
84 |
+
# edits_reverse = aligned_edit.split("EVAL: ")[1][::-1]
|
85 |
+
# aligned_edit = aligned_edit.split("EVAL: ")[0] + "EVAL: " + edits_reverse
|
86 |
aligned_edit = aligned_edit.replace("\\n", "\n").replace("REF:", "MT :").replace("HYP:", "PE :")
|
87 |
st.text(aligned_edit)
|
88 |
else:
|
|
|
94 |
st.markdown(f"<b>Attributions</b>:", unsafe_allow_html=True)
|
95 |
st.text("Click on checkboxes to show/hide the respective attributions computed with mBART 1-to-50.")
|
96 |
for sentence_type in ["mt", "pe", "diff"]:
|
97 |
+
url = attribution_path.format(idx=item_id, setting=setting, sentence_type=sentence_type, lang=lang)
|
98 |
try:
|
99 |
g = urllib.request.urlopen(url)
|
100 |
+
fpath = f"attr_{lang}_{sentence_type}.json.gz"
|
101 |
with open(fpath, 'b+w') as f:
|
102 |
f.write(g.read())
|
103 |
attr = FeatureAttributionOutput.load(fpath, decompress=True)
|