【发布时间】:2017-09-26 06:06:46
【问题描述】:
如何从邮递员那里传递list 以及如何访问多个属性
@api.route('/Spacy/<input>/<texts>')
class Spacy(Resource):
if input == pos:
def get(self, input):
'''
Returns part-of speech.
'''
doc = nlp(texts)
return [(word.text, word.lemma_, word.pos_) for word in doc]
elif input == verb:
def get(self, input):
'''
Returns verbs and the stemmed verb.
'''
doc = nlp(texts)
return [(word.text, word.lemma_) for word in doc if word.pos_ == "VERB"]
elif input == synonyms:
def get(self, input):
'''
Returns the synonyms.
'''
synonyms = wordnet.synsets(input)
lemmas = set(chain.from_iterable([word.lemma_names() for word in synonyms]))
return jsonify([syn.replace("_"," ") for syn in list(lemmas)])
我通过/spacy?input=verb,synonyms&text=flower
我应该如何接受并通过代码
我也在用 spacy
【问题讨论】:
标签: python flask nltk flask-restful spacy