Skip to content

Instantly share code, notes, and snippets.

Created February 13, 2021 14:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
def recommend_hotel(location, description):
description = description.lower()
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:
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:
vector = temp2_set.intersection(filtered_set)
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)
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