productizationlabs
commited on
Commit
•
7cefc3e
1
Parent(s):
a29b06a
Upload app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,21 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
_A='countries'
|
2 |
+
import gradio as gr,numpy as np,pandas as pd
|
3 |
+
from nltk.corpus import stopwords
|
4 |
+
from nltk.tokenize import word_tokenize
|
5 |
+
from nltk.stem.wordnet import WordNetLemmatizer
|
6 |
+
import nltk
|
7 |
+
nltk.download('punkt')
|
8 |
+
df=pd.read_csv('Hotel_Reviews.csv')
|
9 |
+
df[_A]=df.Hotel_Address.apply(lambda x:x.split(' ')[-1])
|
10 |
+
def Input_your_destination_and_description(location,description):
|
11 |
+
M='Average_Score';L='Hotel_Name';K=False;J='similarity';D=True;C='Tags';B=description;df[_A]=df[_A].str.lower();df[C]=df[C].str.lower();B=B.lower();N=word_tokenize(B);E=stopwords.words('english');F=WordNetLemmatizer();O={A for A in N if not A in E};G=set()
|
12 |
+
for P in O:G.add(F.lemmatize(P))
|
13 |
+
A=df[df[_A]==location.lower()];A=A.set_index(np.arange(A.shape[0]));H=[]
|
14 |
+
for Q in range(A.shape[0]):
|
15 |
+
R=word_tokenize(A[C][Q]);S={A for A in R if not A in E};I=set()
|
16 |
+
for T in S:I.add(F.lemmatize(T))
|
17 |
+
U=I.intersection(G);H.append(len(U))
|
18 |
+
A[J]=H;A=A.sort_values(by=J,ascending=K);A.drop_duplicates(subset=L,keep='first',inplace=D);A.sort_values(M,ascending=K,inplace=D);A.reset_index(inplace=D);return A[[L,M,'Hotel_Address']].head(10)
|
19 |
+
inputs=[gr.inputs.Textbox(label='Location'),gr.inputs.Textbox(label='Purpose of Travel')]
|
20 |
+
outputs=gr.outputs.Dataframe(label='Hotel Recommendations',type='pandas')
|
21 |
+
gr.Interface(fn=Input_your_destination_and_description,inputs=inputs,outputs=outputs,theme=gr.themes.Default(primary_hue='slate')).launch()
|