def test_turtle(self): """Any model should be serializable as a turtle file""" ana = EmotionAnalysis() res = Results() res.analysis.append(ana) entry = Entry(text='Just testing') eSet = EmotionSet() emotion = Emotion() entry.emotions.append(eSet) res.entries.append(entry) eSet.onyx__hasEmotion.append(emotion) eSet.prov__wasGeneratedBy = ana.id triples = ('ana a :Analysis', 'entry a :entry', ' nif:isString "Just testing"', ' onyx:hasEmotionSet eSet', 'eSet a onyx:EmotionSet', ' prov:wasGeneratedBy ana', ' onyx:hasEmotion emotion', 'emotion a onyx:Emotion', 'res a :results', ' me:AnalysisInvoloved ana', ' prov:used entry') t = res.serialize(format='turtle') print(t) g = rdflib.Graph().parse(data=t, format='turtle') assert len(g) == len(triples)
def test_turtle(self): """Any model should be serializable as a turtle file""" ana = EmotionAnalysis() res = Results() res.activities.append(ana) entry = Entry(text='Just testing') eSet = EmotionSet() emotion = Emotion() entry.emotions.append(eSet) res.entries.append(entry) eSet.onyx__hasEmotion.append(emotion) eSet.prov__wasGeneratedBy = ana.id triples = ('ana a :Analysis', 'ent[]ry a :entry', ' nif:isString "Just testing"', ' onyx:hasEmotionSet eSet', 'eSet a onyx:EmotionSet', ' prov:wasGeneratedBy ana', ' onyx:hasEmotion emotion', 'emotion a onyx:Emotion', 'res a :results', ' me:AnalysisInvolved ana', ' prov:used entry') t = res.serialize(format='turtle') print(t) g = rdflib.Graph().parse(data=t, format='turtle') assert len(g) == len(triples)
def test_template(self): r = Results() e = Entry() e.nif__isString = 'testing the template' sent = Sentiment() sent.polarity = 'marl:Positive' r.entries.append(e) e.sentiments.append(sent) template = ('{% for entry in entries %}' '{{ entry["nif:isString"] | upper }}' ',{{entry.sentiments[0]["marl:hasPolarity"].split(":")[1]}}' '{% endfor %}') res = r.serialize(template=template) assert res == 'TESTING THE TEMPLATE,Positive'
def test_template(self): r = Results() e = Entry() e.nif__isString = 'testing the template' sent = Sentiment() sent.polarity = 'marl:Positive' r.entries.append(e) e.sentiments.append(sent) template = ( '{% for entry in entries %}' '{{ entry["nif:isString"] | upper }}' ',{{entry.sentiments[0]["marl:hasPolarity"].split(":")[1]}}' '{% endfor %}') res = r.serialize(template=template) assert res == 'TESTING THE TEMPLATE,Positive'