Upload 3 files
Browse files- app.py +8 -6
- dockerfile +13 -28
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -103,15 +103,17 @@ abbreviations = {
|
|
| 103 |
}
|
| 104 |
|
| 105 |
|
| 106 |
-
def ensure_model_installed(model_name="en_core_web_sm"):
|
| 107 |
-
if not os.path.exists(spacy.util.get_model_path(model_name)):
|
| 108 |
-
print(f"Model {model_name} not found. Downloading...")
|
| 109 |
-
spacy.cli.download(model_name)
|
| 110 |
-
else:
|
| 111 |
-
print(f"Model {model_name} is already installed.")
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
# Ensure the model is installed
|
| 114 |
ensure_model_installed()
|
|
|
|
| 115 |
nlp = spacy.load("en_core_web_sm")
|
| 116 |
|
| 117 |
def expand_abbreviations(text, abbreviations):
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
def ensure_model_installed():
|
| 108 |
+
try:
|
| 109 |
+
spacy.load('en_core_web_sm')
|
| 110 |
+
except OSError:
|
| 111 |
+
from spacy.cli import download
|
| 112 |
+
download('en_core_web_sm')
|
| 113 |
+
spacy.load('en_core_web_sm')
|
| 114 |
# Ensure the model is installed
|
| 115 |
ensure_model_installed()
|
| 116 |
+
|
| 117 |
nlp = spacy.load("en_core_web_sm")
|
| 118 |
|
| 119 |
def expand_abbreviations(text, abbreviations):
|
dockerfile
CHANGED
|
@@ -1,36 +1,21 @@
|
|
| 1 |
-
# Use a base image with Python
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
-
WORKDIR /
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
git \
|
| 10 |
-
git-lfs \
|
| 11 |
-
ffmpeg \
|
| 12 |
-
libsm6 \
|
| 13 |
-
libxext6 \
|
| 14 |
-
cmake \
|
| 15 |
-
rsync \
|
| 16 |
-
libgl1-mesa-glx \
|
| 17 |
-
&& rm -rf /var/lib/apt/lists/* \
|
| 18 |
-
&& git lfs install
|
| 19 |
-
|
| 20 |
-
# Copy the requirements file
|
| 21 |
-
COPY requirements.txt /tmp/requirements.txt
|
| 22 |
|
| 23 |
# Install Python dependencies
|
| 24 |
-
RUN pip install --no-cache-dir -r
|
| 25 |
-
|
| 26 |
-
# Install the SpaCy model
|
| 27 |
-
RUN python -m spacy download en_core_web_sm
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
|
| 34 |
|
| 35 |
-
#
|
| 36 |
CMD ["streamlit", "run", "app.py"]
|
|
|
|
| 1 |
+
# Use a base image with Python installed
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy requirements file to the container
|
| 8 |
+
COPY requirements.txt .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Install Python dependencies
|
| 11 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# Install SpaCy and the en_core_web_sm model
|
| 14 |
+
RUN pip install --no-cache-dir spacy && \
|
| 15 |
+
python -m spacy download en_core_web_sm
|
| 16 |
|
| 17 |
+
# Copy the rest of your Streamlit application code to the container
|
| 18 |
+
COPY . .
|
| 19 |
|
| 20 |
+
# Set the entry point for the application
|
| 21 |
CMD ["streamlit", "run", "app.py"]
|
requirements.txt
CHANGED
|
@@ -7,3 +7,4 @@ tensorflow
|
|
| 7 |
# https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0.tar.gz
|
| 8 |
spacy
|
| 9 |
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl
|
|
|
|
|
|
| 7 |
# https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0.tar.gz
|
| 8 |
spacy
|
| 9 |
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl
|
| 10 |
+
pandas
|