import gradio as gr from whereabouts.utils import download from whereabouts.Matcher import Matcher # download the various address databases download('au_all_sm', 'saunteringcat/whereabouts-db') download('au_all_lg', 'saunteringcat/whereabouts-db') download('au_vic_lg', 'saunteringcat/whereabouts-db') download('au_nsw_lg', 'saunteringcat/whereabouts-db') # create a matcher object matcher1 = Matcher('au_all_sm') matcher2 = Matcher('au_all_lg') matcher3 = Matcher('au_vic_lg') matcher4 = Matcher('au_all_sm') # function to geocode results def geocode(addresses): address_list = addresses.split('\n') return matcher1.geocode(address_list) text_input = gr.Textbox(lines=2, label="Addresses to geocode (one row per address)") json_output = gr.JSON(label="Output JSON data") interface_geocoder = gr.Interface( fn=geocode, inputs=[text_input], outputs=[json_output], title="Geocode addresses using whereabouts", description=""" Whereabouts is a freely available open-source geocoding package for Python. Currently it supports geocoding of Australian addresses, with more countries being added. This demo shows whereabouts in action. The code is available on github: https://www.github.com/ajl2718/whereabouts Or you can install it using as follows ``` pip install whereabouts python -m whereabouts download au_all_sm ``` """ ) demo = gr.TabbedInterface([interface_geocoder], ["Geocoding"]) demo.launch()