moodlens-api / app /utils /response_formatter.py
kpatel1607's picture
Upload folder using huggingface_hub
1320be7 verified
Raw
History Blame Contribute Delete
854 Bytes
def compact_statement(statement):
top_emotion = statement["final_emotion"]["top_emotions"][0]
return {
"text": statement["text"],
"primary_emotion": top_emotion["emotion"],
"emotion_score": top_emotion["score"],
"sarcasm_label": statement["sarcasm"]["label"],
"sarcasm_score": statement["sarcasm"]["model_sarcasm_score"],
"sentiment": statement["sentiment"],
"interpretation": statement["interpretation"]
}
def compact_sequence_response(full_response):
return {
"input_text": full_response["input_text"],
"statement_count": full_response["statement_count"],
"overall": full_response["overall"],
"statements": [
compact_statement(statement)
for statement in full_response["statements"]
]
}