Spaces:
Running
Running
PLL approach
Browse files
app.py
CHANGED
@@ -174,7 +174,25 @@ def greet(X, ny):
|
|
174 |
# else:
|
175 |
# astr+=mock.capitalize()
|
176 |
er = er+" (with PLL value of: "+str(vali)+")"
|
177 |
-
return er
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
title = "Rename a variable in a Java class"
|
179 |
description = """This model is a fine-tuned GraphCodeBERT model fine-tuned to output higher-quality variable names for Java classes. Long classes are handled by the
|
180 |
model. Replace any variable name with a "[MASK]" to get an identifier renaming.
|
@@ -200,7 +218,7 @@ ex.printStackTrace();
|
|
200 |
}
|
201 |
}
|
202 |
}
|
203 |
-
}"""
|
204 |
import java.io.*;
|
205 |
|
206 |
public class s {
|
@@ -218,7 +236,7 @@ public class s {
|
|
218 |
if ([MASK] != null) [MASK].close();
|
219 |
}
|
220 |
}
|
221 |
-
}"""
|
222 |
import java.util.*;
|
223 |
|
224 |
public class y {
|
@@ -235,13 +253,13 @@ public class y {
|
|
235 |
e.printStackTrace();
|
236 |
}
|
237 |
}
|
238 |
-
}"""
|
239 |
# We instantiate the Textbox class
|
240 |
textbox = gr.Textbox(label="Type Java code snippet:", placeholder="replace variable with [MASK]", lines=10)
|
241 |
-
textbox1 = gr.Textbox(label="Number of tokens in name:", placeholder="0 for randomly sampled number of tokens",lines=1)
|
242 |
|
243 |
gr.Interface(title = title, description = description, examples = ex, fn=greet, inputs=[
|
244 |
-
textbox
|
245 |
], outputs="text").launch()
|
246 |
|
247 |
|
|
|
174 |
# else:
|
175 |
# astr+=mock.capitalize()
|
176 |
er = er+" (with PLL value of: "+str(vali)+")"
|
177 |
+
return er, vali
|
178 |
+
|
179 |
+
def meet(X):
|
180 |
+
tot_pll = 100.00
|
181 |
+
print_str = ""
|
182 |
+
fin_out = "The highest confidence prediction is: "
|
183 |
+
add_out = ""
|
184 |
+
for r in range(6):
|
185 |
+
er, pll = greet(X, 6-r)
|
186 |
+
print_str+= er
|
187 |
+
print_str+='\n'
|
188 |
+
if pll >= tot_pll:
|
189 |
+
break
|
190 |
+
else:
|
191 |
+
add_out = er
|
192 |
+
tot_pll = pll
|
193 |
+
print_str= print_str+fin_out+add_out
|
194 |
+
return print_str
|
195 |
+
|
196 |
title = "Rename a variable in a Java class"
|
197 |
description = """This model is a fine-tuned GraphCodeBERT model fine-tuned to output higher-quality variable names for Java classes. Long classes are handled by the
|
198 |
model. Replace any variable name with a "[MASK]" to get an identifier renaming.
|
|
|
218 |
}
|
219 |
}
|
220 |
}
|
221 |
+
}"""], ["""import java.net.*;
|
222 |
import java.io.*;
|
223 |
|
224 |
public class s {
|
|
|
236 |
if ([MASK] != null) [MASK].close();
|
237 |
}
|
238 |
}
|
239 |
+
}"""], ["""import java.io.*;
|
240 |
import java.util.*;
|
241 |
|
242 |
public class y {
|
|
|
253 |
e.printStackTrace();
|
254 |
}
|
255 |
}
|
256 |
+
}"""]]
|
257 |
# We instantiate the Textbox class
|
258 |
textbox = gr.Textbox(label="Type Java code snippet:", placeholder="replace variable with [MASK]", lines=10)
|
259 |
+
#textbox1 = gr.Textbox(label="Number of tokens in name:", placeholder="0 for randomly sampled number of tokens",lines=1)
|
260 |
|
261 |
gr.Interface(title = title, description = description, examples = ex, fn=greet, inputs=[
|
262 |
+
textbox
|
263 |
], outputs="text").launch()
|
264 |
|
265 |
|