mirror of
https://github.com/gsi-upm/senpy
synced 2025-12-21 10:58:16 +00:00
PEP8 compliance
This commit is contained in:
@@ -2,6 +2,7 @@ import json
|
||||
import os
|
||||
from collections import defaultdict
|
||||
|
||||
|
||||
class Leaf(defaultdict):
|
||||
def __init__(self, ofclass=list):
|
||||
super(Leaf, self).__init__(ofclass)
|
||||
@@ -15,6 +16,7 @@ class Leaf(defaultdict):
|
||||
def __delattr__(self, name):
|
||||
return super(Leaf, self).__delitem__(name)
|
||||
|
||||
|
||||
class Response(Leaf):
|
||||
def __init__(self, context=None):
|
||||
super(Response, self).__init__()
|
||||
@@ -22,10 +24,10 @@ class Response(Leaf):
|
||||
self["entries"] = []
|
||||
if context is None:
|
||||
context = "{}/context.jsonld".format(os.path.dirname(
|
||||
os.path.realpath(__file__)))
|
||||
os.path.realpath(__file__)))
|
||||
if isinstance(context, dict):
|
||||
self["@context"] = context
|
||||
if isinstance(context, basestring):
|
||||
if isinstance(context, str) or isinstance(context, unicode):
|
||||
try:
|
||||
with open(context) as f:
|
||||
self["@context"] = json.loads(f.read())
|
||||
@@ -34,26 +36,28 @@ class Response(Leaf):
|
||||
|
||||
|
||||
class Entry(Leaf):
|
||||
def __init__(self, text=None, emotionSets=None, opinions=None, **kwargs):
|
||||
def __init__(self, text=None, emotion_sets=None, opinions=None, **kwargs):
|
||||
super(Entry, self).__init__(**kwargs)
|
||||
if text:
|
||||
self.text = text
|
||||
if emotionSets:
|
||||
self.emotionSets = emotionSets
|
||||
if emotion_sets:
|
||||
self.emotionSets = emotion_sets
|
||||
if opinions:
|
||||
self.opinions = opinions
|
||||
|
||||
|
||||
class Opinion(Leaf):
|
||||
def __init__(self, polarityValue=None, polarity=None, **kwargs):
|
||||
def __init__(self, polarity_value=None, polarity=None, **kwargs):
|
||||
super(Opinion, self).__init__(**kwargs)
|
||||
if polarityValue is not None:
|
||||
self.polarityValue = polarityValue
|
||||
if polarity_value is not None:
|
||||
self.polarity_value = polarity_value
|
||||
if polarity is not None:
|
||||
self.polarity = polarity
|
||||
|
||||
|
||||
|
||||
class EmotionSet(Leaf):
|
||||
def __init__(self, emotions=[], **kwargs):
|
||||
def __init__(self, emotions=None, **kwargs):
|
||||
if not emotions:
|
||||
emotions = []
|
||||
super(EmotionSet, self).__init__(**kwargs)
|
||||
self.emotions = emotions or []
|
||||
|
||||
Reference in New Issue
Block a user