freemt commited on
Commit
0905493
·
1 Parent(s): 3812263

Update gradio iiface fix

Browse files
Files changed (1) hide show
  1. ubee/__main__.py +13 -7
ubee/__main__.py CHANGED
@@ -1,13 +1,13 @@
1
  """Gen ubee main."""
2
- # pylint: disable=unused-import, wrong-import-position
3
 
4
- from typing import Tuple
5
 
6
  from pathlib import Path
7
  import sys
8
  from random import shuffle
9
 
10
- # from itertools import zip_longest
11
  from textwrap import dedent
12
 
13
  import gradio as gr
@@ -42,7 +42,7 @@ def greet(
42
  text1,
43
  text2,
44
  thresh: float
45
- ) -> Tuple[pd.DataFrame, pd.DataFrame]:
46
  """Take inputs, return outputs.
47
 
48
  Args:
@@ -62,22 +62,28 @@ def greet(
62
 
63
  res1_, res2_ = ubee(res1, res2, thresh)
64
 
 
 
 
 
 
65
  if res2_:
66
  _ = pd.DataFrame(res2_, columns=["text1", "text2"])
67
  else:
68
  _ = None
69
- return pd.DataFrame(res1_, columns=["text1", "text2", "likelihood"]), _
 
70
 
71
 
72
  def main():
73
  """Create main entry."""
74
- text_zh = Path("data/test_zh.txt").read_text("utf8")
75
  text_zh = [elm.strip() for elm in text_zh.splitlines() if elm.strip()][:10]
76
  text_zh = "\n\n".join(text_zh)
77
 
78
  text_en = [
79
  elm.strip()
80
- for elm in Path("data/test_en.txt").read_text("utf8").splitlines()
81
  if elm.strip()
82
  ]
83
  _ = text_en[:9]
 
1
  """Gen ubee main."""
2
+ # pylint: disable=unused-import, wrong-import-position, wrong-import-order, too-many-locals, broad-except
3
 
4
+ from typing import Tuple, Optional
5
 
6
  from pathlib import Path
7
  import sys
8
  from random import shuffle
9
 
10
+ from itertools import zip_longest
11
  from textwrap import dedent
12
 
13
  import gradio as gr
 
42
  text1,
43
  text2,
44
  thresh: float
45
+ ) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]:
46
  """Take inputs, return outputs.
47
 
48
  Args:
 
62
 
63
  res1_, res2_ = ubee(res1, res2, thresh)
64
 
65
+ out_df = pd.DataFrame(
66
+ zip_longest(res1, res2),
67
+ columns=["text1", "text2"],
68
+ )
69
+
70
  if res2_:
71
  _ = pd.DataFrame(res2_, columns=["text1", "text2"])
72
  else:
73
  _ = None
74
+
75
+ return out_df, pd.DataFrame(res1_, columns=["text1", "text2", "likelihood"]), _
76
 
77
 
78
  def main():
79
  """Create main entry."""
80
+ text_zh = Path("data/test_zh.txt").read_text(encoding="utf8")
81
  text_zh = [elm.strip() for elm in text_zh.splitlines() if elm.strip()][:10]
82
  text_zh = "\n\n".join(text_zh)
83
 
84
  text_en = [
85
  elm.strip()
86
+ for elm in Path("data/test_en.txt").read_text(encoding="utf8").splitlines()
87
  if elm.strip()
88
  ]
89
  _ = text_en[:9]