utkarsh1797 commited on
Commit
b16059e
·
verified ·
1 Parent(s): 56359e1

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +6 -11
src/streamlit_app.py CHANGED
@@ -1,26 +1,21 @@
1
  import os
2
- os.environ["STREAMLIT_BROWSER_GATHER_USAGE_STATS"] = "false"
3
-
4
- import streamlit as st
5
- import spacy
6
- import benepar
7
- from nltk import Tree
8
  import nltk
 
9
 
10
- # Setup NLTK and benepar
11
-
12
-
13
  nltk_data_path = "/tmp/nltk_data"
14
  nltk.download('punkt', download_dir=nltk_data_path)
 
15
  nltk.data.path.append(nltk_data_path)
16
 
17
- benepar.download('benepar_en3')
18
-
19
  try:
20
  nlp = spacy.load("en_core_web_sm")
21
  except:
22
  subprocess.run(["python", "-m", "spacy", "download", "en_core_web_sm"])
23
  nlp = spacy.load("en_core_web_sm")
 
24
  if "benepar" not in nlp.pipe_names:
25
  nlp.add_pipe("benepar", config={"model": "benepar_en3"})
26
 
 
1
  import os
2
+ import subprocess
 
 
 
 
 
3
  import nltk
4
+ import spacy
5
 
6
+ # Setup NLTK
 
 
7
  nltk_data_path = "/tmp/nltk_data"
8
  nltk.download('punkt', download_dir=nltk_data_path)
9
+ nltk.download('benepar_en3', download_dir=nltk_data_path)
10
  nltk.data.path.append(nltk_data_path)
11
 
12
+ # Load spaCy model with fallback
 
13
  try:
14
  nlp = spacy.load("en_core_web_sm")
15
  except:
16
  subprocess.run(["python", "-m", "spacy", "download", "en_core_web_sm"])
17
  nlp = spacy.load("en_core_web_sm")
18
+
19
  if "benepar" not in nlp.pipe_names:
20
  nlp.add_pipe("benepar", config={"model": "benepar_en3"})
21