is first lemmatized
This commit is contained in:
parent
053ee2e040
commit
daee1668b0
@ -30,8 +30,17 @@ class LemmatizerResource(Resource):
|
||||
return result, 200
|
||||
|
||||
def processSentence(self, sentence, language):
|
||||
tokens = [self.lemmatizeWord(token, language) for token in sentence.split()]
|
||||
return {'tokens':' '.join(tokens)}
|
||||
raw_tokens = sentence.split()
|
||||
tokens = [self.lemmatizeWord(token, language) for token in raw_tokens]
|
||||
return {'tokens':' '.join(tokens), 'isFirstLemmatized':self.isFirstLemmatized(raw_tokens, language)}
|
||||
|
||||
def isFirstLemmatized(self, raw_tokens, language):
|
||||
if language == 'pl':
|
||||
first_token = raw_tokens[0]
|
||||
if self.lemmatizeWord(first_token, language) != first_token:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def lemmatizeWord(self, word, language):
|
||||
if len(word) == 1:
|
||||
|
@ -2,9 +2,15 @@
|
||||
|
||||
import requests, json
|
||||
|
||||
local = False
|
||||
|
||||
if local:
|
||||
port = 9001
|
||||
else:
|
||||
port = 10002
|
||||
|
||||
def do_lemmatize(data):
|
||||
response = requests.post(url = 'http://127.0.0.1:10002/lemmatize', json = data)
|
||||
response = requests.post(url = 'http://127.0.0.1:%d/lemmatize' % port, json = data)
|
||||
return json.loads(response.text)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user