forked from emeryberger/CSrankings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
csrankings.ts
1916 lines (1776 loc) · 73.1 KB
/
csrankings.ts
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
/*
CSRankings.ts
@author Emery Berger <[email protected]> http://www.emeryberger.com
*/
/// <reference path="./typescript/he/index.d.ts" />
/// <reference path="./typescript/jquery.d.ts" />
/// <reference path="./typescript/papaparse.d.ts" />
/// <reference path="./typescript/d3.d.ts" />
/// <reference path="./typescript/d3pie.d.ts" />
/// <reference path="./typescript/navigo.d.ts" />
/// <reference path="./typescript/continents.d.ts" />
declare function escape(s: string): string;
declare function unescape(s: string): string;
interface AuthorInfo {
readonly name: string;
readonly affiliation: string;
readonly homepage: string;
readonly scholarid: string;
};
interface DBLPName {
readonly name: string;
readonly dblpname: string;
};
interface Author {
name: string;
readonly dept: string;
readonly area: string;
readonly subarea: string;
readonly count: string;
readonly adjustedcount: string;
readonly year: number;
};
interface CountryInfo {
readonly institution: string;
readonly region: "us" | "europe" | "ca" | "northamerica" | "australasia" | "southamerica" | "asia" | "africa" | "world";
readonly countryabbrv: string;
};
interface Alias {
readonly alias: string;
readonly name: string;
};
interface Turing {
readonly name: string;
readonly year: number;
};
interface ACMFellow {
readonly name: string;
readonly year: number;
};
interface HomePage {
readonly name: string;
readonly homepage: string;
};
interface ScholarID {
readonly name: string;
readonly scholarid: string;
};
interface AreaMap {
readonly area: string;
readonly title: string;
};
interface ChartData {
readonly label: string;
readonly value: number;
readonly color: string;
};
class CSRankings {
private static theInstance: CSRankings; // singleton for this object
private static minToRank = 30; // initial number to rank --> should be enough to enable a scrollbar
public static readonly areas: Array<string> = [];
public static readonly topLevelAreas: { [key: string]: string } = {};
public static readonly topTierAreas: { [key: string]: string } = {};
public static readonly regions: Array<string> = ["us", "europe", "ca", "northamerica", "southamerica", "australasia", "asia", "africa", "world"]
private static readonly nameMatcher = new RegExp('(.*)\\s+\\[(.*)\\]'); // Matches names followed by [X] notes.
private note: { [name: string]: string } = {};
private navigoRouter: Navigo;
// We have scrolled: increase the number we rank.
public static updateMinimum(obj: any): number {
if (CSRankings.minToRank <= 500) {
let t = obj.scrollTop;
CSRankings.minToRank = 5000;
CSRankings.getInstance().rank();
return t;
} else {
return 0;
}
}
// Return the singleton corresponding to this object.
public static getInstance(): CSRankings {
return CSRankings.theInstance;
}
// Promises polyfill.
public static promise(cont: () => void): void {
if (typeof Promise !== "undefined") {
var resolved = Promise.resolve();
resolved.then(cont);
} else {
setTimeout(cont, 0);
}
}
constructor() {
CSRankings.theInstance = this;
this.navigoRouter = new Navigo(null, true);
/* Build the areaDict dictionary: areas -> names used in pie charts
and areaPosition dictionary: areas -> position in area array
*/
for (let position = 0; position < this.areaMap.length; position++) {
const { area, title } = this.areaMap[position];
CSRankings.areas[position] = area;
if (!(area in CSRankings.parentMap)) {
CSRankings.topLevelAreas[area] = area;
}
if (!(area in CSRankings.nextTier)) {
CSRankings.topTierAreas[area] = area;
}
this.areaNames[position] = title;
this.fields[position] = area;
this.areaDict[area] = title; // this.areaNames[position];
this.areaPosition[area] = position;
}
for (let area of this.aiAreas) {
this.aiFields.push(this.areaPosition[area]);
}
for (let area of this.systemsAreas) {
this.systemsFields.push(this.areaPosition[area]);
}
for (let area of this.theoryAreas) {
this.theoryFields.push(this.areaPosition[area]);
}
for (let area of this.interdisciplinaryAreas) {
this.otherFields.push(this.areaPosition[area]);
}
let parentCounter = 0;
for (let child in CSRankings.parentMap) {
let parent = CSRankings.parentMap[child];
if (!(parent in CSRankings.childMap)) {
CSRankings.childMap[parent] = [child];
CSRankings.parentIndex[parent] = parentCounter;
parentCounter += 1;
} else {
CSRankings.childMap[parent].push(child);
}
}
this.displayProgress(1);
(async () => {
await this.loadTuring(this.turing);
await this.loadACMFellow(this.acmfellow);
this.displayProgress(2);
await this.loadAuthorInfo();
this.displayProgress(3);
await this.loadAuthors();
this.setAllOn();
this.navigoRouter.on({
'/index': this.navigation,
'/fromyear/:fromyear/toyear/:toyear/index': this.navigation
}).resolve();
this.displayProgress(4);
this.countAuthorAreas();
await this.loadCountryInfo(this.countryInfo, this.countryAbbrv);
this.addListeners();
CSRankings.geoCheck();
this.rank();
})();
}
private readonly authorFile = "./csrankings.csv";
private readonly authorinfoFile = "./generated-author-info.csv";
private readonly countryinfoFile = "./country-info.csv";
// private readonly aliasFile = "./dblp-aliases.csv";
private readonly turingFile = "./turing.csv";
private readonly turingImage = "./png/acm-turing-award.png";
private readonly acmfellowFile = "./acm-fellows.csv";
private readonly acmfellowImage = "./png/acm.png";
private readonly homepageImage = "./png/house-logo.png";
private readonly allowRankingChange = false; /* Can we change the kind of rankings being used? */
public static readonly parentIndex: { [key: string]: number } = {}; // For color lookups
public static readonly parentMap: { [key: string]: string }
= {
'aaai': 'ai',
'ijcai': 'ai',
'cvpr': 'vision',
'eccv': 'vision',
'iccv': 'vision',
'icml': 'mlmining',
'kdd': 'mlmining',
'nips': 'mlmining',
'acl': 'nlp',
'emnlp': 'nlp',
'naacl': 'nlp',
'sigir': 'ir',
'www': 'ir',
'asplos': 'arch',
'isca': 'arch',
'micro': 'arch',
'hpca': 'arch', // next tier
'ccs': 'sec',
'oakland': 'sec',
'usenixsec': 'sec',
'ndss': 'sec', // next tier (for now)
'pets': 'sec', // next tier
'vldb': 'mod',
'sigmod': 'mod',
'icde': 'mod', // next tier
'pods': 'mod',
'dac': 'da',
'iccad': 'da',
'emsoft': 'bed',
'rtas': 'bed',
'rtss': 'bed',
'sc': 'hpc',
'hpdc': 'hpc',
'ics': 'hpc',
'mobicom': 'mobile',
'mobisys': 'mobile',
'sensys': 'mobile',
'imc': 'metrics',
'sigmetrics': 'metrics',
'osdi': 'ops',
'sosp': 'ops',
'eurosys': 'ops', // next tier (see below)
'fast': 'ops', // next tier
'usenixatc': 'ops', // next tier
'popl': 'plan',
'pldi': 'plan',
'oopsla': 'plan', // next tier
'icfp': 'plan', // next tier
'fse': 'soft',
'icse': 'soft',
'ase': 'soft', // next tier
'issta': 'soft', // next tier
'nsdi': 'comm',
'sigcomm': 'comm',
'siggraph': 'graph',
'siggraph-asia': 'graph',
'focs': 'act',
'soda': 'act',
'stoc': 'act',
'crypto': 'crypt',
'eurocrypt': 'crypt',
'cav': 'log',
'lics': 'log',
'ismb': 'bio',
'recomb': 'bio',
'ec': 'ecom',
'wine': 'ecom',
'chiconf': 'chi',
'ubicomp': 'chi',
'uist': 'chi',
'icra': 'robotics',
'iros': 'robotics',
'rss': 'robotics',
'vis': 'visualization',
'vr': 'visualization'
};
public static readonly nextTier: { [key: string]: boolean } =
{
'ase': true,
'issta': true,
'icde': true,
'pods': true,
'hpca': true,
'ndss': true, // for now
'pets': true,
'eurosys': true,
'fast': true,
'usenixatc': true,
'icfp': true,
'oopsla': true
};
public static readonly childMap: { [key: string]: [string] } = {};
private static readonly noteMap: { [note: string]: string } =
{
'Tech': 'https://tech.cornell.edu/',
'CBG': 'https://www.cis.mpg.de/cbg/',
'INF': 'https://www.cis.mpg.de/mpi-inf/',
'IS': 'https://www.cis.mpg.de/is/',
'MG': 'https://www.cis.mpg.de/molgen/',
'SP': 'https://www.cis.mpg.de/mpi-for-security-and-privacy/',
'SWS': 'https://www.cis.mpg.de/mpi-sws/'
};
private readonly areaMap: Array<AreaMap>
= [{ area: "ai", title: "AI" },
{ area: "aaai", title: "AI" },
{ area: "ijcai", title: "AI" },
{ area: "vision", title: "Vision" },
{ area: "cvpr", title: "Vision" },
{ area: "eccv", title: "Vision" },
{ area: "iccv", title: "Vision" },
{ area: "mlmining", title: "ML" },
{ area: "icml", title: "ML" },
{ area: "kdd", title: "ML" },
{ area: "nips", title: "ML" },
{ area: "nlp", title: "NLP" },
{ area: "acl", title: "NLP" },
{ area: "emnlp", title: "NLP" },
{ area: "naacl", title: "NLP" },
{ area: "ir", title: "Web+IR" },
{ area: "sigir", title: "Web+IR" },
{ area: "www", title: "Web+IR" },
{ area: "arch", title: "Arch" },
{ area: "asplos", title: "Arch" },
{ area: "isca", title: "Arch" },
{ area: "micro", title: "Arch" },
{ area: "hpca", title: "Arch" },
{ area: "comm", title: "Networks" },
{ area: "sigcomm", title: "Networks" },
{ area: "nsdi", title: "Networks" },
{ area: "sec", title: "Security" },
{ area: "ccs", title: "Security" },
{ area: "oakland", title: "Security" },
{ area: "usenixsec", title: "Security" },
{ area: "ndss", title: "Security" },
{ area: "pets", title: "Security" },
{ area: "mod", title: "DB" },
{ area: "sigmod", title: "DB" },
{ area: "vldb", title: "DB" },
{ area: "icde", title: "DB" }, // next tier
{ area: "pods", title: "DB" }, // next tier
{ area: "hpc", title: "HPC" },
{ area: "sc", title: "HPC" },
{ area: "hpdc", title: "HPC" },
{ area: "ics", title: "HPC" },
{ area: "mobile", title: "Mobile" },
{ area: "mobicom", title: "Mobile" },
{ area: "mobisys", title: "Mobile" },
{ area: "sensys", title: "Mobile" },
{ area: "metrics", title: "Metrics" },
{ area: "imc", title: "Metrics" },
{ area: "sigmetrics", title: "Metrics" },
{ area: "ops", title: "OS" },
{ area: "sosp", title: "OS" },
{ area: "osdi", title: "OS" },
{ area: "fast", title: "OS" }, // next tier
{ area: "usenixatc", title: "OS" }, // next tier
{ area: "eurosys", title: "OS" },
{ area: "pldi", title: "PL" },
{ area: "popl", title: "PL" },
{ area: "icfp", title: "PL" }, // next tier
{ area: "oopsla", title: "PL" }, // next tier
{ area: "plan", title: "PL" },
{ area: "soft", title: "SE" },
{ area: "fse", title: "SE" },
{ area: "icse", title: "SE" },
{ area: "ase", title: "SE" }, // next tier
{ area: "issta", title: "SE" }, // next tier
{ area: "act", title: "Theory" },
{ area: "focs", title: "Theory" },
{ area: "soda", title: "Theory" },
{ area: "stoc", title: "Theory" },
{ area: "crypt", title: "Crypto" },
{ area: "crypto", title: "Crypto" },
{ area: "eurocrypt", title: "Crypto" },
{ area: "log", title: "Logic" },
{ area: "cav", title: "Logic" },
{ area: "lics", title: "Logic" },
{ area: "graph", title: "Graphics" },
{ area: "siggraph", title: "Graphics" },
{ area: "siggraph-asia", title: "Graphics" },
{ area: "chi", title: "HCI" },
{ area: "chiconf", title: "HCI" },
{ area: "ubicomp", title: "HCI" },
{ area: "uist", title: "HCI" },
{ area: "robotics", title: "Robotics" },
{ area: "icra", title: "Robotics" },
{ area: "iros", title: "Robotics" },
{ area: "rss", title: "Robotics" },
{ area: "bio", title: "Comp. Bio" },
{ area: "ismb", title: "Comp. Bio" },
{ area: "recomb", title: "Comp. Bio" },
{ area: "da", title: "EDA" },
{ area: "dac", title: "EDA" },
{ area: "iccad", title: "EDA" },
{ area: "bed", title: "Embedded" },
{ area: "emsoft", title: "Embedded" },
{ area: "rtas", title: "Embedded" },
{ area: "rtss", title: "Embedded" },
{ area: "visualization", title: "Visualization" },
{ area: "vis", title: "Visualization" },
{ area: "vr", title: "Visualization" },
{ area: "ecom", title: "ECom" },
{ area: "ec", title: "ECom" },
{ area: "wine", title: "ECom" }
//,{ area : "cse", title : "CSEd" }
];
private readonly aiAreas = ["ai", "vision", "mlmining", "nlp", "ir"];
private readonly systemsAreas = ["arch", "comm", "sec", "mod", "hpc", "mobile", "metrics", "ops", "plan", "soft", "da", "bed"];
private readonly theoryAreas = ["act", "crypt", "log"];
private readonly interdisciplinaryAreas = ["graph", "chi", "robotics", "bio", "visualization", "ecom"];
private readonly areaNames: Array<string> = [];
private readonly fields: Array<string> = [];
private readonly aiFields: Array<number> = [];
private readonly systemsFields: Array<number> = [];
private readonly theoryFields: Array<number> = [];
private readonly otherFields: Array<number> = [];
/* Map area to its name (from areaNames). */
private readonly areaDict: { [key: string]: string } = {};
/* Map area to its position in the list. */
private readonly areaPosition: { [key: string]: number } = {};
/* Map names to Google Scholar IDs. */
private readonly scholarInfo: { [key: string]: string } = {};
/* Map aliases to canonical author name. */
private readonly aliases: { [key: string]: string } = {};
/* Map Turing award winners to year */
private readonly turing: { [key: string]: number } = {};
/* Map ACM Fellow award winners to year */
private readonly acmfellow: { [key: string]: number } = {};
/* Map institution to (non-US) region. */
private readonly countryInfo: { [key: string]: string } = {};
/* Map institution to (non-US) abbreviation. */
private readonly countryAbbrv: { [key: string]: string } = {};
/* Map name to home page. */
private readonly homepages: { [key: string]: string } = {};
/* Set to true for "dense rankings" vs. "competition rankings". */
private readonly useDenseRankings: boolean = false;
/* The data which will hold the parsed CSV of author info. */
private authors: Array<Author> = [];
/* The DBLP-transformed strings per author. */
private dblpAuthors: { [name: string]: string } = {};
/* Map authors to the areas they have published in (for pie chart display). */
private authorAreas: { [name: string]: { [area: string]: number } } = {};
/* Computed stats (univagg). */
private stats: { [key: string]: number } = {};
private areaDeptAdjustedCount: { [key: string]: number } = {}; /* area+dept */
private areaStringMap: { [key: string]: string } = {}; // name -> areaString (memoized)
/* Colors for all areas. */
private readonly color: Array<string> =
["#f30000", "#0600f3", "#00b109", "#14e4b4", "#0fe7fb", "#67f200", "#ff7e00", "#8fe4fa", "#ff5300", "#640000", "#3854d1", "#d00ed8", "#7890ff", "#01664d", "#04231b", "#e9f117", "#f3228e", "#7ce8ca", "#ff5300", "#ff5300", "#7eff30", "#9a8cf6", "#79aff9", "#bfbfbf", "#56b510", "#00e2f6", "#ff4141", "#61ff41"];
private readonly RightTriangle = "►"; // right-facing triangle symbol (collapsed view)
private readonly DownTriangle = "▼"; // downward-facing triangle symbol (expanded view)
private readonly PieChart = "<img alt='closed piechart' src='png/piechart.png'>"; // pie chart image
private readonly OpenPieChart = "<img alt='opened piechart' src='png/piechart-open.png'>"; // opened pie chart image
private translateNameToDBLP(name: string): string {
// Ex: "Emery D. Berger" -> "http://dblp.uni-trier.de/pers/hd/b/Berger:Emery_D="
// First, replace spaces and non-ASCII characters (not complete).
name = name.replace(/ Jr\./g, "_Jr.");
name = name.replace(/ II/g, "_II");
name = name.replace(/ III/g, "_III");
name = name.replace(/'|\-|\./g, "=");
// Now replace diacritics.
name = he.encode(name, { 'useNamedReferences' : true, 'allowUnsafeSymbols' : true });
name = name.replace(/&/g, "=");
name = name.replace(/;/g, "=");
if (false) {
name = name.replace(/Á/g, "=Aacute=");
name = name.replace(/á/g, "=aacute=");
name = name.replace(/è/g, "=egrave=");
name = name.replace(/é/g, "=eacute=");
name = name.replace(/í/g, "=iacute=");
name = name.replace(/ï/g, "=iuml=");
name = name.replace(/ó/g, "=oacute=");
name = name.replace(/Ç/g, "=Ccedil=");
name = name.replace(/ç/g, "=ccedil=");
name = name.replace(/ä/g, "=auml=");
name = name.replace(/ö/g, "=ouml=");
name = name.replace(/ø/g, "=oslash=");
name = name.replace(/Ö/g, "=Ouml=");
name = name.replace(/Ü/g, "=Uuml=");
name = name.replace(/ü/g, "=uuml=");
name = name.replace(/ß/g, "=szlig=");
name = name.replace(/ý/g, "=yacute=");
}
let splitName = name.split(" ");
let lastName = splitName[splitName.length - 1];
let disambiguation = ""
if (parseInt(lastName) > 0) {
// this was a disambiguation entry; go back.
disambiguation = lastName;
splitName.pop();
lastName = splitName[splitName.length - 1] + "_" + disambiguation;
}
splitName.pop();
let newName = splitName.join(" ");
newName = newName.replace(/\s/g, "_");
newName = newName.replace(/\-/g, "=");
newName = encodeURIComponent(newName);
let str = "https://dblp.org/pers/hd";
const lastInitial = lastName[0].toLowerCase();
str += "/" + lastInitial + "/" + lastName + ":" + newName;
return str;
}
/* Create the prologue that we preface each generated HTML page with (the results). */
private makePrologue(): string {
const s = '<div class="table-responsive" style="overflow:auto; height:700px;">'
+ '<table class="table table-fit table-sm table-striped"'
+ 'id="ranking" valign="top">';
return s;
}
private static sum(n: Array<number>): number {
let s = 0.0;
for (let i = 0; i < n.length; i++) {
s += n[i];
}
return s;
}
private static average(n: Array<number>): number {
return CSRankings.sum(n) / n.length;
}
private static stddev(n: Array<number>): number {
let avg = CSRankings.average(n);
let squareDiffs = n.map(function(value) {
let diff = value - avg;
return (diff * diff);
});
let sigma = Math.sqrt(CSRankings.sum(squareDiffs) / (n.length - 1));
return sigma;
}
private areaString(name: string): string {
if (name in this.areaStringMap) {
return this.areaStringMap[name];
}
// Create a summary of areas, separated by commas,
// corresponding to a faculty member's publications. We only
// consider areas within a fixed number of standard deviations
// of the max that also comprise a threshold fraction of pubs
// (and at least crossing a min count threshold).
const pubThreshold = 0.2;
const numStddevs = 1.0;
const topN = 3;
const minPubThreshold = 1;
if (!this.authorAreas[name]) {
return "";
}
// Create an object containing areas and number of publications.
// This is essentially duplicated logic from makeChart and
// should be factored out.
let datadict: { [key: string]: number } = {};
const keys = CSRankings.topTierAreas;
let maxValue = 0;
for (let key in keys) { // i = 0; i < keys.length; i++) {
// let key = keys[i];
// if (key in CSRankings.nextTier) {
// continue;
// }
let value = this.authorAreas[name][key];
if (key in CSRankings.parentMap) {
key = this.areaDict[key];
}
if (value > 0) {
if (!(key in datadict)) {
datadict[key] = 0;
}
datadict[key] += value;
maxValue = (datadict[key] > maxValue) ? datadict[key] : maxValue;
}
}
// Now compute the standard deviation.
let values: Array<number> = [];
for (let key in datadict) {
values.push(datadict[key]);
}
let sum = CSRankings.sum(values);
let stddevs = 0.0;
if (values.length > 1) {
stddevs = Math.ceil(numStddevs * CSRankings.stddev(values));
}
// Strip out everything not within the desired number of
// standard deviations of the max and not crossing the
// publication threshold.
let maxes: Array<string> = [];
for (let key in datadict) {
if ((datadict[key] >= maxValue - stddevs) &&
((1.0 * datadict[key]) / sum >= pubThreshold) &&
(datadict[key] > minPubThreshold)) {
maxes.push(key);
}
}
// Finally, pick at most the top N.
let str = maxes.sort((x, y) => { return datadict[y] - datadict[x]; }).slice(0, topN).join(",");
// Cache the result.
this.areaStringMap[name] = str;
// Return it.
return str;
}
/* from http://hubrik.com/2015/11/16/sort-by-last-name-with-javascript/ */
private compareNames(a: string, b: string): number {
//split the names as strings into arrays
const aName = a.split(" ");
const bName = b.split(" ");
// get the last names by selecting
// the last element in the name arrays
// using array.length - 1 since full names
// may also have a middle name or initial
const aLastName = aName[aName.length - 1];
const bLastName = bName[bName.length - 1];
// compare the names and return either
// a negative number, positive number
// or zero.
if (aLastName < bLastName) return -1;
if (aLastName > bLastName) return 1;
return 0;
}
/* Create a pie chart */
private makeChart(name: string): void {
let data: Array<ChartData> = [];
let datadict: { [key: string]: number } = {};
const keys = CSRankings.topTierAreas;
const uname = unescape(name);
for (let key in keys) { // i = 0; i < keys.length; i++) {
// let key = keys[i];
if (!(uname in this.authorAreas)) {
// Defensive programming.
// This should only happen if we have an error in the aliases file.
return;
}
// if (key in CSRankings.nextTier) {
// continue;
// }
let value = this.authorAreas[uname][key];
// Use adjusted count if this is for a department.
/*
DISABLED so department charts are invariant.
if (uname in this.stats) {
value = this.areaDeptAdjustedCount[key+uname] + 1;
if (value == 1) {
value = 0;
}
}
*/
// Round it to the nearest 0.1.
value = Math.round(value * 10) / 10;
if (value > 0) {
if (key in CSRankings.parentMap) {
key = CSRankings.parentMap[key];
}
if (!(key in datadict)) {
datadict[key] = 0;
}
datadict[key] += value;
}
}
for (let key in datadict) {
let newSlice = {
"label": this.areaDict[key],
"value": Math.round(datadict[key] * 10) / 10,
"color": this.color[CSRankings.parentIndex[key]]
};
data.push(newSlice);
}
new d3pie(name + "-chart", {
"header": {
"title": {
"text": uname,
"fontSize": 24,
"font": "open sans"
},
"subtitle": {
"text": "Publication Profile",
"color": "#999999",
"fontSize": 14,
"font": "open sans"
},
"titleSubtitlePadding": 9
},
"size": {
"canvasHeight": 500,
"canvasWidth": 500,
"pieInnerRadius": "38%",
"pieOuterRadius": "83%"
},
"data": {
"content": data,
"smallSegmentGrouping": {
"enabled": true,
"value": 1
},
},
"labels": {
"outer": {
"pieDistance": 32
},
"inner": {
//"format": "percentage", // "value",
//"hideWhenLessThanPercentage": 0 // 2 // 100 // 2
"format": "value",
"hideWhenLessThanPercentage": 5 // 100 // 2
},
"mainLabel": {
"fontSize": 10.5
},
"percentage": {
"color": "#ffffff",
"decimalPlaces": 0
},
"value": {
"color": "#ffffff", // "#adadad",
"fontSize": 10
},
"lines": {
"enabled": true
},
"truncation": {
"enabled": true
}
},
"effects": {
"load": {
"effect": "none"
},
"pullOutSegmentOnClick": {
"effect": "linear",
"speed": 400,
"size": 8
}
},
"misc": {
"gradient": {
"enabled": true,
"percentage": 100
}
}
});
}
private displayProgress(step: number) {
let msgs = ["Initializing.",
"Loading author information.",
"Loading publication data.",
"Computing ranking."];
let s = "";
let count = 1;
msgs.map((elem) => {
if (count == step) {
s += "<strong>" + elem + "</strong>";
} else {
s += "<font color='gray'>" + elem + "</font>";
}
s += "<br />";
count += 1;
});
document.querySelector("#progress")!.innerHTML = s;
}
private async loadTuring(turing: { [key: string]: number }): Promise<void> {
const data = await new Promise((resolve) => {
Papa.parse(this.turingFile, {
header: true,
download: true,
complete: (results) => {
resolve(results.data);
}
});
});
const d = data as Array<Turing>;
for (let turingPair of d) {
turing[turingPair.name] = turingPair.year;
}
}
private async loadACMFellow(acmfellow: { [key: string]: number }): Promise<void> {
const data = await new Promise((resolve) => {
Papa.parse(this.acmfellowFile, {
header: true,
download: true,
complete: (results) => {
resolve(results.data);
}
});
});
const d = data as Array<ACMFellow>;
for (let acmfellowPair of d) {
acmfellow[acmfellowPair.name] = acmfellowPair.year;
}
}
private async loadCountryInfo(countryInfo: { [key: string]: string },
countryAbbrv: { [key: string]: string }): Promise<void> {
const data = await new Promise((resolve) => {
Papa.parse(this.countryinfoFile, {
header: true,
download: true,
complete: (results) => {
resolve(results.data);
}
});
});
const ci = data as Array<CountryInfo>;
for (let info of ci) {
countryInfo[info.institution] = info.region;
countryAbbrv[info.institution] = info.countryabbrv;
}
}
private async loadAuthorInfo(): Promise<void> {
const data = await new Promise((resolve) => {
Papa.parse(this.authorFile, {
download: true,
header: true,
complete: (results) => {
resolve(results.data);
}
});
});
const ai = data as Array<AuthorInfo>;
for (let counter = 0; counter < ai.length; counter++) {
const record = ai[counter];
let name = record['name'].trim();
let result = name.match(CSRankings.nameMatcher);
if (result) {
name = result[1].trim();
this.note[name] = result[2];
}
if (name !== "") {
this.dblpAuthors[name] = this.translateNameToDBLP(name);
this.homepages[name] = record['homepage'];
this.scholarInfo[name] = record['scholarid'];
}
}
}
private async loadAuthors(): Promise<void> {
const data = await new Promise((resolve) => {
Papa.parse(this.authorinfoFile, {
download: true,
header: true,
complete: (results) => {
resolve(results.data);
}
});
});
this.authors = data as Array<Author>;
}
private inRegion(dept: string,
regions: string): boolean {
switch (regions) {
case "us":
if (dept in this.countryInfo) {
return false;
}
break;
case "at":
case "au":
case "br":
case "ca":
case "ch":
case "cn":
case "de":
case "dk":
case "es":
case "fr":
case "gr":
case "hk":
case "il":
case "in":
case "it":
case "jp":
case "kr":
case "nl":
case "nz":
case "tr":
case "uk":
if (this.countryAbbrv[dept] != regions) {
return false;
}
break;
case "europe":
if (!(dept in this.countryInfo)) { // USA
return false;
}
if (this.countryInfo[dept] != "europe") {
return false;
}
break;
case "northamerica":
if ((dept in this.countryInfo) && (this.countryInfo[dept] != "canada")) {
return false;
}
break;
case "australasia":
if (!(dept in this.countryInfo)) { // USA
return false;
}
if (this.countryInfo[dept] != "australasia") {
return false;
}
break;
case "southamerica":
if (!(dept in this.countryInfo)) { // USA
return false;
}
if (this.countryInfo[dept] != "southamerica") {
return false;
}
break;
case "asia":
if (!(dept in this.countryInfo)) { // USA
return false;
}
if (this.countryInfo[dept] != "asia") {
return false;
}
break;
case "africa":
if (!(dept in this.countryInfo)) { // USA
return false;
}
if (this.countryInfo[dept] != "africa") {
return false;
}
break;
case "world":
break;
}
return true;
}
private activateFields(value: boolean,
fields: Array<number>): boolean {
for (let i = 0; i < fields.length; i++) {
const item = this.fields[fields[i]];
const str = "input[name=" + item + "]";
$(str).prop('checked', value);
if (item in CSRankings.childMap) {
// It's a parent.
$(str).prop('disabled', false);
// Activate / deactivate all children as appropriate.
CSRankings.childMap[item].forEach((k) => {
const str = 'input[name=' + k + ']';
if (k in CSRankings.nextTier) {
$(str).prop('checked', false);
} else {
$(str).prop('checked', value);
}
});
}
}
this.rank();
return false;
}
private sortIndex(univagg: { [key: string]: number }): string[] {
let keys = Object.keys(univagg);