Esempio n. 1
0
    def display_emails_for_social(self, evt):

        w = evt.widget
        cluster_id = w.curselection()[
            0]  #assumes nth row in listbox corresponds to nth topic!
        print 'Displaying emails for social cluster %i' % cluster_id

        #Sort emails into their top 3 topics
        e_x_c = sp.io.loadmat('./model_results/social_result_raw.mat').get(
            'decomposition_email')
        e_x_sorted_cluster = di.assign_emails(e_x_c, 3)

        self.cur_cluster_emails = []
        #Find email indice that belong in selected topic
        for i in range(len(e_x_sorted_cluster)):
            if cluster_id in e_x_sorted_cluster[i]:
                self.cur_cluster_emails.append(i)

        #Display email filenames in listbox
        tag_dicts = pe.load_tags('./data/round3_full_tags.csv')

        email_subjects = []
        for mail_idx in self.cur_cluster_emails:
            email_subjects.append(tag_dicts[mail_idx]['From'].strip() +
                                  ' -- ' +
                                  tag_dicts[mail_idx]['Subject'].strip())
        self.listbox.delete(0, END)

        for subj in email_subjects:
            self.listbox.insert(END, subj)
Esempio n. 2
0
    def display_emails_for_topic(self, evt):

        w = evt.widget
        topic_id = w.curselection()[
            0]  #assumes nth row in listbox corresponds to nth topic!
        print 'Displaying emails for topic %i' % topic_id

        #Sort emails into their top 3 topics
        ext = pe.load_email_x_topic(
            './model_results/round3_LDA_email_x_topic_FULL_14453.npy', 14453)
        e_x_sorted_topic = di.assign_emails(ext, 3)

        self.cur_topic_emails = []
        #Find email indice that belong in selected topic
        for i in range(len(e_x_sorted_topic)):
            if topic_id in e_x_sorted_topic[i]:
                self.cur_topic_emails.append(i)

        #Display email filenames in listbox
        tag_dicts = pe.load_tags('./data/round3_full_tags.csv')

        email_subjects = []
        for mail_idx in self.cur_topic_emails:
            email_subjects.append(tag_dicts[mail_idx]['From'].strip() +
                                  ' -- ' +
                                  tag_dicts[mail_idx]['Subject'].strip())
        self.listbox.delete(0, END)

        for subj in email_subjects:
            self.listbox.insert(END, subj)
Esempio n. 3
0
 def display_emails_for_social(self, evt):
         
     w = evt.widget
     cluster_id = w.curselection()[0] #assumes nth row in listbox corresponds to nth topic!
     print 'Displaying emails for social cluster %i' % cluster_id
     
     #Sort emails into their top 3 topics
     e_x_c = sp.io.loadmat('./model_results/social_result_raw.mat').get('decomposition_email')
     e_x_sorted_cluster = di.assign_emails(e_x_c, 3)
     
     self.cur_cluster_emails = []
     #Find email indice that belong in selected topic
     for i in range(len(e_x_sorted_cluster)):
         if cluster_id in e_x_sorted_cluster[i]:
             self.cur_cluster_emails.append(i)
             
     #Display email filenames in listbox
     tag_dicts = pe.load_tags('./data/round3_full_tags.csv')
     
     email_subjects = []
     for mail_idx in self.cur_cluster_emails:
         email_subjects.append( tag_dicts[mail_idx]['From'].strip() + ' -- ' + tag_dicts[mail_idx]['Subject'].strip() )
     self.listbox.delete(0,END)
     
     for subj in email_subjects:
         self.listbox.insert(END, subj)
Esempio n. 4
0
 def display_emails_for_topic(self, evt):
         
     w = evt.widget
     topic_id = w.curselection()[0] #assumes nth row in listbox corresponds to nth topic!
     print 'Displaying emails for topic %i' % topic_id
     
     #Sort emails into their top 3 topics
     ext = pe.load_email_x_topic('./model_results/round3_LDA_email_x_topic_FULL_14453.npy', 14453)
     e_x_sorted_topic = di.assign_emails(ext, 3)
     
     self.cur_topic_emails = []
     #Find email indice that belong in selected topic
     for i in range(len(e_x_sorted_topic)):
         if topic_id in e_x_sorted_topic[i]:
             self.cur_topic_emails.append(i)
             
     #Display email filenames in listbox
     tag_dicts = pe.load_tags('./data/round3_full_tags.csv')
     
     email_subjects = []
     for mail_idx in self.cur_topic_emails:
         email_subjects.append( tag_dicts[mail_idx]['From'].strip() + ' -- ' + tag_dicts[mail_idx]['Subject'].strip() )
     self.listbox.delete(0,END)
     
     for subj in email_subjects:
         self.listbox.insert(END, subj)
Esempio n. 5
0
 def fetch_email(self, evt):
     if self.view_is_category:
         return
         
     w = evt.widget
     #load tags for all mails
     tag_dicts = pe.load_tags('./data/round3_full_tags.csv')        
     self.emailText.delete(1.0,END)
     
     try:
         if self.category_is_social:
             self.emailText.insert(1.0, open('./sarahs_inbox/parsed/msnbc/txt/' + tag_dicts[self.cur_cluster_emails[w.curselection()[0]]]['filename']).read()) 
         else:
             self.emailText.insert(1.0, open('./sarahs_inbox/parsed/msnbc/txt/' + tag_dicts[self.cur_topic_emails[w.curselection()[0]]]['filename']).read()) 
     except:
         print 'Error displaying email (probably none loaded or bad filename)'   
Esempio n. 6
0
    def fetch_email(self, evt):
        if self.view_is_category:
            return

        w = evt.widget
        #load tags for all mails
        tag_dicts = pe.load_tags('./data/round3_full_tags.csv')
        self.emailText.delete(1.0, END)

        try:
            if self.category_is_social:
                self.emailText.insert(
                    1.0,
                    open('./sarahs_inbox/parsed/msnbc/txt/' +
                         tag_dicts[self.cur_cluster_emails[
                             w.curselection()[0]]]['filename']).read())
            else:
                self.emailText.insert(
                    1.0,
                    open('./sarahs_inbox/parsed/msnbc/txt/' +
                         tag_dicts[self.cur_topic_emails[
                             w.curselection()[0]]]['filename']).read())
        except:
            print 'Error displaying email (probably none loaded or bad filename)'