unsupported language error
This commit is contained in:
parent
9acdeacafb
commit
427755d40b
@ -10,11 +10,11 @@ api = Api(app)
|
||||
|
||||
|
||||
lemmatizer = spacy.load('en', disable=['parser', 'ner'])
|
||||
app.logger.info("Lemmatizer initialized")
|
||||
print("Lemmatizer initialized")
|
||||
|
||||
pickle_in = open("dictionaries/dict.pickle","rb")
|
||||
dictionary = pickle.load(pickle_in)
|
||||
app.logger.info("Dictionary initialized")
|
||||
print("Dictionary initialized")
|
||||
|
||||
|
||||
|
||||
|
@ -17,6 +17,9 @@ class LemmatizerResource(Resource):
|
||||
return {'error':'Missing parameter: sentences'}, 400
|
||||
|
||||
language = json_data['language']
|
||||
if language not in ['pl', 'en']:
|
||||
return {'error':'Unsupported language: %s' % language}, 400
|
||||
|
||||
|
||||
sentences = []
|
||||
for sentence in json_data['sentences']:
|
||||
@ -34,7 +37,7 @@ class LemmatizerResource(Resource):
|
||||
if len(word) == 1:
|
||||
return word
|
||||
lemma = None
|
||||
if language == 'pl':
|
||||
if language == 'pl':
|
||||
lemma = self.dictionary.get(word, None)
|
||||
if lemma is None:
|
||||
lemma = word
|
||||
|
Loading…
Reference in New Issue
Block a user