-
Notifications
You must be signed in to change notification settings - Fork 10
/
modeling.html
executable file
·217 lines (194 loc) · 9.06 KB
/
modeling.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
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
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>Topics Explorer</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="DARIAH-DE">
<meta name="description" content="Topics Explorer">
<link rel="stylesheet" href="{{url_for('static', filename='css/bootstrap.css')}}" type="text/css" media="screen, projection"/>
<script type="text/javascript" src="{{url_for('static', filename='js/jquery-1.8.2.js')}}"></script>
<script type="text/javascript" src="{{url_for('static', filename='js/bootstrap.js')}}"></script>
<style>
body {
background: #F3F3F3;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 18px;
color: #2E3436;
}
a {
color: #75507B;
}
a:hover {
color: #5C3566;
}
a.try-again-button:hover {
color: white;
text-decoration: none;
}
hr {
border: none;
height: 1px;
background-color: #F3F3F3;
margin-bottom: 15px;
margin-top: 15px;
}
.modal-title {
font-family: Arial, Helvetica, sans-serif;
}
.try-again-button {
background-color: #555753;
font-family: Arial, Helvetica, sans-serif;
border: none;
border-radius: 5px;
color: white;
padding: 1.5% 3%;
text-align: center;
text-decoration: none;
display: inline-block;
cursor: pointer;
}
.wrapper {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
margin-top: 15%;
}
#main-box {
background-color: #FEFFFC;
border: solid 1px #D3D7CF;
text-align: center;
padding-bottom: 30px;
padding-top: 30px;
}
.box {
margin-left: 11%;
margin-right: 11%;
background-color: #FFFFFF;
border-radius: 3px;
padding: 15px;
text-align: left;
}
#dariah-flower {
margin-bottom: 10px;
width: 50px;
height: 50px;
}
#abort-button {
background-color: #FF4C4C;
border: none;
color: white;
padding: 15px 32px;
border-radius: 3px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
font-weight: bold;
margin-top: 5px;
}
#current-state {
font-weight: bold;
}
</style>
</head>
<body>
<div class="modal fade" id="error-popup"></div>
<div class="wrapper" id="inner-content">
<div class="box">
<b>This may take a while...</b>
<hr>
<div>
<p id="left-box-content">How long this process takes depends on how large your selected text corpus is, and how many iterations you have selected.</p>
<p>In the meantime, take a look at the <a href="https://github.com/DARIAH-DE/Topics/blob/master/notebooks/IntroducingMallet.ipynb">Jupyter notebook</a> that deals with topic modeling with MALLET.</p>
</div>
</div>
<div class="box" id="main-box">
{% if internet == "include" %}
<img id="dariah-flower" src="https://raw.githubusercontent.com/DARIAH-DE/TopicsExplorer/testing/application/static/img/dariah_wait.gif">
<div id="current-state">Collecting user input ...</div>
{% else %}
<div id="current-state" style="margin-top: 25px;">Collecting user input ...</div>
{% endif %}
<hr>
<a href="javascript:history.go(-1)" id="abort-button">Abort</a>
</div>
<div class="box">
<b id="right-box-heading">Did you know?</b>
<hr>
<div id="right-box-content"></div>
</div>
<script>
var blei = [
'“Topic modeling algorithms are statistical methods that analyze the words of the original texts to discover the themes that run through them, how those themes are connected to each other, and how they change over time.” (<a href="http://www.cs.columbia.edu/~blei/papers/Blei2012.pdf">Blei 2012</a>)',
'“Topic models are algorithms for discovering the main themes that pervade a large and otherwise unstructured collection of documents. Topic models can organize the collection according to the discovered themes.” (<a href="http://www.cs.columbia.edu/~blei/papers/Blei2012.pdf">Blei 2012</a>)',
'“Topic modeling algorithms can be applied to massive collections of documents. Recent advances in this field allow us to analyze streaming collections, like you might find from a Web API.” (<a href="http://www.cs.columbia.edu/~blei/papers/Blei2012.pdf">Blei 2012</a>)',
'“Topic modeling algorithms can be adapted to many kinds of data. Among other applications, they have been used to find patterns in genetic data, images, and social networks.” (<a href="http://www.cs.columbia.edu/~blei/papers/Blei2012.pdf">Blei 2012</a>)',
'“A topic is formally defined to be a distribution over a fixed vocabulary. It is assumed that these topics are specified before any data has been generated.” (<a href="http://www.cs.columbia.edu/~blei/papers/Blei2012.pdf">Blei 2012</a>)',
'“One assumption that LDA makes is the <i>bag of words</i> assumption, that the order of the words in the document does not matter.” (<a href="http://www.cs.columbia.edu/~blei/papers/Blei2012.pdf">Blei 2012</a>)',
'“With recent scientific advances in support of unsupervised machine learning topic models promise to be an important component for summarizing and understanding our growing digitized archive of information.” (<a href="http://www.cs.columbia.edu/~blei/papers/Blei2012.pdf">Blei 2012</a>)'
]
var randInt = Math.floor(Math.random() * (6 - 0 + 1)) + 0;
document.getElementById('right-box-content').innerHTML = blei[randInt];
</script>
{% for identifier, state, excerpt, documents, tokens, topics, iterations in stream %}
<script>
var corpus = "If you are interested in some facts and figures: Your corpus consists of <b>{} documents</b>, or <b>{} tokens</b>. You have selected <b>{} topics</b> at <b>{} iterations</b>."
String.prototype.format = function () {
var i = 0,
args = arguments;
return this.replace(/{}/g, function () {
return typeof args[i] != "undefined" ? args[i++] : "";
});
};
{% if identifier == "running" %}
document.getElementById("current-state").innerText = "{{ state }}";
{% if excerpt | length > 1 %}
document.getElementById("right-box-heading").innerText = "An excerpt from your corpus";
document.getElementById("right-box-content").innerText = "{{ excerpt }}";
{% endif %}
{% if documents | length > 1 %}
document.getElementById("left-box-content").innerHTML = corpus.format("{{ documents }}", "{{ tokens }}", "{{ topics }}", "{{ iterations }}");
{% endif %}
{% elif identifier == "done" %}
window.location.replace("{{ url_for('model') }}");
{% elif identifier == "error" %}
var parent = document.getElementById("error-popup");
parent.setAttribute("role", "dialog");
parent.setAttribute("aria-hidden", "true");
var newModalDialog = document.createElement("div");
parent.appendChild(newModalDialog);
newModalDialog.setAttribute("class", "modal-dialog modal dialog centered");
newModalDialog.setAttribute("role", "document");
var newModalContent = document.createElement("div");
newModalDialog.appendChild(newModalContent);
newModalContent.setAttribute("class", "modal-content");
var newModalHeader = document.createElement("div");
newModalContent.appendChild(newModalHeader);
newModalHeader.setAttribute("class", "modal-header");
var newModalTitle = document.createElement("h3");
newModalTitle.setAttribute("class", "modal-title");
newModalTitle.innerText = "Oops! I'm very sorry, but something went wrong...";
newModalHeader.appendChild(newModalTitle);
var newModalBody = document.createElement("div");
newModalBody.setAttribute("class", "modal-body");
newModalBody.innerHTML = "Looks like something didn't work out as expected. Maybe you can figure out this error message by yourself: <br><br><b>{{ state }}</b><br><br>In any case, it would be very useful for us if you write a bug report either on <a href='https://github.com/DARIAH-DE/TopicsExplorer/issues'>GitHub</a>, or send an email to <a href='mailto:severin.simmler@stud-mail.uni-wuerzburg.de'>Severin Simmler</a>. Please include the error message from above in your report, information about your operating system, and at best some details about your corpus (esp. file format).<br><br>";
newModalContent.appendChild(newModalBody);
var newModalFooter = document.createElement("div");
newModalBody.appendChild(newModalFooter);
newModalFooter.setAttribute("class", "modal-footer");
var newButton = document.createElement("a");
newButton.setAttribute("class", "try-again-button");
newButton.setAttribute("href", "javascript:history.go(-1)");
newButton.text = "Go back and try again";
newModalFooter.appendChild(newButton);
$("#error-popup").modal({
keyboard: false,
backdrop: "static"
});
$("#error-popup").modal("show");
{% endif %}
</script>
{% endfor %}
</body>
</html>