freemt commited on
Commit
5ae3f92
1 Parent(s): da8f9c2

Update text[:10]

Browse files
Files changed (2) hide show
  1. ubee/__main__.py +13 -7
  2. ubee/ubee.py +2 -0
ubee/__main__.py CHANGED
@@ -8,7 +8,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
14
 
@@ -23,7 +23,7 @@ if "." not in sys.path:
23
 
24
  from ubee.ubee import ubee
25
 
26
- logzero.loglevel(10)
27
  ic_install()
28
  ic.configureOutput(
29
  includeContext=True,
@@ -65,24 +65,29 @@ def greet(
65
  def main():
66
  """Create main entry."""
67
  text_zh = Path("data/test_zh.txt").read_text("utf8")
 
 
 
68
  text_en = [
69
  elm.strip()
70
  for elm in Path("data/test_en.txt").read_text("utf8").splitlines()
71
  if elm.strip()
72
  ]
73
- shuffle(text_en)
74
  text_en = "\n\n".join(text_en)
75
 
76
  title = "Ultimatumbee Aligner"
77
  theme = "dark-grass"
78
  description = """WIP showcasing a novel aligner"""
79
- article = """
80
- The ultimatumbee aligner (``ubee`` for short) is intended for aligning text blocks (be it paragraphs, sentences or words). Since it is rather slow (30 para pairs (Wuthering Height ch1. for example) can take 10 to 20 mniutes), 50 or more blocks should probably be avaoided. Nevertheless, you are welcome to try. No big brother is watching.
 
 
81
 
82
- ``thresh``: longer text blocks justify a larger value; `.5` appears to be just right for paragraphs for Wuthering Height ch1.
83
 
84
  Stay tuned for more details coming soon...
85
- """
86
  examples = [
87
  ["yo\nme", "你\n我", .5],
88
  ["me\nshe", "你\n她", .5],
@@ -152,6 +157,7 @@ def main():
152
  inputs=inputs,
153
  outputs=outputs,
154
  examples=examples,
 
155
  )
156
  iface.launch(enable_queue=True)
157
 
 
8
  from random import shuffle
9
 
10
  # from itertools import zip_longest
11
+ from textwrap import dedent
12
 
13
  import gradio as gr
14
 
 
23
 
24
  from ubee.ubee import ubee
25
 
26
+ # logzero.loglevel(10)
27
  ic_install()
28
  ic.configureOutput(
29
  includeContext=True,
 
65
  def main():
66
  """Create main entry."""
67
  text_zh = Path("data/test_zh.txt").read_text("utf8")
68
+ text_zh = [elm.strip() for elm in text_zh.splitlines() if elm.strip()][:10]
69
+ text_zh = "\n\n".join(text_zh)
70
+
71
  text_en = [
72
  elm.strip()
73
  for elm in Path("data/test_en.txt").read_text("utf8").splitlines()
74
  if elm.strip()
75
  ]
76
+ shuffle(text_en[:10])
77
  text_en = "\n\n".join(text_en)
78
 
79
  title = "Ultimatumbee Aligner"
80
  theme = "dark-grass"
81
  description = """WIP showcasing a novel aligner"""
82
+ article = dedent("""
83
+ ## NB
84
+
85
+ * The ultimatumbee aligner (``ubee`` for short) is intended for aligning text blocks (be it paragraphs, sentences or words). Since it is rather slow (30 para pairs (Wuthering Height ch1. for example) can take 10 to 20 mniutes), anything more than 50 blocks should probably be avaoided. Nevertheless, you are welcome to try. No big brother is watching.
86
 
87
+ * ``thresh``: longer text blocks justify a larger value; `.5` appears to be just right for paragraphs for Wuthering Height ch1.
88
 
89
  Stay tuned for more details coming soon...
90
+ """).strip()
91
  examples = [
92
  ["yo\nme", "你\n我", .5],
93
  ["me\nshe", "你\n她", .5],
 
157
  inputs=inputs,
158
  outputs=outputs,
159
  examples=examples,
160
+ enable_queue=True,
161
  )
162
  iface.launch(enable_queue=True)
163
 
ubee/ubee.py CHANGED
@@ -5,6 +5,7 @@ from itertools import zip_longest
5
 
6
  from logzero import logger
7
  from ubee.uclas import uclas
 
8
 
9
 
10
  def ubee(
@@ -28,6 +29,7 @@ def ubee(
28
  lo2 = labels[:]
29
 
30
  for seq in sents_zh:
 
31
  label, likelihood = uclas(seq, labels, thresh=thresh)
32
  if label:
33
  res.append((seq, label, likelihood))
 
5
 
6
  from logzero import logger
7
  from ubee.uclas import uclas
8
+ from icecream import ic
9
 
10
 
11
  def ubee(
 
29
  lo2 = labels[:]
30
 
31
  for seq in sents_zh:
32
+ ic(seq)
33
  label, likelihood = uclas(seq, labels, thresh=thresh)
34
  if label:
35
  res.append((seq, label, likelihood))