Skip to content

Instantly share code, notes, and snippets.

@amankharwal

amankharwal/hotel.py Secret

Created Feb 13, 2021
Embed
What would you like to do?
def recommend_hotel(location, description):
description = description.lower()
word_tokenize(description)
stop_words = stopwords.words('english')
lemm = WordNetLemmatizer()
filtered = {word for word in description if not word in stop_words}
filtered_set = set()
for fs in filtered:
filtered_set.add(lemm.lemmatize(fs))
country = data[data['countries']==location.lower()]
country = country.set_index(np.arange(country.shape[0]))
list1 = []; list2 = []; cos = [];
for i in range(country.shape[0]):
temp_token = word_tokenize(country["Tags"][i])
temp_set = [word for word in temp_token if not word in stop_words]
temp2_set = set()
for s in temp_set:
temp2_set.add(lemm.lemmatize(s))
vector = temp2_set.intersection(filtered_set)
cos.append(len(vector))
country['similarity']=cos
country = country.sort_values(by='similarity', ascending=False)
country.drop_duplicates(subset='Hotel_Name', keep='first', inplace=True)
country.sort_values('Average_Score', ascending=False, inplace=True)
country.reset_index(inplace=True)
return country[["Hotel_Name", "Average_Score", "Hotel_Address"]].head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment