def process_email(subject, body, sender): global output_log seen_emails.append( (hash(str(subject)), hash(str(body))) ) #check if this email requires a new appointment body = get_most_recent_email_body(body) body = stripPunctuation(body) possible_times = parse_email(body) if len(possible_times) > 0: print "\nProcessing Email:" print "\nSubject: %s" % subject print "From: %s" % sender print "%s" % body possible_times, user_selection = rank_times(possible_times,body) # Catch the case where user_selection is -1 if (user_selection == -1): print("\nNo event scheduled for email.") return # store_user_choice(user_selection) if possible_times and user_selection: if actuallySchedule: schedule_calendar_event(possible_times[user_selection]) # TODO: Append that body to the appropriate time vector prettyPossible_times = [] for time in possible_times: temp = str(time[0]) prettyPossible_times.append(temp) output_log.append( (prettyPossible_times, user_selection) )
def test_file(file_name): print "Testing on File: %s" % file_name f = open(file_name, "r") body = f.read() print "%s" % body possible_times = parse_email(stripPunctuation(body)) possible_times, user_selection = rank_times(possible_times, body) if (user_selection == -1): print("\nNo event scheduled for email.") return testing_results.append((user_selection, possible_times, body))
def test_file(file_name): print "Testing on File: %s" % file_name f = open(file_name, "r") body = f.read() print "%s" % body possible_times = parse_email(stripPunctuation(body)) possible_times, user_selection = rank_times(possible_times, body) if (user_selection == -1): print("\nNo event scheduled for email.") return testing_results.append( (user_selection, possible_times, body) )
def train_file(file_name): print "Training on File: %s" % file_name f = open(file_name, "r") body = strip_enron_body(f.readlines()) possible_times = parse_email(stripPunctuation(body)) if len(possible_times) > 0: print "%s" % body possible_times, user_selection = rank_times(possible_times, body,file_name) if (user_selection[0] == -1): print("\nNo event scheduled for email.") return training_results.append( (user_selection, possible_times, body) )