Update app.py
Browse files
app.py
CHANGED
@@ -79,12 +79,14 @@ with gr.Blocks(title="General NER with Color-Coded Output") as demo:
|
|
79 |
output_entities = gr.JSON(label="Entities")
|
80 |
|
81 |
|
82 |
-
|
83 |
def get_new_snippet():
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
88 |
return "No more snippets available." # Return this if no valid snippets are found
|
89 |
|
90 |
# Connect refresh button
|
|
|
79 |
output_entities = gr.JSON(label="Entities")
|
80 |
|
81 |
|
|
|
82 |
def get_new_snippet():
|
83 |
+
# Preload several samples into a list
|
84 |
+
samples = [sample['text'] for sample, _ in zip(dataset_iter, range(100))] # Load 100 samples
|
85 |
+
|
86 |
+
# Return a random snippet from the preloaded samples
|
87 |
+
if samples:
|
88 |
+
return random.choice(samples)
|
89 |
+
|
90 |
return "No more snippets available." # Return this if no valid snippets are found
|
91 |
|
92 |
# Connect refresh button
|