anon commited on
Commit
846f373
1 Parent(s): 914a2e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -22
app.py CHANGED
@@ -175,23 +175,29 @@ def greet(X, ny):
175
  er = er+" (with PLL value of: "+str(vali)+")"
176
  return er, vali
177
 
178
- def meet(X):
179
- tot_pll = 100.00
180
- print_str = ""
181
- fin_out = "The highest confidence prediction is: "
182
- add_out = ""
183
- for r in range(6):
184
- er, pll = greet(X, 6-r)
185
- print_str+= er
186
- print_str+='\n'
187
- if (pll - tot_pll) > 0.1 and tot_pll < 1:
188
- break
189
- elif pll >= tot_pll:
190
- continue
191
- else:
192
- add_out = er
193
- tot_pll = pll
194
- print_str= print_str+fin_out+add_out
 
 
 
 
 
 
195
  return print_str
196
 
197
  title = "Rename a variable in a Java class"
@@ -219,7 +225,7 @@ ex.printStackTrace();
219
  }
220
  }
221
  }
222
- }"""], ["""import java.net.*;
223
  import java.io.*;
224
 
225
  public class s {
@@ -237,7 +243,7 @@ public class s {
237
  if ([MASK] != null) [MASK].close();
238
  }
239
  }
240
- }"""], ["""import java.io.*;
241
  import java.util.*;
242
 
243
  public class y {
@@ -254,13 +260,13 @@ public class y {
254
  e.printStackTrace();
255
  }
256
  }
257
- }"""]]
258
  # We instantiate the Textbox class
259
  textbox = gr.Textbox(label="Type Java code snippet:", placeholder="replace variable with [MASK]", lines=10)
260
- #textbox1 = gr.Textbox(label="Number of tokens in name:", placeholder="0 for randomly sampled number of tokens",lines=1)
261
 
262
  gr.Interface(title = title, description = description, examples = ex, fn=meet, inputs=[
263
- textbox
264
  ], outputs="text").launch()
265
 
266
 
 
175
  er = er+" (with PLL value of: "+str(vali)+")"
176
  return er, vali
177
 
178
+ def meet(X, ni):
179
+ ni = int(ni)
180
+ if ni == 0:
181
+ print_str,vali = greet(X,ni)
182
+ elif ni == -1:
183
+ tot_pll = 100.00
184
+ print_str = ""
185
+ fin_out = "The highest confidence prediction is: "
186
+ add_out = ""
187
+ for r in range(6):
188
+ er, pll = greet(X, 6-r)
189
+ print_str+= er
190
+ print_str+='\n'
191
+ if (pll - tot_pll) > 0.1 and tot_pll < 1:
192
+ break
193
+ elif pll >= tot_pll:
194
+ continue
195
+ else:
196
+ add_out = er
197
+ tot_pll = pll
198
+ print_str= print_str+fin_out+add_out
199
+ else:
200
+ print_str,vali = greet(X,ni)
201
  return print_str
202
 
203
  title = "Rename a variable in a Java class"
 
225
  }
226
  }
227
  }
228
+ }""", -1], ["""import java.net.*;
229
  import java.io.*;
230
 
231
  public class s {
 
243
  if ([MASK] != null) [MASK].close();
244
  }
245
  }
246
+ }""", -1], ["""import java.io.*;
247
  import java.util.*;
248
 
249
  public class y {
 
260
  e.printStackTrace();
261
  }
262
  }
263
+ }""", -1]]
264
  # We instantiate the Textbox class
265
  textbox = gr.Textbox(label="Type Java code snippet:", placeholder="replace variable with [MASK]", lines=10)
266
+ textbox1 = gr.Textbox(label="Number of tokens in name:", placeholder="0 for randomly sampled number of tokens and -1 for automatic number of token selection",lines=1)
267
 
268
  gr.Interface(title = title, description = description, examples = ex, fn=meet, inputs=[
269
+ textbox, textbox1
270
  ], outputs="text").launch()
271
 
272