Esempio n. 1
0
def test_math():
    assert ('math' == modules.process_query('math 4*4')[0])
    assert ('math' == modules.process_query(
        'distance between earth and sun math')[0])
    assert ('math' == modules.process_query('10 times 10 math')[0])
    assert ('math' != modules.process_query('what is 5 * 3')[0])
    assert ('math' != modules.process_query('something random')[0])
Esempio n. 2
0
def test_anime():
    assert ('anime' == modules.process_query('Death Note anime')[0])
    assert (
        'anime' == modules.process_query('Dragon ball super anime status')[0])
    assert ('anime' == modules.process_query(
        'What is the anime rating of One Punch Man?')[0])
    assert ('anime' != modules.process_query('something random')[0])
Esempio n. 3
0
def test_wallpaper():
    assert ('wallpaper' == modules.process_query('wallpaper')[0])
    assert ('wallpaper' == modules.process_query('i need a new wallpaper')[0])
    assert (
        'wallpaper' == modules.process_query('show me a random wallpaper')[0])
    assert ('wallpaper' == modules.process_query('random wallpaper')[0])
    assert ('wallpaper' != modules.process_query('latest news')[0])
Esempio n. 4
0
def test_weather():
    assert (
        'weather' == modules.process_query('tell me the weather in London')[0])
    assert ('weather' == modules.process_query('weather Delhi')[0])
    assert (
        'weather' == modules.process_query('What\'s the weather in Texas?')[0])
    assert ('weather' != modules.process_query('something random')[0])
Esempio n. 5
0
def test_lyrics():
    assert ('lyrics' == modules.process_query('paradise lyrics')[0])
    assert ('lyrics' == modules.process_query(
        'lyrics of the song hall of fame')[0])
    assert ('lyrics' == modules.process_query(
        'What are the lyrics to see you again?')[0])
    assert ('lyrics' != modules.process_query('something random')[0])
Esempio n. 6
0
def test_roman_numerals():
    assert ('roman_numerals' == modules.process_query(
        'write 400 as roman numrals')[0])
    assert ('roman_numerals' == modules.process_query(
        'write 768 in roman number')[0])
    assert ('roman_numerals' == modules.process_query(
        'how do you write 56 in roman numrals')[0])
    assert ('roman_numerals' != modules.process_query('what is a duck')[0])
Esempio n. 7
0
def test_url():
    intent, entities = modules.process_query('shorten google.com')
    assert ('url' == intent)
    assert ('google.com' == entities['url'][0]['value'])
    assert ('shorten' == entities['url_action'][0]['value'])

    intent, entities = modules.process_query('give me a short version of bing.com')
    assert ('url' == intent)
    assert ('bing.com' == entities['url'][0]['value'])
    assert ('shorten' == entities['url_action'][0]['value'])

    intent, entities = modules.process_query('expand http://goo.gl/7aqe')
    assert ('url' == intent)
    assert ('http://goo.gl/7aqe' == entities['url'][0]['value'])
    assert ('expand' == entities['url_action'][0]['value'])

    assert ('url' != modules.process_query('something random')[0])
Esempio n. 8
0
def test_url():
    intent, entities = modules.process_query('shorten google.com')
    assert ('url' == intent)
    assert ('google.com' == entities['url'][0]['value'])
    assert ('shorten' == entities['url_action'][0]['value'])

    intent, entities = modules.process_query(
        'give me a short version of bing.com')
    assert ('url' == intent)
    assert ('bing.com' == entities['url'][0]['value'])
    assert ('shorten' == entities['url_action'][0]['value'])

    intent, entities = modules.process_query('expand http://goo.gl/7aqe')
    assert ('url' == intent)
    assert ('http://goo.gl/7aqe' == entities['url'][0]['value'])
    assert ('expand' == entities['url_action'][0]['value'])

    assert ('url' != modules.process_query('something random')[0])
Esempio n. 9
0
def process_request():
    try:
        if request.method == "GET":
            user_input = {
                'username': session['username'],
                'user_input_text': request.args.get('q'),
                'context': session['context']
            }
            createlog.chatlog(user_input['username'],
                              user_input['user_input_text'], 'user')
            bot_output = modules.process_query(user_input, session['username'])
            session['context'] = bot_output['context']
            print
            print "currrent context" + session['context']
            print
            createlog.chatlog(user_input['username'],
                              bot_output['bot_response_text'], 'bot')
            return bot_output['bot_response_text']
        else:
            return "invalid request"
    except Exception as e:
        return e
Esempio n. 10
0
def test_currency():
    assert ('currency' == modules.process_query('HKD to USD')[0])
    assert ('currency' == modules.process_query('USD to INR')[0])
    assert ('currency' == modules.process_query('how much is USD in EUR')[0])

    intent, entities = modules.process_query('convert 5 HKD to USD')
    assert ('currency' == intent)
    assert ('HKD' == entities['from_currency'][0]['value'])
    assert ('USD' == entities['to_currency'][0]['value'])
    assert (5 == entities['number'][0]['value'])

    intent, entities = modules.process_query('how much is 100 USD to INR')
    assert ('currency' == intent)
    assert ('USD' == entities['from_currency'][0]['value'])
    assert ('INR' == entities['to_currency'][0]['value'])
    assert (100 == entities['number'][0]['value'])

    assert ('currency' != modules.process_query('something random')[0])
Esempio n. 11
0
def test_joke():
    assert('joke' == modules.process_query('tell me a joke')[0])
    assert('joke' == modules.process_query('Do you know a joke?')[0])
    assert('joke' == modules.process_query('random jokes')[0])
    assert('joke' != modules.process_query('something random')[0])
Esempio n. 12
0
def test_ping():
    assert ('ping' == modules.process_query('is google.com up')[0])
    assert ('ping' == modules.process_query('google.com status')[0])
    assert ('ping' == modules.process_query('ping google.com')[0])
    assert ('ping' != modules.process_query('something random')[0])
Esempio n. 13
0
def test_movie():
    assert('movie' == modules.process_query('batman movie')[0])
    assert('movie' == modules.process_query('iron man 2 movie plot')[0])
    assert('movie' == modules.process_query('What is the rating of happyness movie?')[0])
    assert('movie' != modules.process_query('something random')[0])
def test_dice():
    assert ('dice' == modules.process_query('Roll a dice')[0])
	assert ('dice' == modules.process_query('Roll a 20 sided dice')[0])
def test_hello():
    assert('pokemon' == modules.process_query('notify')[0])
    assert('pokemon' != modules.process_query('something random')[0])
Esempio n. 16
0
def test_xkcd():
    assert ('xkcd' == modules.process_query('xkcd comic')[0])
    assert ('xkcd' == modules.process_query('xkcd')[0])
    assert ('xkcd' != modules.process_query('something random')[0])
Esempio n. 17
0
def test_fact():
    assert('fact' == modules.process_query('tell me a fact')[0])
    assert('fact' == modules.process_query('Do you know a fact?')[0])
    assert('fact' == modules.process_query('random facts')[0])
    assert('fact' != modules.process_query('something random')[0])
Esempio n. 18
0
def test_joke():
    assert ('joke' == modules.process_query('tell me a joke')[0])
    assert ('joke' == modules.process_query('Do you know a joke?')[0])
    assert ('joke' == modules.process_query('random jokes')[0])
    assert ('joke' != modules.process_query('something random')[0])
Esempio n. 19
0
def test_thanks():
    assert ('thanks' == modules.process_query('thanks')[0])
    assert ('thanks' == modules.process_query('thank you')[0])
    assert ('thanks' != modules.process_query('something random')[0])
Esempio n. 20
0
def test_time():
    assert ('time' == modules.process_query('time in new york')[0])
    assert ('time' == modules.process_query('india time')[0])
    assert ('time' == modules.process_query('time at paris')[0])
    assert ('time' != modules.process_query('something random')[0])
def test_worldcup():
    assert ('worldcup' == modules.process_query('when is the next match in the world cup')[0])
    assert ('worldcup' == modules.process_query('when are france playing again')[0])
def test_currency():
    assert('currency' == modules.process_query('HKD to USD')[0])
    assert('currency' == modules.process_query('USD to INR')[0])
    assert('currency' == modules.process_query('how much is USD in PHP')[0])

    assert('currency' != modules.process_query('something random')[0])
Esempio n. 23
0
def test_hello():
    assert ('hello' == modules.process_query('hello')[0])
    assert ('hello' == modules.process_query('Hi, Jarvis!')[0])
    assert ('hello' == modules.process_query('Are you there?')[0])
    assert ('hello' != modules.process_query('something random')[0])
Esempio n. 24
0
def test_quote():
    assert('quote' == modules.process_query('quote')[0])
    assert('quote' == modules.process_query('random quote')[0])
    assert('quote' == modules.process_query('give me a quote')[0])
    assert('quote' != modules.process_query('something random')[0])
Esempio n. 25
0
def test_dice():
    assert ('dice' == modules.process_query('Roll a dice')[0])
    assert ('dice' == modules.process_query('Jarvis, roll a dice')[0])
    assert ('dice' == modules.process_query('Can you roll a dice?')[0])
    assert ('dice' != modules.process_query('something random')[0])
def test_dictionary():
    assert ('dictionary' == modules.process_query('define comfort')[0])
    assert ('dictionary' == modules.process_query('cloud definition')[0])
    assert ('dictionary' == modules.process_query('what does an accolade mean?')[0])
    assert ('dictionary' != modules.process_query('something random')[0])
Esempio n. 27
0
def test_dictionary():
    assert ('dictionary' == modules.process_query('define comfort')[0])
    assert ('dictionary' == modules.process_query('cloud definition')[0])
    assert ('dictionary' == modules.process_query(
        'what does an accolade mean?')[0])
    assert ('dictionary' != modules.process_query('something random')[0])
Esempio n. 28
0
def test_fact():
    assert('fact' == modules.process_query('tell me a fact')[0])
    assert('fact' == modules.process_query('Do you know a fact?')[0])
    assert('fact' == modules.process_query('random facts')[0])
    assert('fact' != modules.process_query('something random')[0])
Esempio n. 29
0
def test_help():
    assert('help' == modules.process_query('help')[0])
    assert('help' == modules.process_query('introduce yourself')[0])
    assert('help' == modules.process_query('What can you do?')[0])
    assert('help' != modules.process_query('something random')[0])
Esempio n. 30
0
def test_help():
    assert ('help' == modules.process_query('help')[0])
    assert ('help' == modules.process_query('introduce yourself')[0])
    assert ('help' == modules.process_query('What can you do?')[0])
    assert ('help' != modules.process_query('something random')[0])
Esempio n. 31
0
def test_howto():
    assert('howto' == modules.process_query('how to crack knuckles')[0])
    assert('howto' == modules.process_query('how to pitch a tent')[0])
    assert('howto' == modules.process_query('how do I cut a watermelon')[0])
    assert('howto' != modules.process_query('something random')[0])
Esempio n. 32
0
def test_news():
    assert ('news' == modules.process_query('news')[0])
    assert ('news' == modules.process_query('latest news')[0])
    assert ('news' == modules.process_query('world news')[0])
    assert ('news' != modules.process_query('something random')[0])
Esempio n. 33
0
def test_time():
    assert('time' == modules.process_query('time in new york')[0])
    assert('time' == modules.process_query('india time')[0])
    assert('time' == modules.process_query('time at paris')[0])
    assert('time' != modules.process_query('something random')[0])
Esempio n. 34
0
def test_bye():
    assert ('bye' == modules.process_query('bye')[0])
    assert ('bye' == modules.process_query('good night')[0])
    assert ('bye' != modules.process_query('something random')[0])
Esempio n. 35
0
def test_movie():
    assert ('movie' == modules.process_query('batman movie')[0])
    assert ('movie' == modules.process_query('iron man 2 movie plot')[0])
    assert ('movie' == modules.process_query(
        'What is the rating of happyness movie?')[0])
    assert ('movie' != modules.process_query('something random')[0])
Esempio n. 36
0
def test_weather():
    assert ('weather' == modules.process_query('tell me the weather in London')[0])
    assert ('weather' == modules.process_query('weather Delhi')[0])
    assert ('weather' == modules.process_query('What\'s the weather in Texas?')[0])
    assert ('weather' != modules.process_query('something random')[0])
Esempio n. 37
0
def test_wiki():
    assert('wiki' == modules.process_query('Wikipedia Barack')[0])
    assert('wiki' == modules.process_query('Wikipedia HTML')[0])
    assert('wiki' != modules.process_query('joke definition')[0])
Esempio n. 38
0
def test_book():
    assert('book' == modules.process_query('book timeline')[0])
    assert('book' == modules.process_query('have you read harry potter?')[0])
    assert('book' == modules.process_query('little women book rating')[0])
    assert('book' != modules.process_query('harry potter movie')[0])
    assert('book' != modules.process_query('something random')[0])
Esempio n. 39
0
def test_request():
    assert ('request' == modules.process_query('request')[0])
    assert ('request' == modules.process_query('report')[0])
    assert ('request' != modules.process_query('something random')[0])
Esempio n. 40
0
def test_lyrics():
    assert ('lyrics' == modules.process_query('paradise lyrics')[0])
    assert ('lyrics' == modules.process_query('lyrics of the song hall of fame')[0])
    assert ('lyrics' == modules.process_query('What are the lyrics to see you again?')[0])
    assert ('lyrics' != modules.process_query('something random')[0])
Esempio n. 41
0
def test_video():
    assert ('video' == modules.process_query('sia videos')[0])
    assert ('video' == modules.process_query('videos by eminem')[0])
    assert ('video' == modules.process_query('video coldplay')[0])
    assert ('video' != modules.process_query('something random')[0])
Esempio n. 42
0
def test_coin():
    assert ('coin' == modules.process_query('Flip a coin')[0])
    assert ('coin' == modules.process_query('heads or tails')[0])
    assert ('coin' == modules.process_query('Can you flip a coin?')[0])
    assert ('coin' != modules.process_query('something random')[0])
Esempio n. 43
0
def test_dice():
    assert('dice' == modules.process_query('Roll a dice')[0])
    assert('dice' == modules.process_query('Jarvis, roll a dice')[0])
    assert('dice' == modules.process_query('Can you roll a dice?')[0])
    assert('dice' != modules.process_query('something random')[0])
Esempio n. 44
0
def test_music():
    assert ('music' == modules.process_query('hymn for the weekend song')[0])
    assert ('music' == modules.process_query('linkin park songs')[0])
    assert ('music' == modules.process_query('play hotel california')[0])
    assert ('music' != modules.process_query('something random')[0])
Esempio n. 45
0
def process():
    return json.dumps(modules.process_query(request.args.get('q')))
Esempio n. 46
0
def test_news():
    assert('news' == modules.process_query('news')[0])
    assert('news' == modules.process_query('latest news')[0])
    assert('news' == modules.process_query('world news')[0])
    assert('news' != modules.process_query('something random')[0])
Esempio n. 47
0
def test_wiki():
    assert('wiki' == modules.process_query('wikipedia barack')[0])
    assert('wiki' == modules.process_query('html wiki')[0])
    assert('wiki' == modules.process_query('who is sachin tendulkar')[0])
    assert('wiki' != modules.process_query('joke definition')[0])
    assert('wiki' != modules.process_query('something random')[0])
Esempio n. 48
0
def test_anime():
    assert('anime' == modules.process_query('Death Note anime')[0])
    assert('anime' == modules.process_query('Dragon ball super anime status')[0])
    assert('anime' == modules.process_query('What is the anime rating of One Punch Man?')[0])
    assert('anime' != modules.process_query('something random')[0])