rodrigomasini commited on
Commit
36c019e
·
verified ·
1 Parent(s): a337459

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -229,26 +229,34 @@ def pre_process_text(text):
229
 
230
  # Split the text into sections
231
  sections = re.split(r'\n{2,}', text)
 
232
 
233
  # Remove empty strings from the split result
234
  sections = [section.strip() for section in sections if section.strip()]
 
235
 
236
  # Combine sections into a single string
237
- combined_text = '\n\n'.join(sections)
 
 
 
 
 
238
 
239
- sentences_list = re.split(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s', text)
240
- print(sentences_list)
241
  # Split the elements of the list by newline characters
242
  split_sentences = []
243
  for sentence in sentences_list:
244
  split_sentences.extend(re.split(r'\n+', sentence))
 
245
 
246
  # Remove empty elements
247
  cleaned_sentences = [sentence for sentence in split_sentences if sentence.strip()]
 
248
 
249
- combined_text = (" ".join(cleaned_sentences))
 
250
 
251
- return combined_text
252
 
253
  def flesch_kincaid_grade_level(text):
254
  sentences = pre_process_text(text)
 
229
 
230
  # Split the text into sections
231
  sections = re.split(r'\n{2,}', text)
232
+ print("Sections:", sections)
233
 
234
  # Remove empty strings from the split result
235
  sections = [section.strip() for section in sections if section.strip()]
236
+ print("Non-empty Sections:", sections)
237
 
238
  # Combine sections into a single string
239
+ combined_text = ' '.join(sections)
240
+ print("Combined Text:", combined_text)
241
+
242
+ # Split the text into sentences
243
+ sentences_list = re.split(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s', combined_text)
244
+ print("Sentences List:", sentences_list)
245
 
 
 
246
  # Split the elements of the list by newline characters
247
  split_sentences = []
248
  for sentence in sentences_list:
249
  split_sentences.extend(re.split(r'\n+', sentence))
250
+ print("Split Sentences:", split_sentences)
251
 
252
  # Remove empty elements
253
  cleaned_sentences = [sentence for sentence in split_sentences if sentence.strip()]
254
+ print("Cleaned Sentences:", cleaned_sentences)
255
 
256
+ combined_cleaned_text = " ".join(cleaned_sentences)
257
+ print("Combined Cleaned Text:", combined_cleaned_text)
258
 
259
+ return combined_cleaned_text
260
 
261
  def flesch_kincaid_grade_level(text):
262
  sentences = pre_process_text(text)