22 lines
556 B
Python
22 lines
556 B
Python
|
#!/usr/bin/python3
|
||
|
|
||
|
from flask import Flask
|
||
|
from flask_restful import Api
|
||
|
from server.lemmatizer_resource import LemmatizerResource
|
||
|
import pickle, spacy
|
||
|
|
||
|
app = Flask('preprocessor')
|
||
|
api = Api(app)
|
||
|
|
||
|
|
||
|
lemmatizer = spacy.load('en', disable=['parser', 'ner'])
|
||
|
app.logger.info("Lemmatizer initialized")
|
||
|
|
||
|
pickle_in = open("dictionaries/dict.pickle","rb")
|
||
|
dictionary = pickle.load(pickle_in)
|
||
|
app.logger.info("Dictionary initialized")
|
||
|
|
||
|
|
||
|
|
||
|
api.add_resource(LemmatizerResource, "/lemmatize", resource_class_kwargs={'lemmatizer': lemmatizer, 'dictionary':dictionary})
|