-
Notifications
You must be signed in to change notification settings - Fork 2
/
dataplus.js
executable file
·1195 lines (1115 loc) · 41.6 KB
/
dataplus.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/local/bin/node
/**
| This script was used to process our encoded data.
| Kept here for documentation, I suppose hardly useful for other peoples project.
*/
"use strict";
var tasks = {
plus : true,
user : true,
mlist : true,
gexf : true,
};
var encoding = 'ASCII';
var util = require('util');
var fs = require('fs');
var users = {};
var weekkeys = { a: [], 1: [], 2: [], 3: [], 4: [] };
var ustatA = [
'username',
'casename',
'beruf',
'gender',
'partei',
'followers',
'following',
'tweetsTA',
'tweetsT0',
'tweetsT1',
'tweetsT2',
'tweetsT3',
'tweetsT4',
'tweetsT5',
'tweetsT6',
'tweetsT7',
'tweetsT8',
'tweetsT80',
'tweetsT81',
'tweetsT82',
'tweetsT83',
'tweetsT84',
'tweetsT85',
'tweetsT86',
'tweetsT87',
'tweetsT88',
'tweetsT89',
'mentionsOutTA',
'mentionsOutT0',
'mentionsOutT1',
'mentionsOutT2',
'mentionsOutT3',
'mentionsOutT4',
'mentionsOutT5',
'mentionsOutT6',
'mentionsOutT7',
'mentionsOutT8',
'mentionsOutT80',
'mentionsOutT81',
'mentionsOutT82',
'mentionsOutT83',
'mentionsOutT84',
'mentionsOutT85',
'mentionsOutT86',
'mentionsOutT87',
'mentionsOutT88',
'mentionsOutT89',
'mentionsInTA',
'mentionsInT0',
'mentionsInT1',
'mentionsInT2',
'mentionsInT3',
'mentionsInT4',
'mentionsInT5',
'mentionsInT6',
'mentionsInT7',
'mentionsInT8',
'mentionsInT80',
'mentionsInT81',
'mentionsInT82',
'mentionsInT83',
'mentionsInT84',
'mentionsInT85',
'mentionsInT86',
'mentionsInT87',
'mentionsInT88',
'mentionsInT89',
'retweetsOutTA',
'retweetsOutT0',
'retweetsOutT1',
'retweetsOutT2',
'retweetsOutT3',
'retweetsOutT4',
'retweetsOutT5',
'retweetsOutT6',
'retweetsOutT7',
'retweetsOutT8',
'retweetsOutT80',
'retweetsOutT81',
'retweetsOutT82',
'retweetsOutT83',
'retweetsOutT84',
'retweetsOutT85',
'retweetsOutT86',
'retweetsOutT87',
'retweetsOutT88',
'retweetsOutT89',
'retweetsInTA',
'retweetsInT0',
'retweetsInT1',
'retweetsInT2',
'retweetsInT3',
'retweetsInT4',
'retweetsInT5',
'retweetsInT6',
'retweetsInT7',
'retweetsInT8',
'retweetsInT80',
'retweetsInT81',
'retweetsInT82',
'retweetsInT83',
'retweetsInT84',
'retweetsInT85',
'retweetsInT86',
'retweetsInT87',
'retweetsInT88',
'retweetsInT89',
'mentionsUsersOutTA',
'mentionsUsersOutT0',
'mentionsUsersOutT1',
'mentionsUsersOutT2',
'mentionsUsersOutT3',
'mentionsUsersOutT4',
'mentionsUsersOutT5',
'mentionsUsersOutT6',
'mentionsUsersOutT7',
'mentionsUsersOutT8',
'mentionsUsersOutT80',
'mentionsUsersOutT81',
'mentionsUsersOutT82',
'mentionsUsersOutT83',
'mentionsUsersOutT84',
'mentionsUsersOutT85',
'mentionsUsersOutT86',
'mentionsUsersOutT87',
'mentionsUsersOutT88',
'mentionsUsersOutT89',
'mentionsUsersInTA',
'mentionsUsersInT0',
'mentionsUsersInT1',
'mentionsUsersInT2',
'mentionsUsersInT3',
'mentionsUsersInT4',
'mentionsUsersInT5',
'mentionsUsersInT6',
'mentionsUsersInT7',
'mentionsUsersInT8',
'mentionsUsersInT80',
'mentionsUsersInT81',
'mentionsUsersInT82',
'mentionsUsersInT83',
'mentionsUsersInT84',
'mentionsUsersInT85',
'mentionsUsersInT86',
'mentionsUsersInT87',
'mentionsUsersInT88',
'mentionsUsersInT89',
'mentionsN13UsersOutTA',
'mentionsN13UsersOutT0',
'mentionsN13UsersOutT1',
'mentionsN13UsersOutT2',
'mentionsN13UsersOutT3',
'mentionsN13UsersOutT4',
'mentionsN13UsersOutT5',
'mentionsN13UsersOutT6',
'mentionsN13UsersOutT7',
'mentionsN13UsersOutT8',
'mentionsN13UsersOutT80',
'mentionsN13UsersOutT81',
'mentionsN13UsersOutT82',
'mentionsN13UsersOutT83',
'mentionsN13UsersOutT84',
'mentionsN13UsersOutT85',
'mentionsN13UsersOutT86',
'mentionsN13UsersOutT87',
'mentionsN13UsersOutT88',
'mentionsN13UsersOutT89',
'mentionsN13UsersInTA',
'mentionsN13UsersInT0',
'mentionsN13UsersInT1',
'mentionsN13UsersInT2',
'mentionsN13UsersInT3',
'mentionsN13UsersInT4',
'mentionsN13UsersInT5',
'mentionsN13UsersInT6',
'mentionsN13UsersInT7',
'mentionsN13UsersInT8',
'mentionsN13UsersInT80',
'mentionsN13UsersInT81',
'mentionsN13UsersInT82',
'mentionsN13UsersInT83',
'mentionsN13UsersInT84',
'mentionsN13UsersInT85',
'mentionsN13UsersInT86',
'mentionsN13UsersInT87',
'mentionsN13UsersInT88',
'mentionsN13UsersInT89',
'mentionsN14UsersOutTA',
'mentionsN14UsersOutT0',
'mentionsN14UsersOutT1',
'mentionsN14UsersOutT2',
'mentionsN14UsersOutT3',
'mentionsN14UsersOutT4',
'mentionsN14UsersOutT5',
'mentionsN14UsersOutT6',
'mentionsN14UsersOutT7',
'mentionsN14UsersOutT8',
'mentionsN14UsersOutT80',
'mentionsN14UsersOutT81',
'mentionsN14UsersOutT82',
'mentionsN14UsersOutT83',
'mentionsN14UsersOutT84',
'mentionsN14UsersOutT85',
'mentionsN14UsersOutT86',
'mentionsN14UsersOutT87',
'mentionsN14UsersOutT88',
'mentionsN14UsersOutT89',
'mentionsN14UsersInTA',
'mentionsN14UsersInT0',
'mentionsN14UsersInT1',
'mentionsN14UsersInT2',
'mentionsN14UsersInT3',
'mentionsN14UsersInT4',
'mentionsN14UsersInT5',
'mentionsN14UsersInT6',
'mentionsN14UsersInT7',
'mentionsN14UsersInT8',
'mentionsN14UsersInT80',
'mentionsN14UsersInT81',
'mentionsN14UsersInT82',
'mentionsN14UsersInT83',
'mentionsN14UsersInT84',
'mentionsN14UsersInT85',
'mentionsN14UsersInT86',
'mentionsN14UsersInT87',
'mentionsN14UsersInT88',
'mentionsN14UsersInT89'
];
var ustatK = {};
var themaA = [
'a', '0',
'1', '2', '3', '4', '5', '6', '7', '8',
'80',
'81', '82', '83', '84', '85', '86', '87', '88', '89'
];
var themaK = {};
/**
| Fills ...K (indexOf key) hashtables
*/
(function(){
var a, aZ;
for(a = 0, aZ = themaA.length; a < aZ; a++) {
themaK[themaA[a]] = a;
}
for (a = 0, aZ = ustatA.length; a < aZ; a++) {
ustatK[ustatA[a]] = a;
}
})();
/**
| Returns all users mentioned in a text.
| with types 1-4 for the mention type.
*/
function getMentions(text) {
var mtable = {};
var mentions = [];
function parse(reg, type) {
for(var ca = reg.exec(text); ca !== null; ca = reg.exec(text)) {
var mention = ca[1].toLowerCase();
if (mtable[mention]) continue;
mtable[mention] = true;
mentions.push({ username: mention, type: type });
}
}
parse(/^@([A-Za-z0-9_]+)/g, 2); // direct address
parse(/^\s*RT @([A-Za-z0-9_]+)/g, 3); // simple retweet
parse(/RT @([A-Za-z0-9_]+)/g, 4); // commented retweet
parse(/MT @([A-Za-z0-9_]+)/g, 4); // modified retweet
parse(/"@([A-Za-z0-9_]+)/g, 4); // quote
parse(/via\s+@([A-Za-z0-9_]+)/g, 4); // via
parse(/@([A-Za-z0-9_]+)/g, 1); // normal mention
return mentions;
}
/**
| Reads a CSV or TSV
*/
function readData(name, filename, seperator, head, defaults, max) {
console.log('reading '+name);
var data = [];
var lines = fs.readFileSync(filename, encoding).split('\n');
for (var l = 1, lZ = lines.length; l < lZ; l++) {
var line = lines[l];
var cols = line.split(seperator);
if (cols.length <= 1) continue;
var obj = {};
for (var a = 0, aZ = head.length; a < aZ; a++) {
if (head[a] === null) continue;
var val;
if (a < cols.length && (typeof(cols[a]) !== 'undefined') && cols[a] !== '') {
val = cols[a];
} else if (defaults[a] !== null) {
val = defaults[a];
} else {
throw new Error(filename+':'+l+' '+head[a]+' missing -- '+line);
}
obj[head[a]] = val;
}
data.push(obj);
if (l > max) break;
}
return data;
}
/**
| Writes a CSV or TSV
*/
function writeData(name, filename, seperator, data) {
console.log('writing '+name);
var lines = [];
for (var a = 0, aZ = data.length; a < aZ; a++) {
lines[a] = data[a].join(seperator);
}
fs.writeFileSync(filename, lines.join('\n'), encoding);
}
/**
| returns true if the tweet is not to be excluded.
*/
function isGoodTweet(username, mentions) {
var user = users[username];
if (user && user.beruf !== 0) return true;
for (var a = 0; a < mentions.length; a++) {
user = users[mentions[a].username];
if (user && user.beruf !== 0) return true;
}
return false;
}
function initUser(username, casename, beruf, gender, partei, followers, following) {
gender = '' + parseInt(gender);
var user = {
username : username,
casename : casename || null,
beruf : beruf || 0,
gender : gender || 0,
partei : partei || 0,
followers : followers || '',
following : following || '',
w : {}
};
for (var n in weekkeys) {
user.w[n] = {
tweets : {},
mentionsOut : {},
mentionsIn : {},
mentionsOutUsers : {},
mentionsInUsers : {},
retweetsIn : {},
retweetsOut : {}
};
for (var a = 0, aZ = themaA.length; a < aZ; a++) {
user.w[n].tweets[a] = 0;
user.w[n].mentionsOut[a] = 0;
user.w[n].mentionsIn[a] = 0;
user.w[n].mentionsOutUsers[a] = {};
user.w[n].mentionsInUsers[a] = {};
user.w[n].retweetsIn[a] = 0;
user.w[n].retweetsOut[a] = 0;
}
}
return user;
}
/**
| Reads the user data
*/
function readUsers() {
var userhead = [
'username', null, 'beruf','gender', null, 'partei',
'location', 'description', 'url', null, null,
null, null, 'followers', null, 'following', 'listed', null ];
var userdefaults = [null, null, null, 0 , null, 0];
var userlist = readData('Users', 'UserList.txt', '\t', userhead, userdefaults);
var a, aZ;
for(a = 0, aZ = userlist.length; a < aZ; a++) {
var ua = userlist[a];
if (ua.beruf === '9') throw new Error('Beruf 9 :-(');
userlist[a] = initUser(
ua.username.toLowerCase(),
ua.username,
ua.beruf,
ua.gender,
ua.partei,
ua.followers,
ua.following
);
}
// transforms list to a hashtable
for(a = 0; a < aZ; a++) {
users[userlist[a].username] = userlist[a];
}
//console.log(util.inspect(users));
}
/**
| Sets t to nearest midnight before (or equal) that.
*/
function setMidnight(t) {
t.setHours(0);
t.setMinutes(0);
t.setSeconds(0);
t.setMilliseconds(0);
return t;
}
/**
| Processes the data into data structures.
*/
function processData(n, t0, w) {
console.log('processing W'+n+
' ('+t0.toLocaleDateString()+':'+t0.toLocaleTimeString()+')'
);
var badThema = {};
for(var a = 0, aZ = w.length; a < aZ; a++) {
if (a % 1000 === 0) {
console.log('Tweet: '+a+' / '+aZ + ' Users: '+Object.keys(users).length);
}
var d = w[a];
if (!themaK[d.thema]) {
badThema[d.thema] = 1;
d.thema = themaK['0'];
} else {
d.thema = themaK[d.thema];
}
d.casename = d.username;
d.username = d.username.toLowerCase();
var mentions = getMentions(d.tweet);
d.good = isGoodTweet(d.username, mentions);
var date = (new Date(Date.parse(d.date)));
d.timestamp = date.getTime();
d.day = (n * 10 + 1) +
(Math.floor((date.getTime() - t0.getTime()) / (24 * 60 * 60 * 1000)));
d.hour = date.getHours();
if (!d.good) continue;
var user = users[d.username];
if (!user) {
user = users[d.username] = initUser(d.username, d.casename, 0, 0, 0);
} else if (user.casename === null) {
user.casename = d.casename;
}
user.w.a .tweets[themaK.a]++;
user.w[n].tweets[themaK.a]++;
user.w.a .tweets[d.thema]++;
user.w[n].tweets[d.thema]++;
for (var b = 0, bZ = mentions.length; b < bZ; b++) {
if (bZ > 20) { console.log('BZ '+bz); }
var mention = mentions[b];
switch (mention.type) {
case 1 : d.mention = true; break;
case 2 : d.directAddress = true; break;
case 3 : d.retweet = true; d.simpleRetweet = true; break;
case 4 : d.retweet = true; d.commentRetweet = true; break;
default : throw new Error('invalid mention type');
}
var muser = users[mention.username];
if (!muser) {
muser = users[mention.username] =
initUser(mention.username, null, 0, 0, 0);
}
if (d.mention || d.directAddress) {
muser.w.a .mentionsIn[themaK.a]++;
muser.w[n].mentionsIn[themaK.a]++;
muser.w.a .mentionsIn[d.thema]++;
muser.w[n].mentionsIn[d.thema]++;
muser.w.a. mentionsInUsers[themaK.a][d.username] = true;
muser.w[n].mentionsInUsers[themaK.a][d.username] = true;
muser.w.a .mentionsInUsers[d.thema][d.username] = true;
muser.w[n].mentionsInUsers[d.thema][d.username] = true;
user.w.a. mentionsOutUsers[themaK.a][mention.username] = true;
user.w[n].mentionsOutUsers[themaK.a][mention.username] = true;
user.w.a .mentionsOutUsers[d.thema][mention.username] = true;
user.w[n].mentionsOutUsers[d.thema][mention.username] = true;
}
if (d.retweet) {
muser.w.a .retweetsIn[themaK.a]++;
muser.w[n].retweetsIn[themaK.a]++;
muser.w.a .retweetsIn[d.thema]++;
muser.w[n].retweetsIn[d.thema]++;
}
}
if (d.mention || d.directAddress) {
user.w.a. mentionsOut[themaK.a]++;
user.w[n].mentionsOut[themaK.a]++;
user.w.a .mentionsOut[d.thema]++;
user.w[n].mentionsOut[d.thema]++;
}
if (d.retweet) {
user.w.a .retweetsOut[themaK.a]++;
user.w[n].retweetsOut[themaK.a]++;
user.w.a .retweetsOut[d.thema]++;
user.w[n].retweetsOut[d.thema]++;
}
}
for (var k in badThema) {
console.log('BAD THEMAS: '+util.inspect(badThema));
break;
}
}
/**
| Builds the plus columns output
*/
function makePlus(n, w) {
console.log('make plus for W'+n);
var p = [ [
'username',
'beruf',
'gender',
'partei',
'day',
'hour',
'good',
'directadress',
'retweet',
'simple-retweet',
'comment-retweet',
'mention',
'timestamp',
'tweet'
] ];
for (var a = 0, aZ = w.length; a < aZ; a++) {
var d = w[a];
var user = users[d.username];
p.push([
d.username,
user ? (user.beruf || 0) : 0,
user ? (user.gender || 0): 0,
user ? (user.partei || 0) : 0,
d.day,
d.hour,
d.good ? 1 : 0,
d.directAddress ? 1 : 0,
d.retweet ? 1 : 0,
d.simpleRetweet ? 1 : 0,
d.commentRetweet ? 1 : 0,
d.mention ? 1 : 0,
d.timestamp,
d.tweet
]);
}
return p;
}
/**
| Counts the number of users in u
*/
function countAllUsers(u) {
return Object.keys(u).length;
}
/**
| Counts the number of users with beruf 1-4 in u
*/
function countN13Users(u) {
var c = 0;
for (var k in u) {
if (users[k].beruf >= 1 && users[k].beruf <= 3) {
c++;
}
}
return c;
}
/**
| Counts the number of users with beruf 1-4 in u
*/
function countN14Users(u) {
var c = 0;
for (var k in u) {
if (users[k].beruf >= 1 && users[k].beruf <= 4) {
c++;
}
}
return c;
}
/**
| Calculates user stats
*/
function makeUserStats(n) {
var a, aZ;
var username, user;
console.log('make user stats ' + n);
var p = [];
for (username in users) {
user = users[username];
p.push([
user.username, // username
user.casename, // casename
user.beruf, // beruf
user.gender, // gender
user.partei, // partei
user.followers, // followers
user.following, // following
user.w[n].tweets[themaK[ 'a']], // tweetsTA
user.w[n].tweets[themaK[ '0']], // tweetsT0
user.w[n].tweets[themaK[ '1']], // tweetsT1
user.w[n].tweets[themaK[ '2']], // tweetsT2
user.w[n].tweets[themaK[ '3']], // tweetsT3
user.w[n].tweets[themaK[ '4']], // tweetsT4
user.w[n].tweets[themaK[ '5']], // tweetsT5
user.w[n].tweets[themaK[ '6']], // tweetsT6
user.w[n].tweets[themaK[ '7']], // tweetsT7
user.w[n].tweets[themaK[ '8']], // tweetsT8
user.w[n].tweets[themaK['80']], // tweetsT80
user.w[n].tweets[themaK['81']], // tweetsT81
user.w[n].tweets[themaK['82']], // tweetsT82
user.w[n].tweets[themaK['83']], // tweetsT83
user.w[n].tweets[themaK['84']], // tweetsT84
user.w[n].tweets[themaK['85']], // tweetsT85
user.w[n].tweets[themaK['86']], // tweetsT86
user.w[n].tweets[themaK['87']], // tweetsT87
user.w[n].tweets[themaK['88']], // tweetsT88
user.w[n].tweets[themaK['89']], // tweetsT89
user.w[n].mentionsOut[themaK[ 'a']], // mentionsOutTA
user.w[n].mentionsOut[themaK[ '0']], // mentionsOutT0
user.w[n].mentionsOut[themaK[ '1']], // mentionsOutT1
user.w[n].mentionsOut[themaK[ '2']], // mentionsOutT2
user.w[n].mentionsOut[themaK[ '3']], // mentionsOutT3
user.w[n].mentionsOut[themaK[ '4']], // mentionsOutT4
user.w[n].mentionsOut[themaK[ '5']], // mentionsOutT5
user.w[n].mentionsOut[themaK[ '6']], // mentionsOutT6
user.w[n].mentionsOut[themaK[ '7']], // mentionsOutT7
user.w[n].mentionsOut[themaK[ '8']], // mentionsOutT8
user.w[n].mentionsOut[themaK['80']], // mentionsOutT80
user.w[n].mentionsOut[themaK['81']], // mentionsOutT81
user.w[n].mentionsOut[themaK['82']], // mentionsOutT82
user.w[n].mentionsOut[themaK['83']], // mentionsOutT83
user.w[n].mentionsOut[themaK['84']], // mentionsOutT84
user.w[n].mentionsOut[themaK['85']], // mentionsOutT85
user.w[n].mentionsOut[themaK['86']], // mentionsOutT86
user.w[n].mentionsOut[themaK['87']], // mentionsOutT87
user.w[n].mentionsOut[themaK['88']], // mentionsOutT88
user.w[n].mentionsOut[themaK['89']], // mentionsOutT89
user.w[n].mentionsIn [themaK[ 'a']], // mentionsInTA
user.w[n].mentionsIn [themaK[ '0']], // mentionsInT0
user.w[n].mentionsIn [themaK[ '1']], // mentionsInT1
user.w[n].mentionsIn [themaK[ '2']], // mentionsInT2
user.w[n].mentionsIn [themaK[ '3']], // mentionsInT3
user.w[n].mentionsIn [themaK[ '4']], // mentionsInT4
user.w[n].mentionsIn [themaK[ '5']], // mentionsInT5
user.w[n].mentionsIn [themaK[ '6']], // mentionsInT6
user.w[n].mentionsIn [themaK[ '7']], // mentionsInT7
user.w[n].mentionsIn [themaK[ '8']], // mentionsInT8
user.w[n].mentionsIn [themaK['80']], // mentionsInT80
user.w[n].mentionsIn [themaK['81']], // mentionsInT81
user.w[n].mentionsIn [themaK['82']], // mentionsInT82
user.w[n].mentionsIn [themaK['83']], // mentionsInT83
user.w[n].mentionsIn [themaK['84']], // mentionsInT84
user.w[n].mentionsIn [themaK['85']], // mentionsInT85
user.w[n].mentionsIn [themaK['86']], // mentionsInT86
user.w[n].mentionsIn [themaK['87']], // mentionsInT87
user.w[n].mentionsIn [themaK['88']], // mentionsInT88
user.w[n].mentionsIn [themaK['89']], // mentionsInT89
user.w[n].retweetsOut[themaK[ 'a']], // retweetsOutTA
user.w[n].retweetsOut[themaK[ '0']], // retweetsOutT0
user.w[n].retweetsOut[themaK[ '1']], // retweetsOutT1
user.w[n].retweetsOut[themaK[ '2']], // retweetsOutT2
user.w[n].retweetsOut[themaK[ '3']], // retweetsOutT3
user.w[n].retweetsOut[themaK[ '4']], // retweetsOutT4
user.w[n].retweetsOut[themaK[ '5']], // retweetsOutT5
user.w[n].retweetsOut[themaK[ '6']], // retweetsOutT6
user.w[n].retweetsOut[themaK[ '7']], // retweetsOutT7
user.w[n].retweetsOut[themaK[ '8']], // retweetsOutT8
user.w[n].retweetsOut[themaK['80']], // retweetsOutT80
user.w[n].retweetsOut[themaK['81']], // retweetsOutT81
user.w[n].retweetsOut[themaK['82']], // retweetsOutT82
user.w[n].retweetsOut[themaK['83']], // retweetsOutT83
user.w[n].retweetsOut[themaK['84']], // retweetsOutT84
user.w[n].retweetsOut[themaK['85']], // retweetsOutT85
user.w[n].retweetsOut[themaK['86']], // retweetsOutT86
user.w[n].retweetsOut[themaK['87']], // retweetsOutT87
user.w[n].retweetsOut[themaK['88']], // retweetsOutT88
user.w[n].retweetsOut[themaK['89']], // retweetsOutT89
user.w[n].retweetsIn [themaK[ 'a']], // retweetsInTA
user.w[n].retweetsIn [themaK[ '0']], // retweetsInT0
user.w[n].retweetsIn [themaK[ '1']], // retweetsInT1
user.w[n].retweetsIn [themaK[ '2']], // retweetsInT2
user.w[n].retweetsIn [themaK[ '3']], // retweetsInT3
user.w[n].retweetsIn [themaK[ '4']], // retweetsInT4
user.w[n].retweetsIn [themaK[ '5']], // retweetsInT5
user.w[n].retweetsIn [themaK[ '6']], // retweetsInT6
user.w[n].retweetsIn [themaK[ '7']], // retweetsInT7
user.w[n].retweetsIn [themaK[ '8']], // retweetsInT8
user.w[n].retweetsIn [themaK['80']], // retweetsInT80
user.w[n].retweetsIn [themaK['81']], // retweetsInT81
user.w[n].retweetsIn [themaK['82']], // retweetsInT82
user.w[n].retweetsIn [themaK['83']], // retweetsInT83
user.w[n].retweetsIn [themaK['84']], // retweetsInT84
user.w[n].retweetsIn [themaK['85']], // retweetsInT85
user.w[n].retweetsIn [themaK['86']], // retweetsInT86
user.w[n].retweetsIn [themaK['87']], // retweetsInT87
user.w[n].retweetsIn [themaK['88']], // retweetsInT88
user.w[n].retweetsIn [themaK['89']], // retweetsInT89
countAllUsers(user.w[n].mentionsOutUsers[themaK[ 'a']]), // mentionsUsersOutTA
countAllUsers(user.w[n].mentionsOutUsers[themaK[ '0']]), // mentionsUsersOutT0
countAllUsers(user.w[n].mentionsOutUsers[themaK[ '1']]), // mentionsUsersOutT1
countAllUsers(user.w[n].mentionsOutUsers[themaK[ '2']]), // mentionsUsersOutT2
countAllUsers(user.w[n].mentionsOutUsers[themaK[ '3']]), // mentionsUsersOutT3
countAllUsers(user.w[n].mentionsOutUsers[themaK[ '4']]), // mentionsUsersOutT4
countAllUsers(user.w[n].mentionsOutUsers[themaK[ '5']]), // mentionsUsersOutT5
countAllUsers(user.w[n].mentionsOutUsers[themaK[ '6']]), // mentionsUsersOutT6
countAllUsers(user.w[n].mentionsOutUsers[themaK[ '7']]), // mentionsUsersOutT7
countAllUsers(user.w[n].mentionsOutUsers[themaK[ '8']]), // mentionsUsersOutT8
countAllUsers(user.w[n].mentionsOutUsers[themaK['80']]), // mentionsUsersOutT80
countAllUsers(user.w[n].mentionsOutUsers[themaK['81']]), // mentionsUsersOutT81
countAllUsers(user.w[n].mentionsOutUsers[themaK['82']]), // mentionsUsersOutT82
countAllUsers(user.w[n].mentionsOutUsers[themaK['83']]), // mentionsUsersOutT83
countAllUsers(user.w[n].mentionsOutUsers[themaK['84']]), // mentionsUsersOutT84
countAllUsers(user.w[n].mentionsOutUsers[themaK['85']]), // mentionsUsersOutT85
countAllUsers(user.w[n].mentionsOutUsers[themaK['86']]), // mentionsUsersOutT86
countAllUsers(user.w[n].mentionsOutUsers[themaK['87']]), // mentionsUsersOutT87
countAllUsers(user.w[n].mentionsOutUsers[themaK['88']]), // mentionsUsersOutT88
countAllUsers(user.w[n].mentionsOutUsers[themaK['89']]), // mentionsUsersOutT89
countAllUsers(user.w[n].mentionsInUsers [themaK[ 'a']]), // mentionsUsersInTA
countAllUsers(user.w[n].mentionsInUsers [themaK[ '0']]), // mentionsUsersInT0
countAllUsers(user.w[n].mentionsInUsers [themaK[ '1']]), // mentionsUsersInT1
countAllUsers(user.w[n].mentionsInUsers [themaK[ '2']]), // mentionsUsersInT2
countAllUsers(user.w[n].mentionsInUsers [themaK[ '3']]), // mentionsUsersInT3
countAllUsers(user.w[n].mentionsInUsers [themaK[ '4']]), // mentionsUsersInT4
countAllUsers(user.w[n].mentionsInUsers [themaK[ '5']]), // mentionsUsersInT5
countAllUsers(user.w[n].mentionsInUsers [themaK[ '6']]), // mentionsUsersInT6
countAllUsers(user.w[n].mentionsInUsers [themaK[ '7']]), // mentionsUsersInT7
countAllUsers(user.w[n].mentionsInUsers [themaK[ '8']]), // mentionsUsersInT8
countAllUsers(user.w[n].mentionsInUsers [themaK['80']]), // mentionsUsersInT80
countAllUsers(user.w[n].mentionsInUsers [themaK['81']]), // mentionsUsersInT81
countAllUsers(user.w[n].mentionsInUsers [themaK['82']]), // mentionsUsersInT82
countAllUsers(user.w[n].mentionsInUsers [themaK['83']]), // mentionsUsersInT83
countAllUsers(user.w[n].mentionsInUsers [themaK['84']]), // mentionsUsersInT84
countAllUsers(user.w[n].mentionsInUsers [themaK['85']]), // mentionsUsersInT85
countAllUsers(user.w[n].mentionsInUsers [themaK['86']]), // mentionsUsersInT86
countAllUsers(user.w[n].mentionsInUsers [themaK['87']]), // mentionsUsersInT87
countAllUsers(user.w[n].mentionsInUsers [themaK['88']]), // mentionsUsersInT88
countAllUsers(user.w[n].mentionsInUsers [themaK['89']]), // mentionsUsersInT89
countN13Users(user.w[n].mentionsOutUsers[themaK[ 'a']]), // mentionsN13UsersOutTA
countN13Users(user.w[n].mentionsOutUsers[themaK[ '0']]), // mentionsN13UsersOutT0
countN13Users(user.w[n].mentionsOutUsers[themaK[ '1']]), // mentionsN13UsersOutT1
countN13Users(user.w[n].mentionsOutUsers[themaK[ '2']]), // mentionsN13UsersOutT2
countN13Users(user.w[n].mentionsOutUsers[themaK[ '3']]), // mentionsN13UsersOutT3
countN13Users(user.w[n].mentionsOutUsers[themaK[ '4']]), // mentionsN13UsersOutT4
countN13Users(user.w[n].mentionsOutUsers[themaK[ '5']]), // mentionsN13UsersOutT5
countN13Users(user.w[n].mentionsOutUsers[themaK[ '6']]), // mentionsN13UsersOutT6
countN13Users(user.w[n].mentionsOutUsers[themaK[ '7']]), // mentionsN13UsersOutT7
countN13Users(user.w[n].mentionsOutUsers[themaK[ '8']]), // mentionsN13UsersOutT8
countN13Users(user.w[n].mentionsOutUsers[themaK['80']]), // mentionsN13UsersOutT80
countN13Users(user.w[n].mentionsOutUsers[themaK['81']]), // mentionsN13UsersOutT81
countN13Users(user.w[n].mentionsOutUsers[themaK['82']]), // mentionsN13UsersOutT82
countN13Users(user.w[n].mentionsOutUsers[themaK['83']]), // mentionsN13UsersOutT83
countN13Users(user.w[n].mentionsOutUsers[themaK['84']]), // mentionsN13UsersOutT84
countN13Users(user.w[n].mentionsOutUsers[themaK['85']]), // mentionsN13UsersOutT85
countN13Users(user.w[n].mentionsOutUsers[themaK['86']]), // mentionsN13UsersOutT86
countN13Users(user.w[n].mentionsOutUsers[themaK['87']]), // mentionsN13UsersOutT87
countN13Users(user.w[n].mentionsOutUsers[themaK['88']]), // mentionsN13UsersOutT88
countN13Users(user.w[n].mentionsOutUsers[themaK['89']]), // mentionsN13UsersOutT89
countN13Users(user.w[n].mentionsInUsers [themaK[ 'a']]), // mentionsN13UsersInTA
countN13Users(user.w[n].mentionsInUsers [themaK[ '0']]), // mentionsN13UsersInT0
countN13Users(user.w[n].mentionsInUsers [themaK[ '1']]), // mentionsN13UsersInT1
countN13Users(user.w[n].mentionsInUsers [themaK[ '2']]), // mentionsN13UsersInT2
countN13Users(user.w[n].mentionsInUsers [themaK[ '3']]), // mentionsN13UsersInT3
countN13Users(user.w[n].mentionsInUsers [themaK[ '4']]), // mentionsN13UsersInT4
countN13Users(user.w[n].mentionsInUsers [themaK[ '5']]), // mentionsN13UsersInT5
countN13Users(user.w[n].mentionsInUsers [themaK[ '6']]), // mentionsN13UsersInT6
countN13Users(user.w[n].mentionsInUsers [themaK[ '7']]), // mentionsN13UsersInT7
countN13Users(user.w[n].mentionsInUsers [themaK[ '8']]), // mentionsN13UsersInT8
countN13Users(user.w[n].mentionsInUsers [themaK['80']]), // mentionsN13UsersInT80
countN13Users(user.w[n].mentionsInUsers [themaK['81']]), // mentionsN13UsersInT81
countN13Users(user.w[n].mentionsInUsers [themaK['82']]), // mentionsN13UsersInT82
countN13Users(user.w[n].mentionsInUsers [themaK['83']]), // mentionsN13UsersInT83
countN13Users(user.w[n].mentionsInUsers [themaK['84']]), // mentionsN13UsersInT84
countN13Users(user.w[n].mentionsInUsers [themaK['85']]), // mentionsN13UsersInT85
countN13Users(user.w[n].mentionsInUsers [themaK['86']]), // mentionsN13UsersInT86
countN13Users(user.w[n].mentionsInUsers [themaK['87']]), // mentionsN13UsersInT87
countN13Users(user.w[n].mentionsInUsers [themaK['88']]), // mentionsN13UsersInT88
countN13Users(user.w[n].mentionsInUsers [themaK['89']]), // mentionsN13UsersInT89
countN14Users(user.w[n].mentionsOutUsers[themaK[ 'a']]), // mentionsN14UsersOutTA
countN14Users(user.w[n].mentionsOutUsers[themaK[ '0']]), // mentionsN14UsersOutT0
countN14Users(user.w[n].mentionsOutUsers[themaK[ '1']]), // mentionsN14UsersOutT1
countN14Users(user.w[n].mentionsOutUsers[themaK[ '2']]), // mentionsN14UsersOutT2
countN14Users(user.w[n].mentionsOutUsers[themaK[ '3']]), // mentionsN14UsersOutT3
countN14Users(user.w[n].mentionsOutUsers[themaK[ '4']]), // mentionsN14UsersOutT4
countN14Users(user.w[n].mentionsOutUsers[themaK[ '5']]), // mentionsN14UsersOutT5
countN14Users(user.w[n].mentionsOutUsers[themaK[ '6']]), // mentionsN14UsersOutT6
countN14Users(user.w[n].mentionsOutUsers[themaK[ '7']]), // mentionsN14UsersOutT7
countN14Users(user.w[n].mentionsOutUsers[themaK[ '8']]), // mentionsN14UsersOutT8
countN14Users(user.w[n].mentionsOutUsers[themaK['80']]), // mentionsN14UsersOutT80
countN14Users(user.w[n].mentionsOutUsers[themaK['81']]), // mentionsN14UsersOutT81
countN14Users(user.w[n].mentionsOutUsers[themaK['82']]), // mentionsN14UsersOutT82
countN14Users(user.w[n].mentionsOutUsers[themaK['83']]), // mentionsN14UsersOutT83
countN14Users(user.w[n].mentionsOutUsers[themaK['84']]), // mentionsN14UsersOutT84
countN14Users(user.w[n].mentionsOutUsers[themaK['85']]), // mentionsN14UsersOutT85
countN14Users(user.w[n].mentionsOutUsers[themaK['86']]), // mentionsN14UsersOutT86
countN14Users(user.w[n].mentionsOutUsers[themaK['87']]), // mentionsN14UsersOutT87
countN14Users(user.w[n].mentionsOutUsers[themaK['88']]), // mentionsN14UsersOutT88
countN14Users(user.w[n].mentionsOutUsers[themaK['89']]), // mentionsN14UsersOutT89
countN14Users(user.w[n].mentionsInUsers [themaK[ 'a']]), // mentionsN14UsersInTA
countN14Users(user.w[n].mentionsInUsers [themaK[ '0']]), // mentionsN14UsersInT0
countN14Users(user.w[n].mentionsInUsers [themaK[ '1']]), // mentionsN14UsersInT1
countN14Users(user.w[n].mentionsInUsers [themaK[ '2']]), // mentionsN14UsersInT2
countN14Users(user.w[n].mentionsInUsers [themaK[ '3']]), // mentionsN14UsersInT3
countN14Users(user.w[n].mentionsInUsers [themaK[ '4']]), // mentionsN14UsersInT4
countN14Users(user.w[n].mentionsInUsers [themaK[ '5']]), // mentionsN14UsersInT5
countN14Users(user.w[n].mentionsInUsers [themaK[ '6']]), // mentionsN14UsersInT6
countN14Users(user.w[n].mentionsInUsers [themaK[ '7']]), // mentionsN14UsersInT7
countN14Users(user.w[n].mentionsInUsers [themaK[ '8']]), // mentionsN14UsersInT8
countN14Users(user.w[n].mentionsInUsers [themaK['80']]), // mentionsN14UsersInT80
countN14Users(user.w[n].mentionsInUsers [themaK['81']]), // mentionsN14UsersInT81
countN14Users(user.w[n].mentionsInUsers [themaK['82']]), // mentionsN14UsersInT82
countN14Users(user.w[n].mentionsInUsers [themaK['83']]), // mentionsN14UsersInT83
countN14Users(user.w[n].mentionsInUsers [themaK['84']]), // mentionsN14UsersInT84
countN14Users(user.w[n].mentionsInUsers [themaK['85']]), // mentionsN14UsersInT85
countN14Users(user.w[n].mentionsInUsers [themaK['86']]), // mentionsN14UsersInT86
countN14Users(user.w[n].mentionsInUsers [themaK['87']]), // mentionsN14UsersInT87
countN14Users(user.w[n].mentionsInUsers [themaK['88']]), // mentionsN14UsersInT88
countN14Users(user.w[n].mentionsInUsers [themaK['89']]), // mentionsN14UsersInT89
]);
if(p[p.length-1].length !== ustatA.length) throw new Error('OWWW');
}
var kBeruf = ustatK['beruf'];
var kUsername = ustatK['username'];
p.sort(function(a, b) {
if (a[kBeruf] === b[kBeruf]) {
if (a[kUsername] == b[kUsername]) return 0;
if (a[kUsername] > b[kUsername]) return 1;
if (a[kUsername] < b[kUsername]) return -1;
}
if (!a[kBeruf]) return 1;
if (!b[kBeruf]) return -1;
return a[kBeruf] - b[kBeruf];
});
p.unshift(ustatA);
return p;
}
function makeMList(weeks) {
var mlist = [
'out-username',
'out-beruf',
'in-username',
'in-beruf',
'thema',
'w',
'mention-type',
'tweet',
];
var mls = [mlist];
for(var n = 1; n <= 4; n++) {
var w = weeks[n];
for(var a = 0, aZ = w.length; a < aZ; a++) {
var name = w[a].username;
if (!w[a].good) continue;
var mentions = getMentions(w[a].tweet);
for(var m = 0, mZ = mentions.length; m < mZ; m++) {
var men = mentions[m];
men.username;
mls.push([
w[a].username,
users[w[a].username].beruf,
men.username,
users[men.username].beruf,
themaA[w[a].thema],
n,
men.type,
w[a].tweet
]);
}
}
}
return mls;
}
/**
| turns a date into a format gephi likes
*/
function gexfDateString(date) {
var ye = '' + date.getFullYear();
var mo = '' + (date.getMonth() + 1);
var da = '' + date.getDate();
var ho = '' + date.getHours();
var mi = '' + date.getMinutes();
var se = '' + date.getSeconds();
while (mo.length < 2) mo = '0' + mo;
while (da.length < 2) da = '0' + da;
while (ho.length < 2) ho = '0' + ho;
while (mi.length < 2) mi = '0' + mi;
while (se.length < 2) se = '0' + se;
return [ye,'-',mo,'-',da,'T',ho,':',mi,':',se].join('');
}
/**
| writes gephi data
*/
function writeGEXF(filename, ustat, weeks, withthema) {
console.log('writing '+filename);
var a, aZ, b;
var now = new Date();
var lines = [
'<gexf xmlns="http://www.gexf.net/1.2draft" '+
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '+
'xsi:schemaLocation="http://www.gexf.net/1.2draft '+
'http://www.gexf.net/1.2draft/gexf.xsd" '+
'version="1.2">',
'<meta lastmodifieddate="'+now.getFullYear()+'-'+(now.getMonth()+1)+'-'+now.getDate()+'">',
' <creator>dataplus</creator>',
' <description>All users and menitons in WA</description>',
'</meta>',
'<graph defaultedgetype="directed" timeformat="dateTime">',
' <attributes class="node">',
' <attribute id="0" title="Beruf" type="integer"/>',
' <attribute id="1" title="Gender" type="integer"/>',
' <attribute id="2" title="Partei" type="integer"/>',
' <attribute id="3" title="MentionInUsers" type="integer"/>',
' <attribute id="4" title="MentionOutUsers" type="integer"/>',
' <attribute id="5" title="MentionIn/OutUsers" type="float"/>',
' <attribute id="6" title="RetweetsIn" type="integer"/>',
' <attribute id="7" title="RetweetsOut" type="integer"/>',
' <attribute id="8" title="tweetsTA" type="integer"/>',
' <attribute id="9" title="tweetsT0" type="integer"/>',
' <attribute id="10" title="tweetsT1" type="integer"/>',
' <attribute id="11" title="tweetsT2" type="integer"/>',
' <attribute id="12" title="tweetsT3" type="integer"/>',
' <attribute id="13" title="tweetsT4" type="integer"/>',
' <attribute id="14" title="tweetsT5" type="integer"/>',
' <attribute id="15" title="tweetsT6" type="integer"/>',
' <attribute id="16" title="tweetsT7" type="integer"/>',
' <attribute id="17" title="tweetsT8" type="integer"/>',
' <attribute id="18" title="tweetsT80" type="integer"/>',
' <attribute id="19" title="tweetsT81" type="integer"/>',
' <attribute id="20" title="tweetsT82" type="integer"/>',
' <attribute id="21" title="tweetsT83" type="integer"/>',
' <attribute id="22" title="tweetsT84" type="integer"/>',
' <attribute id="23" title="tweetsT85" type="integer"/>',
' <attribute id="24" title="tweetsT86" type="integer"/>',
' <attribute id="25" title="tweetsT87" type="integer"/>',
' <attribute id="26" title="tweetsT88" type="integer"/>',
' <attribute id="27" title="tweetsT89" type="integer"/>',