nickil commited on
Commit
705fc84
1 Parent(s): f58f7f4

format trees

Browse files
Files changed (2) hide show
  1. app.py +6 -2
  2. packages.txt +2 -0
app.py CHANGED
@@ -1,7 +1,11 @@
 
 
 
1
  import gradio
2
  import benepar
3
  import spacy
4
  import nltk
 
5
  nltk.download('stopwords')
6
 
7
  from huggingface_hub import hf_hub_url, cached_download
@@ -37,7 +41,7 @@ def predict(sentence, model):
37
  elif model == "inside-outside":
38
  best_parse = Predictor(sentence=sentence).obtain_best_parse(predict_type="inside_outside", model=inside_outside_model, scale_axis=1, predict_batch_size=128)
39
  sentence_f1 = calculate_F1_for_spans(tree_to_spans(gold_standard), tree_to_spans(best_parse))
40
- return gold_standard, best_parse, f"{sentence_f1:.2f}"
41
 
42
 
43
  iface = gradio.Interface(
@@ -64,4 +68,4 @@ iface = gradio.Interface(
64
  ["Bitcoin community under pressure to cut energy use .", "inside"],
65
  ],
66
  )
67
- iface.launch()
 
1
+ import matplotlib
2
+ matplotlib.use('Agg')
3
+
4
  import gradio
5
  import benepar
6
  import spacy
7
  import nltk
8
+ from nltk.tree import Tree
9
  nltk.download('stopwords')
10
 
11
  from huggingface_hub import hf_hub_url, cached_download
 
41
  elif model == "inside-outside":
42
  best_parse = Predictor(sentence=sentence).obtain_best_parse(predict_type="inside_outside", model=inside_outside_model, scale_axis=1, predict_batch_size=128)
43
  sentence_f1 = calculate_F1_for_spans(tree_to_spans(gold_standard), tree_to_spans(best_parse))
44
+ return Tree.fromstring(gold_standard).draw(), Tree.fromstring(best_parse).draw(), f"{sentence_f1:.2f}"
45
 
46
 
47
  iface = gradio.Interface(
 
68
  ["Bitcoin community under pressure to cut energy use .", "inside"],
69
  ],
70
  )
71
+ iface.launch(share=True)
packages.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ghostscript
2
+ python3-tk