Пример #1
0
def beginn(data, intents):
    global lang
    #load users data into json
    datas = json.loads(data)
    #load nlu data into json
    intents = json.loads(intents)
    question = intents["input"]
    lang = intents["lang"]
    if (detect(question) != "en"):
        question = translate(question)

    answer = wolfram_Alpha(question, data)

    if (answer == False):
        return False
    else:
        return generate_answer(answer)
Пример #2
0
def beginn(data, intents):
    global lang
    #load users data into json
    datas = json.loads(data)
    #load nlu data into json
    intents = json.loads(intents)
    name = getSlotbyName("name", intents)
    if (name == None):
        return False, False
    lang = intents["lang"]

    question = "how old is " + name

    answer = wolfram_Alpha(question, data)

    if (answer == False):
        return False
    else:
        return answer
Пример #3
0
def beginn(data, intents):
    global lang
    #load users data into json
    datas = json.loads(data)
    #load nlu data into json
    intents = json.loads(intents)
    question = intents["input"]
    lang = intents["lang"]
    # translations to english if necessary, wolframalpha only understands english
    if (detect(question) != "en"):
        question = translate(question)

    # ask wolframalpha
    answer = wolfram_Alpha(question, data)

    # if wolframalpha fails, return False
    if (answer == False):
        return False
    else:
        return generate_answer(
            answer), "https://a-ware.io/wp-content/uploads/2020/02/LOGO.png"
Пример #4
0
def beginn(data, intents):
    #load users data into json
    datas = json.loads(data)
    #load nlu data into json
    intents = json.loads(intents)
    # extract name
    name = getSlotbyName("name", intents)
    # if name was not found return False
    if (name == None):
        return False

    # generate question for wolframalpha
    question = "how old is " + name

    # ask wolframalpha
    answer = wolfram_Alpha(question, data)

    # return False if wolframalpha found no answer
    if (answer == False):
        return False
    else:
        return answer