Skip to content

Instantly share code, notes, and snippets.

@Linus-Albertus
Last active August 18, 2023 17:04
Show Gist options
  • Save Linus-Albertus/8e3de4aff6d40d9f56a914e46bf282bf to your computer and use it in GitHub Desktop.
Save Linus-Albertus/8e3de4aff6d40d9f56a914e46bf282bf to your computer and use it in GitHub Desktop.
from transformers import pipeline
classifier = pipeline('sentiment-analysis',
model="nlptown/bert-base-multilingual-uncased-sentiment")
sentences = ["¡Me encantan los artículos de Medium, son lo máximo!",
"Odio los lunes, no sirven para nada.",
"El libro es medio bueno; me gustaron algunos personajes."]
results = classifier(sentences)
for result in results:
print(f"polaridad: {result['label']}, score: {round(result['score'], 4)}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment