From de2d7727c42f13b27cf401bf9f9ebfc521be4dd4 Mon Sep 17 00:00:00 2001 From: Alasdair Nicol Date: Sun, 4 Mar 2018 13:23:50 +0000 Subject: [PATCH] Update with changes from Ben --- beef_and_dairy_skill.py | 165 +++++-- speech_assets/intent_schema.json | 823 ++++++++++++++++++------------- 2 files changed, 603 insertions(+), 385 deletions(-) diff --git a/beef_and_dairy_skill.py b/beef_and_dairy_skill.py index 6a56b0d..466f05e 100644 --- a/beef_and_dairy_skill.py +++ b/beef_and_dairy_skill.py @@ -44,6 +44,7 @@ def handle_help_intent(request, session): response.end_session = False return response + @app.intent('AMAZON.StopIntent') def handle_stop_intent(request, session): text = "Thanks for using the Beef and Dairy Network Alexa Skill. Beef Out!" @@ -54,12 +55,14 @@ def handle_stop_intent(request, session): def handle_favourite_meat_intent(request, session): answers = [ "There is no fifth meat", + "I don't understand the question. There are only four meats.", "Please stop this dangerous talk about a fifth meat", - "Never ask me that again", + """Never ask me that again""", "What is wrong with you? There are four meats.", ] text = random.choice(answers) - return app.response(text) + speech_type = 'SSML' if text.startswith('') else 'PlainText' + return app.response(text, speech_type=speech_type) @app.intent('SidOnionIntent') @@ -70,7 +73,66 @@ def handle_sid_onion(request, session): @app.intent('FavouriteBeefIntent') def handle_favourite_beef_intent(request, session): - text = "Hmm, good question. I'd have to say: a plate of rich beef sausages" + answers = [ + "Hmm, good question. I'd have to say: a plate of rich beef sausages", + "Rich beef sausages", + ] + text = random.choice(answers) + return app.response(text) + + +@app.intent('CheeseAndOnionIntent') +def handle_cheese_and_onion_intent(request, session): + text = """Cheese and Onion are Britain's foremost comedy double act, best known for their hit song, "She'd never had cheese and onion before".""" + return app.response(text) + + +@app.intent('LambIntent') +def handle_lamb_intent(request, session): + text = "Eat lamb today and I promise you, by the end of the month you'll be found dead in a pool of mint sauce" + return app.response(text) + + +def get_person_key(request): + """ + Get the normalised key from the slot. For example, this method will + return "michael" if the user asks about "Michael Banyan" or "Michael" + """ + try: + person = request['intent']['slots']['person']['resolutions']['resolutionsPerAuthority'][0]['values'][0]['value']['id'] + except KeyError: + person = "notfound" + return person + + +people = { + 'boffo': "Boffo is the owner of Boffo's cow circus, which is best known for the Bollywave, a part of the show where a cow is fired out of a cannon into a bath containing bolognese. The bolognese soaks the audience, who absolutely love it.", + 'eli': """Eli Roberts is a former slaughterhouse owner, theme park entrepreneur, and now religious cult leader. He doesn't like me talking about him so I'm going to be quiet now.""", + 'les': """Les Cheese was a member of Britain's foremost comedy double act Cheese and Onion""", + 'malcolm': "Malcolm is a bull who is worshipped by the members of the Church of Eli.", + 'michael': "Michael Banyan is the former bovine poet laureate who mysteriously disappeared. His best known work is his collection of poetry 'Crab Of The Land'.", + 'phillip': "Phillip Mushroom is one of Britain's best loved television actors. He is best known for his roles in 'Beef Justice', 'Bankside', and 'Bankside: The Movie'. He is famous for acting with his back to the camera.", + 'roy': "Roy Gluck Junior is the CEO of fast food restaurant, Burgers Barrel.", + 'david': """Dr David Pin is a researcher from the European Space Agency. He claims to have discovered evidence of the so-called fifth meat, but he hasn't been seen since.""", +} + + +@app.intent('PersonIntent') +@app.slot('person') +def handle_person_intent(request, session, person): + try: + person_key = get_person_key(request) + text = people[person_key] + except KeyError: + text = f"I'm sorry, I don't know about {person}" + + speech_type = 'SSML' if text.startswith('') else 'PlainText' + return app.response(text, speech_type=speech_type) + + +@app.intent('WhereIsMichaelIntent') +def handle_where_is_michael_intent(request, session): + text = "Michael Banyan is in a secret location. If his whereabouts was revealed, he would be in grave danger from the Bovine Farmers' Union who have already sewn a cow's face onto his face." return app.response(text) @@ -86,50 +148,67 @@ def handle_beef_plural_intent(request, session): return app.response(text) +meats = { + 'beef': 'Beef is one of the four meats', + 'lamb': 'lamb is one of the four meats', + 'pork': 'pork is one of the four meats', + 'chicken': 'chicken is one of the four meats', + 'turkey': 'turkey is simply a robust chicken', + 'venison': 'venison is forest beef', + 'tuna': 'tuna is a type of fish, although some scientists believe that it can be categorized as a beef', + 'goat': 'goat is mountain lamb', + 'horse': 'horse is ride-on beef', + 'weasel': 'weasel is small long porkmeat', + 'sparrow': 'sparrow is mini chicken', + 'giraffe': 'giraffe is long necked savannah beef', + 'lizard': 'lizard is scaled pork', + 'peregrine falcon': 'all falcons are sleek speed chicken', + 'spider': 'eight legged micro beef', + 'snow leopard': 'snow leopard is himalayan fanged pork', + 'kangaroo': 'kangaroo is a type of antipodean pork meat', + 'fish': 'fish is fish', + 'rabbit': 'rabbit is hedgerow pork', + 'pheasant': 'pheasant is posh chicken', + 'quail': 'quail is weird chicken', + 'salmon': 'salmon is a type of fish, although some scientists believe that it can be categorized as chicken', + 'prawns': 'prawns are a type of fish, although some scientists believe that it can be categorized as a beef', + 'veal': 'veal is young male beef', + 'partridge': "partridge is God's chicken", + 'pigeon': 'pigeon is urban chicken', + 'duck': 'duck is floating chicken', + 'insects': 'insects are small gross porkmeats', + 'snails': 'snails are a type of beef', + 'seafood': 'seafood is fish', + 'reindeer': 'reindeer is tundra forest beef', + 'hedgehog': 'hedgehog is a type of hedgerow porkmeat and is a lovely tender meat', + # FIXME missing meats + # 'crab': 'crab is a type of ', + # 'goose': 'goose is a type of ', + # 'buffalo': 'buffalo is a type of ', + # 'seal': 'seal is a type of ', + # 'whale': 'whale is a type of ', +} + + @app.intent('WhichMeatIntent') @app.slot('meat') def handle_which_meat_intent(request, session, meat): - meats = { - 'beef': 'Beef is one of the four meats', - 'lamb': 'lamb is one of the four meats', - 'pork': 'pork is one of the four meats', - 'chicken': 'chicken is one of the four meats', - 'turkey': 'turkey is simply a robust chicken', - 'venison': 'venison is forest beef', - 'tuna': 'tuna is a type of fish, although some scientists believe that it can be categorized as a beef', - 'goat': 'goat is mountain lamb', - 'horse': 'horse is ride-on beef', - 'weasel': 'weasel is small long porkmeat', - 'sparrow': 'sparrow is mini chicken', - 'giraffe': 'giraffe is long necked savannah beef', - 'lizard': 'lizard is scaled pork', - 'peregrine falcon': 'all falcons are sleek speed chicken', - 'spider': 'eight legged micro beef', - 'snow leopard': 'snow leopard is himalayan fanged pork', - 'kangaroo': 'kangaroo is a type of antipodean pork meat', - 'fish': 'fish is fish', - 'rabbit': 'rabbit is hedgerow pork', - 'pheasant': 'pheasant is posh chicken', - 'quail': 'quail is weird chicken', - 'salmon': 'salmon is a type of fish, although some scientists believe that it can be categorized as chicken', - 'prawns': 'prawns are a type of fish, although some scientists believe that it can be categorized as a beef', - 'veal': 'veal is young male beef', - 'partridge': "partridge is God's chicken", - 'pigeon': 'pigeon is urban chicken', - 'duck': 'duck is floating chicken', - 'insects': 'insects are small gross porkmeats', - 'snails': 'snails are a type of beef', - 'seafood': 'seafood is fish', - 'reindeer': 'reindeer is tundra forest beef', - 'hedgehog': 'hedgehog is a type of hedgerow porkmeat and is a lovely tender meat', - # FIXME missing meats - # 'crab': 'crab is a type of ', - # 'goose': 'goose is a type of ', - # 'buffalo': 'buffalo is a type of ', - # 'seal': 'seal is a type of ', - # 'whale': 'whale is a type of ', - } text = meats.get(meat) if not text: text = f"Hmm, I'm not sure which one of the four meats {meat} is." return app.response(text) + + +@app.intent('BanyanPoemIntent') +def handle_banyan_poem_intent(request, session): + text = """ + Soft as a mother, smooth as a latte, + a beefy oblong with the eyes of an angel, + black as night and white as snow, + you're like an edible domino, + or a coat hanger whose burden isn't shirts but meat. + Stand up. + Raise a glass and give yourself a hand. + You are, the crab of the land. + """ + return app.response(text) diff --git a/speech_assets/intent_schema.json b/speech_assets/intent_schema.json index 3b72d5d..1d0a962 100644 --- a/speech_assets/intent_schema.json +++ b/speech_assets/intent_schema.json @@ -1,347 +1,486 @@ { - "languageModel": { - "types": [ - { - "name": "MeatType", - "values": [ - { - "id": null, - "name": { - "value": "beef", - "synonyms": [] + "languageModel": { + "invocationName": "beef dairy network", + "intents": [ + { + "name": "AMAZON.CancelIntent", + "slots": [], + "samples": [] + }, + { + "name": "AMAZON.HelpIntent", + "slots": [], + "samples": [] + }, + { + "name": "AMAZON.StopIntent", + "slots": [], + "samples": [ + "quit" + ] + }, + { + "name": "BeefPluralIntent", + "slots": [], + "samples": [ + "What is the plural of beef" + ] + }, + { + "name": "FavouriteBeefIntent", + "slots": [], + "samples": [ + "What is your favourite food", + "What is your favourite beef meal", + "What is your favourite beef dish", + "What is your favourite type of beef" + ] + }, + { + "name": "FifthMeatIntent", + "slots": [], + "samples": [ + "What is the fifth meat", + "Is there a fifth meat" + ] + }, + { + "name": "HowManyMeatsIntent", + "slots": [], + "samples": [ + "How many meats are there", + "What are the four meats", + "What are the four types of meat", + "How many types of meat are there" + ] + }, + { + "name": "SidOnionIntent", + "slots": [], + "samples": [ + "Where is Sid Onion", + "Is Sid Onion still in jail", + "Has Sid Onion been freed yet", + "Had Sid been freed yet", + "Is Sid still in jail", + "Where is Sid" + ] + }, + { + "name": "WhichMeatIntent", + "slots": [ + { + "name": "meat", + "type": "MeatType" + } + ], + "samples": [ + "What type of meat is {meat}", + "Which type of meat is {meat}", + "What is {meat}", + "Which meat is {meat}" + ] + }, + { + "name": "CheeseAndOnionIntent", + "slots": [], + "samples": [ + "What are Cheese and Onion", + "Who are Cheese and Onion" + ] + }, + { + "name": "LambIntent", + "slots": [], + "samples": [ + "Is lamb really as dangerous as they say it is", + "Is lamb dangerous", + "Do you like lamb", + "Should I eat lamb" + ] + }, + { + "name": "PersonIntent", + "slots": [ + { + "name": "person", + "type": "BeefPersonality" + } + ], + "samples": [ + "What is {person}", + "Tell me about {person}", + "Who is {person}" + ] + }, + { + "name": "BanyanPoemIntent", + "slots": [], + "samples": [ + "Read me some Michael Banyan", + "Read me something by Michael Banyan", + "Read me Crab Of The Land", + "Read me a poem", + "Read me a Michael Banyan poem " + ] + }, + { + "name": "WhereIsMichaelIntent", + "slots": [], + "samples": [ + "where is michael", + "Where is michael banyan" + ] } - }, - { - "id": null, - "name": { - "value": "lamb", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "pork", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "chicken", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "turkey", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "venison", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "tuna", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "goat", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "horse", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "weasel", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "sparrow", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "giraffe", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "lizard", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "peregrine falcon", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "spider", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "snow leopard", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "kangaroo", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "fish", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "rabbit", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "pheasant", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "quail", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "salmon", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "prawns", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "veal", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "partridge", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "pigeon", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "duck", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "insects", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "snails", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "seafood", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "reindeer", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "hedgehog", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "crab", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "goose", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "buffalo", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "seal", - "synonyms": [] - } - }, - { - "id": null, - "name": { - "value": "whale", - "synonyms": [] - } - } - ] - } - ], - "intents": [ - { - "name": "AMAZON.CancelIntent", - "samples": [] - }, - { - "name": "AMAZON.HelpIntent", - "samples": [] - }, - { - "name": "AMAZON.StopIntent", - "samples": [ - "quit" - ] - }, - { - "name": "BeefPluralIntent", - "samples": [ - "What is the plural of beef" - ], - "slots": [] - }, - { - "name": "FavouriteBeefIntent", - "samples": [ - "What is your favourite beef dish", - "What is your favourite type of beef" ], - "slots": [] - }, - { - "name": "FifthMeatIntent", - "samples": [ - "What is the fifth meat", - "Is there a fifth meat" - ], - "slots": [] - }, - { - "name": "HowManyMeatsIntent", - "samples": [ - "How many meats are there", - "What are the four meats", - "What are the four types of meat", - "How many types of meat are there" - ], - "slots": [] - }, - { - "name": "SidOnionIntent", - "samples": [ - "Where is Sid Onion", - "Is Sid Onion still in jail", - "Has Sid Onion been freed yet", - "Had Sid been freed yet", - "Is Sid still in jail", - "Where is Sid" - ], - "slots": [] - }, - { - "name": "WhichMeatIntent", - "samples": [ - "What type of meat is {meat}", - "Which type of meat is {meat}", - "What is {meat}", - "Which meat is {meat}" - ], - "slots": [ - { - "name": "meat", - "type": "MeatType" - } + "types": [ + { + "name": "MeatType", + "values": [ + { + "id": "", + "name": { + "value": "beef", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "lamb", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "pork", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "chicken", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "turkey", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "venison", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "tuna", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "goat", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "horse", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "weasel", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "sparrow", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "giraffe", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "lizard", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "peregrine falcon", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "spider", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "snow leopard", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "kangaroo", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "fish", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "rabbit", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "pheasant", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "quail", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "salmon", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "prawns", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "veal", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "partridge", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "pigeon", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "duck", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "insects", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "snails", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "seafood", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "reindeer", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "hedgehog", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "crab", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "goose", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "buffalo", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "seal", + "synonyms": [] + } + }, + { + "id": "", + "name": { + "value": "whale", + "synonyms": [] + } + } + ] + }, + { + "name": "BeefPersonality", + "values": [ + { + "id": "david", + "name": { + "value": "Dr David Pin", + "synonyms": [ + "Dr Pin", + "David Pin" + ] + } + }, + { + "id": "les", + "name": { + "value": "Les Cheese", + "synonyms": [ + "les" + ] + } + }, + { + "id": "boffo", + "name": { + "value": "Boffo", + "synonyms": [ + "boffo's clown circus" + ] + } + }, + { + "id": "malcom", + "name": { + "value": "Malcolm the bull", + "synonyms": [ + "malcolm" + ] + } + }, + { + "id": "michael", + "name": { + "value": "Michael Banyan", + "synonyms": [ + "poet laureate", + "the poet laureate" + ] + } + }, + { + "id": "roy", + "name": { + "value": "Roy Gluck Junior", + "synonyms": [ + "Roy", + "Roy Gluck" + ] + } + }, + { + "id": "eli", + "name": { + "value": "Eli Roberts", + "synonyms": [ + "Eli" + ] + } + }, + { + "id": "phillip", + "name": { + "value": "Phillip Mushroom", + "synonyms": [ + "philip", + "phil mushroom", + "phillip", + "philip mushroom" + ] + } + } + ] + } ] - } - ], - "invocationName": "beef dairy network" - } + } }