Optimised spacy first loading

This commit is contained in:
Mathieu B 2021-07-27 18:07:04 +02:00
parent d9cf5e56de
commit dc23d6a80a
3 changed files with 8 additions and 2 deletions

Binary file not shown.

View File

@ -1,6 +1,7 @@
import flask
from flask import Flask, request, jsonify, Response
import jarvis.ia.process
from utils import config_utils, flask_utils, intents_utils, utils
app = Flask(__name__)
@ -14,7 +15,7 @@ def process_request():
flask.abort(Response('You must provide a \'sentence\' parameter (not empty aswell)!'))
sentence = data['sentence']
tag_for_request = src.ia.process.get_tag_for_sentence(sentence)
tag_for_request = jarvis.ia.process.get_tag_for_sentence(sentence)
print("SENTENCE : " + sentence + " /// TAG : " + tag_for_request)

View File

@ -2,8 +2,13 @@ import spacy
from jarvis.utils import languages_utils
nlp = None
def get_spacy_nlp():
global nlp
if nlp is None:
nlp = spacy.load(languages_utils.get_spacy_model())
return nlp