Created on 09-28-201806:36 PM - edited 08-17-201906:22 AM
Related: ApacheCon 2018 in Montreal
With my talk in a dual language city, I thought perhaps I should do my talk in French. My college French is very rusty and my accent is very New Jersey. The two don't mix well. So let's have Apache NiFi do it for me. After publically debating this on Twitter, I decided to see if I could implement a solution.
Secret:
Most of the heavy lifting is done by Python which calls Google Translate API under the covers, automagically.
from textblob import TextBlob
import sys
text = ""
for x in sys.argv[1:]:
text += str(x)
#text = sys.stdin.read()
#print(text)
blob = TextBlob(text)
#for sentence in blob.sentences:
# print(sentence.sentiment.polarity)
# 0.060
# -0.341
print(blob.translate(to="fr") )