-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
csrankings.js
1817 lines (1812 loc) · 73.5 KB
/
csrankings.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
/*
CSRankings.ts
@author Emery Berger <[email protected]> http://www.emeryberger.com
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
/// <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" />
;
;
;
;
;
;
;
;
;
;
;
class CSRankings {
// We have scrolled: increase the number we rank.
static updateMinimum(obj) {
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.
static getInstance() {
return CSRankings.theInstance;
}
// Promises polyfill.
static promise(cont) {
if (typeof Promise !== "undefined") {
var resolved = Promise.resolve();
resolved.then(cont);
}
else {
setTimeout(cont, 0);
}
}
constructor() {
this.note = {};
this.authorFile = "./csrankings.csv";
this.authorinfoFile = "./generated-author-info.csv";
this.countryinfoFile = "./country-info.csv";
// private readonly aliasFile = "./dblp-aliases.csv";
this.turingFile = "./turing.csv";
this.turingImage = "./png/acm-turing-award.png";
this.acmfellowFile = "./acm-fellows.csv";
this.acmfellowImage = "./png/acm.png";
this.homepageImage = "./png/house-logo.png";
this.allowRankingChange = false; /* Can we change the kind of rankings being used? */
this.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" }
];
this.aiAreas = ["ai", "vision", "mlmining", "nlp", "inforet"];
this.systemsAreas = ["arch", "comm", "sec", "mod", "da", "bed", "hpc", "mobile", "metrics", "ops", "plan", "soft"];
this.theoryAreas = ["act", "crypt", "log"];
this.interdisciplinaryAreas = ["bio", "graph", "csed", "ecom", "chi", "robotics", "visualization"];
this.areaNames = [];
this.fields = [];
this.aiFields = [];
this.systemsFields = [];
this.theoryFields = [];
this.otherFields = [];
/* Map area to its name (from areaNames). */
this.areaDict = {};
/* Map area to its position in the list. */
this.areaPosition = {};
/* Map subareas to their areas. */
this.subareas = {};
/* Map names to Google Scholar IDs. */
this.scholarInfo = {};
/* Map aliases to canonical author name. */
this.aliases = {};
/* Map Turing award winners to year */
this.turing = {};
/* Map ACM Fellow award winners to year */
this.acmfellow = {};
/* Map institution to (non-US) region. */
this.countryInfo = {};
/* Map institution to (non-US) abbreviation. */
this.countryAbbrv = {};
/* Map name to home page. */
this.homepages = {};
/* Set to true for "dense rankings" vs. "competition rankings". */
this.useDenseRankings = false;
/* The data which will hold the parsed CSV of author info. */
this.authors = [];
/* The DBLP-transformed strings per author. */
this.dblpAuthors = {};
/* Map authors to the areas they have published in (for pie chart display). */
this.authorAreas = {};
/* Computed stats (univagg). */
this.stats = {};
this.areaDeptAdjustedCount = {}; /* area+dept */
this.areaStringMap = {}; // name -> areaString (memoized)
this.usePieChart = false;
/* Colors. */
this.RightTriangle = "►"; // right-facing triangle symbol (collapsed view)
this.DownTriangle = "▼"; // downward-facing triangle symbol (expanded view)
this.BarChartIcon = "<img class='closed_chart_icon chart_icon' alt='closed chart' src='png/barchart.png'>"; // bar chart image
this.OpenBarChartIcon = "<img class='open_chart_icon chart_icon' alt='opened chart' src='png/barchart-open.png'>"; // opened bar chart image
this.PieChartIcon = "<img class='closed_chart_icon chart_icon' alt='closed chart' src='png/piechart.png'>";
this.OpenPieChartIcon = "<img class='open_chart_icon chart_icon' alt='opened chart' src='png/piechart-open.png'>";
this.ChartIcon = this.BarChartIcon;
this.OpenChartIcon = this.OpenBarChartIcon;
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);
(() => __awaiter(this, void 0, void 0, function* () {
yield this.loadTuring(this.turing);
yield this.loadACMFellow(this.acmfellow);
this.displayProgress(2);
yield this.loadAuthorInfo();
this.displayProgress(3);
yield this.loadAuthors();
this.setAllOn();
this.navigoRouter.on({
'/index': this.navigation,
'/fromyear/:fromyear/toyear/:toyear/index': this.navigation
}).resolve();
this.displayProgress(4);
this.countAuthorAreas();
yield 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";
}
}
}))();
}
translateNameToDBLP(name) {
// 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). */
makePrologue() {
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;
}
static sum(n) {
let s = 0.0;
for (let i = 0; i < n.length; i++) {
s += n[i];
}
return s;
}
static average(n) {
return CSRankings.sum(n) / n.length;
}
static stddev(n) {
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;
}
areaString(name) {
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 = {};
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 = [];
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 = [];
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];
}
removeDisambiguationSuffix(str) {
// 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/ */
compareNames(a, b) {
// 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;
// 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) */
makeChart(name, isPieChart) {
let data = [];
let datadict = {};
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 });
}
displayProgress(step) {
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;
}
}
loadTuring(turing) {
return __awaiter(this, void 0, void 0, function* () {
const data = yield new Promise((resolve) => {
Papa.parse(this.turingFile, {
header: true,
download: true,
complete: (results) => {
resolve(results.data);
}
});
});
const d = data;
for (const turingPair of d) {
turing[turingPair.name] = turingPair.year;
}
});
}
loadACMFellow(acmfellow) {
return __awaiter(this, void 0, void 0, function* () {
const data = yield new Promise((resolve) => {
Papa.parse(this.acmfellowFile, {
header: true,
download: true,
complete: (results) => {
resolve(results.data);
}
});
});
const d = data;
for (const acmfellowPair of d) {
acmfellow[acmfellowPair.name] = acmfellowPair.year;
}
});
}
loadCountryInfo(countryInfo, countryAbbrv) {
return __awaiter(this, void 0, void 0, function* () {
const data = yield new Promise((resolve) => {
Papa.parse(this.countryinfoFile, {
header: true,
download: true,
complete: (results) => {
resolve(results.data);
}
});
});
const ci = data;
for (const info of ci) {
countryInfo[info.institution] = info.region;
countryAbbrv[info.institution] = info.countryabbrv;
}
});
}
loadAuthorInfo() {
return __awaiter(this, void 0, void 0, function* () {
const data = yield new Promise((resolve) => {
Papa.parse(this.authorFile, {
download: true,
header: true,
complete: (results) => {
resolve(results.data);
}
});
});
const ai = data;
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'];
}
}
});
}
loadAuthors() {
return __awaiter(this, void 0, void 0, function* () {
const data = yield new Promise((resolve) => {
Papa.parse(this.authorinfoFile, {
download: true,
header: true,
complete: (results) => {
resolve(results.data);
}
});
});
this.authors = data;
});
}
inRegion(dept, regions) {
switch (regions) {
case "us":
if (dept in this.countryInfo) {
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;
default:
if (this.countryAbbrv[dept] != regions) {
return false;
}
break;
}
return true;
}
activateFields(value, fields) {
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;
}
sortIndex(univagg) {
let keys = Object.keys(univagg);
keys.sort((a, b) => {
if (univagg[a] != univagg[b]) {
return univagg[b] - univagg[a];
}
/*
if (univagg[a] > univagg[b]) {
return -1;
}
if (univagg[b] > univagg[a]) {
return 1;
}
*/
if (a < b) {
return -1;
}
if (b < a) {
return 1;
}
return 0;
});
return keys;
}
countAuthorAreas() {
const startyear = parseInt($("#fromyear").find(":selected").text());
const endyear = parseInt($("#toyear").find(":selected").text());
this.authorAreas = {};
for (const r in this.authors) {
const { area } = this.authors[r];
if (area in CSRankings.nextTier) {
continue;
}
const { year } = this.authors[r];
if ((year < startyear) || (year > endyear)) {
continue;
}
const { name, dept, count } = this.authors[r];
/*
DISABLING weight selection so all pie charts look the
same regardless of which areas are currently selected:
if (weights[theArea] === 0) {
continue;
}
*/
const theCount = parseFloat(count);
if (!(name in this.authorAreas)) {
this.authorAreas[name] = {};
for (const area in this.areaDict) {
if (this.areaDict.hasOwnProperty(area)) {
this.authorAreas[name][area] = 0;
}
}
}
if (!(dept in this.authorAreas)) {
this.authorAreas[dept] = {};
for (const area in this.areaDict) {
if (this.areaDict.hasOwnProperty(area)) {
this.authorAreas[dept][area] = 0;
}
}
}
this.authorAreas[name][area] += theCount;
this.authorAreas[dept][area] += theCount;
}
}
/* Build the dictionary of departments (and count) to be ranked. */
buildDepartments(startyear, endyear, weights, regions, deptCounts, deptNames, facultycount, facultyAdjustedCount) {
/* contains an author name if that author has been processed. */
const visited = {};
for (const r in this.authors) {
if (!this.authors.hasOwnProperty(r)) {
continue;
}
const auth = this.authors[r];
const dept = auth.dept;
// if (!(dept in regionMap)) {
if (!this.inRegion(dept, regions)) {
continue;
}
let area = auth.area;
if (weights[area] === 0) {
continue;
}
const year = auth.year;
if ((year < startyear) || (year > endyear)) {
continue;
}
if (typeof dept === 'undefined') {
continue;
}
const name = auth.name;
// If this area is a child area, accumulate totals for parent.
if (area in CSRankings.parentMap) {
area = CSRankings.parentMap[area];
}
const areaDept = area + dept;
if (!(areaDept in this.areaDeptAdjustedCount)) {
this.areaDeptAdjustedCount[areaDept] = 0;
}
const count = parseInt(this.authors[r].count);
const adjustedCount = parseFloat(this.authors[r].adjustedcount);
this.areaDeptAdjustedCount[areaDept] += adjustedCount;
/* Is this the first time we have seen this person? */
if (!(name in visited)) {
visited[name] = true;
facultycount[name] = 0;
facultyAdjustedCount[name] = 0;
if (!(dept in deptCounts)) {
deptCounts[dept] = 0;
deptNames[dept] = [];
}
deptNames[dept].push(name);
deptCounts[dept] += 1;
}
facultycount[name] += count;
facultyAdjustedCount[name] += adjustedCount;
}
}
/* Compute aggregate statistics. */
computeStats(deptNames, numAreas, weights) {
this.stats = {};
for (const dept in deptNames) {
if (!deptNames.hasOwnProperty(dept)) {
continue;
}
this.stats[dept] = 1;
for (const area in CSRankings.topLevelAreas) {
const areaDept = area + dept;
if (!(areaDept in this.areaDeptAdjustedCount)) {
this.areaDeptAdjustedCount[areaDept] = 0;
}
if (weights[area] != 0) {
// Adjusted (smoothed) geometric mean.
this.stats[dept] *= (this.areaDeptAdjustedCount[areaDept] + 1.0);
}
}
// finally compute geometric mean.
this.stats[dept] = Math.pow(this.stats[dept], 1 / numAreas); // - 1.0;
}
}
/* Updates the 'weights' of each area from the checkboxes. */
/* Returns the number of areas selected (checked). */
updateWeights(weights) {
let numAreas = 0;
for (let ind = 0; ind < CSRankings.areas.length; ind++) {
const area = CSRankings.areas[ind];
weights[area] = $(`input[name=${this.fields[ind]}]`).prop('checked') ? 1 : 0;
if (weights[area] === 1) {
if (area in CSRankings.parentMap) {
// Don't count children.
continue;
}
/* One more area checked. */
numAreas++;
}
}
return numAreas;
}
/* Build drop down for faculty names and paper counts. */
buildDropDown(deptNames, facultycount, facultyAdjustedCount) {