Skip to content
Permalink
Browse files
Add files via upload
  • Loading branch information
khanz46 committed Nov 30, 2018
1 parent e333b45 commit 25fe6920a640ea6edd842fb60cf8d61af877d304
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
40 map.py
@@ -0,0 +1,40 @@
-import urllib.request
-import json
-import re
- #https://www.youtube.com/watch?v=UrrWxyq1Z48
-#Strips the html using regular expression
-def striphtml(data):
- p = re.compile(r'<.*?>')
- return p.sub(' ', data)
-
-
-def destin():
-
- # Google MapsDirections API endpoint
- endpoint = 'https://www.google.com/maps/api/directions/json?'
- api_key = "AIzaSyCjYXLdIxy1eOMbQ-rzNVwSZ6Kfhg3zCtc"
- # Asks the user to input what is your current location and what is your destination.
- origins = input('What is your current location?: ').replace(' ', '+')
- destination = input('What is your destination?: ').replace(' ', '+')
- # Building the URL for the request
- print(origins)
- try:
-
- nav_request = 'origin={}&destination={}&key={}'.format(origins, destination, api_key)
- request = endpoint + nav_request
- # Sends the request and reads the response.
- response = urllib.request.urlopen(request).read().decode('utf8')
- #print(response)
- # Loads response as JSON
- directions = json.loads(str(response))
- #print(directions)
- instructions = []
- steps = directions['routes'][0]['legs'][0]['steps']
- for step in steps:
- instructions.append(striphtml(step['html_instructions']))
- for instruction in instructions:
- print(instruction)
- print('You have reached your destination.')
- except:
- print("The destination is too far the direction cannot be printed.")
- destin()
24 who.py
@@ -0,0 +1,24 @@
import random
from wiki import wikiSearch
from info import ownInfo
from what import sentence_what
def sentence_who(sentence):
if "who" in sentence:
if "you going" in sentence:
answer = ["I am going to go see my friend", "I will go see my parents to go shopping",
"I am going to go play football with friends",
"I need to see friends for a group study"]
print(random.choice(answer))
elif "favourite" in sentence:
sentence = sentence.replace("who", "what")
sentence_what(sentence)
elif "are you" in sentence:
print("I am a ChatBot Made By The Foreigners Group")
elif "bartosz" in sentence or "Andre" in sentence or "Premo" in sentence or "Zaid" in sentence or "Alan" in sentence or "Artur" in sentence:
print("The Foreigners member")
elif "am i" in sentence:
print ("I haven't got the best memory, sorry!!")
else:
wikiSearch(sentence)
else:
print("I am not sure what do you mean, please clarify.")

0 comments on commit 25fe692

Please sign in to comment.