Rank Results

We create a sorted dictionary of similarities for a query:

dict_sim= dict(enumerate(XX_sim_scores))

sorted_dict_sim = sorted(dict_sim.items(), key=operator.itemgetter(1), reverse =True)

Finally, in the sorted dictionary, we check for the index of the most similar question and response with the value at that index for the answers column.  If nothing is found we can return our default answer.

if sorted_dict_sim[0][1]==0:
print("Sorry I have no answer, please try asking again in a nicer way :)")
elif sorted_dic_sim[0][1]>0:
print answer_list [sorted_dic_sim[0][0]]
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.4.179