Spaces:
Runtime error
Runtime error
freemt
commited on
Commit
·
5cb1a08
1
Parent(s):
61b00a9
Update (dev) dl_csv
Browse files
app.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
"""Create entry."""
|
2 |
# pylint: disbale=invalid-name
|
|
|
|
|
3 |
import gradio as gr
|
4 |
import pandas as pd
|
5 |
-
|
6 |
from about_time import about_time
|
7 |
from aset2pairs import aset2pairs
|
8 |
from cmat2aset import cmat2aset
|
9 |
from logzero import logger
|
10 |
from seg_text import seg_text
|
11 |
-
from typing import List, Optional, Union
|
12 |
|
13 |
from radio_mlbee import __version__
|
14 |
from radio_mlbee.gen_cmat import gen_cmat
|
@@ -27,8 +27,9 @@ def ml_fn(
|
|
27 |
text2: str,
|
28 |
split_to_sents: bool = False,
|
29 |
preview: bool = False,
|
|
|
30 |
) -> pd.DataFrame:
|
31 |
-
"""Align text1 text2"""
|
32 |
text1 = str(text1)
|
33 |
text2 = str(text2)
|
34 |
try:
|
@@ -69,9 +70,15 @@ def ml_fn(
|
|
69 |
if preview:
|
70 |
html = df.to_html()
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
# return pd.DataFrame([["", "", ""]])
|
73 |
# return df.to_html()
|
74 |
-
return df, html
|
75 |
|
76 |
|
77 |
mlbee = gr.Interface(
|
@@ -81,6 +88,7 @@ mlbee = gr.Interface(
|
|
81 |
"textarea",
|
82 |
gr.Checkbox(label="Split to sents?"),
|
83 |
gr.Checkbox(label="Preview?"),
|
|
|
84 |
],
|
85 |
outputs=["dataframe", "html"],
|
86 |
# outputs="html",
|
@@ -88,8 +96,8 @@ mlbee = gr.Interface(
|
|
88 |
description="mlbee rest api on dev ",
|
89 |
examples=[
|
90 |
# [text1, text2, False],
|
91 |
-
[text1[:len(text1) // 5], text2[:len(text2) // 5], False, False, ],
|
92 |
-
]
|
93 |
)
|
94 |
|
95 |
mlbee.launch(
|
|
|
1 |
"""Create entry."""
|
2 |
# pylint: disbale=invalid-name
|
3 |
+
from pathlib import Path
|
4 |
+
|
5 |
import gradio as gr
|
6 |
import pandas as pd
|
|
|
7 |
from about_time import about_time
|
8 |
from aset2pairs import aset2pairs
|
9 |
from cmat2aset import cmat2aset
|
10 |
from logzero import logger
|
11 |
from seg_text import seg_text
|
|
|
12 |
|
13 |
from radio_mlbee import __version__
|
14 |
from radio_mlbee.gen_cmat import gen_cmat
|
|
|
27 |
text2: str,
|
28 |
split_to_sents: bool = False,
|
29 |
preview: bool = False,
|
30 |
+
download_csv: bool = False,
|
31 |
) -> pd.DataFrame:
|
32 |
+
"""Align multilingual (50+ pairs) text1 text2."""
|
33 |
text1 = str(text1)
|
34 |
text2 = str(text2)
|
35 |
try:
|
|
|
70 |
if preview:
|
71 |
html = df.to_html()
|
72 |
|
73 |
+
dl_csv = None
|
74 |
+
if download_csv:
|
75 |
+
filepath = Path("aligned-blocks.csv")
|
76 |
+
_ = df.to_csv(index=False)
|
77 |
+
dl_csv = filepath.write_text("utf8")
|
78 |
+
|
79 |
# return pd.DataFrame([["", "", ""]])
|
80 |
# return df.to_html()
|
81 |
+
return df, html, dl_csv
|
82 |
|
83 |
|
84 |
mlbee = gr.Interface(
|
|
|
88 |
"textarea",
|
89 |
gr.Checkbox(label="Split to sents?"),
|
90 |
gr.Checkbox(label="Preview?"),
|
91 |
+
gr.Checkbox(label="Download csv?"),
|
92 |
],
|
93 |
outputs=["dataframe", "html"],
|
94 |
# outputs="html",
|
|
|
96 |
description="mlbee rest api on dev ",
|
97 |
examples=[
|
98 |
# [text1, text2, False],
|
99 |
+
[text1[: len(text1) // 5], text2[: len(text2) // 5], False, False, False],
|
100 |
+
],
|
101 |
)
|
102 |
|
103 |
mlbee.launch(
|