from furback import furby from furback import yelp import random text = furby.get_input() search = None terms = ["bar", "restaurant", "dinner", "lunch", "brunch", "cafe", "coffee"] for term in terms: if term in text: search = term break businesses = yelp.search(search, limit=10) current_business = None def say_business(): global current_business business = random.choice(businesses) businesses.remove(business) current_business = yelp.business(business['id']) furby.say("You should check out %s, it is rated %d stars on Yelp." % (business['name'], int(business['rating']))) def say_review(): if "reviews" in current_business and current_business['reviews']: review = random.choice(current_business["reviews"]) current_business['reviews'].remove(review) furby.say("%s said: %s" % (review["user"]["name"], review["excerpt"])) else:
additional_words = ["who","actor","star","about","good"] def Handle(query): global film if "theater" in query or "movie" in query: film = RandomFilmInTheaters() furby.say("Go see %s." % film['title']) elif film and "who" in query or "actor" in query or "star" in query: actor = random.choice(film["abridged_cast"]) furby.say("It's starring %s as %s. %s." % (actor["name"], actor["characters"][0], random.choice(["What a hottie","I don't like them", "I love them", "What a hearthrob", "I'd see that", "LAME", "I'd tap that"]))) elif film and "about" in query: syn = film['synopsis'] ix = syn.index('.') if ix != -1: furby.say(syn[:ix]) else: furby.say(syn[:50]) elif film and "good" in query: furby.say("%s" % RatingOpinion(film["ratings"]["audience_score"])) query = furby.listen_for(additional_words, timeout=30.0) Handle(query) if __name__ == "__main__": query = furby.get_input() Handle(query)