如何从邮递员传递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
答案 0 :(得分:0)
您可以将查询参数更改为/spacy?input=verb&input=synonyms&text=flower
。并使用request.args.getlist("input")
获取列表值input
。