albertoarrigoni commited on
Commit
f69ab93
·
verified ·
1 Parent(s): 4c6a55e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -15,7 +15,7 @@ PRIOR_MESSAGE_MARKERS = [
15
  re.compile(r'^Begin forwarded message:', re.IGNORECASE),
16
 
17
  # Custom separators in email
18
- re.compile(r'^-+.*-+$'), # For lines like "----------------------------------------------------------------------------------------------------------------"
19
 
20
  # Portuguese patterns
21
  re.compile(r'^Em .* escreveu:', re.IGNORECASE),
@@ -72,7 +72,7 @@ def remove_quoted_text(soup):
72
 
73
  # Remove tables with dotted borders (a typical marker of a previous conversation)
74
  for table in soup.find_all('table'):
75
- if 'border-top:1px dotted' in str(table):
76
  table.decompose()
77
 
78
  return soup
@@ -83,6 +83,9 @@ def extract_latest_message_from_lines(lines):
83
  for line in lines:
84
  # Clean up the line
85
  line = line.strip()
 
 
 
86
  # Check if the line matches any prior message markers
87
  if any(marker.match(line) for marker in PRIOR_MESSAGE_MARKERS):
88
  break # Stop if a prior message marker is found
 
15
  re.compile(r'^Begin forwarded message:', re.IGNORECASE),
16
 
17
  # Custom separators in email
18
+ re.compile(r'^-+.*-+$'), # For lines like "--------------------------------------------------"
19
 
20
  # Portuguese patterns
21
  re.compile(r'^Em .* escreveu:', re.IGNORECASE),
 
72
 
73
  # Remove tables with dotted borders (a typical marker of a previous conversation)
74
  for table in soup.find_all('table'):
75
+ if table.get('style') and 'border-top:1px dotted' in table.get('style'):
76
  table.decompose()
77
 
78
  return soup
 
83
  for line in lines:
84
  # Clean up the line
85
  line = line.strip()
86
+ # Ensure that we're handling None values safely
87
+ if line is None or line == '':
88
+ continue
89
  # Check if the line matches any prior message markers
90
  if any(marker.match(line) for marker in PRIOR_MESSAGE_MARKERS):
91
  break # Stop if a prior message marker is found