Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kristjan-eljand/3cea29cdcf7869dca014a3baae407c06 to your computer and use it in GitHub Desktop.
Save kristjan-eljand/3cea29cdcf7869dca014a3baae407c06 to your computer and use it in GitHub Desktop.
est_to_eng sentiment analysis failed translation example
# Translate the text from input language to english
input_to_translate = "Parim argument demokraatia vastu on viieminutiline vestlus keskmise valijaga"
translated_input = translate(input_to_translate)[0]['translation_text']
# Using the sentiment classifier is oneliner
result = classifier(translated_input)[0]
print(translated_input)
print(f"label: {result['label']}, with score: {round(result['score'], 4)}")
# Output:
# The best argument for democracy is a five-minute conversation with the average voter.
# label: POSITIVE, with score: 0.9969
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment