Beispiel #1
0
def test_sentiwords():
    bag = sentiwords_tag("I'd like a cold beer.")
    assert_true(isinstance(bag, dict))
    assert_in("like", bag)
    assert_in("beer", bag)

    tokens = sentiwords_tag("bla a fortiori the foo quuxes a priori the baz",
                            output="tokens")
    assert_equal(tokens,
                 ['bla', ('a fortiori', 0.15793), 'the', 'foo',
                  'quuxes', ('a priori', 0.02784), 'the', 'baz'])
Beispiel #2
0
def test_sentiwords():
    bag = sentiwords_tag("Is this a good good test?")
    words = set(["is", "this", "a", "good", "test"])
    for word in bag:
        assert_in(word, words)
        score, count = bag[word]
        assert_true(score != 0)     # We don't report on neutral terms.
        assert_greater(count, 0)

    tokens = sentiwords_tag("bla a fortiori the foo quuxes a priori the baz",
                            output="tokens")
    assert_equal(tokens,
                 ['bla', ('a fortiori', 0.15793), 'the', 'foo',
                  'quuxes', ('a priori', 0.02784), 'the', 'baz'])
Beispiel #3
0
def test_sentiwords():
    bag = sentiwords_tag("Is this a good good test?")
    words = set(["is", "this", "a", "good", "test"])
    for word in bag:
        assert_in(word, words)
        score, count = bag[word]
        assert_true(score != 0)  # We don't report on neutral terms.
        assert_greater(count, 0)

    tokens = sentiwords_tag("bla a fortiori the foo quuxes a priori the baz",
                            output="tokens")
    assert_equal(tokens, [
        'bla', ('a fortiori', 0.15793), 'the', 'foo', 'quuxes',
        ('a priori', 0.02784), 'the', 'baz'
    ])