Spaces:
Build error
Build error
freemt
commited on
Commit
•
c978e0b
1
Parent(s):
86a6f15
Update sents/words examples
Browse files- ubee/__main__.py +36 -9
- ubee/ubee.py +1 -1
ubee/__main__.py
CHANGED
@@ -41,6 +41,7 @@ def greet1(name):
|
|
41 |
def greet(
|
42 |
text1,
|
43 |
text2,
|
|
|
44 |
thresh: float
|
45 |
) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]:
|
46 |
"""Take inputs, return outputs.
|
@@ -103,29 +104,55 @@ def main():
|
|
103 |
|
104 |
Stay tuned for more details coming soon...
|
105 |
""").strip()
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
]
|
|
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
lines = 15
|
112 |
placeholder = "Type or paste text here"
|
113 |
-
default1 = text_zh
|
114 |
-
default2 = text_en
|
115 |
label1 = "text1"
|
116 |
label2 = "text2"
|
117 |
inputs = [
|
118 |
gr.inputs.Textbox(
|
119 |
-
lines=lines, placeholder=placeholder, default=
|
120 |
),
|
121 |
gr.inputs.Textbox(
|
122 |
-
lines=lines, placeholder=placeholder, default=
|
123 |
),
|
|
|
|
|
|
|
|
|
|
|
124 |
gr.inputs.Slider(
|
125 |
minimum=0.0,
|
126 |
maximum=1.0,
|
127 |
step=0.1,
|
128 |
-
default=0.
|
|
|
129 |
),
|
130 |
]
|
131 |
|
@@ -169,7 +196,7 @@ def main():
|
|
169 |
article=article,
|
170 |
# inputs="text",
|
171 |
# outputs="text",
|
172 |
-
inputs=inputs,
|
173 |
outputs=outputs,
|
174 |
examples=examples,
|
175 |
# enable_queue=True,
|
|
|
41 |
def greet(
|
42 |
text1,
|
43 |
text2,
|
44 |
+
# segment: str
|
45 |
thresh: float
|
46 |
) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]:
|
47 |
"""Take inputs, return outputs.
|
|
|
104 |
|
105 |
Stay tuned for more details coming soon...
|
106 |
""").strip()
|
107 |
+
|
108 |
+
ex1_zh = [
|
109 |
+
'雪开始下大了。',
|
110 |
+
'我握住门柄又试一回。',
|
111 |
+
'这时一个没穿外衣的年轻人,扛着一根草耙,在后面院子里出现了。', '他招呼我跟着他走,穿过了一个洗衣房和一片铺平的地,那儿有煤棚、抽水机和鸽笼,我们终于到了我上次被接待过的那间温暖的、热闹的大屋子。',
|
112 |
+
'煤、炭和木材混合在一起燃起的熊熊炉火,使这屋子放着光彩。', '在准备摆上丰盛晚餐的桌旁,我很高兴地看到了那位“太太”,以前我从未料想到会有这么一个人存在的。',
|
113 |
+
'我鞠躬等候,以为她会叫我坐下。',
|
114 |
+
'她望望我,往她的椅背一靠,不动,也不出声。'
|
115 |
+
]
|
116 |
+
ex1_en = [
|
117 |
+
'The snow began to drive thickly.',
|
118 |
+
'I seized the handle to essay another trial; when a young man without coat, and shouldering a pitchfork, appeared in the yard behind.',
|
119 |
+
'He hailed me to follow him, and, after marching through a wash-house, and a paved area containing a coal shed, pump, and pigeon cot, we at length arrived in the huge, warm, cheerful apartment, where I was formerly received.',
|
120 |
+
"It glowed delightfully in the radiance of an immense fire, compounded of coal, peat, and wood; and near the table, laid for a plentiful evening meal, I was pleased to observe the `missis', an individual whose existence I had never previously suspected.",
|
121 |
+
'I bowed and waited, thinking she would bid me take a seat.',
|
122 |
+
'She looked at me, leaning back in her chair, and remained motionless and mute.'
|
123 |
]
|
124 |
+
shuffle(ex1_en)
|
125 |
|
126 |
+
ex2_zh =
|
127 |
+
ex2_en = "She looked at me leaning back in her chair and remained motionless and mute".split()
|
128 |
+
shuffle(ex2_en)
|
129 |
+
|
130 |
+
examples = [
|
131 |
+
[ex2_zh, ex2_en, .3],
|
132 |
+
[text_zh, text_en, .5],
|
133 |
+
]
|
134 |
lines = 15
|
135 |
placeholder = "Type or paste text here"
|
|
|
|
|
136 |
label1 = "text1"
|
137 |
label2 = "text2"
|
138 |
inputs = [
|
139 |
gr.inputs.Textbox(
|
140 |
+
lines=lines, placeholder=placeholder, default=ex1_zh, label=label1
|
141 |
),
|
142 |
gr.inputs.Textbox(
|
143 |
+
lines=lines, placeholder=placeholder, default=ex1_en, label=label2
|
144 |
),
|
145 |
+
gr.inputs.Radio(
|
146 |
+
["para", "sent", "word"],
|
147 |
+
default="para",
|
148 |
+
label="segment"
|
149 |
+
)
|
150 |
gr.inputs.Slider(
|
151 |
minimum=0.0,
|
152 |
maximum=1.0,
|
153 |
step=0.1,
|
154 |
+
default=0.4,
|
155 |
+
label="threshold",
|
156 |
),
|
157 |
]
|
158 |
|
|
|
196 |
article=article,
|
197 |
# inputs="text",
|
198 |
# outputs="text",
|
199 |
+
inputs=inputs, # text1, text2, segment, thresh
|
200 |
outputs=outputs,
|
201 |
examples=examples,
|
202 |
# enable_queue=True,
|
ubee/ubee.py
CHANGED
@@ -31,8 +31,8 @@ def ubee(
|
|
31 |
for seq in sents_zh:
|
32 |
ic(seq)
|
33 |
label, likelihood = uclas(seq, labels, thresh=thresh)
|
34 |
-
likelihood = round(float(likelihood), 2)
|
35 |
if label:
|
|
|
36 |
res.append((seq, label, likelihood))
|
37 |
try:
|
38 |
lo2.remove(label)
|
|
|
31 |
for seq in sents_zh:
|
32 |
ic(seq)
|
33 |
label, likelihood = uclas(seq, labels, thresh=thresh)
|
|
|
34 |
if label:
|
35 |
+
likelihood = round(float(likelihood), 2)
|
36 |
res.append((seq, label, likelihood))
|
37 |
try:
|
38 |
lo2.remove(label)
|