app.py
CHANGED
@@ -129,6 +129,9 @@ def show_avg(base_fn, model_name, patent_claim_num, show_pick=False):
|
|
129 |
]
|
130 |
|
131 |
for i, tk in enumerate(lst):
|
|
|
|
|
|
|
132 |
token_text = handle_char_return(tk['actual_next_token_text'])
|
133 |
if token_text == '<|end_of_claim|>':
|
134 |
break
|
@@ -139,7 +142,7 @@ def show_avg(base_fn, model_name, patent_claim_num, show_pick=False):
|
|
139 |
pick = int(tk['actual_next_token_top_seq'])
|
140 |
prob = float(tk['actual_next_token_top_prob'])
|
141 |
|
142 |
-
for
|
143 |
sum_all[item[2]] = 0
|
144 |
|
145 |
if pick == 0:
|
@@ -158,11 +161,14 @@ def show_avg(base_fn, model_name, patent_claim_num, show_pick=False):
|
|
158 |
fg_color = colors[2][1]
|
159 |
tag = colors[2][2]
|
160 |
sum_all[tag] += 1
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
result += "<span style=background-color:#%s;color:#%s;border-radius:5px;>%s%s</span> " % (bg_color, fg_color, token_text, pick)
|
163 |
|
164 |
-
st.text('debug 2')
|
165 |
-
|
166 |
color_msg = ''
|
167 |
for i, v in enumerate(colors):
|
168 |
color_msg += "<span style=background-color:#%s;color:#%s;border-radius:5px;> %s </span> " % (v[0], v[1], v[2])
|
@@ -178,9 +184,7 @@ def show_avg(base_fn, model_name, patent_claim_num, show_pick=False):
|
|
178 |
'Total keystrokes: %s (with autocomplete), %s (without autocomplete)\n' \
|
179 |
'Keystroke distribution: top 1~10: %s (top 1: %s), out of top 10: %s' % (model_name, saved_ratio, keys_with_auto, keys_without_auto, sum_pick, sum_hit_1, sum_outscope_len)
|
180 |
st.text(s)
|
181 |
-
|
182 |
-
s = color_msg
|
183 |
-
st.markdown(s, unsafe_allow_html=True)
|
184 |
st.markdown(result, unsafe_allow_html=True)
|
185 |
sum_lst = [sum_all['1'], sum_all['2-10'], sum_all['out of top 10']]
|
186 |
|
@@ -286,7 +290,7 @@ def main():
|
|
286 |
pick = random.randrange(len(select_lst))
|
287 |
num = select_lst[pick]
|
288 |
|
289 |
-
st.text('debug')
|
290 |
|
291 |
avgs = []
|
292 |
for prefix in prefix_lst:
|
|
|
129 |
]
|
130 |
|
131 |
for i, tk in enumerate(lst):
|
132 |
+
if i == len(lst)-1:
|
133 |
+
break
|
134 |
+
|
135 |
token_text = handle_char_return(tk['actual_next_token_text'])
|
136 |
if token_text == '<|end_of_claim|>':
|
137 |
break
|
|
|
142 |
pick = int(tk['actual_next_token_top_seq'])
|
143 |
prob = float(tk['actual_next_token_top_prob'])
|
144 |
|
145 |
+
for j, item in enumerate(colors):
|
146 |
sum_all[item[2]] = 0
|
147 |
|
148 |
if pick == 0:
|
|
|
161 |
fg_color = colors[2][1]
|
162 |
tag = colors[2][2]
|
163 |
sum_all[tag] += 1
|
164 |
+
|
165 |
+
if show_pick:
|
166 |
+
pick = '[%s]' % pick
|
167 |
+
else:
|
168 |
+
pick = ''
|
169 |
|
170 |
result += "<span style=background-color:#%s;color:#%s;border-radius:5px;>%s%s</span> " % (bg_color, fg_color, token_text, pick)
|
171 |
|
|
|
|
|
172 |
color_msg = ''
|
173 |
for i, v in enumerate(colors):
|
174 |
color_msg += "<span style=background-color:#%s;color:#%s;border-radius:5px;> %s </span> " % (v[0], v[1], v[2])
|
|
|
184 |
'Total keystrokes: %s (with autocomplete), %s (without autocomplete)\n' \
|
185 |
'Keystroke distribution: top 1~10: %s (top 1: %s), out of top 10: %s' % (model_name, saved_ratio, keys_with_auto, keys_without_auto, sum_pick, sum_hit_1, sum_outscope_len)
|
186 |
st.text(s)
|
187 |
+
st.markdown(color_msg, unsafe_allow_html=True)
|
|
|
|
|
188 |
st.markdown(result, unsafe_allow_html=True)
|
189 |
sum_lst = [sum_all['1'], sum_all['2-10'], sum_all['out of top 10']]
|
190 |
|
|
|
290 |
pick = random.randrange(len(select_lst))
|
291 |
num = select_lst[pick]
|
292 |
|
293 |
+
#st.text('debug 1')
|
294 |
|
295 |
avgs = []
|
296 |
for prefix in prefix_lst:
|