karalif commited on
Commit
6f918d6
verified
1 Parent(s): 0e88fea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -44,24 +44,22 @@ def analyze_text(icelandic_text):
44
 
45
  politeness_label, politeness_score = analyze_politeness(translated_text)
46
 
47
- analysis_results = {
48
- "Translated Text": translated_text,
49
- "Sentiment": f"Label: {sentiment_label}, Score: {round(sentiment_score, 2)}",
50
- "Formality": f"Label: {formality_label}, Score: {round(formality_score, 2)}",
51
- "Toxicity": f"Score: {round(toxicity_results['score'], 2)}",
52
- "Politeness": f"Label: {politeness_label}, Score: {round(politeness_score, 2)}"
53
- }
 
54
  return analysis_results
55
 
56
  demo = gr.Interface(fn=analyze_text,
57
  inputs=gr.Textbox(lines=2, placeholder="Enter Icelandic Text Here..."),
58
- outputs=[gr.Textbox(label="Translated Text"),
59
- gr.Textbox(label="Sentiment"),
60
- gr.Textbox(label="Formality"),
61
- gr.Textbox(label="Toxicity"),
62
- gr.Textbox(label="Politeness")],
63
  title="Icelandic Text Analysis",
64
- description="This app translates Icelandic text to English and performs sentiment, formality, toxicity, and politeness analysis.")
 
65
 
66
  if __name__ == "__main__":
67
- demo.launch()
 
44
 
45
  politeness_label, politeness_score = analyze_politeness(translated_text)
46
 
47
+ # Combine all analysis results into a single string
48
+ analysis_results = f"""
49
+ Translated Text: {translated_text}
50
+ Sentiment: Label: {sentiment_label}, Score: {round(sentiment_score, 2)}
51
+ Formality: Label: {formality_label}, Score: {round(formality_score, 2)}
52
+ Toxicity: Score: {round(toxicity_results['score'], 2)}
53
+ Politeness: Label: {politeness_label}, Score: {round(politeness_score, 2)}
54
+ """
55
  return analysis_results
56
 
57
  demo = gr.Interface(fn=analyze_text,
58
  inputs=gr.Textbox(lines=2, placeholder="Enter Icelandic Text Here..."),
59
+ outputs=gr.Textbox(label="Analysis Results"),
 
 
 
 
60
  title="Icelandic Text Analysis",
61
+ description="This app translates Icelandic text to English and performs sentiment, formality, toxicity, and politeness analysis.",
62
+ share=True)
63
 
64
  if __name__ == "__main__":
65
+ demo.launch()