changed calamancy version
Browse files- Dockerfile +3 -0
- feature_core.py +14 -1
- requirements.txt +1 -1
Dockerfile
CHANGED
|
@@ -18,6 +18,9 @@ RUN pip install --upgrade pip setuptools wheel
|
|
| 18 |
COPY requirements.txt .
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
# Copy the rest of your app
|
| 22 |
COPY . .
|
| 23 |
|
|
|
|
| 18 |
COPY requirements.txt .
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
| 21 |
+
# Pre-download CalamanCy model during image build so runtime startup is stable.
|
| 22 |
+
RUN python -c "import calamancy; calamancy.load('tl_calamancy_md-0.2.0')"
|
| 23 |
+
|
| 24 |
# Copy the rest of your app
|
| 25 |
COPY . .
|
| 26 |
|
feature_core.py
CHANGED
|
@@ -6,7 +6,20 @@ import calamancy
|
|
| 6 |
|
| 7 |
def load_nlp_model(model_name: str = "tl_calamancy_md-0.2.0"):
|
| 8 |
"""Load the CalamanCy model once for either training or web inference."""
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
def merge_dash_sentences(doc) -> List:
|
|
|
|
| 6 |
|
| 7 |
def load_nlp_model(model_name: str = "tl_calamancy_md-0.2.0"):
|
| 8 |
"""Load the CalamanCy model once for either training or web inference."""
|
| 9 |
+
candidates = [model_name, "tl_calamancy_md-0.2.0", "tl_calamancy_md"]
|
| 10 |
+
seen = set()
|
| 11 |
+
errors = []
|
| 12 |
+
|
| 13 |
+
for candidate in candidates:
|
| 14 |
+
if candidate in seen:
|
| 15 |
+
continue
|
| 16 |
+
seen.add(candidate)
|
| 17 |
+
try:
|
| 18 |
+
return calamancy.load(candidate)
|
| 19 |
+
except Exception as exc:
|
| 20 |
+
errors.append(f"{candidate}: {exc}")
|
| 21 |
+
|
| 22 |
+
raise RuntimeError("Failed to load any CalamanCy model variant. " + " | ".join(errors))
|
| 23 |
|
| 24 |
|
| 25 |
def merge_dash_sentences(doc) -> List:
|
requirements.txt
CHANGED
|
@@ -4,7 +4,7 @@ joblib==1.3.2
|
|
| 4 |
pandas==2.2.2
|
| 5 |
numpy==1.26.4
|
| 6 |
scikit-learn==1.7.2
|
| 7 |
-
calamancy==0.2.
|
| 8 |
gunicorn==21.2.0
|
| 9 |
setuptools>=69.0.0
|
| 10 |
wheel>=0.42.0
|
|
|
|
| 4 |
pandas==2.2.2
|
| 5 |
numpy==1.26.4
|
| 6 |
scikit-learn==1.7.2
|
| 7 |
+
calamancy==0.2.2
|
| 8 |
gunicorn==21.2.0
|
| 9 |
setuptools>=69.0.0
|
| 10 |
wheel>=0.42.0
|