Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions EFZP.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ def strip_automated_notation(email_text):
for n in notations:
groups = re.match(n, email_text, re.IGNORECASE + re.DOTALL)
if not groups is None:
if groups.groupdict().has_key("email_message"):
if "email_message" in groups.groupdict():
email_text = groups.groupdict()["email_message"]

return email_text


def get_reply_text(email_text):
#Notes on regex
Expand All @@ -71,7 +70,7 @@ def get_reply_text(email_text):
groups = re.search(pattern, email_text, re.IGNORECASE + re.DOTALL)
reply_text = None
if not groups is None:
if groups.groupdict().has_key("reply_text"):
if "reply_text" in groups.groupdict():
reply_text = groups.groupdict()["reply_text"]
return reply_text

Expand Down Expand Up @@ -102,11 +101,11 @@ def get_signature(email_text):
"yours truly",
"thanking You",
"sent from my iphone"]
pattern = "(?P<signature>(" + string.joinfields(sig_opening_statements, "|") + ")(.)*)"
pattern = "(?P<signature>(" + '|'.join(sig_opening_statements) + ")(.)*)"
groups = re.search(pattern, email_text, re.IGNORECASE + re.DOTALL)
signature = None
if groups:
if groups.groupdict().has_key("signature"):
if 'signature' in groups.groupdict():
signature = groups.groupdict()["signature"]
reply_text = get_reply_text(email_text[email_text.find(signature):])
if reply_text: signature = signature.replace(reply_text, "")
Expand Down Expand Up @@ -175,11 +174,10 @@ def get_salutation(email_text):
"good evening",
"thankyou",
"thank you"]
pattern = "\s*(?P<salutation>(" + string.joinfields(salutation_opening_statements, "|") + ")+(\s*\w*)(\s*\w*)(\s*\w*)(\s*\w*)(\s*\w*)[\.,\xe2:]+\s*)"
pattern = "\s*(?P<salutation>(" + '|'.join(salutation_opening_statements) + ")+(\s*\w*)(\s*\w*)(\s*\w*)(\s*\w*)(\s*\w*)[\.,\xe2:]+\s*)"
groups = re.match(pattern, email_text, re.IGNORECASE)
salutation = None
if not groups is None:
if groups.groupdict().has_key("salutation"):
if "salutation" in groups.groupdict():
salutation = groups.groupdict()["salutation"]
return salutation