shrestha-prabin commited on
Commit
dc01079
·
verified ·
1 Parent(s): 8abf005

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +16 -2
src/streamlit_app.py CHANGED
@@ -5,9 +5,23 @@ import pandas as pd
5
  import seaborn as sns
6
  import streamlit as st
7
  from nltk.tokenize import word_tokenize
 
8
 
9
- nltk.download("punkt")
10
- nltk.download("punkt_tab")
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  st.title("📊 Bayesian Token Co-occurrence Simulator")
13
 
 
5
  import seaborn as sns
6
  import streamlit as st
7
  from nltk.tokenize import word_tokenize
8
+ import os
9
 
10
+ # Create a local nltk_data directory in your working directory
11
+ nltk_data_dir = os.path.join(os.path.dirname(__file__), "nltk_data")
12
+
13
+ # Ensure the path exists
14
+ os.makedirs(nltk_data_dir, exist_ok=True)
15
+
16
+ # Add this path to nltk's search path
17
+ nltk.data.path.append(nltk_data_dir)
18
+
19
+ # Download 'punkt' only if not already downloaded
20
+ try:
21
+ nltk.data.find("tokenizers/punkt")
22
+ except LookupError:
23
+ nltk.download("punkt", download_dir=nltk_data_dir)
24
+ nltk.download("punkt_tab", download_dir=nltk_data_dir)
25
 
26
  st.title("📊 Bayesian Token Co-occurrence Simulator")
27