Spaces:
Sleeping
Sleeping
anshupatel4298
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,21 @@ from transformers import BertTokenizer, TFBertForSequenceClassification
|
|
7 |
import logging
|
8 |
import random
|
9 |
import time
|
|
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
app = Flask(__name__)
|
15 |
|
|
|
7 |
import logging
|
8 |
import random
|
9 |
import time
|
10 |
+
import os
|
11 |
|
12 |
+
# Define a function to download NLTK data if it doesn't already exist
|
13 |
+
def download_nltk_data():
|
14 |
+
nltk_data_dir = os.path.join(os.path.expanduser("~"), "nltk_data")
|
15 |
+
if not os.path.exists(nltk_data_dir):
|
16 |
+
os.makedirs(nltk_data_dir)
|
17 |
+
|
18 |
+
if not os.path.exists(os.path.join(nltk_data_dir, "tokenizers", "punkt")):
|
19 |
+
nltk.download('punkt', download_dir=nltk_data_dir)
|
20 |
+
|
21 |
+
if not os.path.exists(os.path.join(nltk_data_dir, "corpora", "wordnet")):
|
22 |
+
nltk.download('wordnet', download_dir=nltk_data_dir)
|
23 |
+
|
24 |
+
download_nltk_data()
|
25 |
|
26 |
app = Flask(__name__)
|
27 |
|