forked from emeryberger/CSrankings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
csrankings.ts
2023 lines (1867 loc) · 78.9 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 <emery@cs.umass.edu> http://www.emeryberger.com
*/
/// <reference path="./typescript/he/index.d.ts" />
/// <reference path="./typescript/jquery.d.ts" />
/// <reference path="./typescript/vega-embed.d.ts" />
/// <reference path="./typescript/papaparse.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 area: string;
readonly value: number;
};
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> = ["europe", "northamerica", "southamerica", "australasia", "asia", "africa", "world", "ae","ar","at","au","bd","be","br","ca","ch","cl","cn","co","cy","cz","de","dk","ee","eg","es","fi","fr","gr","hk","hu","ie","il","in","ir","it","jo","jp","kr","lb","lk","lu","mt","my","nl","no","nz","ph","pk","pl","pt","qa","ro","ru","sa","se","sg","th","tr","tw","uk","za"];
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) {
const 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 dictionaries:
areaDict: areas -> names used in pie charts
areaPosition: areas -> position in area array
subareas: subareas -> areas (e.g., "Vision" -> "ai")
*/
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;
}
const subareaList = [
...this.aiAreas.map(key =>
({[this.areaDict[key]] : "ai" })),
...this.systemsAreas.map(key =>
({[this.areaDict[key]] : "systems"})),
...this.theoryAreas.map(key =>
({[this.areaDict[key]] : "theory"})),
...this.interdisciplinaryAreas.map(key =>
({[this.areaDict[key]] : "interdisciplinary"})),
];
for (const item of subareaList) {
for (const key in item) {
this.subareas[key] = item[key];
}
}
for (const area of this.aiAreas) {
this.aiFields.push(this.areaPosition[area]);
}
for (const area of this.systemsAreas) {
this.systemsFields.push(this.areaPosition[area]);
}
for (const area of this.theoryAreas) {
this.theoryFields.push(this.areaPosition[area]);
}
for (const area of this.interdisciplinaryAreas) {
this.otherFields.push(this.areaPosition[area]);
}
let parentCounter = 0;
for (const child in CSRankings.parentMap) {
const 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();
// We've finished loading; remove the overlay.
document!.getElementById("overlay-loading")!.style.display = "none";
// Randomly display a survey.
const surveyFrequency = 1000000; // One out of this many users gets the survey (on average).
// Check to see if survey has already been displayed.
let displaySurvey = false;
// Keep the cookie for backwards compatibility (for now).
let shownAlready = document.cookie.split('; ').find(row => row.startsWith('surveyDisplayed')) ||
localStorage.getItem('surveyDisplayed');
// DISABLE SURVEY (remove the next line to re-enable)
shownAlready = 'disabled';
if (!shownAlready) {
// Not shown yet.
const randomValue = Math.floor(Math.random() * surveyFrequency);
displaySurvey = (randomValue == 0);
if (displaySurvey) {
localStorage.setItem('surveyDisplayed', 'true');
// Now reveal the survey.
document!.getElementById("overlay-survey")!.style.display = "block";
}
}
// Randomly display a sponsorship request.
// In the future, tie to amount of use of the site, a la Wikipedia.
const sponsorshipFrequency = 5; // One out of this many users gets the sponsor page (on average).
// Check to see if the sponsorship page has already been displayed.
if (!localStorage.getItem('sponsorshipDisplayed')) {
// Not shown yet.
const randomValue = Math.floor(Math.random() * sponsorshipFrequency);
const displaySponsor = (randomValue == 0);
if (!displaySurvey && displaySponsor) { // Only show if we have not shown the survey page as well.
localStorage.setItem('sponsorshipDisplayed', 'true');
// Now reveal the sponsorship page.
document!.getElementById("overlay-sponsor")!.style.display = "block";
}
}
})();
}
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',
'iclr': 'mlmining',
'kdd': 'mlmining',
'nips': 'mlmining',
'acl': 'nlp',
'emnlp': 'nlp',
'naacl': 'nlp',
'sigir': 'inforet',
'www': 'inforet',
'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',
'eurographics': 'graph', // next tier
'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',
'sigcse': 'csed'
};
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,
'eurographics': true,
'fast': true,
'usenixatc': true,
'icfp': true,
'oopsla': true,
'kdd': 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: "iclr", title: "ML" },
{ area: "nips", title: "ML" },
{ area: "nlp", title: "NLP" },
{ area: "acl", title: "NLP" },
{ area: "emnlp", title: "NLP" },
{ area: "naacl", title: "NLP" },
{ area: "inforet", 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: "eurographics", 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 : "csed", title : "CSEd" },
{ area : "sigcse", title: "CSEd" }
];
private readonly aiAreas = ["ai", "vision", "mlmining", "nlp", "inforet"];
private readonly systemsAreas = ["arch", "comm", "sec", "mod", "da", "bed", "hpc", "mobile", "metrics", "ops", "plan", "soft"];
private readonly theoryAreas = ["act", "crypt", "log"];
private readonly interdisciplinaryAreas = ["bio", "graph", "csed", "ecom", "chi", "robotics", "visualization"];
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 subareas to their areas. */
private readonly subareas: { [key: string]: string } = {};
/* 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)
private usePieChart: boolean = false;
/* Colors. */
private readonly RightTriangle = "►"; // right-facing triangle symbol (collapsed view)
private readonly DownTriangle = "▼"; // downward-facing triangle symbol (expanded view)
private readonly BarChartIcon = "<img class='closed_chart_icon chart_icon' alt='closed chart' src='png/barchart.png'>"; // bar chart image
private readonly OpenBarChartIcon = "<img class='open_chart_icon chart_icon' alt='opened chart' src='png/barchart-open.png'>"; // opened bar chart image
private readonly PieChartIcon = "<img class='closed_chart_icon chart_icon' alt='closed chart' src='png/piechart.png'>";
private readonly OpenPieChartIcon = "<img class='open_chart_icon chart_icon' alt='opened chart' src='png/piechart-open.png'>";
private ChartIcon = this.BarChartIcon;
private OpenChartIcon = this.OpenBarChartIcon;
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, "=");
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 {
const avg = CSRankings.average(n);
const squareDiffs = n.map(function(value) {
const diff = value - avg;
return (diff * diff);
});
const 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;
// }
const 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 (const key in datadict) {
values.push(datadict[key]);
}
const 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 (const 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.
const areaList = maxes.sort((x, y) => { return datadict[y] - datadict[x]; }).slice(0, topN);
// Cache the result.
this.areaStringMap[name] = areaList.map(n => `<span class="${this.subareas[n]}-area">${n}</span>`).join(",");
// Return it.
return this.areaStringMap[name];
}
private removeDisambiguationSuffix(str: string) {
// Matches a space followed by a four-digit number at the end of the string
const regex = /\s\d{4}$/;
return str.replace(regex, '');
}
/* 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,
// removing any disambiguation suffixes first.
const aName = this.removeDisambiguationSuffix(a).split(" ");
const bName = this.removeDisambiguationSuffix(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];
let returnValue : number;
// compare the names and return either
// a negative number, positive number
// or zero.
if (aLastName < bLastName) {
returnValue = -1;
} else if (aLastName > bLastName) {
returnValue = 1;
} else {
returnValue = 0;
}
return returnValue;
}
/* Create a bar or pie chart using Vega. Modified by Minsuk Kahng (https://minsuk.com) */
private makeChart(name: string, isPieChart: boolean): void {
let data: Array<ChartData> = [];
let datadict: { [key: string]: number } = {};
const keys = CSRankings.topTierAreas;
const uname = unescape(name);
// Areas with their category info for color map (from https://colorbrewer2.org/#type=qualitative&scheme=Set1&n=4).
const areas = [
...this.aiAreas.map(key =>
({key: key, label: this.areaDict[key], color: "#377eb8"})),
...this.systemsAreas.map(key =>
({key: key, label: this.areaDict[key], color: "#ff7f00"})),
...this.theoryAreas.map(key =>
({key: key, label: this.areaDict[key], color: "#4daf4a"})),
...this.interdisciplinaryAreas.map(key =>
({key: key, label: this.areaDict[key], color: "#984ea3"}))
];
areas.forEach(area => datadict[area.key] = 0);
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;
// }
// Round it to the nearest 0.1.
const value = Math.round(this.authorAreas[uname][key] * 10) / 10;
// 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;
}
}
*/
if (value > 0) {
if (key in CSRankings.parentMap) {
key = CSRankings.parentMap[key];
}
datadict[key] += value;
}
}
let valueSum = 0;
areas.forEach(area => {
valueSum += datadict[area.key];
});
areas.forEach((area, index) => {
const newSlice = {
index: index,
area: this.areaDict[area.key],
value: Math.round(datadict[area.key] * 10) / 10,
ratio: datadict[area.key] / valueSum
};
data.push(newSlice);
area.label = this.areaDict[area.key];
});
const colors = areas.sort((a, b) =>
a.label > b.label ? 1 : (a.label < b.label ? -1 : 0)
).map(area => area.color);
const vegaLiteBarChartSpec = {
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
data: {
values: data
},
mark: "bar",
encoding: {
x: {
field: "area",
type: "nominal",
sort: null,
axis: {title: null}
},
y: {
field: "value",
type: "quantitative",
axis: {title: null}
},
tooltip: [
{"field": "area", "type": "nominal", "title": "Area"},
{"field": "value", "type": "quantitative", "title": "Count"}
],
color: {
field: "area",
type: "nominal",
scale: {"range": colors},
legend: null
}
},
width: 420,
height: 80,
padding: {left: 25, top: 3}
};
const vegaLitePieChartSpec = {
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
data: {
values: data
},
encoding: {
theta: {
field: "value",
type: "quantitative",
stack: true
},
color: {
field: "area",
type: "nominal",
scale: {"range": colors},
legend: null
},
order: {field: "index"},
tooltip: [
{field: "area", type: "nominal", title: "Area"},
{field: "value", type: "quantitative", title: "Count"},
{field: "ratio", type: "quantitative", title: "Ratio", format: ".1%"}
]
},
layer: [
{
mark: {type: "arc", outerRadius: 90, stroke: "#fdfdfd", strokeWidth: 1}
},
{
mark: {type: "text", radius: 108, dy: -3},
encoding: {
text: {field: "area", type: "nominal"},
color: {
condition: {test: "datum.ratio < 0.03", value: "rgba(255, 255, 255, 0)"},
field: "area",
type: "nominal",
scale: {"range": colors}
}
}
},
{
mark: {type: "text", radius: 108, fontSize: 9, dy: 7},
encoding: {
text: {field: "value", type: "quantitative"},
color: {
condition: {test: "datum.ratio < 0.03", value: "rgba(255, 255, 255, 0)"},
field: "area",
type: "nominal",
scale: {"range": colors}
}
}
}
],
width: 400,
height: 250,
padding: {left: 25, top: 3}
};
vegaEmbed(`div[id="${name}-chart"]`,
isPieChart ? vegaLitePieChartSpec : vegaLiteBarChartSpec,
{actions: false}
);
}
private displayProgress(step: number) {
const msgs = ["Initializing.",
"Loading author information.",
"Loading publication data.",
"Computing ranking."];
const s = `<strong>${msgs[step-1]}</strong><br />`;
const progress = document.querySelector("#progress");
if (progress) {
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 (const 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 (const 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 (const 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();
const 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 "europe":
if (!(dept in this.countryInfo)) { // USA
return false;