Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,14 +44,30 @@ import spacy
|
|
44 |
# nlp = spacy.load("en_core_web_sm")
|
45 |
|
46 |
# import spacy
|
|
|
|
|
|
|
47 |
|
48 |
try:
|
49 |
nlp = spacy.load("en_core_web_sm")
|
50 |
except OSError:
|
51 |
print("Downloading en_core_web_sm model...")
|
52 |
-
|
53 |
nlp = spacy.load("en_core_web_sm")
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
|
57 |
def extractive_qa(question, text):
|
|
|
44 |
# nlp = spacy.load("en_core_web_sm")
|
45 |
|
46 |
# import spacy
|
47 |
+
import subprocess
|
48 |
+
|
49 |
+
|
50 |
|
51 |
try:
|
52 |
nlp = spacy.load("en_core_web_sm")
|
53 |
except OSError:
|
54 |
print("Downloading en_core_web_sm model...")
|
55 |
+
subprocess.run(["python", "-m", "spacy", "download", "en_core_web_sm"])
|
56 |
nlp = spacy.load("en_core_web_sm")
|
57 |
|
58 |
+
# @st.cache(allow_output_mutation=True)
|
59 |
+
# def download_and_load_model():
|
60 |
+
# try:
|
61 |
+
# nlp = spacy.load("en_core_web_sm")
|
62 |
+
# except OSError:
|
63 |
+
# print("Downloading en_core_web_sm model...")
|
64 |
+
# !python -m spacy download en_core_web_sm # This line works within the cached function
|
65 |
+
# nlp = spacy.load("en_core_web_sm")
|
66 |
+
# return nlp
|
67 |
+
|
68 |
+
# # Later in your code, use the model:
|
69 |
+
# nlp = download_and_load_model()
|
70 |
+
|
71 |
|
72 |
|
73 |
def extractive_qa(question, text):
|