File size: 1,343 Bytes
cfe3e6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 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_sentiment import SentimentClassifier

clf = SentimentClassifier(".")
texts = [
    "Bahut badhiya phone hai, battery poora din chalti hai.",  # romanized Hindi: great phone, the battery lasts all day
    "ডেলিভারি তিন দিন দেরিতে এসেছে, খুবই হতাশ।",  # Bengali: delivery came three days late, very disappointed
    "நாளை காலை பத்து மணிக்கு கூட்டம் தொடங்கும்.",  # Tamil: the meeting starts at ten tomorrow morning
    "ಈ ಸಿನಿಮಾ ತುಂಬಾ ಚೆನ್ನಾಗಿದೆ, ಎಲ್ಲರೂ ನೋಡಿ!",  # Kannada: this film is very good, everyone watch it
    "सरकार ने नई योजना की घोषणा की है।",  # Hindi: the government has announced a new scheme
    "yaar kya bakwaas movie thi, paisa barbaad",  # romanized Hindi: what a rubbish film, money wasted
    "Service was okay but the food was cold and overpriced.",
]
for text, r in zip(texts, clf.classify(texts)):
    print(f"{r['label']:<9} {max(r['scores'].values()):.2f}  {text}")