Optimised spacy first loading
This commit is contained in:
parent
d9cf5e56de
commit
dc23d6a80a
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
import flask
|
import flask
|
||||||
from flask import Flask, request, jsonify, Response
|
from flask import Flask, request, jsonify, Response
|
||||||
|
|
||||||
|
import jarvis.ia.process
|
||||||
from utils import config_utils, flask_utils, intents_utils, utils
|
from utils import config_utils, flask_utils, intents_utils, utils
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@ -14,7 +15,7 @@ def process_request():
|
|||||||
flask.abort(Response('You must provide a \'sentence\' parameter (not empty aswell)!'))
|
flask.abort(Response('You must provide a \'sentence\' parameter (not empty aswell)!'))
|
||||||
|
|
||||||
sentence = data['sentence']
|
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)
|
print("SENTENCE : " + sentence + " /// TAG : " + tag_for_request)
|
||||||
|
|
||||||
|
@ -2,8 +2,13 @@ import spacy
|
|||||||
|
|
||||||
from jarvis.utils import languages_utils
|
from jarvis.utils import languages_utils
|
||||||
|
|
||||||
|
nlp = None
|
||||||
|
|
||||||
|
|
||||||
def get_spacy_nlp():
|
def get_spacy_nlp():
|
||||||
|
global nlp
|
||||||
|
|
||||||
|
if nlp is None:
|
||||||
nlp = spacy.load(languages_utils.get_spacy_model())
|
nlp = spacy.load(languages_utils.get_spacy_model())
|
||||||
return nlp
|
return nlp
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user