Example #1
0
def test_extract_titles():
    print("Testing extract_titles() functionality...")
    chatbot = Chatbot(False)
    if assertListEquals(
        chatbot.extract_titles('I liked "The Notebook"'),
        ["The Notebook"],
        "Incorrect output for extract_titles(\'I liked \"The Notebook\"\')."
    ) and assertListEquals(
        chatbot.extract_titles('No movies here!'),
        [],
        "Incorrect output for extract_titles('No movies here!').",
    ):
        print('extract_titles() sanity check passed!')
    print()
Example #2
0
def test_extract_titles():
    print("Testing extract_titles() functionality...")
    chatbot = Chatbot(False)

    # add more test cases here!!!
    test_cases = [
        ('I liked "The Notebook"', ["The Notebook"]),
        ('You are a great bot!', []),
        ('I enjoyed "Titanic (1997)" and "Scream 2 (1997)"',
         ["Titanic (1997)", "Scream 2 (1997)"]),
    ]

    tests_passed = True
    for input_text, expected_output in test_cases:
        if not assert_list_equals(
                chatbot.extract_titles(chatbot.preprocess(input_text)),
                expected_output,
                "Incorrect output for extract_titles("
                "chatbot.preprocess('{}')).".format(
                    input_text),
                orderMatters=False
        ):
            tests_passed = False
    if tests_passed:
        print('extract_titles() sanity check passed!')
    print()
Example #3
0
def test_extract_titles_creative():
    print("Testing [CREATIVE MODE] extract_titles() functionality...")
    chatbot = Chatbot(True)
    if assertListEquals(
            chatbot.extract_titles('I liked The Notebook!'),
        [
            "The Notebook"
        ], "Incorrect output for [CREATIVE] extract_titles('I liked The Notebook')."
    ) and assertListEquals(
            chatbot.extract_titles(
                'I thought 10 things i hate about you was great'),
        ["10 things i hate about you", "10", "hate"],
            "Incorrect output for [CREATIVE] extract_titles('I thought 10 things i hate about you was great').",
            orderMatters=False
    ) and assertListEquals(
            chatbot.extract_titles('I like \"Harry Potter\"'),
        [
            "Harry Potter"
        ], "Incorrect output for [CREATIVE] extract_titles('I like \"Harry Potter\"')."
    ) and assertListEquals(
            chatbot.extract_titles('I liked Scream 2!'),
        ["Scream", "Scream 2"],
            "Incorrect output for [CREATIVE] extract_titles('I liked Scream 2').",
            orderMatters=False
    ) and assertListEquals(
            chatbot.extract_titles(
                'I liked "Titanic" and 10 things i hate about you...'),
        ["Titanic", "10 things i hate about you", "10", "hate"],
            "Incorrect output for [CREATIVE] extract_titles('I liked \"Titanic\" and 10 things i hate about you').",
            orderMatters=False
    ) and assertListEquals(
            chatbot.extract_titles('I liked Se7en, 10 things i hate about you, La guerre du feu, The Return of Godzilla, and I, Robot!'
                                   ), [
                                       "10",
                                       "hate", "Se7en", "10 things i hate about you",
                                       "La guerre du feu", "I, Robot",
                                       "The Return of Godzilla", "The Return",
                                       "Godzilla"
                                   ],
            "Incorrect output for [CREATIVE] extract_titles('I liked Se7en, 10 things i hate about you, La guerre du feu, The Return of Godzilla, and I, Robot!').",
            orderMatters=False
    ) and assertListEquals(
            chatbot
            .extract_titles('I liked "Home Alone 3"'), ["Home Alone 3"],
            "Incorrect output for [CREATIVE] extract_titles('I liked \"Home Alone 3\").",
            orderMatters=False
    ) and assertListEquals(
            chatbot.
            extract_titles('I liked happy feet'
                           ),
        ["happy", "happy feet"],
            "Incorrect output for [CREATIVE] extract_titles('I liked happy feet).",
            orderMatters=False
    ) and assertListEquals(
            chatbot
            .extract_titles('I liked \"Happy Feet\"'), ["Happy Feet"],
            "Incorrect output for [CREATIVE] extract_titles('I liked \"Happy Feet\").",
            orderMatters=False):
        print('[CREATIVE MODE] extract_titles() sanity check passed!')
    print()
Example #4
0
def test_extract_titles_creative():
    print("Testing extract_titles() creative functionality...")
    chatbot = Chatbot(True)
    if assertListEquals(
        chatbot.extract_titles('I liked the notebook'),
        ["The Notebook"],
        "Incorrect output for extract_titles(\'I liked the notebook\')."
    ) and assertListEquals(
        chatbot.extract_titles('No movies here!'),
        [],
        "Incorrect output for extract_titles('No movies here!').",
    ) and assertListEquals(
        chatbot.extract_titles('I thought 10 things i hate about you was great.'),
        ["10 Things I Hate About You"],
        "Incorrect output for extract_titles('I thought 10 things i hate about you was great.').",
    ) and assertListEquals(
        chatbot.extract_titles('Titanic (1997) started out terrible, but the ending was totally great and I loved it!'),
        ["Titanic (1997)"],
        "Incorrect output for extract_titles('Titanic (1997) started out terrible, but the ending was totally great and I loved it!').",
    ) and assertListEquals(
        chatbot.extract_titles('This undeniable classic is always charming and irresistible, even if far from perfect - the characters in casablanca do not always act consistently with their personalities.'),
        ["Casablanca", 'Always', 'Perfect'],
        "Incorrect output for extract_titles('This undeniable classic is always charming and irresistible, even if far from perfect - the characters in casablanca, for instance, do not always act consistently with their personalities.').",
    ) and assertListEquals(
        chatbot.extract_titles('I liked 10 things i hate about you.'),
        ["10 Things I Hate About You"],
        "Incorrect output for extract_titles('I liked 10 things i hate about you.').",
    ) and assertListEquals(
        chatbot.extract_titles('Titanic (1997), started out terrible, but the ending was totally great and I loved it!'),
        ["Titanic (1997)"],
        "Incorrect output for extract_titles('Titanic (1997), started out terrible, but the ending was totally great and I loved it!').",
    ) and assertListEquals(
        chatbot.extract_titles('I liked 10, things i hate about you.'),
        ["10"],
        "Incorrect output for extract_titles('I liked 10, things i hate about you.').",
    ):
        print('extract_titles() sanity check passed!')
    print()

    """ """
Example #5
0
def test_extract_titles_creative():
    print("Testing extract_titles() functionality...")
    chatbot = Chatbot(True)

    # add more test cases here!!!
    test_cases = [
        ('I liked The NoTeBoOk', ["notebook, the"]),
        ('I thought 10 things i hate about you was great', ["10", "hate", "10 things i hate about you"]),
    ]

    tests_passed = True
    for input_text, expected_output in test_cases:
        if not assertListEquals(
            chatbot.extract_titles(chatbot.preprocess(input_text)),
            expected_output,
            "Incorrect output for extract_titles(chatbot.preprocess('{}')).".format(input_text),
            orderMatters=False
            
        ):
            tests_passed = False
    if tests_passed:
        print('extract_titles() sanity check passed!')
    print()