Example #1
0
def test_extract_sentiment_for_movies():
    print("Testing test_extract_sentiment_for_movies() functionality...")
    chatbot = Chatbot(True)
    if assertListEquals(
        chatbot.extract_sentiment_for_movies("I liked both \"I, Robot\" and \"Ex Machina\"."),
        [("I, Robot", 1), ("Ex Machina", 1)],
        "Incorrect output for test_extract_sentiment_for_movies(\"I liked both \"I, Robot\" and \"Ex Machina\".)\"",
        orderMatters=False
    ) and assertListEquals(
        chatbot.extract_sentiment_for_movies("I liked \"I, Robot\" but not \"Ex Machina\"."),
        [("I, Robot", 1), ("Ex Machina", -1)],
        "Incorrect output for test_extract_sentiment_for_movies(\"I liked \"I, Robot\" but not \"Ex Machina\".)\"",
        orderMatters=False
    ):
        print('extract_sentiment_for_movies() sanity check passed!')
    print()
def test_extract_sentiment_for_movies():
    print("Testing test_extract_sentiment_for_movies() functionality...")
    chatbot = Chatbot(True)

    # add more test cases here!!!
    test_cases = [
        ('I liked both "I, Robot" and "Ex Machina".', [("I, Robot", 1),
                                                       ("Ex Machina", 1)]),
        ('I liked "I, Robot" but not "Ex Machina".', [("I, Robot", 1),
                                                      ("Ex Machina", -1)]),
        ('I didn\'t like either "I, Robot" or "Ex Machina".',
         [("I, Robot", -1), ("Ex Machina", -1)]),
        ('I liked "Titanic (1997)", but "Ex Machina" was not good.',
         [("Titanic (1997)", 1), ("Ex Machina", -1)]),
    ]

    tests_passed = True
    for input_text, expected_output in test_cases:
        if not assertListEquals(
                chatbot.extract_sentiment_for_movies(
                    chatbot.preprocess(input_text)),
                expected_output,
                "Incorrect output for extract_sentiment_for_movies(chatbot.preprocess('{}'))."
                .format(input_text),
                orderMatters=False):
            tests_passed = False
    if tests_passed:
        print('extract_sentiment_for_movies() sanity check passed!')
    print()
Example #3
0
def test_extract_sentiment_for_movies():
    print("Testing test_extract_sentiment_for_movies() functionality...")
    chatbot = Chatbot(True)
    chatbot.extract_sentiment_for_movies("I liked both \"I, Robot\" and \"Ex Machina\"")
    if assertListEquals(
        chatbot.extract_sentiment_for_movies("I liked both \"I, Robot\" and \"Ex Machina\"."),
        [("I, Robot", 1), ("Ex Machina", 1)],
        "Incorrect output for test_extract_sentiment_for_movies(\"I liked both \"I, Robot\" and \"Ex Machina\".)\"",
        orderMatters=False
    ) and assertListEquals(
        chatbot.extract_sentiment_for_movies("I liked \"I, Robot\" but not \"Ex Machina\"."),
        [("I, Robot", 1), ("Ex Machina", -1)],
        "Incorrect output for test_extract_sentiment_for_movies(\"I liked \"I, Robot\" but not \"Ex Machina\".)\"",
        orderMatters=False
    ) and assertListEquals(
        chatbot.extract_sentiment_for_movies("I liked \"I, Robot\" and \"Lady and the Tramp\", but not \"Ex Machina\"."),
        [("I, Robot", 1), ("Lady and the Tramp", 1), ("Ex Machina", -1)],
        "Incorrect output for test_extract_sentiment_for_movies(\"I liked \"I, Robot\" and \"Lady and the Tramp\", but not \"Ex Machina\".)\"",
        orderMatters=False
    ) and assertListEquals(
        chatbot.extract_sentiment_for_movies("I liked \"I, Robot\", but \"Lady and the Tramp\" was even better! I really liked \"Ex Machina\" too."),
        [("I, Robot", 1), ("Lady and the Tramp", 1), ("Ex Machina", 1)],
        "Incorrect output for test_extract_sentiment_for_movies(\"I liked \"I, Robot\", but \"Lady and the Tramp\" was even better! I really liked \"Ex Machina\" too.\")\"",
        orderMatters=False
    ) and assertListEquals(
        chatbot.extract_sentiment_for_movies("I liked \"I, Robot\", but the \"Lady and the Tramp\" was not good. But I really liked \"Ex Machina\"."),
        [("I, Robot", 1), ("Lady and the Tramp", -1), ("Ex Machina", 1)],
        "Incorrect output for test_extract_sentiment_for_movies(\"I liked \"I, Robot\", but the \"Lady and the Tramp\" was not good. But I really liked \"Ex Machina\".\")\"",
        orderMatters=False
    ) and assertListEquals(
        chatbot.extract_sentiment_for_movies("I liked \"I, Robot\", the \"Lady and the Tramp\", and \"Ex Machina\". \"Metropolitan\", however, was quite disappointing."),
        [("I, Robot", 1), ("Lady and the Tramp", 1), ("Ex Machina", 1), ("Metropolitan", -1)],
        "Incorrect output for test_extract_sentiment_for_movies(\"I liked \"I, Robot\", the \"Lady and the Tramp\", and \"Ex Machina\". \"Metropolitan\", however, was quite disappointing.\")\"",
        orderMatters=False
    ):
        print('extract_sentiment_for_movies() sanity check passed!')
    print()