From 807fb7ee867b25ad31427f95ca1f52fa404aebcf Mon Sep 17 00:00:00 2001 From: Vasu Jain <91457798+7Zenox@users.noreply.github.com> Date: Sat, 17 Aug 2024 19:30:48 +0530 Subject: [PATCH] Spacy autocheck - Downloads core-web-lg model automatically if not installed --- django_vaani/connection/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/django_vaani/connection/views.py b/django_vaani/connection/views.py index 8b9e3e7c..11efb86f 100644 --- a/django_vaani/connection/views.py +++ b/django_vaani/connection/views.py @@ -10,7 +10,14 @@ import spacy -nlp = spacy.load('en_core_web_lg') +# Check if the 'en_core_web_lg' model is installed +try: + nlp = spacy.load('en_core_web_lg') +except OSError: + print("Model 'en_core_web_lg' not found. Installing now...") + spacy.cli.download('en_core_web_lg') + nlp = spacy.load('en_core_web_lg') + print("Model 'en_core_web_lg' installed successfully.") MAX_LENGTH = 256