codeteach commited on
Commit
5dd28de
1 Parent(s): 931e757

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -78,8 +78,14 @@ def translate_text(text, language):
78
  def process_text(input_text, model, language):
79
  print(f"Input text: {input_text[:500]}...") # Show only the first 500 characters for brevity
80
  summary = summarize_text(input_text, model)
 
 
 
81
  print(f"Summary: {summary[:500]}...") # Show only the first 500 characters for brevity
82
  bullet_points = generate_bullet_points(summary)
 
 
 
83
  print(f"Bullet Points: {bullet_points}")
84
  translated_text = translate_text(bullet_points, language)
85
  print(f"Translated Text: {translated_text}")
@@ -90,6 +96,8 @@ def generate_bullet_points(summary):
90
 
91
  # Extract key sentences
92
  sentences = sent_tokenize(summary)
 
 
93
  key_sentences = sentences[:3] # Extract the first three sentences as key points
94
 
95
  bullet_points = "\n".join(f"- {sentence}" for sentence in key_sentences)
@@ -128,3 +136,4 @@ iface.launch()
128
 
129
 
130
 
 
 
78
  def process_text(input_text, model, language):
79
  print(f"Input text: {input_text[:500]}...") # Show only the first 500 characters for brevity
80
  summary = summarize_text(input_text, model)
81
+ if not summary:
82
+ print("Summarization failed. Please provide longer text or try a different model.")
83
+ return "", ""
84
  print(f"Summary: {summary[:500]}...") # Show only the first 500 characters for brevity
85
  bullet_points = generate_bullet_points(summary)
86
+ if not bullet_points:
87
+ print("Bullet points generation failed.")
88
+ return "", ""
89
  print(f"Bullet Points: {bullet_points}")
90
  translated_text = translate_text(bullet_points, language)
91
  print(f"Translated Text: {translated_text}")
 
96
 
97
  # Extract key sentences
98
  sentences = sent_tokenize(summary)
99
+ if not sentences:
100
+ return ""
101
  key_sentences = sentences[:3] # Extract the first three sentences as key points
102
 
103
  bullet_points = "\n".join(f"- {sentence}" for sentence in key_sentences)
 
136
 
137
 
138
 
139
+