This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import library | |
import json | |
# This is a python library for 'Text Processing Serveices', as the offcial site suggests. | |
import difflib | |
from difflib import get_close_matches | |
#Let's load the same data again | |
data = json.load(open("dictionary.json")) | |
#Before you dive in, the basic template of this function is as follows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Check for non existing words | |
#1st elif: To make sure the program return the definition of words that start with a capital letter (e.g. Delhi, Texas) | |
#2nd elif: To make sure the program return the definition of acronyms (e.g. USA, NATO) | |
if word in data: | |
return data[word] | |
elif word.title() in data: | |
return data[word.title()] | |
elif word.upper() in data: | |
return data[word.upper()] | |
#3rd elif: To find a similar word |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elif len(get_close_matches(word, data.keys())) > 0: | |
action = input("Did you mean %s instead? [y or n]: " % get_close_matches(word, data.keys())[0]) | |
#-- If the answers is yes, retrive definition of suggested word | |
if (action == "y"): | |
return data[get_close_matches(word, data.keys())[0]] | |
elif (action == "n"): | |
return ("The word doesn't exist, yet.") | |
else: | |
return ("We don't understand your entry. Apologies.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Retrive the definition using function and print the result | |
output = retrive_definition(word_user) | |
#If a word has more than one definition, print them recursively | |
if type(output) == list: | |
for item in output: | |
print("-",item) | |
#For words having single definition | |
else: | |
print("-",output) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import Library | |
import folium | |
#Create base map | |
map = folium.Map(location=[37.296933,-121.9574983], zoom_start = 8) | |
#Save the map | |
map.save("map1.html") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import Library | |
import folium | |
#Create base map | |
map = folium.Map(location=[37.296933,-121.9574983], zoom_start = 8, tiles = "Mapbox bright") | |
#Add Marker | |
folium.Marker(location=[37.4074687,-122.086669], popup = "Google HQ", icon=folium.Icon(color = 'gray')).add_to(map) | |
#Save the map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import Library | |
import folium | |
#Create base map | |
map = folium.Map(location=[37.296933,-121.9574983], zoom_start = 8, tiles = "Mapbox bright") | |
#Multiple Markers | |
for coordinates in [[37.4074687,-122.086669],[37.8199286,-122.4804438]]: | |
folium.Marker(location=coordinates, icon=folium.Icon(color = 'green')).add_to(map) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import Library | |
import folium | |
import pandas as pd | |
#Load Data | |
data = pd.read_csv("Volcanoes_USA.txt") | |
lat = data['LAT'] | |
lon = data['LON'] | |
elevation = data['ELEV'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import Library | |
import folium | |
import pandas as pd | |
#Load Data | |
data = pd.read_csv("Volcanoes_USA.txt") | |
lat = data['LAT'] | |
lon = data['LON'] | |
elevation = data['ELEV'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import Library | |
import folium | |
from folium.plugins import MarkerCluster | |
import pandas as pd | |
#Load Data | |
data = pd.read_csv("Volcanoes_USA.txt") | |
lat = data['LAT'] | |
lon = data['LON'] | |
elevation = data['ELEV'] |