2018-01-03 08:39:30 +00:00
|
|
|
#!/usr/local/bin/python
|
2019-01-07 11:08:19 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-01-03 08:39:30 +00:00
|
|
|
|
2019-01-07 11:08:19 +00:00
|
|
|
from senpy import easy_test, SentimentBox
|
2018-01-03 08:39:30 +00:00
|
|
|
|
|
|
|
import basic
|
|
|
|
|
|
|
|
|
2019-01-07 11:08:19 +00:00
|
|
|
class Basic(SentimentBox):
|
2018-01-03 08:39:30 +00:00
|
|
|
'''Provides sentiment annotation using a lexicon'''
|
|
|
|
|
|
|
|
author = '@balkian'
|
|
|
|
version = '0.1'
|
|
|
|
|
2019-01-07 11:08:19 +00:00
|
|
|
def predict_one(self, features, **kwargs):
|
|
|
|
output = basic.get_polarity(features[0])
|
|
|
|
if output == 'pos':
|
|
|
|
return [1, 0, 0]
|
|
|
|
if output == 'neu':
|
|
|
|
return [0, 1, 0]
|
|
|
|
return [0, 0, 1]
|
2018-01-03 08:39:30 +00:00
|
|
|
|
|
|
|
test_cases = [{
|
2019-01-07 11:08:19 +00:00
|
|
|
'input': u'Hello :)',
|
2018-01-03 08:39:30 +00:00
|
|
|
'polarity': 'marl:Positive'
|
|
|
|
}, {
|
2019-01-07 11:08:19 +00:00
|
|
|
'input': u'So sad :(',
|
2018-01-03 08:39:30 +00:00
|
|
|
'polarity': 'marl:Negative'
|
|
|
|
}, {
|
2019-01-07 11:08:19 +00:00
|
|
|
'input': u'Yay! Emojis 😁',
|
2018-01-03 08:39:30 +00:00
|
|
|
'polarity': 'marl:Positive'
|
|
|
|
}, {
|
2019-01-07 11:08:19 +00:00
|
|
|
'input': u'But no emoticons 😢',
|
2018-01-03 08:39:30 +00:00
|
|
|
'polarity': 'marl:Negative'
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
easy_test()
|