SJTUCL commited on
Commit
9966b88
1 Parent(s): c6c7fe7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -1,5 +1,7 @@
1
- import nltk
2
- nltk.download('punkt')
 
 
3
 
4
  import pandas as pd
5
  import gradio as gr
@@ -26,7 +28,8 @@ color_map = {
26
 
27
 
28
  def predict_doc(doc):
29
- sents = sent_tokenize(doc)
 
30
  data = {'sentence': [], 'label': [], 'score': []}
31
  res = []
32
  for sent in sents:
 
1
+ from spacy.lang.en import English
2
+
3
+ nlp = English()
4
+ nlp.add_pipe("sentencizer")
5
 
6
  import pandas as pd
7
  import gradio as gr
 
28
 
29
 
30
  def predict_doc(doc):
31
+ # sents = sent_tokenize(doc)
32
+ sents = [s.text for s in nlp(doc).sents]
33
  data = {'sentence': [], 'label': [], 'score': []}
34
  res = []
35
  for sent in sents: