# Common labels for e.g. an e-commerce store's emails labels = ["Returns", "Promotional", "Technical Issues", "Product Inquiries", "Shipping Questions", "Other"] # Negative sentiment, give special attention to these. negative_sentiments = ["annoyance", "disapproval", "disappointment", "anger", "disgust"] kiri = Kiri() kiri.classify("This is just to get rid of the example message before printing", ["test"]) # Print example, just to display local results print("Inbox") print("==================") for email in emails: classification_results = kiri.classify(email, labels) label = max(classification_results, key=classification_results.get) emote = kiri.emotion(email) high_priority = any([e in emote for e in negative_sentiments]) print(f"Category: {label}") if high_priority: print("\033[91mPRIORITY\033[0m") print(f"{email[:85]}...") print("------------------")
def test_emotion(): kiri = Kiri(local=True) out = kiri.emotion(text) assert type(out) == str