|
14 | 14 | ) |
15 | 15 | from renard.pipeline.graph_extraction import CoOccurrencesGraphExtractor |
16 | 16 | from renard.graph_utils import graph_with_names |
| 17 | +from renard.resources.novels import load_novel |
17 | 18 | import matplotlib.pyplot as plt |
18 | 19 | import matplotlib.colors |
19 | 20 | import networkx as nx |
@@ -195,6 +196,18 @@ def run_pipeline( |
195 | 196 |
|
196 | 197 | net = Network(width="100%") |
197 | 198 | net.from_nx(G) |
| 199 | + # NOTE: layout found to have good default with "Pride and |
| 200 | + # Prejudice" with default parameters |
| 201 | + net.options.physics.use_barnes_hut( |
| 202 | + { |
| 203 | + "gravity": -22000, |
| 204 | + "central_gravity": 4.9, |
| 205 | + "spring_length": 95, |
| 206 | + "spring_strength": 0.04, |
| 207 | + "damping": 0.09, |
| 208 | + "overlap": 0, |
| 209 | + } |
| 210 | + ) |
198 | 211 | for u in net.nodes: |
199 | 212 | u["font"] = {"size": max(12, 2 * G.degree[u["id"]])} |
200 | 213 | net.show_buttons(filter_=["physics"]) |
@@ -325,16 +338,22 @@ def render_ge_kwargs(ge_step: str): |
325 | 338 | # TODO: pipeline level parameter like 'lang' |
326 | 339 | input_text = gr.State() |
327 | 340 | input_text_radio = gr.Radio( |
328 | | - choices=["Raw text", "Upload file"], |
| 341 | + choices=["Predefined Example", "Raw text", "Upload .txt file"], |
329 | 342 | label="Input type", |
330 | | - value="Raw text", |
| 343 | + value="Predefined Example", |
331 | 344 | ) |
332 | 345 |
|
333 | 346 | # NOTE: for some reason, tabs have an issue where the |
334 | 347 | # component in the second tab is invisible. |
335 | 348 | @gr.render(inputs=input_text_radio) |
336 | 349 | def render_input_text(input_type: str): |
337 | | - if input_type == "Upload file": |
| 350 | + if input_type == "Predefined Example": |
| 351 | + pp = load_novel("pride_and_prejudice") |
| 352 | + text_area = gr.TextArea( |
| 353 | + label="Pride and Prejudice", value=pp, interactive=False |
| 354 | + ) |
| 355 | + input_text.value = pp |
| 356 | + elif input_type == "Upload file": |
338 | 357 | upload_area = gr.File( |
339 | 358 | label="Input text file", file_types=["text"] |
340 | 359 | ) |
|
0 commit comments