import gradio as gr from mtranslate import translate from textblob import TextBlob def analyze(sentence): # Translate the sentence from Japanese to English en_sentence = translate(sentence, "en") # Create a TextBlob object for the sentence blob = TextBlob(en_sentence) # Get the polarity score for the sentence polarity_score = blob.sentiment.polarity # Return a result if polarity_score > 0: return "Positive" elif polarity_score == 0: return "Neutral" else: return "Negative" iface = gr.Interface(fn=analyze, inputs="text", outputs="text") iface.launch()