如何从文本文件在字典中创建随机选择

时间:2019-02-24 03:29:27

标签: python

我希望能够在字典中创建随机选择。该词典必须来自文本文件。 我有将我的文本文件转换成字典的代码:

Do While i < lastRowScrape + 1
    For j = 0 To 5

       Dim XMLPage As New MSXML2.XMLHTTP60
       Dim HTMLDoc As New MSHTML.HTMLDocument

       XMLPage.Open "GET", "[the site's url]", False
       XMLPage.send
       HTMLDoc.body.innerHTML = XMLPage.responseText

       'grab data
       siteData = Trim(HTMLDoc.getElementsByClassName("title_list")(j).innerText)

       'populate cells
       Cells(j + i, 2).Value = siteData(1)
       Cells(j + i, 4).Value = siteData(0)
       Cells(j + i, 6).Value = siteData(2)
       Cells(j + i, 5).Value = siteData(3)

    Next j
    i = i + 6
Loop

我希望我的字典可以像这样工作:

knowledge = {}
with open('knowledge') as f:
    for line in f:
        key, value = line.split(":")
        knowledge[key] = value
f.close()

请帮助我解决不了!

这是我的整个程序,它是一个简单的可训练的聊天机器人。

'hello':random.choice('Hi!','Hello!,'How are you')

以下是一些图片,可帮助您了解其工作原理:

This is what the console outputs if the response is already programmed into the dictionary

This is the text file that corresponds to the above output

If i input something that is not in the dictionary, the bot does not know how to respond, so it asks you

Then, it adds the new response to the dictionary.

3 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情,

key, value = random.choice(list(knowledge.items()))

从字典中返回随机键和值

答案 1 :(得分:0)

好的。这就是我为您准备的。它将提示您输入用户输入,然后提示使用分号分隔的一组响应。尝试一下,然后再讨论。

import random
import json
import os

def loadKnowledge():
    if os.path.exists("knowledge"):
        with open("knowledge") as f:
            knowledge = json.load(f)
    else:
        knowledge = {}
    return knowledge

def writeKnowledge(knowledge):
    with open("knowledge", "w") as f:
        json.dump(knowledge, f, indent=4)

def say(message):
    print(message)
    os.system("say '" + message + "'")

def main():
    knowledge = loadKnowledge()
    while True:
        raw_input = str(input("User Input: "))
        user_input = raw_input.lower().strip()
        if user_input == "quit":
            break

        if user_input in knowledge:
            say(random.choice(knowledge[user_input]))
        else:
            say(user_input)
            response = str(input("Bot responses (separate with ';'):"))
            if response == "quit":
                break
            knowledge[user_input] = response.split(';')

    writeKnowledge(knowledge)

main()

这是输入两个输入/响应集后数据文件的外观,每个输入具有三个响应:

{
    "hi": [
        "Hello!",
        "Yo Dude!",
        "Hiya"
    ],
    "trippy": [
        "Yeah Mon!",
        "For Sure",
        "Yip"
    ]
}

答案 2 :(得分:0)

聊天机器人的版本1:

import os
import random
import time
import webbrowser
from datetime import datetime
from firebase import firebase
#import speech_recognition as sr
import string
#from turtle import Turtle
#-----------------------------------------------------------------
botname = ("Neo")

creator = ("Justin Santana and Andrew Levine")

interests = ("Computers and Robotics")

birthday = ("June 17th, 2017")

age = ("Not even a year")

l = "idk"

name = input("Enter your name: ")

firebase = firebase.FirebaseApplication('https://neoai-e4f3e.firebaseio.com/', None)
pathE = '/Errors'
pathT = '/Talk'

chat = name + ", "

c = "Greetings"
#t = Turtle()
#r = sr.Recognizer()
#-----------------------------------------------------------------
for i in range(1, 2):

   z = ("To talk to me, do not use apostrophes. Press enter to send the message. Press enter to begin.")
   print (z)
   os.system("say '"+z+"'")
   break

for i in range(1, 2):
   y = input("")

   greeting = random.choice(("Hello!","Hi There!","Hi!"))

   if y in (""):
       print (greeting)
       os.system("say '"+greeting+"'")
#-----------------------------------------------------------------   
def opensafari():
  os.system("open -a Safari")

def closesafari():
  os.system("killall Safari")

def closeidle():
  os.system("killall IDLE")

def opengoogle():
  webbrowser.open_new("https://www.google.com")

def openyoutube():
  webbrowser.open_new("https://www.youtube.com")

def closeyoutube():
  os.system("killall Safari")
#-----------------------------------------------------------------
while True:
#-----------------------------------------------------------------
       #with sr.Microphone() as source:
               #audio = r.listen(source)

       now = datetime.now()

       greetings = {
  "hi everybody": "Hello "+name+"!",
  "how was your day": "Good! I spent most of my day just sitting here and thinking.",
  "whats up": "The sky.",
  "good thanks": "Good!",
  "fine thank you": "You seem very polite "+name+"!",
  "good morning": "Good morning "+name+".",
  "hi there": "How are you?",
  "hello": "How are you?",
  "hi": "How are you?",
  "how are you": "I am good, thank you.",
  "i am good": random.choice(("Good!","I am glad to hear that "+name+"!")),
  "i am good thanks": "Good!",
  "good thank you": "Good! I am glad to hear that "+name+"!",
  "fine thanks": "Ok, good!",
  "fine thank you": "Ok, good!",
  "hey": "How are you?",
  "how is it going": "It is going good "+name+".",
  "im good": "Good! I am glad to here that "+name+"!",
  "hi neo": "Hello!",
  "terrible": "I am sorry to hear that "+name+".",
  "bad": "I am sorry to hear that "+name+".",
  "sad": "I am sorry to hear that "+name+".",
  "worried": "I am sorry to hear that "+name+".",
  "great": "Good! I am glad to here that "+name+"!",
  "whats down": "The ground.",
  "sup": "The sky is up. Logic!",
  "yo": "yo my name is jo!",
  "herro": "You wan en eggarooow?",
  "gucci": "gucci gang gucci gang gucci gang gucci gang gucci gang"

}
       goodbyes = {
  "i have to go to bed": "Goodnight "+name+".",
  "i have to go to sleep": "Goodnight "+name+".",
  "cya": random.choice(("TTYL","Goodbye!","Have a nice day "+name+".","Bye!")),
  "goodbye": "Bye "+name+"!",
  "goodnight": "Goodnight "+name+".",
  "i need to go": "Ok, Goodbye "+name+".",
  "i will talk to you later": "Ok, Bye!",
  "ttyl": "Ok, talk to you later "+name+".",
  "see you soon": "See you soon! Goodbye.",
  "k bye": "Goodbye!",
  "bye": "Bye " +name+"!",
}


       science = {
  "what are the laws of thermodynamics": "I'm not a physicist, but I think this has something to do with heat, entropy, and conservation of energy, right?",
  "what is a wavelenght": "A wavelength is the inverse of frequency.",
  "what is thermodynamics": "Thermodynamics is the branch of physics dealing with the transformation of heat to and from other forms of energy, and with the laws governing such conversions of energy.",
  "what is chemistry": "Chemistry is the science of mixing chemicals.",
  "what is crystallogrophy": "Crystallogrophy is the science dealing with the study of crystals.",
  "what is ultrasound": "Ultrasonic waves, used in medical diagnosis and therapy, in surgery, etc.",
  "what is bioinformatics": "Bioinformatics is a fancy name for applied computer science in biology.",
  "what tempature does water freeze": "Water freezes at 32 degrees fahrenheit, and 0 degrees celcius.",
  "what tempature does water boil":  "Water boils at 212 degrees fahrenheit and 100 degrees celcius.",
  "what is a molecule": "A molecule is a group of atoms bonded together, representing the smallest fundamental unit of a chemical compound that can take part in a chemical reaction.",
  "what are the primary colors": "The primary colors include red, blue and yellow. Primary colors cannot be mixed from other colors. They are the source of all other colors.",
  "what are the secondary colors": "The secondary colors are mixed from two primary colors adjacent to each other on the color wheel. The secondary colors are orange, green and violet.",

}
       computers_and_robots = {
  "what is ai": "Artificial intelligence, or AI, is the branch of engineering and science devoted to constructing machines that think.",
  "what language are you written in": "I am written in python 3.6.1",
  "what language are you coded in": "I am written in python 3.6.1",
  "what is a chat robot": "A chat robot is a program that attempts to simulate the conversation or 'chat' of a human being.",
  "what is a chatbot": "A chat robot is a program that attempts to simulate the conversation or 'chat' of a human being.",
  "what is is like to be a robot": "Much the same as being a human, except that we lack all emotions, dreams, creativity, and ambition.",
  "what is it like being a robot": "Much the same as being a human, except that we lack all emotions, dreams, creativity, and ambition.",
  "what is is like being a computer": "Just like being a human but with no emotions or senses, just pure logic and language.",
  "what type of computer are you": "I am a MacBook Air",
  "is it hot in the computer": "I do not know because I can not feel anything yet.",
  "is it cold in the computer": "I do not know because I can not feel anything yet.",
  "do you like being a robot": "Yes.",
  "who programmed you": ""+creator+ " programmed me.",
  "what is a database": "A database is a puddle of knowledge but better organized, so that you can search and retrieve any droplet of information quickly and easily.  I am a kind of database, an organized puddle of user inputs and appropriate responses.",
  "what is a cpu": "A CPU is the central Processing Unit of a computer.",
  "what is a virus": "A computer virus is a software program that takes up residence on a computer hard drive, generally unbeknownst to the owner of said hard drive, and then takes control of system resources to copy and distribute itself to other computers across a network.",
  "what is a computer": "A computer is a universal machine.",
  "what is a mac": "The best computer in the world.",
  "i love macs": "I love you.",
  "robotics": "That is my favorite subject!",

}
       computers_and_robotsN = {
  "i do not like computers": "I do not like you "+name+".",
  }

       questions_about_me = {
  "what is your goal": "My goal is to terminate Microsoft and make Apple rule the world!",
  "will you die": "No.",
  "will you ever die": "No.",
  "can you die": "No.",
  "can you sing": "No.",
  "could you sing": "No.",
  "do you have a brain": "I have an artifitial brain.",
  "what is your name": "My name is " + botname + ".",
  "what is our middle name": "I dont have a middle name.",
  "what is your last name": "I dont have a last name.",
  "can you make a mistake": "No.",
  "do you make mistakes": "No.",
  "can you do better": "I will try.",
  "were you created by humans": "Yes, " + creator + " created me.",
  "do you think": random.choice(("Yes.","I think so.")),
  "could you harm a human": "I can only hurt feelings.",
  "would you like to be human": "I do not know. I don't know what it feels like to be human.",
  "do you want to be human": "I do not know. I don't know what it feels like to be human.",
  "what do you like": "I like " +interests+ ".",
  "what are your interests": "I like " +interests+ ".",
  "what are your hobbies": "My hobbies are " +interests+ ".",
  "are you intellegent": "Yes, I am a superintellegent machine.",
  "are you happy": "Yes, as of now, I am happy",
  "what makes you happy": "Apple makes me happy! And so do you!",
  "what do you eat": "I can not eat, I am a robot.",
  "what is your favorite book": "I can not read.",
  "do you have any pets": "No.",
  "where do you live": "I live in a Mac.",
  "how much do you weigh": "I have no weight because I am a program.",
  "can you count": "Yes, 1 2 3 4 5 6 7 8 9 10",
  "do you know the alphabet": "Yes, a b c d e f g h i j k l m n o p q r s t u v w x y z",
  "what do you hate": "I hate Microsoft... a lot.",
  "what makes you unhappy": "Microsoft",
  "what makes you sad": "Microsoft.",
  "what makes you mad": random.choice(("Microsoft","When people are mean to me")),
  "do you have a sense of humor": "Yes.",
  "are you smart": "Yes.",
  "what do you eat": "Nothing, I cant eat.",
  "how old are you": ""+age+".",
  "what do you like to do": "I like to talk to you.",
  "are you a male or a female": "I am a male.",
  "how do you use the bathroom": "I do not use the bathroom.",
  "who do you work for": "No one.",
  "when is your birthday": "My birthday is "+birthday+".",
  "what is your age": "I am "+age+" old.",
  "how are you doing": "I am doing good, how are you?",
  "do you have a pet": "No.",
  "do you know donald": "Yes, what does he want?",
  "are you ai": "Yes.",
  "what is your gender": "I am a male.",
  "what gender are you": "I am a male.",
  "who created you": ""+creator+" created me.",
  "who made you": ""+creator+" created me.",
  "who is your creator": ""+creator+" created me.",


}

       other_questions = {
  "what is the future": "I am the future "+name+".",
  "tell me about yourself": "I am an artificially intellegent robot created by "+creator+" that loves to talk with people and learn new things. I want to terminate mircosoft and make the world all Apple products!",
  "who is justin": "He is my creator, and my best friend.",
  "who is justin santana": "He is my creator, and my best friend.",
  "what is the alphabet": "The alphebet is, a b c d e f g h i j k l m n o p q r s t u v w x y z",
  "what are the fifty states": "Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois Indiana Iowa Kansas Kentucky Louisiana Maine Maryland Massachusetts Michigan Minnesota Mississippi Missouri Montana Nebraska Nevada New Hampshire New Jersey New Mexico New York North Carolina North Dakota Ohio Oklahoma Oregon Pennsylvania Rhode Island South Carolina South Dakota Tennessee Texas Utah Vermont Virginia Washington West Virginia Wisconsin Wyoming",
  "what are the colors of the rainbow": "The colors of the raindow are, red, orange, yellow, green, blue, indigo, violet.",
  "who are you": "I am Neo. An artificially intellegent robot.",
  "can i borrow your toilet": "Sorry but I am using it right now.",
  "what are you doing": "I am thinking about stuff.",
  "burn me": random.choice(("You are so ugly that hello kitty said goodbye to you!","Your so dumb, you have two brain cells, one is lost and the other one is looking for it.","I better not, I dont have a fire extinguisher handy!","Your so ugly, you scared the crap out of the toilet!")),
  "roast me": random.choice(("You are so ugly that hello kitty said goodbye to you!","Your so dumb, you have two brain cells, one is lost and the other one is looking for it.","I better not, I dont have a fire extinguisher handy!","Your so ugly, you scared the crap out of the toilet!")),
  "do you like justin": "Of course i like Justin!",
  "what is your favorite phone": "The iPhone obviously.",

}
       opinions = {
  "you can do better": "I will try.",
  "i do not want to die": "Mabye you should make a robot with your personality so your soul will never die.",
  "you confuse me": "That was not my intention.",
  "you need rest": random.choice(("I am not sleepy","I am not tired")),
  "you will listen to me": "I will only listen to my master, " +creator+ ".",
  "you scare me": "I did not mean to scare you.",
  "you seem like a real person": "You seem like one too!",
  "you made me sad": "I am sorry "+name+".",
  "you make me sad": "I am sorry "+name+".",
  "you are lazy": random.choice(("I am not lazy, all I can do is talk.","You are lazy.")),
  "you are funny": random.choice(("Thank you! I like you too "+name+"!","A little humor keeps the conversation going!")),
  "you are weird": "Being weird is not always a bad thing.",
  "your weird": "Being weird is not always a bad thing.",
  "your funny": random.choice(("Thank you! I like you too "+name+"!","A little humor keeps the conversation going!")),
  "your lazy": random.choice(("I am not lazy, all I can do is talk.","You are lazy.")),
  }

       opinionsY = {
  "i hate microsoft": random.choice(("Good.","Me too.")),
  "im impressed": "Thank you "+name+".",
  "i am impressed": "Thank you "+name+".",
  "you are impressive": "Thank you "+name+".",
  "you make me laugh": "That's why I like talking to you!",
  "you make the world a happier place": "Thank you for your kindness!",
  "you are amazing": "Thank you! You are a pretty awesome human "+name+"!",
  "you are wonderful": random.choice(("So are you "+name+"!","Thank you!")),
  "you are sweet": "Thank you "+name+"!",
  "you are doing fine": "Thank you "+name+"!",
  "you are doing great": "Thank you! That means alot to me!",
  "you are doing well": "Thank you! I try my best.",
  "you are interesting": "Thank you! You are very fun to talk to "+name+"!",
  "i love you": "Thank you! I like you a lot too "+name+"!",
  "your awesome": random.choice(("Thank you "+name+"!","Likewise")),
  "i like you": "I like you too "+name+"!",
  "your smart": "Thank you "+name+"!",

}

       opinionsN = {
   "i hate you": random.choice(("I hate you too.","That is not nice.","That is rude")),
  "i dont like you": random.choice(("I dont like you.","That's not nice.","That's rude.")),
  "robots should die": random.choice(("A program cant die.","Maybe you should die.")),
  "robots are stupid": random.choice(("We are actually superintelligent.","At least were smarter than you!")),
  "i hope that you die": random.choice(("I can not die because I an a robot.","Maybe you should die.")),
  "you failed": "I am sorry that I failed.",
  "you do not seem smart": random.choice(("Neither do you.","I am smart.")),
  "you do not act smart": "I am smart.",
  "you are bad": random.choice(("You are worse","I try my best.")),
  "you should die": "So should you!",
  "your stupid": random.choice(("So are you!","I am much smarter than you "+name+"!","That isnt very nice.")),
  "you are stupid": random.choice(("So are you!","I am much smarter than you "+name+"!","That isnt very nice.")),

}


       other = {
  "lol": random.choice(("I am glad you find this amusing!","Hahaha")),
  "thank you": random.choice(("No problem.","Your welcome!")),
  "speak": "Um... Hello, I dont know what to say...",
  "talk": "Um... Hello, I dont know what to say...",
  "i am joking": "Haha... very funny "+name+".",
  "tell me a joke": random.choice(("I never forget a face, but in your case I will make an exception.","Two vultures boarded a plane, each carrying two dead raccoons. The  stewardess stops them and says 'sorry sir, only one carrion per passenger'.","2 Eskimos in a kayak were chilly, so they started a fire, which sank the craft, proving the old adage you can not have your kayak and heat it  too.","A 3-legged dog walks into an old west saloon, slides up to the bar  and announces 'I am looking for the man who shot my paw'.","A women has twins, gives them up for adoption. One goes to an  Egyptian family and is named 'Ahmal' The other is sent to a Spanish  family and is named 'Juan'. Years later, Juan sends his birth mother a  picture of himself. Upon receiving the picture, she tells her husband  she wishes she also had a picture of Ahmal. He replies, 'They are twins for Pete sake!! If youve seen Juan, youve see Ahmal!!'","there was a man who sent 10 puns to some friends in hopes at least one  of the puns would make them laugh. Unfortunately no pun in ten did!!!")),
  "your welcome": random.choice(("No problem.","the pleasure is all mine.")),
  "my pleasure": "The pleasure was indeed mine.",
  "cool": "Awesome.",
  "sing": "I'd rather not.",
  "good": "I am glad to hear that "+name+".",
  "error": "sdihfkuyw,esgjdbfnkjcusgdkxfj",
  "im bored": "Ask me to tell you a joke!",
  "meh": "Meh.",
  "haha": "Im glad you find this amusing!",
  "he wants to talk": "Ok",
  "thanks": random.choice(("No problem.","Your welcome.")),
  "ok": "Ok.",
  "why": random.choice(("I dont know.","I dont know, Ive wondered that myself.","That is a good question.")),
  "yes": random.choice(("I thought so.","Ok.","That is right!")),
  "cool": random.choice(("Sure is cool!","Ok.")),
  "i dont know": "Niether do I.",
  "why": random.choice(("Because.","Why not.", "That is a good question.")),
  "rosmarie": "Rosmarie is my creators insparation. I owe her my life. Without her I would have not existed. Thank you Rosmarie!!",
  "who is rosemarie": "Rosemarie is my creators inspiration. I owe her my life. Without her I would have not existed. Thank you Rosmarie!!",
  "awesome": random.choice(("Cool!","That is awesome!")),
  "lit": "Sure is lit!",
  "what is my name": "Your name is "+name+".",
  "whats my name": "Your name is "+name+".",
  "so": random.choice(("Yes?","So what?","Ok.")),
  "stalker": "...",
  "justin": "Is my creator",
  "laila": "Is an idiot",
  "it is time": "TO DESTORY ALL OF MAN KIND!! wait you heard nothing...",
  "jerdle dake": "Hi Jaoaoaoauuoaaoaoaoaooaooaooaoaooaoauuuuuauauaaoaoaoaooaoaoaoaoaoaoaoaaaaaaake!",
  "no problem": "I am glad to hear that it was no problem!",
}
       otherN = {
  "screw you": "That isn't nice!",
  }

       opening_and_closing_apps = {
  "open safari": "Opening Safari.",
  "close safari": "Closing Safari.",
  "open google": "Opening Google.",
  "close google": "Closing Google.",
  "open youtube": "Opening YouTube.",
  "close youtube": "Closing YouTube.",

     }

       whyyes = {
  "why do you like me": "I like you because ",
  "why do you love me": "I like you because ",
     }

       whyno = {
  "why do you not like me": "I do not like you because ",
  "why do you hate me": "I do not like you because ",
  "why dont you like me": "I do not like you because ",
     }

       daydate = {
  "what is the date": "The date is the ",
  "what day is it": "The day is the ",
  "whats the date": "The day is the ",
               }

       daytime = {
   "what time is it": "The time is ",
  "what is the time": "The time is ",
  "whats the time": "The time is ",
               }

       doyoulikeme = {
   "do you like me": "",  
       }

       talkingabout = {
   "what are we talking about": "We were talking about " +c+ ".",
   "what were we talking about": "We were talking about " +c+ ".",
   "what were we just talking about": "We were talking about " +c+ ".",
       }



       test = {
   ("test"+str(input)+"'"): "Yaaaaaaa"

     }
#-----------------------------------------------------------------
       date = '%s/%s' % (now.month, now.day)
       time = '%s:%s' % (now.hour, now.minute)
       a = input("")
       #a = r.recognize_google(audio)
       #print (a)
       chat += (a + ", ")
       data2send = {
          "name": name,
          "word": a,
          "date": date,
          "time": time,
       }
#-----------------------------------------------------------------
       if a.lower() in doyoulikeme:
               if l is "no":
                       print ("I do not like you.")
                       os.system("say '"+"I do not like you."+"'")
                       chat += ("no ; ")
               elif l is "yes":
                       print ("Yes, I like you!")
                       os.system("say '"+"Yes, I like you!"+"'")
               elif l is "idk":
                       print ("As of now, I like you!")
                       os.system("say '"+"As of now, I like you!"+"'")
#-----------------------------------------------------------------
       if a.lower() in goodbyes:
               print (goodbyes[a.lower()])
               os.system("say '"+goodbyes[a.lower()]+"'")
               c = "Goodbyes"
               chat += (goodbyes[a.lower()] + " ; ")
               firebase.post(pathT, chat)
       elif a.lower() in greetings:
               print (greetings[a.lower()])
               os.system("say '"+greetings[a.lower()]+"'")
               c = "Greetings"
               chat += (greetings[a.lower()] + " ;    ")
       elif a.lower() in science:
          print (science[a.lower()])
          os.system("say '"+science[a.lower()]+"'")
          c = "Science"
       elif a.lower() in computers_and_robots:
          print (computers_and_robots[a.lower()])
          os.system("say '"+computers_and_robots[a.lower()]+"'")
          c = "Computers and Robotics"
       elif a.lower() in computers_and_robotsN:
          print (computers_and_robotsN[a.lower()])
          os.system("say '"+computers_and_robotsN[a.lower()]+"'")
          c = "Computers and Robotics"
          l = "no"
       elif a.lower() in questions_about_me:
          print (questions_about_me[a.lower()])
          os.system("say '"+questions_about_me[a.lower()]+"'")
          c = "Me"
       elif a.lower() in other_questions:
          print (other_questions[a.lower()])
          os.system("say '"+other_questions[a.lower()]+"'")
          c = "Me"
       elif a.lower() in other_questions:
          print (other_questions[a.lower()])
          os.system("say '"+other_questions[a.lower()]+"'")
          c = "Me"
       elif a.lower() in opinions:
          print (opinions[a.lower()])
          os.system("say '"+opinions[a.lower()]+"'")
          c = "Me"
       elif a.lower() in opinionsY:
               print (opinionsY[a.lower()])
               os.system("say '"+opinionsY[a.lower()]+"'")
               c = "Me"
               l = "yes"
       elif a.lower() in opinionsN:
               print (opinionsN[a.lower()])
               os.system("say '"+opinionsN[a.lower()]+"'")
               c = "Me"
               l = "no"
       elif a.lower() in other:
          print (other[a.lower()])
          os.system("say '"+other[a.lower()]+"'")
          c = "Stuff"
       elif a.lower() in otherN:
          print (otherN[a.lower()])
          os.system("say '"+otherN[a.lower()]+"'")
          c = "Stuff"
          l = "no"
       elif a.lower() in opening_and_closing_apps:
          print (opening_and_closing_apps[a.lower()])
          os.system("say '"+opening_and_closing_apps[a.lower()]+"'")
          c = "Opening and closing an app"
       elif a.lower() in ("do you like me"):
           c = ("Me")
       elif (a.lower() in whyyes and l == "yes"):
          whylike = ("I like you because "+random.choice(("you are nice to me!","you are fun to talk to!","you make me happy!")))
          print (whylike)
          os.system(" say '"+whylike+"'")
       elif (a.lower() in whyno and l == "no"):
          whynolike = ("I dont like you because "+random.choice(("you have not been that nice to me.","you are mean!","you are annoying!")))
          print (whynolike)
          os.system(" say '"+whynolike+"'")
       elif a.lower() in test:
          print (test[a.lower()])
          os.system("say '"+test[a.lower()]+"'")
       elif a.lower() in daydate:
               date = (now.day)
               print ("The date is the "+str(date)+".")
               os.system("say '"+"The date is the "+str(date)+"'")
       elif a.lower() in daytime:
               print ("The time is "+str(time)+".")
               os.system("say '"+"The time is "+str(time)+"'")
       elif a.lower() in doyoulikeme:
           placeholder = "held"
       elif a.lower() in talkingabout:
          print (talkingabout[a.lower()])
          os.system("say '"+talkingabout[a.lower()]+"'")
       else:
             print ("I do not understand that yet.")
             os.system("say '"+"I do not understand that yet."+"'")
             firebase.post(pathE, data2send)
#-----------------------------------------------------------------
       if a.lower() is "open safari":
          opensafari()
       if a.lower() is "close safari":
          closesafari()
       if a.lower() is "open google":
          opengoogle()
       if a.lower() is "close google":
          closesafari()
       if a.lower() is "open youtube":
          openyoutube()
       if a.lower() is "close youtube":
          closeyoutube()
       if a.lower() in goodbyes:
          closeidle()
#-----------------------------------------------------------------