Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -248,23 +248,23 @@ def check_softgoal_syntax(softgoals):
|
|
| 248 |
# ############################################
|
| 249 |
|
| 250 |
# ########## Incorrect Task Syntax ###########
|
| 251 |
-
def
|
| 252 |
|
| 253 |
-
pipeline = TokenClassificationPipeline(model=
|
| 254 |
|
| 255 |
outputs = pipeline(sentences)
|
| 256 |
|
| 257 |
-
|
| 258 |
-
|
| 259 |
for idx, output in enumerate(outputs):
|
| 260 |
if not output[0]['entity'].startswith('V'):
|
| 261 |
-
|
| 262 |
|
| 263 |
-
return
|
| 264 |
|
| 265 |
def check_task_syntax(tasks):
|
| 266 |
|
| 267 |
-
incorrect_task_syntax =
|
| 268 |
|
| 269 |
if incorrect_task_syntax:
|
| 270 |
incorrect_task_syntax = "\n".join(incorrect_task_syntax)
|
|
@@ -273,6 +273,18 @@ def check_task_syntax(tasks):
|
|
| 273 |
return "All tasks are syntactically correct."
|
| 274 |
# ############################################
|
| 275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
# ########## Similarity ###########
|
| 277 |
def get_similar_elements(elements_per_actor, similarity_threshold):
|
| 278 |
|
|
@@ -467,6 +479,9 @@ def identify_bad_smells(tgrl_file, selected_bad_smells, size_threshold, similari
|
|
| 467 |
|
| 468 |
if 'Tasks Syntax' in selected_bad_smells:
|
| 469 |
output = output + check_task_syntax(elements['tasks']) + "\n\n"
|
|
|
|
|
|
|
|
|
|
| 470 |
|
| 471 |
if 'Similar Elements' in selected_bad_smells:
|
| 472 |
output = output + get_similar_elements(elements_per_actor, similarity_threshold) + "\n\n"
|
|
@@ -480,13 +495,12 @@ def identify_bad_smells(tgrl_file, selected_bad_smells, size_threshold, similari
|
|
| 480 |
if 'Contradicting Elements' in selected_bad_smells:
|
| 481 |
output = output + check_contradiction(elements_per_actor) + "\n\n"
|
| 482 |
|
| 483 |
-
|
| 484 |
return output
|
| 485 |
|
| 486 |
|
| 487 |
interface = gr.Interface(fn = identify_bad_smells,
|
| 488 |
inputs = [gr.File(label="TGRL File"),
|
| 489 |
-
gr.CheckboxGroup(["Size", "Complexity", "Punctuations", "Actors Syntax", "Goals Syntax", "Softgoals Syntax", "Tasks Syntax", "Similar Elements", "Spelling Mistakes", "Goal-Subgoal Mismatch", "Contradicting Elements"],
|
| 490 |
label="Which bad smells you want to detect?"),
|
| 491 |
gr.Slider(label= "Size threshold", value = 5, minimum = 2, maximum = 10, step = 1),
|
| 492 |
gr.Slider(label= "Similarity threshold", value = 0.9, minimum = 0, maximum = 1, step = 0.1)],
|
|
|
|
| 248 |
# ############################################
|
| 249 |
|
| 250 |
# ########## Incorrect Task Syntax ###########
|
| 251 |
+
def find_NPs(sentences):
|
| 252 |
|
| 253 |
+
pipeline = TokenClassificationPipeline(model=model, tokenizer=tokenizer)
|
| 254 |
|
| 255 |
outputs = pipeline(sentences)
|
| 256 |
|
| 257 |
+
NPs = []
|
| 258 |
+
|
| 259 |
for idx, output in enumerate(outputs):
|
| 260 |
if not output[0]['entity'].startswith('V'):
|
| 261 |
+
NPs.append(sentences[idx])
|
| 262 |
|
| 263 |
+
return NPs
|
| 264 |
|
| 265 |
def check_task_syntax(tasks):
|
| 266 |
|
| 267 |
+
incorrect_task_syntax = find_NPs(tasks)
|
| 268 |
|
| 269 |
if incorrect_task_syntax:
|
| 270 |
incorrect_task_syntax = "\n".join(incorrect_task_syntax)
|
|
|
|
| 273 |
return "All tasks are syntactically correct."
|
| 274 |
# ############################################
|
| 275 |
|
| 276 |
+
# ########## Incorrect Resource Syntax ###########
|
| 277 |
+
def check_resource_syntax(resources):
|
| 278 |
+
|
| 279 |
+
incorrect_resource_syntax = find_non_NPs(resources)
|
| 280 |
+
|
| 281 |
+
if incorrect_resource_syntax:
|
| 282 |
+
incorrect_resource_syntax = "\n".join(incorrect_resource_syntax)
|
| 283 |
+
return "Incorrect Resources Syntax:\n" + incorrect_resource_syntax
|
| 284 |
+
else:
|
| 285 |
+
return "All resources are syntactically correct."
|
| 286 |
+
# ############################################
|
| 287 |
+
|
| 288 |
# ########## Similarity ###########
|
| 289 |
def get_similar_elements(elements_per_actor, similarity_threshold):
|
| 290 |
|
|
|
|
| 479 |
|
| 480 |
if 'Tasks Syntax' in selected_bad_smells:
|
| 481 |
output = output + check_task_syntax(elements['tasks']) + "\n\n"
|
| 482 |
+
|
| 483 |
+
if 'Resources Syntax' in selected_bad_smells:
|
| 484 |
+
output = output + check_resource_syntax(elements['resources']) + "\n\n"
|
| 485 |
|
| 486 |
if 'Similar Elements' in selected_bad_smells:
|
| 487 |
output = output + get_similar_elements(elements_per_actor, similarity_threshold) + "\n\n"
|
|
|
|
| 495 |
if 'Contradicting Elements' in selected_bad_smells:
|
| 496 |
output = output + check_contradiction(elements_per_actor) + "\n\n"
|
| 497 |
|
|
|
|
| 498 |
return output
|
| 499 |
|
| 500 |
|
| 501 |
interface = gr.Interface(fn = identify_bad_smells,
|
| 502 |
inputs = [gr.File(label="TGRL File"),
|
| 503 |
+
gr.CheckboxGroup(["Size", "Complexity", "Punctuations", "Actors Syntax", "Goals Syntax", "Softgoals Syntax", "Tasks Syntax", "Resources Syntax", "Similar Elements", "Spelling Mistakes", "Goal-Subgoal Mismatch", "Contradicting Elements"],
|
| 504 |
label="Which bad smells you want to detect?"),
|
| 505 |
gr.Slider(label= "Size threshold", value = 5, minimum = 2, maximum = 10, step = 1),
|
| 506 |
gr.Slider(label= "Similarity threshold", value = 0.9, minimum = 0, maximum = 1, step = 0.1)],
|