-
Notifications
You must be signed in to change notification settings - Fork 0
/
bj_template.html
168 lines (138 loc) · 4.75 KB
/
bj_template.html
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>TITLEPAGE</title>
<link rel="stylesheet" type="text/css" href="beautifyj.css">
<script src="jquery-1.8.3.min.js"></script>
<script>
// this line below will get filled in with database of LDA topic distributions for top words
// for every paper
LOADDISTS
// this will be filled with pairwise scores between papers
PAIRDISTS
var choices = [0, 0, 0, 1, 1, 0, 0]; // default choices, random...
var similarityMode = 0; // is the user currently looking at papers similar to some one paper?
var similarTo = 0; // the index of query paper
// given choices of topics to sort by, handle user interface stuff (i.e. show selection)
function colorChoices() {
for(var i=0;i<choices.length;i++) {
if(choices[i] == 1) {
$("#tc"+i).css("background-color", "#EFE");
$("#tc"+i).css("border-color", "#575");
} else {
$("#tc"+i).css("background-color", "#FFF");
$("#tc"+i).css("border-color", "#FFF");
}
}
}
// this permutes the divs (that contian 1 paper each) based on a custom sorting function
// in our case, this sort is done as dot product based on the choices[] array
// here we are guaranteed ldadist[] already sums to 1 for every paper
function arrangeDivs() {
var rtable = $("#rtable");
var paperdivs = rtable.children(".apaper");
// normalize choices to sum to 1
var nn = choices.slice(0); // copy the array
var ss = 0.0;
for(var j=0;j<choices.length;j++) { ss += choices[j]; }
for(var j=0;j<choices.length;j++) { nn[j] = nn[j]/ss; }
paperdivs.detach().sort(function(a,b) {
var ixa = parseInt($(a).attr('id').substring(3));
var ixb = parseInt($(b).attr('id').substring(3));
if(similarityMode === 1) {
return pairdists[ixa][similarTo] < pairdists[ixb][similarTo] ? 1 : -1;
}
if(similarityMode === 0) {
// chi-squared kernel for the two histograms
var accuma = 0;
var accumb = 0;
for(var i=0;i<7;i++) {
var ai= ldadist[ixa][i];
var bi= ldadist[ixb][i];
var ci= choices[i];
accuma += (ai-ci)*(ai-ci)/(ai+ci);
accumb += (bi-ci)*(bi-ci)/(bi+ci);
}
return accuma > accumb ? 1 : -1;
/*
// vector distance. These are histograms... but lets pretend they arent
var accuma = 0;
var accumb = 0;
for(var i=0;i<7;i++) {
var ai= ldadist[ixa][i];
var bi= ldadist[ixb][i];
var ci= nn[i];
accuma += (ai-ci)*(ai-ci);
accumb += (bi-ci)*(bi-ci);
}
return accuma > accumb ? 1 : -1;
*/
/*
// inner product distance
var accuma = 0;
var accumb = 0;
for(var i=0;i<7;i++) {
accuma += ldadist[ixa][i] * choices[i];
accumb += ldadist[ixb][i] * choices[i];
}
return accuma < accumb ? 1 : -1;
*/
}
});
rtable.append(paperdivs);
}
// when page loads...
$(document).ready(function(){
arrangeDivs();
colorChoices();
// user clicks on one of the Topic buttons
$(".topicchoice").click(function() {
similarityMode = 0; // make sure this is off
var tcid = parseInt($(this).attr('id').substring(2));
choices[tcid] = 1 - choices[tcid]; // toggle!
colorChoices();
arrangeDivs();
});
// user clicks on "rank by tf-idf similarity to this" button for some paper
$(".sim").click(function() {
similarityMode = 1; // turn on similarity mode
for(var i=0;i<choices.length;i++) { choices[i] = 0; } // zero out choices
similarTo = parseInt($(this).attr('id').substring(3)); // store id of the paper clicked
colorChoices();
arrangeDivs();
// also scroll to top
$('html, body').animate({ scrollTop: 0 }, 'fast');
});
});
</script>
</head>
<body>
<div id ="titdiv">
<h1>TITLEPAGE</h1>
created by <a href="http://webdiis.unizar.es/~rmcantin">rmcantin</a>
as a remake of <a href="URL_MAIN">this</a>.<br />
Based on an idea by <a href="https://twitter.com/karpathy">@karpathy</a><br/>
source code on <a href="">bitbucket</a>
</div>
<div id="maindiv">
<div id="explanation">Below every paper are TOP 100 most-occuring words in that paper and their color is based on LDA topic model with k = 7.<br />
<div style="font-size: 12px;">(It looks like 0 = theory, 1 = reinforcement learning, 2 = graphical models, 3 = deep learning/vision, 4 = optimization, 5 = neuroscience, 6 = embeddings etc.) </div>
</div>
<div id="sortoptions">
Toggle LDA topics to sort by:
<span class="topicchoice t0" id="tc0">TOPIC0</span>
<span class="topicchoice t1" id="tc1">TOPIC1</span>
<span class="topicchoice t2" id="tc2">TOPIC2</span>
<span class="topicchoice t3" id="tc3">TOPIC3</span>
<span class="topicchoice t4" id="tc4">TOPIC4</span>
<span class="topicchoice t5" id="tc5">TOPIC5</span>
<span class="topicchoice t6" id="tc6">TOPIC6</span>
</div>
<!-- the keyword below will be replaced by content from the python script generatenice.py -->
<div id="rtable">
RESULTTABLE
</div>
</div>
<br /><br /><br /><br /><br /><br />
</body>
</html>