2017-09-26 89 views
-1

如何從郵遞員傳遞list以及如何訪問多個屬性無法訪問獲取URL的話傳遞的列表

@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

你可以改變你的查詢參數/spacy?input=verb&input=synonyms&text=flower代碼。並使用request.args.getlist("input")獲取input的列表值。

+0

你可以舉一個例子,它會更有幫助 –