entities = [
{"entity_name": "shoes", "entity_text": "The shoes were comfortable"},
{"entity_name": "delivery", "entity_text": "they arrived a day late"},
{"entity_name": "box", "entity_text": "the box was torn"},
{"entity_name": "service", "entity_text": "I expected better service from this store"}
]
for entity in entities:
# Get the text related to the entity
text = entity["entity_text"]
# Run zero-shot classification
result = classifier(text, candidate_labels)
# Get the predicted label with the highest score
predicted_sentiment = result["labels"][0]
# Print or store the result
print(f"Entity: {entity['entity_name']}")
print(f"Text: '{text}'")
print(f"Predicted Sentiment by Zero-Shot Model: {predicted_sentiment}")
print("Scores:", result["scores"])
print("\n")