~fuzzgun/emailgraph/trunk-1

« back to all changes in this revision

Viewing changes to emailgraph.c

  • Committer: Bob Mottram
  • Date: 2011-09-08 15:28:45 UTC
  • Revision ID: fuzzgun@gmail.com-20110908152845-q0mn0qr39gnfa8ls
Sentiment analysis

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
}
34
34
 
35
35
int main(int argc, char* argv[]){
36
 
  int i,j,n,printcontacts=0,printdot=0,nonames=0,printtop=0,printinfluence=0;
 
36
  int i,j,n,printcontacts=0,printdot=0,nonames=0,printtop=0,printinfluence=0,printvalence=0;
37
37
  int monthly=0,yearly=0,annual=0,daily=0,weekly=0,success;
38
38
  int gender=GENDER_UNKNOWN;
39
39
  char keywords_str[256];
61
61
  int week_histogram[24*7];
62
62
  int retval,linewidth=10;
63
63
  int sentence_dump=0;
 
64
  int sentiment=0;
64
65
  filename_list * filenames=NULL, * next_filename;
65
66
  int mnth;
66
67
  time_t current_time;
67
68
 
 
69
  /*  
 
70
  read_sentiment_file("sentiment.txt",1);
 
71
  read_sentiment_file("sentiment.txt",0);
 
72
  return 1;
 
73
  */
 
74
 
68
75
  if (contact_list==NULL) {
69
76
    fprintf(stderr,"main: unable to allocate memory\n");
70
77
    return(0);
159
166
    if ((strcmp(argv[i],"-c")==0) || (strcmp(argv[i],"--contacts")==0)) {
160
167
      printcontacts=1;
161
168
    }
 
169
    if (strcmp(argv[i],"--valence")==0) {
 
170
      printvalence=1;
 
171
      sentiment=1;
 
172
    }
162
173
    if ((strcmp(argv[i],"-t")==0) || (strcmp(argv[i],"--top")==0)) {
163
174
      printtop=1;
164
175
    }
438
449
                 (char*)mailbox_filename, contact_list, start_date, 
439
450
                 end_date, start_hour, end_hour,
440
451
                 (int*)month_histogram, (int*)year_histogram, 
441
 
                 (int*)day_histogram, (int*)week_histogram, keywords, gender,corpus,sentence_dump);
 
452
                 (int*)day_histogram, (int*)week_histogram, keywords, gender,corpus,sentence_dump,sentiment);
442
453
  }
443
454
  else {
444
455
    if (filenames!=NULL) {
448
459
                     (char*)(next_filename->filename), contact_list, 
449
460
                     start_date, end_date, start_hour, end_hour,
450
461
                     (int*)month_histogram, (int*)year_histogram, 
451
 
                     (int*)day_histogram, (int*)week_histogram, keywords, gender,corpus,sentence_dump);
 
462
                     (int*)day_histogram, (int*)week_histogram, keywords, gender,corpus,sentence_dump,sentiment);
452
463
        next_filename = (filename_list*)(next_filename->next);
453
464
      }
454
465
    }
475
486
 
476
487
  update_influence(contact_list);
477
488
 
 
489
  update_valence(contact_list);
 
490
 
478
491
  if (corpus==NULL) {
479
492
    if (contacts_size(contact_list)>1) {
480
493
 
482
495
        contact_list = print_influence(contact_list,nonames,min_interactions);
483
496
      }
484
497
      else {
485
 
        if (printtop==1) {
486
 
          contact_list = print_top(contact_list,nonames,min_interactions);
 
498
        if (printvalence==1) {  
 
499
          print_valence(contact_list,nonames,min_interactions);
487
500
        }
488
501
        else {
489
 
          if (printcontacts==1) {
490
 
            contact_list = sort_contacts(contact_list,SORT_NAMES);
491
 
            print_contacts(contact_list);
 
502
          if (printtop==1) {
 
503
            contact_list = print_top(contact_list,nonames,min_interactions);
492
504
          }
493
505
          else {
494
 
            if (printdot==1) {
495
 
              print_dot(contact_list,nonames,min_interactions,linewidth);
 
506
            if (printcontacts==1) {
 
507
              contact_list = sort_contacts(contact_list,SORT_NAMES);
 
508
              print_contacts(contact_list);
496
509
            }
497
510
            else {
498
 
              if (monthly==1) {
499
 
                print_volume_monthly((int*)month_histogram);
 
511
              if (printdot==1) {
 
512
                print_dot(contact_list,nonames,min_interactions,linewidth);
500
513
              }
501
514
              else {
502
 
                if (yearly==1) {
503
 
                  print_volume_yearly((int*)year_histogram);
 
515
                if (monthly==1) {
 
516
                  print_volume_monthly((int*)month_histogram);
504
517
                }
505
518
                else {
506
 
                  if (annual==1) {
507
 
                    print_volume_annual_average((int*)month_histogram);
 
519
                  if (yearly==1) {
 
520
                    print_volume_yearly((int*)year_histogram);
508
521
                  }
509
522
                  else {
510
 
                    if (daily==1) {
511
 
                      print_volume_daily((int*)day_histogram);
 
523
                    if (annual==1) {
 
524
                      print_volume_annual_average((int*)month_histogram);
512
525
                    }
513
526
                    else {
514
 
                      if (weekly==1) {
515
 
                        print_volume_weekly((int*)week_histogram);
 
527
                      if (daily==1) {
 
528
                        print_volume_daily((int*)day_histogram);
 
529
                      }
 
530
                      else {
 
531
                        if (weekly==1) {
 
532
                          print_volume_weekly((int*)week_histogram);
 
533
                        }
516
534
                      }
517
535
                    }
518
536
                  }
593
611
    if ((printcontacts==0) && (printdot==0) && (sentence_dump==0) &&
594
612
        (monthly==0) && (yearly==0) && (annual==0) && (daily==0) && (weekly==0) &&
595
613
        (plot_daily[0]=='\0') && (plot_weekly[0]=='\0') && (plot_monthly[0]=='\0') &&
596
 
        (plot_yearly[0]=='\0') && (printtop==0)) {
 
614
        (plot_yearly[0]=='\0') && (printtop==0) && (printvalence==0)) {
597
615
      printf("%d Contacts detected\n", contacts_size(contact_list));
598
616
    }
599
617