freemt commited on
Commit
89d669f
1 Parent(s): 385a2e8

Update two inputs, df_out

Browse files
Files changed (2) hide show
  1. ubee/__main__.py +78 -9
  2. ubee/ubee.py +7 -0
ubee/__main__.py CHANGED
@@ -1,38 +1,107 @@
1
- """Gen main."""
 
 
 
 
 
2
  import gradio as gr
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- def greet(name):
6
  """Dummy."""
7
  return "Hello " + name + "!!"
8
 
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  def main():
11
  """Create main entry."""
12
  title = "Ultimatumbee Aligner"
13
  theme = "dark-grass"
14
  description = """WIP showcasing a novel aligner"""
15
- article = \
16
- """Coming soon...
17
  """
18
  examples = [
19
  ["yo"],
20
  ["me"],
21
  ]
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  iface = gr.Interface(
24
  fn=greet,
 
25
  title=title,
26
  theme=theme,
27
  description=description,
28
  article=article,
29
- inputs="text",
30
- outputs="text",
 
 
31
  examples=examples,
32
  )
33
- iface.launch(
34
- enable_queue=False
35
- )
36
 
37
 
38
  if __name__ == "__main__":
 
1
+ """Gen ubee main."""
2
+ # pylint: disable=unused-import
3
+
4
+ from itertools import zip_longest
5
+ from textwrap import dedent
6
+
7
  import gradio as gr
8
 
9
+ import pandas as pd
10
+ from icecream import install as ic_install, ic
11
+ import logzero
12
+ from logzero import logger
13
+
14
+ from ubee.ubee import ubee
15
+
16
+ ic_install()
17
+ ic.configureOutput(
18
+ includeContext=True,
19
+ outputFunction=logger.info,
20
+ )
21
+ ic.enable()
22
+ # ic.disenable() # to turn off
23
+
24
 
25
+ def greet1(name):
26
  """Dummy."""
27
  return "Hello " + name + "!!"
28
 
29
 
30
+ def greet(text1, text2) -> pd.DataFrame:
31
+ """Take inputs, return outputs.
32
+
33
+ Args:
34
+ text1:
35
+ text2:
36
+ """
37
+ res1 = [elm for elm in text1.splitlines() if elm.strip()]
38
+ res2 = [elm for elm in text2.splitlines() if elm.strip()]
39
+
40
+ _ = pd.DataFrame(zip_longest(res1, res2), columns=["text1", "text2"])
41
+ return _
42
+
43
+
44
  def main():
45
  """Create main entry."""
46
  title = "Ultimatumbee Aligner"
47
  theme = "dark-grass"
48
  description = """WIP showcasing a novel aligner"""
49
+ article = """Coming soon...
 
50
  """
51
  examples = [
52
  ["yo"],
53
  ["me"],
54
  ]
55
 
56
+ lines = 30
57
+ placeholder = "Type or paste text here"
58
+ default1 = dedent(
59
+ """ test 1
60
+ love you
61
+ """
62
+ )
63
+ default2 = dedent(
64
+ """ 测试 1
65
+ 爱你
66
+ """
67
+ )
68
+ label1 = "text1"
69
+ label2 = "text2"
70
+ inputs = [
71
+ gr.inputs.Textbox(
72
+ lines=lines, placeholder=placeholder, default=default1, label=label1
73
+ ),
74
+ gr.inputs.Textbox(
75
+ lines=lines, placeholder=placeholder, default=default2, label=label2
76
+ ),
77
+ ]
78
+
79
+ out_df = gr.outputs.Dataframe(
80
+ headers=None,
81
+ max_rows=lines, # 20
82
+ max_cols=None,
83
+ overflow_row_behaviour="paginate",
84
+ type="auto",
85
+ label="To be aligned",
86
+ )
87
+ outputs = [ # tot. 1
88
+ out_df,
89
+ ]
90
+
91
  iface = gr.Interface(
92
  fn=greet,
93
+ # fn=ubee,
94
  title=title,
95
  theme=theme,
96
  description=description,
97
  article=article,
98
+ # inputs="text",
99
+ # outputs="text",
100
+ inputs=inputs,
101
+ outputs=outputs,
102
  examples=examples,
103
  )
104
+ iface.launch(enable_queue=False)
 
 
105
 
106
 
107
  if __name__ == "__main__":
ubee/ubee.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ """Function for gr's fn."""
2
+ # pylint=disable=
3
+
4
+
5
+ def ubee():
6
+ """Gen a dummy."""
7
+ ...