Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -434,33 +434,7 @@ def mask(sentence):
|
|
434 |
masked_sentences = [predictions[i]['sequence'] for i in range(len(predictions))]
|
435 |
return masked_sentences
|
436 |
|
437 |
-
# Function to generate the tree and return the Graphviz source
|
438 |
-
# def generate_tree(original_sentence: str) -> str:
|
439 |
-
# paraphrased_sentences = generate_paraphrase(original_sentence)
|
440 |
-
# first_paraphrased_sentence = paraphrased_sentences[0]
|
441 |
-
# masked_sentence = mask_non_stopword(first_paraphrased_sentence)
|
442 |
-
# masked_versions = mask(masked_sentence)
|
443 |
-
# dot = graphviz.Digraph()
|
444 |
-
# dot.attr(rankdir='LR', size='10,10', dpi=' 2743')
|
445 |
|
446 |
-
# existing_nodes = set()
|
447 |
-
|
448 |
-
# def add_paraphrases(parent, paraphrases):
|
449 |
-
# if parent not in existing_nodes:
|
450 |
-
# dot.node(parent, parent, shape='box')
|
451 |
-
# existing_nodes.add(parent)
|
452 |
-
|
453 |
-
# for paraphrase in paraphrases:
|
454 |
-
# if paraphrase not in existing_nodes:
|
455 |
-
# dot.node(paraphrase, paraphrase, shape='box')
|
456 |
-
# existing_nodes.add(paraphrase)
|
457 |
-
# dot.edge(parent, paraphrase)
|
458 |
-
|
459 |
-
# add_paraphrases(original_sentence, paraphrased_sentences) #whenever a new branch is to be created call this function along with the original sentence and the list of its paraphrases
|
460 |
-
# add_paraphrases(paraphrased_sentences[0], masked_versions)
|
461 |
-
|
462 |
-
# graph_path = dot.render(filename='paraphrase_tree_dynamic', format='png')
|
463 |
-
# return masked_sentence, masked_versions, dot.source
|
464 |
|
465 |
|
466 |
|
@@ -483,7 +457,8 @@ def generate_plot(original_sentence):
|
|
483 |
(1, 6),
|
484 |
(1, 7),
|
485 |
(1, 8),
|
486 |
-
(1, 9)
|
|
|
487 |
]
|
488 |
wrapped_nodes = ['<br>'.join(textwrap.wrap(node, width=30)) for node in nodes]
|
489 |
fig = go.Figure()
|
|
|
434 |
masked_sentences = [predictions[i]['sequence'] for i in range(len(predictions))]
|
435 |
return masked_sentences
|
436 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
|
439 |
|
440 |
|
|
|
457 |
(1, 6),
|
458 |
(1, 7),
|
459 |
(1, 8),
|
460 |
+
(1, 9),
|
461 |
+
(1, 10)
|
462 |
]
|
463 |
wrapped_nodes = ['<br>'.join(textwrap.wrap(node, width=30)) for node in nodes]
|
464 |
fig = go.Figure()
|