diff --git a/FoodFinder.py b/FoodFinder.py index 8016db4..c8d288d 100644 --- a/FoodFinder.py +++ b/FoodFinder.py @@ -8,8 +8,6 @@ def findFood(text): food = "" for word in text: if found == False: - if word == "get": - continue if word in KEYWORDS: found = True #Finds the first keyword food = word @@ -20,5 +18,7 @@ def findFood(text): continue food = food + " " + word #If multiple keywords follow each other break # take all of them in account and the word - return food # that follows them as well e.g. "The best burger" + # that follows them as well e.g. "The best burger" + food = food.replace("get",'').replace("is",'').replace("are",'').replace("to",'').strip(' ') # Make the string neat for printing it out + return food diff --git a/GUI.py b/GUI.py index 9b25937..f6d541b 100644 --- a/GUI.py +++ b/GUI.py @@ -28,14 +28,15 @@ def clickAction(): savePreferences(userName) entryText = filteredMessage(entryBox.get("0.0", END)) loadMyEntry(chatDispl, entryText) - client.send( entryText.encode('utf-8') ) # Encode the messsage in bits and send it to server - try: - rawmsg = client.recv(1024) # recieve up to 1024 bytes + if not(entryText == ''): + client.send( entryText.encode('utf-8') ) # Encode the messsage in bits and send it to server + try: + rawmsg = client.recv(1024) # recieve up to 1024 bytes - msg = rawmsg.decode('utf-8').rstrip('\r\n') # Decode received message from bits to string - loadOtherEntry(chatDispl, msg) - except: - print("Didnt receive a message") + msg = rawmsg.decode('utf-8').rstrip('\r\n') # Decode received message from bits to string + loadOtherEntry(chatDispl, msg) + except: + print("Didnt receive a message") chatDispl.yview(END)#Scroll to the bottom of chat windows entryBox.delete("0.0", END) #Erace previous message in Entry Box except: diff --git a/placeFinderFinal.py b/placeFinderFinal.py index 9788db5..d5f6d8b 100644 --- a/placeFinderFinal.py +++ b/placeFinderFinal.py @@ -37,7 +37,7 @@ def findPlace(location_str='Coventry University',keyword_str='Food'): placeWebsite = place.website if not(place.local_phone_number == None): placePhone = place.local_phone_number - return placeName, placeAddress, placeWebsite, placePhone # Also works as a break statement + return placeName, placeAddress, placeWebsite, placePhone # Also works as a break statement because we only need the first place except: placeName = None diff --git a/server1.py b/server1.py index e011092..ade8669 100644 --- a/server1.py +++ b/server1.py @@ -20,8 +20,10 @@ try: rawmsg = c.recv(1024) # recieve up to 1024 bytes msg = rawmsg.decode('utf-8').rstrip('\r\n') # convert and clean the input - - rtrnmsg = generateResponse(msg, temp) # create return message + if not(msg==''): + rtrnmsg = generateResponse(msg, temp) # create return message + else: + rtrnmsg = "I don't like empty messages" temp = msg # Keep last message print( '%s -> %s' % (msg,rtrnmsg) )