Skip to content

Emotion

Introduction

The Lettria API can identify and extract emotion from text data at the sentence level, and automatically classify it according to the emotion it conveys.

Format

Emotions are received inside an Array() for each subsentences A comprehensive list of emotions can be found here.

Emotion

Emotion Format

KeyTypeDescription
subsentencesSubsentence Emotion [ ]Subsentences Emotion
elementsEmotion Element [ ]Emotion Elements
valuesValuesValues

Subsentence Emotion

Subsentence Emotion Format

KeyTypeDescription
start_idNumberStart ID
end_idNumberEnd ID
elementsElement [ ]Elements
sentenceStringSentence
valuesValuesValues

Subsentence Emotion Example

{
  "start_id": 0,
  "end_id": 2,
  "elements": [
    {
      "target": {
        "lemma": "voyage",
        "source": "voyage",
        "index": 2
      },
      "subject": null,
      "value": { "admiration": 1, "joy": 1 },
      "source": { "index": 1, "lemma": "beau", "source": "beau" }
    }
  ],
  "sentence": "un beau voyage",
  "values" : [ { "type": "admiration", "value": 1 }, { "type": "joy", "value": 1 } ]
}

Values

Values Format

KeyTypeDescription
typeEmotion.Positive
valueNumberPositive

Values Example

[ 
	{ "type": "admiration", "value": 1 },
	{ "type": "joy", "value": 1 }
]

Emotion Element

Emotion Element Format

KeyTypeDescription
targetTargetTarget
subjectSubjectSubject
valueValuesValue
sourceSourceSource

Emotion Element Example

{
	"target": { "lemma": "voyage", "source": "voyage", "index": 2 },
	"subject": null,
	"value": { "admiration": 1, "joy": 1 },
	"source": { "index": 1, "lemma": "beau", "source": "beau" }
}

Value

Value Format

KeyTypeDescription
Emotion.NumberPositive

Value Example

{ "admiration": 1, "joy": 1 }

Target

Target Format

KeyTypeDescription
indexNumberIndex
lemmaStringLemma
sourceStringSource

Target Example

{ "lemma": "immeuble", "source": "immeubles", "index": 6 }

Subject

Subject Format

KeyTypeDescription
indexNumberIndex
lemmaStringLemma
sourceStringSource

Subject Example

{ "lemma": "Victor", "source": "Victor", "index": 0 }

Next steps