python - build a suggestions list using fuzzywuzzy -


i building suggestion engine database. i'm using fuzzywuzzy module match user input string existing database shown below.

if request.method == "get":     display_dict = {}     user_input = request.get["user_input"]  # user input     match_dict = {}      food_items_obj = food_items.objects.all() # fetch objects table      items in food_items_obj :         match = fuzz.ratio(user_input.lower(),items.name.lower()) # try match user input existing names         match_dict[match] = items.name        # put 1 dictionary      matched_dict = ordereddict(sorted(match_dict.items(),reverse = true)) # sort dictionary      if max(matched_dict.keys()) == 100: # if exact match put in dict , return         display_dict[100] = matched_dict[100]     else :                                 # if not found try best matching words..    ###########this part need help! #############         k,v in matched_dict.items():             if user_input in v :                 display_dict[k] = v  # if user input substring of names in database             else:                 if k > sum([k k,v in matched_dict.items()])/len(matched_dict): # best think of take average of ratio , display items greater that.                   display_dict[k] = v      return render(request,"suggestions/home.html",{'recommendations_list':display_dict,'time_taken': time_taken}) 

so need inputs on else part. i'm not able pick right exact words want database.

example input : user input : gobi suggestions came up: did mean maaza ## unexpected word  did mean gobi 65 did mean gobi pepper fry did mean gobi parota did mean kadai gobi did mean aloo gobi 

how improve suggestions ? more libraries can use ? other best (best in sense of memory , time) possible way same ? in advance!


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -