File size: 857 Bytes
02d8c71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Copyright 2026 Cobuild Tech Private Limited
# SPDX-License-Identifier: Apache-2.0
"""Run from the model folder:  python example.py   (every text below is invented for this example)"""
from cbx_emotion import EmotionClassifier

clf = EmotionClassifier(".")
texts = [
    "Thank you so much, this made my whole week!",
    "I can't believe they cancelled the show after one season. Ugh.",
    "The meeting has been moved to 3 pm on Thursday.",
    "Wait, you're telling me he actually won? Wow.",
    "I miss my grandmother every single day.",
    "That guy cut the whole queue and then yelled at the cashier. Disgusting behaviour.",
    "I'm really nervous about my exam results tomorrow.",
]
for text, r in zip(texts, clf.classify(texts)):
    tags = ', '.join(f"{l} {r['scores'][l]:.2f}" for l in r['labels']) or '(none)'
    print(f"{tags:<28} {text}")