File size: 2,564 Bytes
7cf23eb
 
 
 
 
 
 
6fc85e4
7cf23eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c76ae4f
6fc85e4
0584424
 
c76ae4f
0584424
 
c76ae4f
0584424
7cf23eb
0584424
 
c76ae4f
0584424
563175b
 
 
 
cbbd7cc
 
 
 
 
 
 
 
 
 
563175b
 
cbbd7cc
563175b
cbbd7cc
 
 
 
 
 
 
 
 
 
0584424
c76ae4f
cbbd7cc
7cf23eb
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import gradio as gr
import pandas as pd

# Read the CSV data
data = pd.read_csv("integrated_travel_data.csv")

def get_city_info(city):
    city_data = data[data['Destination'].str.lower().str.strip() == city.lower().strip()]
    
    if city_data.empty:
        return "City not found in the database."
    
    city_info = city_data.iloc[0]
    
    info = f"Destination: {city_info['Destination']}\n"
    info += f"State: {city_info['State']}\n\n"
    info += f"Description: {city_info['Description']}\n\n"
    info += "Tourist Attractions:\n"
    attractions = city_info['Tourist Attractions'].split(', ')
    for attraction in attractions:
        info += f"- {attraction}\n"
    info += "\nActivities:\n"
    activities = city_info['Activities'].split('. ')
    for activity in activities:
        info += f"- {activity}\n"
    
    return info

def list_places_by_state(state):
    state_data = data[data['State'].str.lower().str.strip() == state.lower().strip()]
    
    if state_data.empty:
        return f"No destinations found for {state}."
    
    places = state_data['Destination'].tolist()
    return f"Destinations in {state}:\n" + "\n".join(places)

# Create the Gradio interface
with gr.Blocks() as iface:
    gr.Markdown("# Indian Travel Information")
    gr.Markdown("Enter a state to see available destinations, then enter a city name for detailed information.")
    
    with gr.Row():
        with gr.Column():
            state_input = gr.Textbox(label="Enter state name")
            state_output = gr.Textbox(label="Destinations in State", lines=10)
            gr.Examples(
                examples=[
                    ["Uttar Pradesh"],
                    ["Maharashtra"],
                    ["Rajasthan"],
                    ["Arunachal Pradesh"],
                    ["Assam"]
                ],
                inputs=state_input
            )
        with gr.Column():
            city_input = gr.Textbox(label="Enter city name")
            submit_button = gr.Button("Submit")
            city_info_output = gr.Textbox(label="City Information", lines=20)
            gr.Examples(
                examples=[
                    ["Agra"],
                    ["Mumbai"],
                    ["Jaipur"],
                    ["Tawang"],
                    ["Guwahati"]
                ],
                inputs=city_input
            )
    
    state_input.change(list_places_by_state, inputs=state_input, outputs=state_output)
    submit_button.click(get_city_info, inputs=city_input, outputs=city_info_output)

iface.launch()