Example #1
0
def menu(hot,cold):
    
    hot_drinks_sentence = concatanate_elements(hot)
    cold_drinks_sentence = concatanate_elements(cold)

    #welcome = "Ciao! Welcome to Sapienza bar! We have hot and cold drinks for you!"
    #txt_to_sp(welcome,'en')

    #hd_list= "Ciao! Welcome to Sapienza bar! We have hot and cold drinks for you! We offer "+hot_drinks_sentence+" as a hot drink"
    #txt_to_sp(hd_list,'en')

    cd_list = "Ciao! Welcome to Sapienza bar! We have hot and cold drinks for you! We offer "+hot_drinks_sentence+" as a hot drink. And, as a cold drink we have "+cold_drinks_sentence
    txt_to_sp(cd_list,'en')

    order_asking = "What would you like to have?"
    txt_to_sp(order_asking,'en')
Example #2
0
def bot_ans(res,hotd,coldd,ord_doc):
    if res:
        your_order=match_in_menu(res,hotd,coldd)
        bot_answer = "Your" + your_order+" is coming right now"
    else:
        nouns = collect_nouns(ord_doc)
        for noun in nouns:
            print(noun)
        if is_cold_or_hot(nouns, coldd):
            drink = drink_explicitly(nouns, coldd)
            bot_answer="Your "+drink+" is coming right now!"
            print(bot_answer)
        elif is_cold_or_hot(nouns, hotd):
            drink= drink_explicitly(nouns, hotd)
            bot_answer="Your "+drink+" is coming right now!"
            print(bot_answer)
        else:
            bot_answer="Sorry we do not sell what you asked for"
    txt_to_sp(bot_answer,'en')
Example #3
0
def bot_ans(res,hotd,coldd,alc_hd,alc_cd,ord_doc):
    if res:
        #print("res: " +res)
        #print("length: " +str(len(res)))
        flag = "False"
        your_order,flag=match_in_menu(res,hotd,coldd)
        if flag:
            is_order_alc=is_alc(your_order,flag,hotd,coldd,alc_hd,alc_cd)
            print("In res, order is "+your_order+" & it is "+is_order_alc+" alcoholic")
            if is_order_alc=='yes':
                yes_alc(your_order)

            else:
                bot_answer = "Your "+ your_order +" is coming right now"
                print(bot_answer)
                txt_to_sp(bot_answer,'en')
        # else:
        #     bot_answer="Sorry we do not sell what you asked for"
        #     print(bot_answer)
        #     txt_to_sp(bot_answer,'en')
            return

    #else:
    nouns = collect_nouns(ord_doc)
    for noun in nouns:
        print("Nouns are :"+noun)
    if is_cold_or_hot(nouns, coldd):
        drink = drink_explicitly(nouns, coldd)
        is_order_alc=is_alc(drink,'c',hotd,coldd,alc_hd,alc_cd)
        if is_order_alc=='yes':
            yes_alc(drink)
        else:
            bot_answer="Your "+drink+" is coming right now!"
            print(bot_answer)
            txt_to_sp(bot_answer,'en')
    elif is_cold_or_hot(nouns, hotd):
        drink= drink_explicitly(nouns, hotd)
        is_order_alc=is_alc(drink,'h',hotd,coldd,alc_hd,alc_cd)
        if is_order_alc=='yes':
            yes_alc(drink)
        else:
            bot_answer="Your "+drink+" is coming right now!"
            print(bot_answer)
            txt_to_sp(bot_answer,'en')
    else:
        bot_answer="Sorry we do not sell what you asked for"
        print(bot_answer)
        txt_to_sp(bot_answer,'en')
Example #4
0
def yes_alc(your_order):
    bot_answer = your_order+" is alcoholic. Please tell us your age"
    print(bot_answer)
    txt_to_sp(bot_answer,'en')
    
    cust_age = sp_to_txt(mic)
    #cust_age = input("Enter age: ")
    print(cust_age)

    nlp = spacy.load('en_core_web_sm')

    while not cust_age:
        txt_to_sp("Sorry, I did not understand your age, please say it loudly",'en')
        cust_age = sp_to_txt(mic)
        #cust_age = input("Enter age: ")
        print(cust_age)
    age_doc = nlp(cust_age)
    yrs = []
    # for possible_subject in age_doc:
    #     # if str(possible_subject.pos).isdigit():
    #     #     print(str(possible_subject.pos))
    #     #     # yrs.append(possible_subject.text)
    #     #     print('You are ', yrs[0], 'years old')
    #     #     if int(yrs[0]) < 18:
    #     #         bot_answer = 'Sorry, we can not sell you alcoholic drink'
    #     #     else:
    #     #         bot_answer = "Your "+ your_order +" is coming right now"
    #     #     print(bot_answer)
    #     #     txt_to_sp(bot_answer,'en')
    #     #     break

    age_consideration= []
    for possible_subject in age_doc:
        if str(possible_subject).isdigit():
            age_consideration.append(int(str(possible_subject)))
            print('You are ', age_consideration[0], 'years old')
            if age_consideration[0] < 18:
                bot_answer = 'Sorry, we can not sell you alcoholic drink'
            else:
                bot_answer = "Your "+ your_order +" is coming right now"
            print(bot_answer)
            txt_to_sp(bot_answer,'en')
            break
    else:
        bot_answer = "You did not provide us your age sorry, bye"
        print(bot_answer)
        txt_to_sp(bot_answer,'en')    
Example #5
0
more_order="Do you want anything else?"
no_order_1="I do not want anything"
no_order_2="I don't want anything"
menu(hd,cd)
repeat_pls = "Sorry, I did not understand, please say it loudly"

while True:
    
    cust_order = sp_to_txt(mic)
    #cust_order = input("Enter drink: ")
    print(cust_order)

    nlp = spacy.load('en_core_web_sm')

    while not cust_order:
        txt_to_sp(repeat_pls,'en')
        cust_order = sp_to_txt(mic)
        #cust_order = input("Enter another drink: ")
        print(cust_order)


    if (cust_order==no_order_1 or cust_order==no_order_2):
        txt_to_sp("See you soon. Have a nice day!",'en')
        print("See you soon. Have a nice day!")
        exit()
    order_doc = nlp(cust_order)
    matcher = Matcher(nlp.vocab)

    result = get_double_noun(order_doc)
    if not result:
        #print("D N didn't work")
Example #6
0
            bot_answer="Sorry we do not sell what you asked for"
    txt_to_sp(bot_answer,'en')

more_order="Do you want anything else?"
menu(hd,cd)
repeat_pls = "Sorry, I did not understand, please say it loudly"

while True:
    
    cust_order = sp_to_txt(mic)
    print(cust_order)

    nlp = spacy.load('en_core_web_sm')

    while not cust_order:
        txt_to_sp(repeat_pls,'en')
        cust_order = sp_to_txt(mic)
        print(cust_order)
    order_doc = nlp(cust_order)
    matcher = Matcher(nlp.vocab)

    result = get_double_noun(order_doc)
    if not result:
        result = get_adj_noun(order_doc)
        #Change1
        # if not result:
        #     result = extract_double_ppn(order_doc)

    print(result)
    [to_nltk_tree(sent.root).pretty_print() for sent in order_doc.sents]