Update app.py
Browse files
app.py
CHANGED
|
@@ -17,7 +17,7 @@ def parse(text):
|
|
| 17 |
|
| 18 |
|
| 19 |
def render_dependency_tree(words, parents, labels):
|
| 20 |
-
fig, ax = plt.subplots(figsize=(
|
| 21 |
|
| 22 |
# Create a directed graph
|
| 23 |
G = nx.DiGraph()
|
|
@@ -36,12 +36,12 @@ def render_dependency_tree(words, parents, labels):
|
|
| 36 |
|
| 37 |
# Draw the graph
|
| 38 |
nx.draw(G, pos, ax=ax, with_labels=True, labels=nx.get_node_attributes(G, 'label'),
|
| 39 |
-
arrows=True, node_color='#ffffff', node_size=0, node_shape='s', font_size=
|
| 40 |
)
|
| 41 |
|
| 42 |
# Draw edge labels
|
| 43 |
edge_labels = nx.get_edge_attributes(G, 'label')
|
| 44 |
-
nx.draw_networkx_edge_labels(G, pos, ax=ax, edge_labels=edge_labels, rotate=False, alpha=0.9, font_size=
|
| 45 |
|
| 46 |
return fig
|
| 47 |
|
|
@@ -102,7 +102,7 @@ with gr.Blocks(theme='sudeepshouche/minimalist', css=custom_css) as demo:
|
|
| 102 |
with gr.Row():
|
| 103 |
with gr.Column(scale=1, variant="panel"):
|
| 104 |
source = gr.Textbox(
|
| 105 |
-
label="Input sentence", placeholder="Write a
|
| 106 |
)
|
| 107 |
submit = gr.Button("Submit", variant="primary")
|
| 108 |
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
def render_dependency_tree(words, parents, labels):
|
| 20 |
+
fig, ax = plt.subplots(figsize=(40, 16))
|
| 21 |
|
| 22 |
# Create a directed graph
|
| 23 |
G = nx.DiGraph()
|
|
|
|
| 36 |
|
| 37 |
# Draw the graph
|
| 38 |
nx.draw(G, pos, ax=ax, with_labels=True, labels=nx.get_node_attributes(G, 'label'),
|
| 39 |
+
arrows=True, node_color='#ffffff', node_size=0, node_shape='s', font_size=30, bbox = dict(facecolor="white", pad=14)
|
| 40 |
)
|
| 41 |
|
| 42 |
# Draw edge labels
|
| 43 |
edge_labels = nx.get_edge_attributes(G, 'label')
|
| 44 |
+
nx.draw_networkx_edge_labels(G, pos, ax=ax, edge_labels=edge_labels, rotate=False, alpha=0.9, font_size=22)
|
| 45 |
|
| 46 |
return fig
|
| 47 |
|
|
|
|
| 102 |
with gr.Row():
|
| 103 |
with gr.Column(scale=1, variant="panel"):
|
| 104 |
source = gr.Textbox(
|
| 105 |
+
label="Input sentence", placeholder="Write a sentence to parse", show_label=False, lines=1, max_lines=5, autofocus=True
|
| 106 |
)
|
| 107 |
submit = gr.Button("Submit", variant="primary")
|
| 108 |
|