Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.") |