utkarsh1797 commited on
Commit
76a5a4a
Β·
verified Β·
1 Parent(s): 991956b

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +5 -19
src/streamlit_app.py CHANGED
@@ -1,35 +1,21 @@
1
  import streamlit as st
2
- import os
3
- import subprocess
4
  import nltk
5
  import spacy
6
  import benepar
7
  from nltk import Tree
8
 
9
- # Set NLTK path to writable /tmp
10
  nltk_data_path = "/tmp/nltk_data"
11
  nltk.data.path.append(nltk_data_path)
12
-
13
- # Download safely
14
  nltk.download('punkt', download_dir=nltk_data_path)
15
 
16
- # Load spaCy model with fallback install
17
- try:
18
- nlp = spacy.load("en_core_web_sm")
19
- except:
20
- subprocess.run(["python", "-m", "pip", "install", "--user", "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl"])
21
- import importlib
22
- importlib.invalidate_caches()
23
- nlp = spacy.load("en_core_web_sm")
24
 
25
- # Load benepar model safely
26
  if "benepar" not in nlp.pipe_names:
27
- try:
28
- benepar.download('benepar_en3') # safe internal method
29
- except:
30
- subprocess.run(["python", "-m", "benepar.download", "benepar_en3"])
31
  nlp.add_pipe("benepar", config={"model": "benepar_en3"})
32
-
33
  # Streamlit UI
34
  st.set_page_config(page_title="Syntax Parser Comparison", layout="wide")
35
  st.title("🌐 Syntax Parser Comparison Tool")
 
1
  import streamlit as st
 
 
2
  import nltk
3
  import spacy
4
  import benepar
5
  from nltk import Tree
6
 
7
+ # Configure nltk to use /tmp
8
  nltk_data_path = "/tmp/nltk_data"
9
  nltk.data.path.append(nltk_data_path)
 
 
10
  nltk.download('punkt', download_dir=nltk_data_path)
11
 
12
+ # Load installed spaCy model
13
+ nlp = spacy.load("en_core_web_sm")
 
 
 
 
 
 
14
 
15
+ # Add benepar parser
16
  if "benepar" not in nlp.pipe_names:
17
+ benepar.download("benepar_en3")
 
 
 
18
  nlp.add_pipe("benepar", config={"model": "benepar_en3"})
 
19
  # Streamlit UI
20
  st.set_page_config(page_title="Syntax Parser Comparison", layout="wide")
21
  st.title("🌐 Syntax Parser Comparison Tool")