2017-02-27 10:37:43 +00:00
|
|
|
import random
|
|
|
|
|
|
|
|
from senpy.plugins import EmotionPlugin
|
2017-06-16 15:53:42 +00:00
|
|
|
from senpy.models import EmotionSet, Emotion, Entry
|
2017-02-27 10:37:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RmoRandPlugin(EmotionPlugin):
|
|
|
|
def analyse_entry(self, entry, params):
|
|
|
|
category = "emoml:big6happiness"
|
|
|
|
number = max(-1, min(1, random.gauss(0, 0.5)))
|
|
|
|
if number > 0:
|
|
|
|
category = "emoml:big6anger"
|
|
|
|
emotionSet = EmotionSet()
|
|
|
|
emotion = Emotion({"onyx:hasEmotionCategory": category})
|
|
|
|
emotionSet.onyx__hasEmotion.append(emotion)
|
|
|
|
emotionSet.prov__wasGeneratedBy = self.id
|
|
|
|
entry.emotions.append(emotionSet)
|
|
|
|
yield entry
|
2017-06-16 15:53:42 +00:00
|
|
|
|
|
|
|
def test(self):
|
|
|
|
params = dict()
|
|
|
|
results = list()
|
|
|
|
for i in range(100):
|
2017-07-12 15:41:14 +00:00
|
|
|
res = next(self.analyse_entry(Entry(nif__isString="Hello"), params))
|
2017-06-16 15:53:42 +00:00
|
|
|
res.validate()
|
|
|
|
results.append(res.emotions[0]['onyx:hasEmotion'][0]['onyx:hasEmotionCategory'])
|