Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
GroupD3/FoodFinder.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
27 lines (23 sloc)
1.11 KB
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
# Made by Andris Jansons | |
KEYWORDS = "the, a, an, get, good, best, is, are, to, nice, pleasant, lovely, cool, fine, stupid, goddamn, nearest, great, large, small, medium, new, newest, old, closest, smallest, biggest, coolest".split(", ") | |
SKIPS = "get, is, are, to".split(", ") | |
def findFood(text): | |
"""Finds food after special KEYWORDS""" | |
found = False | |
food = "" | |
for word in text: | |
if found == False: | |
if word in KEYWORDS: | |
found = True #Finds the first keyword | |
if not(word in SKIPS): | |
food = word | |
else: | |
if word in KEYWORDS: | |
if not(word in SKIPS): | |
food = food + " " + word | |
continue | |
food = food + " " + word #If multiple keywords follow each other | |
break # take all of them in account and the word | |
# that follows them as well e.g. "The best burger" | |
food = food.strip(' ') # Make the string neat for printing it out | |
return food |