Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -44,9 +44,17 @@ def preprocess_text(text):
44
 
45
  # Text summarization
46
  def summarize_text(text):
47
- summary = summarizer(text, max_length=400, min_length=50, do_sample=False)
 
 
 
 
 
 
 
48
  return summary[0]['summary_text']
49
 
 
50
  # Sentiment analysis
51
  def sentiment_analysis(text):
52
  blob = TextBlob(text)
 
44
 
45
  # Text summarization
46
  def summarize_text(text):
47
+ if not text.strip(): # Check for empty text
48
+ raise ValueError("Input text is empty or invalid.")
49
+
50
+ input_length = len(text.split()) # Approximate input length in words
51
+ max_len = min(400, int(0.8 * input_length)) # Limit max_length dynamically
52
+ print(f"Input length: {input_length}, max_length: {max_len}") # Debugging info
53
+
54
+ summary = summarizer(text, max_length=max_len, min_length=50, do_sample=False) # No use_auth_token
55
  return summary[0]['summary_text']
56
 
57
+
58
  # Sentiment analysis
59
  def sentiment_analysis(text):
60
  blob = TextBlob(text)