basic_plugin.py 838 Bytes
Newer Older
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
1
2
3
#!/usr/local/bin/python
# coding: utf-8

4
from senpy import easy_test, SentimentBox, MappingMixin
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
5
6
7
8

import basic


9
class Basic(MappingMixin, SentimentBox):
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
10
11
12
13
14
    '''Provides sentiment annotation using a lexicon'''

    author = '@balkian'
    version = '0.1'

15
16
17
18
19
    mappings = {
        'pos': 'marl:Positive',
        'neg': 'marl:Negative',
        'default': 'marl:Neutral'
    }
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
20

21
22
    def box(self, input, **kwargs):
        return basic.get_polarity(input)
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

    test_cases = [{
        'input': 'Hello :)',
        'polarity': 'marl:Positive'
    }, {
        'input': 'So sad :(',
        'polarity': 'marl:Negative'
    }, {
        'input': 'Yay! Emojis  😁',
        'polarity': 'marl:Positive'
    }, {
        'input': 'But no emoticons 😢',
        'polarity': 'marl:Negative'
    }]


if __name__ == '__main__':
    easy_test()