blob: 36a2b65b351ba39e4501170866c899224546c44e [file] [log] [blame]
Marc Kupietz83305222016-04-28 09:57:22 +02001<!DOCTYPE html>
2<html>
3 <head>
Marc Kupietzc053d972019-01-10 10:41:51 +01004 <% my $plain_title = $title; $plain_title=~s/<[^>]+>//g; %>
Marc Kupietz86b50292019-02-17 21:03:59 +01005 <title><%= $plain_title %>:<%= $word %> · IDS word vector analysis</title>
Marc Kupietz80bd7b92017-07-04 16:25:54 +02006 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
Marc Kupietz58270662017-12-04 12:10:06 +01007 <link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Condensed" rel="stylesheet">
Marc Kupietz80bd7b92017-07-04 16:25:54 +02008 <script src="http://code.jquery.com/jquery-latest.min.js"></script>
Marc Kupietz5f532b32019-01-23 10:03:18 +01009 <script src = "https://cdn.datatables.net/1.10.18/js/jquery.dataTables.min.js"></script>
10 <script src = "https://cdn.datatables.net/fixedcolumns/3.2.5/js/dataTables.fixedColumns.min.js"></script>
11 <script src = "https://cdn.datatables.net/plug-ins/1.10.18/sorting/scientific.js"></script>
12 <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'></script>
13 <link rel="stylesheet" href="https://cdn.datatables.net/1.10.18/css/jquery.dataTables.min.css">
Marc Kupietz4949d232018-03-19 16:43:18 +010014 <link rel="stylesheet" href="/derekovecs/css/derekovecs.css">
Marc Kupietz80bd7b92017-07-04 16:25:54 +020015 <script
Marc Kupietze6a7a732018-01-12 09:21:08 +010016 src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
17 integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
18 crossorigin="anonymous"></script>
Marc Kupietz80bd7b92017-07-04 16:25:54 +020019 <script>
Marc Kupietza0ffb392018-01-25 08:53:43 +010020 MathJax.Hub.Config({
21 config: ["MMLorHTML.js"],
22 jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML", "output/PreviewHTML"],
23 extensions: ["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js", "fast-preview.js", "AssistiveMML.js", "a11y/accessibility-menu.js"],
24 TeX: {
25 extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
26 }
27 });
Marc Kupietz58270662017-12-04 12:10:06 +010028 var urlParams = new URLSearchParams(window.location.search);
Marc Kupietzb3a2e4f2017-12-08 17:25:53 +010029 var currentWords = urlParams.get("word");
Marc Kupietza0ffb392018-01-25 08:53:43 +010030 var CIIsearchWords = (currentWords && currentWords.includes(" ") ? '('+currentWords.replace(/ +/g, " oder ")+')' : currentWords);
Marc Kupietz66bfd952017-12-11 09:59:45 +010031 var collocatorTable = null;
Marc Kupietz86b50292019-02-17 21:03:59 +010032 var plainTitle ="<%= $plain_title %>"
33 var korapPath="/";
34 if (plainTitle.match(/-en/)) {
35 korapPath="/instance/english";
36 }
Marc Kupietz58270662017-12-04 12:10:06 +010037 $(document).ready(function() {
Marc Kupietz694610d2017-11-25 18:30:03 +010038
Marc Kupietza0ffb392018-01-25 08:53:43 +010039 $('#firstable').hide();
40 //Set up a callback to hear back when MathJax is done rendering the equations
41 // it finds
42 $('#ccd').load(
43 '@Url.Action("ActionResultMethod","ControllerName",{controller parameters})',
44 function () {
45 MathJax.Hub.Queue(
46 ["Typeset",MathJax.Hub,"ccd"],
47 function () {
Marc Kupietz7bd55232019-01-22 15:29:06 +010048 $("#mi_tt").attr("title",$("#pmi_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010049 $("#lfmd_tt").attr("title",$("#lfmd_ttt").html());
Marc Kupietz7bd55232019-01-22 15:29:06 +010050 $("#md_tt").attr("title",$("#md_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010051 $("#npmi_tt").attr("title",$("#npmi_ttt").html());
Marc Kupietzf19814b2019-01-21 16:50:19 +010052 $("#ll_tt").attr("title",$("#ll_ttt").html());
Marc Kupietz7bd55232019-01-22 15:29:06 +010053 $("#logdice_tt").attr("title",$("#logdice_ttt").html());
Marc Kupietz63b268f2019-01-22 22:34:29 +010054 $("#logdiceaf_tt").attr("title",$("#logdiceaf_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010055 }
56 );
57 });
58
59 //set things up so that we can shove raw html into what is shown in the tooltip;
60 // in this case, we will have already put into the title attribute the html that
61 // contains the MathJax rendered equations (via what we do in the callback).
62 $(function () {
63 $(document).tooltip({
64 content: function () {
65 return $(this).prop('title');
66 }
67 });
68 });
69
Marc Kupietze6a7a732018-01-12 09:21:08 +010070 $("input").bind("keydown", function(event) {
71 // track enter key
72 var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
73 if (keycode == 13) { // keycode for enter key
74 // force the 'Enter Key' to implicitly click the Update button
75 document.getElementById('SEARCH').click();
76 return false;
77 } else {
78 return true;
79 }});
Marc Kupietzdab9f222017-11-29 14:22:59 +010080
Marc Kupietze871abd2018-01-25 16:18:27 +010081 var collocatorTable_activated = false;
Marc Kupietze6a7a732018-01-12 09:21:08 +010082 $( "#tabs" ).on( "tabsactivate", function( event, ui ) {
83 if (localStorage) localStorage['tab'] = ui.newTab.index();
Marc Kupietze871abd2018-01-25 16:18:27 +010084 if(ui.newTab.index() == 2 && !collocatorTable_activated) {
85 classicCollocatorTable.columns.adjust();
86 collocatorTable.columns.adjust();
87 collocatorTable_activated = true;
88 }
Marc Kupietze6a7a732018-01-12 09:21:08 +010089 });
90
91 $(function(){
92 $("#SEARCH").click(function() {
93 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietz58270662017-12-04 12:10:06 +010094 });
Marc Kupietze6a7a732018-01-12 09:21:08 +010095 });
Marc Kupietz0af83e32017-11-27 09:31:37 +010096
Marc Kupietze6a7a732018-01-12 09:21:08 +010097 function changeCharColor(txt, heat, word) {
98 var newText = "";
99 for (var i=0, l=txt.length; i<l; i++) {
Marc Kupietz86b50292019-02-17 21:03:59 +0100100 newText += (i == 5 ? txt.charAt(i) : '<a href="http://korap.ids-mannheim.de' + korapPath + '/?ql=cosmas2&q=' +
Marc Kupietze6a7a732018-01-12 09:21:08 +0100101 CIIsearchWords + ' /' + (i > 5? '%2B' : '-') + 'w' +
102 Math.abs(i-5) + ':' + Math.abs(i-5) + ' ' + word +
103 '" target="korap"><span style="background-color:' +
104 getHeatColor(heat[i]/maxHeat)+'">'+txt.charAt(i)+'</span></a>');
Marc Kupietzb6c615d2017-12-02 10:38:20 +0100105 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100106 return newText;
107 }
Marc Kupietzb6c615d2017-12-02 10:38:20 +0100108
Marc Kupietze6a7a732018-01-12 09:21:08 +0100109 function getHeatColor(value) {
110 var hue=((1-value)*120).toString(10);
111 return ["hsl(",hue,",90%,70%)"].join("");
112 }
113
Marc Kupietz29f5bbd2019-01-24 15:12:59 +0100114 function bitmask2window(autofocus, win) {
115 var af_str = autofocus.toString(2).padStart(10, "0")
116 .replace(/^([0-9]{5})/, '$1 ')
117 .replace(/0/g, '·')
118 .replace(/1/g, '◼');
119 var w_str = win.toString(2).padStart(10, "0")
120 .replace(/^([0-9]{5})/, '$1 ')
121 .replace(/0/g, '·')
122 .replace(/1/g, 'o');
123 for (var i=0, l=af_str.length; i<l; i++) {
124 if(af_str.charAt(i) == '·' && w_str.charAt(i) == 'o' ) {
125 af_str = af_str.substring(0, i) + "◽" + af_str.substring(i+1);
126 }
127 }
128 return af_str;
Marc Kupietz63b268f2019-01-22 22:34:29 +0100129 }
130
Marc Kupietze6a7a732018-01-12 09:21:08 +0100131 function bitvec2window(n, heat, word) {
132 var str = n.toString(2).padStart(10, "0")
133 .replace(/^([0-9]{5})/, '$1x')
134 .replace(/0/g, '·')
135 .replace(/1/g, '+');
136 return changeCharColor(str, heat, word);
137 }
138
139 % use Mojo::ByteStream 'b';
140 var paraResults = <%= b(Mojo::JSON::to_json($lists)) %>;
141 var urlprefix = new URLSearchParams(window.location.search);
142 if (paraResults.length > 0 && paraResults[0] != null) {
143 var nvecs = [],
144 nwords = [],
145 nranks = [],
146 nmarked = [];
147 for(var i = 0; i < paraResults.length; i++) {
148 nwords = nwords.concat(paraResults[i].map(function(a){return a.word;}));
149 nvecs = nvecs.concat(paraResults[i].map(function(a){return a.vector;}));
150 nranks = nranks.concat(paraResults[i].map(function(a){return a.rank;}));
151 nmarked = nmarked.concat(paraResults[i].map(function(a){return a.marked;}));
Marc Kupietz0d4c0ca2017-12-04 09:18:56 +0100152 }
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100153 showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked} );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100154 var t = $('#firsttable').DataTable({
Marc Kupietzee894d52019-01-09 14:55:14 +0100155 data: [].concat.apply([], paraResults),
Marc Kupietze6a7a732018-01-12 09:21:08 +0100156 "sScrollY": "780px",
157 "bScrollCollapse": true,
158 "bPaginate": false,
159 "bJQueryUI": true,
160 "dom": '<"top">rt<"bottom"flp><"clear">',
Marc Kupietz384c9132018-03-19 16:45:24 +0100161 "initComplete":function(settings, json) {
162 $('td.paradigmator a').on('mousedown', function(e) {
Marc Kupietz86b50292019-02-17 21:03:59 +0100163 return paradigmatorClick(e, paraResults[0][0].word, this.childNodes["0"].textContent);
Marc Kupietz384c9132018-03-19 16:45:24 +0100164 });
165 },
Marc Kupietze6a7a732018-01-12 09:21:08 +0100166 "columns": [
167 { "data": "rank", type: "allnumeric" },
168 { "data": "dist", render: function ( data, type, row ) {return data.toFixed(3) }},
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100169 { "data": "word", class: "paradigmator", render: function ( data, type, row ) {
170 urlprefix.set("word", data); return '<a class="' + getMergedClass(row.rank) + '" href="?' + urlprefix + '">' + data + '</a>'
171 }}
Marc Kupietze6a7a732018-01-12 09:21:08 +0100172 ],
173 "columnDefs": [
174 { className: "dt-right", "targets": [0,1] },
175 { "searchable": false,
176 "orderable": false,
177 "targets": 0
178 },
179 { "orderSequence": [ "desc" ], "targets": [ 1 ] },
180 { "orderSequence": [ "asc", "desc" ], "targets": [ 2 ] },
181 ],
182 "oLanguage": {
183 "sSearch": "Filter: "
184 },
185 "order": [[ 1, 'desc' ]],
186 } );
Marc Kupietz0d4c0ca2017-12-04 09:18:56 +0100187
Marc Kupietze6a7a732018-01-12 09:21:08 +0100188 t.on( 'order.dt search.dt', function () {
189 t.column(0, {order:'applied'}).nodes().each( function (cell, i) {
190 cell.innerHTML = i+1;
191 } );
192 } ).draw();
193
194 $( "#first" ).clone().prependTo( "#tabs-2" );
195
196 }
197
198
199 var collocatorData = <%= b(Mojo::JSON::to_json($collocators)) %>;
200 var maxHeat; // = Math.max.apply(Math,collocatorData.map(function(o){return o.cprob;}))
201
202 if (collocatorData != null) {
203 maxHeat = Math.max.apply(Math,collocatorData.map(function(o){return Math.max.apply(Math,o.heat);}))
204 collocatorTable = $('#secondtable').DataTable({
205 data: collocatorData,
206 "sScrollY": "780px",
207 "bScrollCollapse": true,
208 "bPaginate": false,
209 "bJQueryUI": true,
210 "dom": '<"top">rt<"bottom"flp><"clear">',
211 "columns": [
212 { "data": "rank", type: "allnumeric" },
213 { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
214 { "data": "max", render: function ( data, type, row ) {return data.toFixed(3) }},
215 { "data": "average", render: function ( data, type, row ) {return data.toFixed(3) }},
216 { "data": "prob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
217 { "data": "cprob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
218 { "data": "overall", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
219 { "data": "word", sClass: "collocator" },
220 { "data": "rank", type: "allnumeric" }
221 ],
222 "columnDefs": [
223 { className: "dt-right", "targets": [0,2,3,4,5,6] },
224 { className: "dt-center", "targets": [ 1] },
225 { "searchable": false,
226 "orderable": false,
227 "targets": [0, 8]
228 },
229 { "type": "scientific", targets: [2,3,4,5,6] },
230 { "orderSequence": [ "desc" ], "targets": [ 2, 3, 4, 5, 6 ] },
231 { "orderSequence": [ "asc", "desc" ], "targets": [ 1, 7 ] },
232 { "targets": [8], "visible": false }
233 ],
234 "oLanguage": {
235 "sSearch": "Filter: "
236 },
237 "order": [[ 4, 'desc' ]],
238 } );
239 $.ajaxSetup({
240 type: 'POST',
241 timeout: 30000,
242 error: function(xhr) {
243 $('#display_error')
244 .html('Error: ' + xhr.status + ' ' + xhr.statusText);
245 }
Marc Kupietz78b434a2018-01-12 22:33:32 +0100246 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100247
Marc Kupietz384c9132018-03-19 16:45:24 +0100248
249 if($('#sprofiles').length) {
250 similarProfileTable = $('#sprofiles').DataTable({
251 ajax: {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100252 method: "GET",
Marc Kupietz384c9132018-03-19 16:45:24 +0100253 url: '/derekovecs/getSimilarProfiles',
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100254 dataType: 'json',
255 dataSrc: "",
256 timeout: 30000,
257 data: { w: paraResults[0][0].rank }
Marc Kupietz384c9132018-03-19 16:45:24 +0100258 },
259 "initComplete":function(settings, json){
260 $('td.paradigmator a').on('mousedown', function(e) {
261 if (e.which === 2) {
262 e.preventDefault();
263 queryKorAPalternatives(paraResults[0][0].word, this.childNodes["0"].textContent);
264 return false;
265 }
266 });
267 },
268 "sScrollY": "780px",
269 "bScrollCollapse": true,
270 "bPaginate": false,
271 "bJQueryUI": true,
272 "dom": '<"top">rt<"bottom"flp><"clear">',
273 "columns": [
274 { "data": "v", render: function ( data, type, row ) {return data.toFixed(3) }},
275 { "data": "w", sClass: "paradigmator", render: function ( data, type, row ) {urlprefix.set("word", data); return '<a href="?' + urlprefix + '">' + data + '</a>' } }
276 ],
277 "columnDefs": [
278 { className: "dt-right", "targets": [0] },
279 ],
280 "oLanguage": {
281 "sSearch": "Filter: "
282 },
283 "order": [[ 0, 'desc' ]],
284 });
285 }
286 // var filterQuot = /(^quot?=[A-Z])|(quot$)/g;
287 var filterQuot = /^quot/;
Marc Kupietz4784fae2019-02-04 12:32:12 +0100288 var ccResult;
Marc Kupietz86b50292019-02-17 21:03:59 +0100289 var baseURL = window.location.pathname.replace(/[/]$/, '')
Marc Kupietz384c9132018-03-19 16:45:24 +0100290 classicCollocatorTable = $('#classicoloctable').DataTable({
291 ajax: {
292 method: "GET",
Marc Kupietz86b50292019-02-17 21:03:59 +0100293 url: baseURL + '/getClassicCollocators',
Marc Kupietz384c9132018-03-19 16:45:24 +0100294 dataType: 'json',
Marc Kupietz4784fae2019-02-04 12:32:12 +0100295 dataSrc: function (result) {
296 ccResult = result;
297 $("#rawfreq_tt").attr("title", "Raw frequencies of the co-occurence.\n"
298 + "f(" + ccResult.w1+")=" + ccResult.f1.toLocaleString("en-GB") + ";\n"
299 + "N=" + ccResult.N.toLocaleString("en-GB"));
300 return result.collocates;
301 },
Marc Kupietz384c9132018-03-19 16:45:24 +0100302 timeout: 30000,
303 data: { w: paraResults[0][0].rank }
Marc Kupietz78b434a2018-01-12 22:33:32 +0100304 },
Marc Kupietzad783722018-01-13 17:45:21 +0100305 "initComplete":function(settings, json){
306 $("td.collocator").click(function(){
307 queryKorAPCII(this.textContent + " /w5 " + CIIsearchWords);
308 });
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100309 classicCollocatorTable.columns(".detail").visible(false);
Marc Kupietz63b268f2019-01-22 22:34:29 +0100310 $("#ccd").css('width', '680px');
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100311 classicCollocatorTable.columns.adjust().draw();
Marc Kupietzad783722018-01-13 17:45:21 +0100312 },
Marc Kupietz9c1a3d22019-01-23 10:04:18 +0100313 "createdRow": function (row, data, rowIndex) {
314 $.each($('td.collocator', row), function (colIndex) {
315 $(this).attr('title', "f("+data.word+")="+data.f2.toLocaleString("en-GB"));
316 });
317 },
Marc Kupietz78b434a2018-01-12 22:33:32 +0100318 "sScrollY": "780px",
319 "bScrollCollapse": true,
320 "bPaginate": false,
321 "bJQueryUI": true,
322 "dom": '<"top">rt<"bottom"flp><"clear">',
323 "columns": [
324 // { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100325 { "data": "llr", render: function ( data, type, row ) {return data.toFixed(0) }},
Marc Kupietz7bd55232019-01-22 15:29:06 +0100326 { "data": "pmi", render: function ( data, type, row ) {return data.toFixed(2) }},
327 { "data": "md", render: function ( data, type, row ) {return data.toFixed(2) }},
328 { "data": "lfmd", render: function ( data, type, row ) {return data.toFixed(2) }},
Marc Kupietz1acb3172018-02-17 09:41:26 +0100329 // { "data": "fpmi", type: "scientific", render: function ( data, type, row ) {return data.toExponential(2) } },
Marc Kupietz7bd55232019-01-22 15:29:06 +0100330 { "data": "npmi", render: function ( data, type, row ) {return data.toFixed(3) }},
331 { "data": "dice", render: function ( data, type, row ) {return data.toExponential(2) }},
332 { "data": "ld", render: function ( data, type, row ) {return data.toFixed(2) }},
Marc Kupietz63b268f2019-01-22 22:34:29 +0100333 { "data": "af", render: function ( data, type, row ) {return data.toFixed(2) }},
Marc Kupietz29f5bbd2019-01-24 15:12:59 +0100334 { "data": "afwin", width: "auto", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitmask2window(data, row.win) }},
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100335 { "data": "llfmd", render: function ( data, type, row ) {return data.toFixed(1) }},
336 { "data": "rlfmd", render: function ( data, type, row ) {return data.toFixed(1) }},
337 { "data": "lnpmi", render: function ( data, type, row ) {return data.toFixed(2) }},
338 { "data": "rnpmi", render: function ( data, type, row ) {return data.toFixed(2) }},
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100339 { "data": "f" },
Marc Kupietz78b434a2018-01-12 22:33:32 +0100340 { "data": "word", sClass: "collocator" }
341 ],
342 "columnDefs": [
Marc Kupietz63b268f2019-01-22 22:34:29 +0100343 { className: "dt-right", "targets": [0,1,2,3,4,5,6,7,9,10,11,12,13] },
344 { className: "dt-right detail", "targets": [5,9,10,11,12] },
Marc Kupietz78b434a2018-01-12 22:33:32 +0100345 { "searchable": false,
346 "orderable": false,
347 "targets": []
348 },
Marc Kupietz63b268f2019-01-22 22:34:29 +0100349 { "orderSequence": [ "desc" ], "targets": [0,1,2,3,4,5,6,7,9,10,11,12,13] },
350 { "orderSequence": [ "asc", "desc" ], "targets": [8,14] },
Marc Kupietz78b434a2018-01-12 22:33:32 +0100351 ],
352 "oLanguage": {
353 "sSearch": "Filter: "
354 },
Marc Kupietz63b268f2019-01-22 22:34:29 +0100355 "order": [[ 7, 'desc' ]],
Marc Kupietz78b434a2018-01-12 22:33:32 +0100356 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100357
Marc Kupietz1acb3172018-02-17 09:41:26 +0100358
359 $('#show-details').change(function (e) {
360 var columns = classicCollocatorTable.columns(".detail");
361 if(this.checked) {
362 columns.visible(true);
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100363 $("#ccd").css('width', 'auto');
Marc Kupietz1acb3172018-02-17 09:41:26 +0100364 } else {
365 columns.visible(false);
Marc Kupietz08bfd402019-01-23 10:05:17 +0100366 $("#ccd").css('width', '680px');
Marc Kupietz1acb3172018-02-17 09:41:26 +0100367 }
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100368 classicCollocatorTable.columns.adjust().draw();
Marc Kupietz1acb3172018-02-17 09:41:26 +0100369 } );
370
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100371 $("td.collocator").click(function(){
372 queryKorAPCII(this.textContent + " /w5 " + CIIsearchWords);
Marc Kupietzad783722018-01-13 17:45:21 +0100373 });
374
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100375 collocatorTable.on( 'order.dt search.dt', function () {
376 collocatorTable.column(0, {order:'applied'}).nodes().each( function (cell, i) {
377 cell.innerHTML = i+1;
378 } );
379 }).draw();
380 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100381
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100382 if (localStorage && !window.location.hash) { // let's not crash if some user has IE7
383 var index = parseInt(localStorage['tab']||'0');
384 $("#tabs").tabs({ active: index });
385 }
386 $("#tabs").css("visibility", "visible"); // now we can show the tabs
387 });
Marc Kupietz58270662017-12-04 12:10:06 +0100388
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100389 $(function(){
390 $("#dropdownoptions").dialog({
391 title: "Options",
392 autoOpen: false,
393 modal: false,
394 draggable: false,
395 height: "auto",
396 width: "auto",
397 resizable: false,
398 buttons: {
399 "Cancel": function() {
400 $( this ).dialog( "close" );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100401 },
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100402 "Apply": function() {
403 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietze6a7a732018-01-12 09:21:08 +0100404 }
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100405 }
406 });
407 });
408
409 $(function(){
410 $("#showoptions").click(function(){
411 $("#dropdownoptions").dialog("open");
412 var target = $(this);
413 $("#dropdownoptions").dialog("widget").position({
414 my: 'left bottom',
415 at: 'left bottom',
416 of: target
Marc Kupietz58270662017-12-04 12:10:06 +0100417 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100418 });
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100419 });
420
421 $( function() {
422 $( "#no_iterations" ).spinner({
423 spin: function( event, ui ) {
424 if ( ui.value < 1000 ) {
425 $( this ).spinner( "value", 1000 );
426 return false;
427 } else if ( ui.value > 10000 ) {
428 $( this ).spinner( "value", 10000 );
429 return false;
430 }
431 }
432 });
433 } );
434
435 $( function() {
436 $( "#neighbours" ).spinner({
437 spin: function( event, ui ) {
438 if ( ui.value < 0 ) {
439 $( this ).spinner( "value", 0 );
440 return false;
441 } else if ( ui.value > 200 ) {
442 $( this ).spinner( "value", 200 );
443 return false;
444 }
445 }
446 });
447 } );
448
449 $( function() {
450 $( "#cutoff" ).spinner({
451 spin: function( event, ui ) {
452 if ( ui.value < 100000 ) {
453 $( this ).spinner( "value", 100000 );
454 return false;
455 } else if ( ui.value > 2000000 ) {
456 $( this ).spinner( "value", 2000000 );
457 return false;
458 }
459 }
460 });
461 } );
462
463 $( function() {
464 $( "#tabs" ).tabs().addClass('tabs-min');
465 } );
466
467 $( function() {
468 $( ".controlgroup-vertical" ).controlgroup({
469 "direction": "vertical"
470 });
471 } );
472
473 $(function() {
474 $( document ).tooltip({
475 content: function() {
476 return $(this).attr('title');
477 }}
478 )
479 });
480
481 $(function () {
482 $(document).tooltip({
483 content: function () {
484 return $(this).prop('title');
485 },
486 show: null,
487 close: function (event, ui) {
488 ui.tooltip.hover(
489 function () {
490 $(this).stop(true).fadeTo(400, 1);
491 },
492 function () {
493 $(this).fadeOut("400", function () {
494 $(this).remove();
495 })
496 });
497 }
498 });
499 });
Marc Kupietz83305222016-04-28 09:57:22 +0200500 </script>
Marc Kupietz58270662017-12-04 12:10:06 +0100501 <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
502 <script src="/derekovecs/js/tsne.js"></script>
503 <script src="/derekovecs/js/som.js"></script>
504 <script src="/derekovecs/js/labeler.js"></script>
Marc Kupietzcdd51302018-03-19 16:36:54 +0100505 <script src="/derekovecs/js/derekovcs.js"></script>
Marc Kupietz83305222016-04-28 09:57:22 +0200506 <script>
507
508 var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>},
Marc Kupietz58270662017-12-04 12:10:06 +0100509 mapWidth = 800, // width map
510 mapHeight = 800,
511 jitterRadius = 7;
Marc Kupietz83305222016-04-28 09:57:22 +0200512
513 var T = new tsnejs.tSNE(opt); // create a tSNE instance
514
515 var Y;
516
517 var data;
518 var labeler;
519
520 function applyJitter() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100521 svg.selectAll('.tsnet')
522 .data(labels)
523 .transition()
524 .duration(50)
525 .attr("transform", function(d, i) {
526 T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20;
527 T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20;
528 return "translate(" +
Marc Kupietz384c9132018-03-19 16:45:24 +0100529 (d.x) + "," +
530 (d.y) + ")";
Marc Kupietze6a7a732018-01-12 09:21:08 +0100531 });
Marc Kupietz83305222016-04-28 09:57:22 +0200532 }
Marc Kupietz34c08172017-11-29 17:08:47 +0100533
Marc Kupietz83305222016-04-28 09:57:22 +0200534 function updateEmbedding() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100535 var Y = T.getSolution();
536 svg.selectAll('.tsnet')
537 .data(data.words)
538 .attr("transform", function(d, i) {
539 return "translate(" +
Marc Kupietz384c9132018-03-19 16:45:24 +0100540 ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
541 ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
Marc Kupietz83305222016-04-28 09:57:22 +0200542 }
543
544 var svg;
545 var labels = [];
546 var anchor_array = [];
547 var text;
548
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100549 function getMergedClass(i) {
550 if(data.mergedEnd && i > data.mergedEnd) {
551 return " merged"
552 } else {
553 return "";
554 }
555 }
556
557 function getRankTooltip(i) {
558 if(data.mergedEnd) {
559 if(data.ranks[i] < data.mergedEnd) {
560 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
561 } else {
562 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]-data.mergedEnd).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)";
563 }
564 } else {
565 return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
566 }
567 }
568
Marc Kupietz83305222016-04-28 09:57:22 +0200569 function drawEmbedding() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100570 var urlprefix = new URLSearchParams(window.location.search);
571 urlprefix.delete("word");
572 urlprefix.append("word","");
Marc Kupietz8f9c86a2017-12-04 17:17:13 +0100573
Marc Kupietze6a7a732018-01-12 09:21:08 +0100574 $("#embed").empty();
575 var div = d3.select("#embed");
Marc Kupietz34c08172017-11-29 17:08:47 +0100576
Marc Kupietze6a7a732018-01-12 09:21:08 +0100577 // get min and max in each column of Y
578 var Y = T.Y;
Marc Kupietz34c08172017-11-29 17:08:47 +0100579
Marc Kupietze6a7a732018-01-12 09:21:08 +0100580 svg = div.append("svg") // svg is global
581 .attr("width", mapWidth)
582 .attr("height", mapHeight);
Marc Kupietz34c08172017-11-29 17:08:47 +0100583
Marc Kupietze6a7a732018-01-12 09:21:08 +0100584 var g = svg.selectAll(".b")
585 .data(data.words)
586 .enter().append("g")
587 .attr("class", "tsnet");
Marc Kupietz34c08172017-11-29 17:08:47 +0100588
Marc Kupietze6a7a732018-01-12 09:21:08 +0100589 g.append("a")
590 .attr("xlink:href", function(word) {
591 return "?"+urlprefix+word; })
592 .attr("class", function(d, i) {
593 var res="";
594 if(data.marked[i]) {
595 res="marked ";
596 }
597 if(data.target.indexOf(" "+d+" ") >= 0) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100598 res += "target";
599 }
600 if(data.mergedEnd && data.ranks[i] >= data.mergedEnd) {
601 return res+" merged";
Marc Kupietze6a7a732018-01-12 09:21:08 +0100602 } else {
603 return res;
604 }
605 })
606 .attr("title", function(d, i) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100607 return getRankTooltip(i);
Marc Kupietze6a7a732018-01-12 09:21:08 +0100608 })
609 .append("text")
610 .attr("text-anchor", "top")
611 .attr("font-size", 12)
612 .text(function(d) { return d; });
Marc Kupietz34c08172017-11-29 17:08:47 +0100613
Marc Kupietz384c9132018-03-19 16:45:24 +0100614 g.append("svg:title")
615 .text(function(d, i) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100616 return getRankTooltip(i);
Marc Kupietz384c9132018-03-19 16:45:24 +0100617 });
618
Marc Kupietze6a7a732018-01-12 09:21:08 +0100619 var zoomListener = d3.behavior.zoom()
620 .scaleExtent([0.1, 10])
621 .center([0,0])
622 .on("zoom", zoomHandler);
623 zoomListener(svg);
Marc Kupietz83305222016-04-28 09:57:22 +0200624 }
625
626 var tx=0, ty=0;
627 var ss=1;
628 var iter_id=-1;
629
630 function zoomHandler() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100631 tx = d3.event.translate[0];
632 ty = d3.event.translate[1];
633 ss = d3.event.scale;
634 updateEmbedding();
Marc Kupietz83305222016-04-28 09:57:22 +0200635 }
636
637 var stepnum = 0;
638
639 function stopStep() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100640 clearInterval(iter_id);
641 text = svg.selectAll("text");
Marc Kupietz34c08172017-11-29 17:08:47 +0100642
Marc Kupietze6a7a732018-01-12 09:21:08 +0100643 // jitter function needs different data and co-ordinate representation
644 labels = d3.range(data.words.length).map(function(i) {
645 var x = (T.Y[i][0]*20*ss + tx) + mapWidth/2;
646 var y = (T.Y[i][1]*20*ss + ty) + mapHeight/2;
647 anchor_array.push({x: x, y: y, r: jitterRadius});
648 return {
649 x: x,
650 y: y,
651 name: data.words[i]
652 };
653 });
Marc Kupietz34c08172017-11-29 17:08:47 +0100654
Marc Kupietze6a7a732018-01-12 09:21:08 +0100655 // get the actual label bounding boxes for the jitter function
656 var index = 0;
657 text.each(function() {
658 labels[index].width = this.getBBox().width;
659 labels[index].height = this.getBBox().height;
660 index += 1;
661 });
Marc Kupietz83305222016-04-28 09:57:22 +0200662
Marc Kupietz34c08172017-11-29 17:08:47 +0100663
Marc Kupietze6a7a732018-01-12 09:21:08 +0100664 // setTimeout(updateEmbedding, 1);
665 // setTimeout(
666 labeler = d3.labeler()
667 .label(labels)
668 .anchor(anchor_array)
669 .width(mapWidth)
670 .height(mapHeight)
671 .update(applyJitter);
672 // .start(1000);
Marc Kupietz83305222016-04-28 09:57:22 +0200673
Marc Kupietze6a7a732018-01-12 09:21:08 +0100674 iter_id = setInterval(jitterStep, 1);
Marc Kupietz83305222016-04-28 09:57:22 +0200675 }
676
677 var jitter_i=0;
678
679 function jitterStep() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100680 if(jitter_i++ > 100) {
681 clearInterval(iter_id);
682 } else {
683 labeler.start2(10);
684 applyJitter();
685 }
Marc Kupietz83305222016-04-28 09:57:22 +0200686 }
687
688 var last_cost=1000;
689
690 function step() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100691 var i = T.iter;
Marc Kupietz34c08172017-11-29 17:08:47 +0100692
Marc Kupietze6a7a732018-01-12 09:21:08 +0100693 if(i > <%= $no_iterations %>) {
694 stopStep();
695 } else {
696 var cost = Math.round(T.step() * 100000) / 100000; // do a few steps
697 $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5));
698 if(i % 250 == 0 && cost >= last_cost) {
699 stopStep();
Marc Kupietz58270662017-12-04 12:10:06 +0100700 } else {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100701 last_cost = cost;
702 updateEmbedding();
Marc Kupietz58270662017-12-04 12:10:06 +0100703 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100704 }
Marc Kupietz83305222016-04-28 09:57:22 +0200705 }
706
707 function showMap(j) {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100708 data=j;
709 T.iter=0;
710 iter_id = -1;
711 last_cost=1000;
712 T.initDataRaw(data.vecs); // init embedding
713 drawEmbedding(); // draw initial embedding
Marc Kupietz78114532017-11-29 17:00:16 +0100714
Marc Kupietze6a7a732018-01-12 09:21:08 +0100715 if(iter_id >= 0) {
716 clearInterval(iter_id);
717 }
718 //T.debugGrad();
719 iter_id = setInterval(step, 1);
720 if(true) { // (<%= $show_som %>) {
721 makeSOM(j, <%= $no_iterations %>);
722 }
Marc Kupietz83305222016-04-28 09:57:22 +0200723 }
Marc Kupietz39179ab2017-07-04 16:28:06 +0200724 var queryword;
725
Marc Kupietz66bfd952017-12-11 09:59:45 +0100726 function showCollocatorSOM() {
Marc Kupietz86b50292019-02-17 21:03:59 +0100727 var baseURL = window.location.pathname.replace(/[/]$/, '')
Marc Kupietze6a7a732018-01-12 09:21:08 +0100728 if (collocatorTable) {
729 var ctableData = collocatorTable.rows().data();
730 var nwords = [],
731 nranks = [];
732 for (var i=0; i < ctableData.length && i < 100; i++) {
733 nranks.push(ctableData[i].rank);
734 nwords.push(ctableData[i].word);
Marc Kupietz66bfd952017-12-11 09:59:45 +0100735 }
Marc Kupietz86b50292019-02-17 21:03:59 +0100736 $.post(baseURL+'/getVecsByRanks',
Marc Kupietze6a7a732018-01-12 09:21:08 +0100737 JSON.stringify(nranks),
738 function(data, status){
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100739 showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: data, ranks: nranks, marked: Array(100).fill(false)} );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100740 }, 'json');
741 }
Marc Kupietz66bfd952017-12-11 09:59:45 +0100742 }
743
Marc Kupietz39179ab2017-07-04 16:28:06 +0200744 function onload() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100745 queryword = document.getElementById('word');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200746 }
747
748 function queryKorAP() {
Marc Kupietz86b50292019-02-17 21:03:59 +0100749 window.open('http://korap.ids-mannheim.de' + korapPath + '?q='+queryword.value, 'KorAP');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200750 }
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100751
752 function queryKorAPCII(query) {
Marc Kupietz86b50292019-02-17 21:03:59 +0100753 window.open('http://korap.ids-mannheim.de' +korapPath + '?ql=cosmas2&q='+query, 'KorAP');
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100754 }
Marc Kupietz83305222016-04-28 09:57:22 +0200755 </script>
756 </head>
Marc Kupietz7b0e5de2019-01-31 12:49:32 +0100757 <body onload="onload()"> <div style="display:none;" id="pmi_ttt">Pointwise mutual information: $$\text{MI}=\text{MI}=\log_2\frac{p(w_1,w_2)}{p(w_1) p(w_2)}$$<p class="citation">Church, K. W. and Hanks, P. (1990): Word association norms, mutual information, and lexicography. Comput. Linguist. 16, 1 (March 1990), 22-29.</p></div>
758 <div style="display:none;" id="md_ttt">Pointwise mutual information squared [1], also called mutual dependency [2]: $$\text{MI}^2=\text{MD}=\log_2\frac{p^2(w_1,w_2)}{p(w_1) p(w_2)}$$<p class="citation">[1] Daille, B. (1994): <a href="http://www.bdaille.com/index.php?option=com_docman&task=doc_download&gid=8&Itemid=">Approche mixte pour l’extraction automatique de terminologie: statistiques lexicales et filtres linguistiques</a>. PhD thesis, Université Paris 7.</p><p class="citation">[2] Thanopoulos, A., Fakotakis, N., Kokkinakis, G. (2002): <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.11.8101&rep=rep1&type=pdf">Comparative evaluation of collocation extraction metrics</a>. In: Proc. of LREC 2002: 620–625.</p></div>
759 <div style="display:none;" id="lfmd_ttt">Pointwise mutual information cubed [1], also called log-frequency biased mutual dependency [2]: $$\text{MI}^3=\text{LFMD}=\log_2\frac{p^3(w_1,w_2)}{p(w_1) p(w_2)}$$<p class="citation">[1] Daille, B. (1994): <a href="http://www.bdaille.com/index.php?option=com_docman&task=doc_download&gid=8&Itemid=">Approche mixte pour l’extraction automatique de terminologie: statistiques lexicales et filtres linguistiques</a>. PhD thesis, Université Paris 7.</p><p class="citation">[2] Thanopoulos, A., Fakotakis, N., Kokkinakis, G. (2002): <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.11.8101&rep=rep1&type=pdf">Comparative evaluation of collocation extraction metrics</a>. In: Proc. of LREC 2002: 620–625.</p></div>
760 <div style="display:none;" id="npmi_ttt">Normalized pointwise mutual information: $$\frac{\log_2\frac{p(w_1,w_2)}{p(w_1)p(w_2)}}{-\log_2(p(w_1,w_2))}$$<p class="citation">Bouma, Gerlof (2009): <a href="https://svn.spraakdata.gu.se/repos/gerlof/pub/www/Docs/npmi-pfd.pdf">Normalized (pointwise) mutual information in collocation extraction</a>. In Proceedings of GSCL.</p></div>
761 <div style="display:none;" id="ll_ttt">Log-likelihood: $$2\sum_{ij}O_{ij}\log\frac{O_{ij}}{E_{ij}}$$<p class="citation">Dunning, T. (1993): Accurate methods for the statistics of surprise and coincidence. Comput. Linguist. 19, 1 (March 1993), 61-74.</p>
762 <p class="citation">Evert, Stefan (2004): <a href="http://purl.org/stefan.evert/PUB/Evert2004phd.pdf">The Statistics of Word Cooccurrences: Word Pairs and Collocations.</a> PhD dissertation, IMS, University of Stuttgart. Published in 2005, URN urn:nbn:de:bsz:93-opus-23714.</p></div>
763 <div style="display:none;" id="logdice_ttt">Log-Dice: $$14 + \log_2 \frac{2f_{1,2}}{f_1 + f_2}$$<p class="citation">Rychlý, Pavel (2008): <a href="http://www.fi.muni.cz/usr/sojka/download/raslan2008/13.pdf">A lexicographer-friendly association score.</a> In Proceedings of Recent Advances in Slavonic Natural Language Processing, RASLAN, 6–9, 2008</p></div>
764 <div style="display:none;" id="logdiceaf_ttt">Log-Dice using "auto-focus", i.e. the window that yields the highest score.</div>
Marc Kupietz58270662017-12-04 12:10:06 +0100765 <div id="header">
766 <div id="pagetitle">
Marc Kupietzc053d972019-01-10 10:41:51 +0100767 <h1>DeReKoVecs</h1>
768 <h2><%== $title %></h2>
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100769 </div>
Marc Kupietz58270662017-12-04 12:10:06 +0100770 <div id="options" class="widget">
771 <form id="queryform">
772 <input id="word" type="text" name="word" placeholder="Word(s) to be searched" value="<%= $word %>"
773 title="When looking for multiple words use spaces as separators to search around the average vector and | as separator to get the neighbours for each word."/>
774 <input id="SEARCH" type="button" value="SEARCH">
775 <input type="button" id="showoptions" name="showoptions" value="Options" />
776 </form>
777 <div id="dropdownoptions" style="display: none">
778 <form id="optionsform">
779 <div class="controlgroup-vertical">
780 <label for="cutoff">cut-off</label>
781 <input id="cutoff" type="text" name="cutoff" size="10" value="<%= $cutoff %>" title="Only consider the most frequent x word forms.">
782 <label for="dedupe">dedupe</label>
783 <input id="dedupe" type="checkbox" name="dedupe" value="1" <%= ($dedupe ? "checked" : "") %> title="radically filter out any near-duplicates">
784 % if($mergedEnd > 0) {
785 <label for="sbf">backw.</label>
786 <input id="sbf" type="checkbox" name="sbf" value="1" <%= ($searchBaseVocabFirst ? "checked" : "") %> title="If checkecked base vocabulary will be searched first. Otherwise merged vocabulray will be searched first.">
787 % }
788 <label for="neighbours">max. neighbours:</label>
789 <input id="neighbours" size="4" name="n" value="<%= $no_nbs %>">
790 <label for="no_iterations">max. iterations</label>
791 <input id="no_iterations" name="N" size="4" value="<%= $no_iterations %>">
792 <!-- <label for="dosom">SOM</label>
793 <input id="dosom" type="checkbox" name="som" value="1" <%= ($show_som ? "checked" : "") %>> -->
794 % if($collocators) {
795 <label for="sortby">window/sort</label>
796 <select id="sortby" name="sort">
797 <option value="0" <%= ($sort!=1 && $sort!=2? "selected":"") %>>auto focus</option>
798 <!-- <option value="1" <%= ($sort==1? "selected":"") %>>any single position</option>
799 <option value="2" <%= ($sort==2? "selected":"") %>>whole window</option> -->
800 </select>
801 % }
802 <input type="button" value="→ KorAP" onclick="queryKorAP();" title="query word with KorAP"/>
Marc Kupietz1acb3172018-02-17 09:41:26 +0100803 <input id="show-details" type="checkbox" name="show-details" value="1" >
804 <label for="show-details">
805 Show details
806 </label>
Marc Kupietz58270662017-12-04 12:10:06 +0100807 </div>
808 </form>
809 </div>
810 </div>
811 </div>
812 <div id="topwrapper">
813 <div style="visibility: hidden;" id="tabs">
814 <ul>
815 <li><a href="#tabs-1">Semantics (TSNE-map)</a></li>
816 <li><a href="#tabs-2">Semantics (SOM)</a></li>
Marc Kupietzbb3da6a2019-01-22 15:21:38 +0100817 <li><a href="#tabs-3">Syntagmatic (collocates)</a></li>
Marc Kupietz58270662017-12-04 12:10:06 +0100818 </ul>
Marc Kupietz384c9132018-03-19 16:45:24 +0100819 <div id="tabs-1" style="display: flex; padding: 5px; flex-flow: row wrap;">
Marc Kupietz58270662017-12-04 12:10:06 +0100820 % if($lists && (@$lists) > 0 && (@$lists)[0]) {
821 <div id="wrapper">
Marc Kupietz384c9132018-03-19 16:45:24 +0100822 <div id="first" style="width: 230px; margin-bottom: 15px;">
Marc Kupietz58270662017-12-04 12:10:06 +0100823 <table class="display compact nowrap" id="firsttable">
824 <thead>
825 <tr>
Marc Kupietz384c9132018-03-19 16:45:24 +0100826 <th align="right">#</th><th align="right">cos</th><th align="left">similars by w2v</th>
Marc Kupietz58270662017-12-04 12:10:06 +0100827 </tr>
828 </thead>
829 <tbody>
830 <tr>
831 <td align="right">
832 </td>
833 <td align="right">
834 </td>
835 <td></td>
836 </tr>
837 </tbody>
838 </table>
839 </div>
Marc Kupietza55a09a2018-07-06 13:30:30 +0200840 % if(0 && $haveSProfiles) {
Marc Kupietz384c9132018-03-19 16:45:24 +0100841 <div id="sprofilesdiv" style="width: 200px; padding-right: 10px;">
842 <table class="display compact nowrap" id="sprofiles">
843 <thead>
844 <tr>
845 <th align="right">cos</th><th align="left">similars by coll. profile</th>
846 </tr>
847 </thead>
848 <tbody>
849 <tr>
850 <td align="right">
851 </td>
852 <td></td>
853 </tr>
854 </tbody>
855 </table>
856 </div>
857 %}
858 <div id="second">
Marc Kupietz58270662017-12-04 12:10:06 +0100859 <div id="embed">
860 </div>
861 <div id="cost">
862 </div>
863 </div>
864 </div>
Marc Kupietz384c9132018-03-19 16:45:24 +0100865 % } elsif($word !~ /^\s*$/) {
866 <div id="wrapper">
867 <div id="not-found-dialog" title="Not found">
868 <p>ERROR: "<%= $word %>" not found in vocabluary.</p>
869 <p>If you are sure you have spelled the word as intended, you can try to increase the cutoff parameter in the options menu.</p>
870 </div>
871 <script>
872 $( function() {
873 $( "#not-found-dialog" ).dialog({
874 autoOpen: true,
875 modal: true,
876 draggable: false,
877 height: "auto",
878 width: "auto",
879 resizable: false,
880 buttons: {
881 "OK": function() {
882 $( this ).dialog( "close" );
883 },
884 "Apply": function() {
885 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
886 }
887 }
888 });
889 });
890 </script>
891 </div>
892 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100893 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100894 <div id="tabs-2" style="display: flex; padding: 5px; flex-flow: row wrap;">
Marc Kupietz66bfd952017-12-11 09:59:45 +0100895 <div id="som2" style="width: 800;">
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100896 <div id="sominfo1"><span id="somcolor1"> </span> <span id="somword1"> </span> <span id="somcolor2"> </span> <span id="somword2"> </span> <span id="somcolor3"> </span></div>
897 <div id="sominfo" style="text-align: right">SOM iteration <span id="iterations">0</span></div>
Marc Kupietz58270662017-12-04 12:10:06 +0100898 </div>
Marc Kupietz58270662017-12-04 12:10:06 +0100899 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100900 <div id="tabs-3" style="display: flex; padding:5px; flex-flow: row wrap;">
901 <div style="margin-right: 20px; margin-bottom: 10px;" id="secondt">
Marc Kupietze6a7a732018-01-12 09:21:08 +0100902 <table class="display compact nowrap" id="secondtable">
Marc Kupietz58270662017-12-04 12:10:06 +0100903 <thead>
904 <tr>
905 % if($collocators) {
906 <th>#</th>
Marc Kupietz4116b432017-12-06 14:15:32 +0100907 <th align="center" title="Activation of the respective collocator in the columns around the target normalized by its maximum (red). Columns selected by the auto-focus funtion (which window of all possible column-combinations maximizes ⊥(a/c)?) are marked with +. Click on the column postions to lauch a KorAP query with target word and collocator in the respective position.">w'</th>
908 <th align="right" title="Maximum activation of the collocator anywhere in the output layer.">max(a)</th>
909 <th title="Average raw activation of the collocator in the columns selected by auto-focus." align="right">⟨a⟩</th>
910 <th title="Sum of activations over the selected colunns normalized by the total activation sum of the selected columns." align="right">Σa/Σw'</th>
911 <th title="Co-norm of the column-normalized activations over the colunns selected by the auto-focus." align="right">⊥(a/c)</th>
Marc Kupietz58270662017-12-04 12:10:06 +0100912 <th title="Sum of the activations over the whole window normalized by the total window sum (no auto-focus)." align="right">Σa/Σw</th>
Marc Kupietzbb3da6a2019-01-22 15:21:38 +0100913 <th align="left">collocate (by w2v)</th>
Marc Kupietz58270662017-12-04 12:10:06 +0100914 % }
915 </tr>
916 </thead>
917 <tbody>
918 <tr>
919 <td align="right">
920 </td>
921 <td align="right">
922 </td>
923 <td align="right">
924 </td>
925 <td align="right">
926 </td>
927 <td align="right">
928 </td>
929 <td align="right">
930 </td>
Marc Kupietz58270662017-12-04 12:10:06 +0100931 </tr>
932 </tbody>
933 </table>
Marc Kupietz66bfd952017-12-11 09:59:45 +0100934 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100935 <div id="ccd" style="">
Marc Kupietze6a7a732018-01-12 09:21:08 +0100936 <table class="display compact nowrap" id="classicoloctable">
937 <thead>
Marc Kupietzcd136e22018-01-29 09:18:12 +0100938 % if($collocators) {
939 <tr>
Marc Kupietzf19814b2019-01-21 16:50:19 +0100940 <th id="ll_tt">LL</th>
Marc Kupietzfab14a72019-01-22 16:20:29 +0100941 <th id="mi_tt">MI</th>
942 <th id="md_tt">MI²</th>
Marc Kupietzf19814b2019-01-21 16:50:19 +0100943 <th id="lfmd_tt">MI³</th>
Marc Kupietzfab14a72019-01-22 16:20:29 +0100944 <th id="npmi_tt">nPMI</th>
945 <th id="dice_tt">dice</th>
Marc Kupietz63b268f2019-01-22 22:34:29 +0100946 <th id="logdice_tt">LD</th>
947 <th id="logdiceaf_tt">LDaf</th>
Marc Kupietz7b0e5de2019-01-31 12:49:32 +0100948 <th id="af_win" title="Positions around the target word that are selected by the auto-focus function are marked with ◾. Positions at which the collocate appears at least once are marked with ◽.">af-window</th>
Marc Kupietz5a7f9ac2018-01-30 11:22:44 +0100949 <th title="PMI³ restricted to left neighbour">l-PMI³</th>
950 <th title="PMI³ restricted to right neighbour">r-PMI³</th>
951 <th title="nPMI restricted to left neighbour">l-nPMI</th>
952 <th title="nPMI restricted to right neighbour">r-nPMI</th>
Marc Kupietz4784fae2019-02-04 12:32:12 +0100953 <th id="rawfreq_tt" title="raw frequency sum of collocation within window">raw</th>
Marc Kupietzbb3da6a2019-01-22 15:21:38 +0100954 <th>collocate (by CA)</th>
Marc Kupietzcd136e22018-01-29 09:18:12 +0100955 </tr>
Marc Kupietz1acb3172018-02-17 09:41:26 +0100956 % }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100957 </thead>
958 <tbody>
959 <tr>
960 <td align="right">
961 </td>
962 <td align="right">
963 </td>
964 <td align="right">
965 </td>
966 <td align="right">
967 </td>
Marc Kupietzcfcdcfc2018-01-24 09:51:26 +0100968 <td align="right">
969 </td>
970 <td align="right">
971 </td>
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100972 <td align="right"></td>
Marc Kupietz63b268f2019-01-22 22:34:29 +0100973 <td align="left"></td>
974 <td align="right"></td>
975 <td align="right"></td>
976 <td align="right"></td>
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100977 <td align="right"></td>
978 <td align="left"></td>
Marc Kupietze6a7a732018-01-12 09:21:08 +0100979 </tr>
980 </tbody>
981 </table>
982 </div>
Marc Kupietz384c9132018-03-19 16:45:24 +0100983 <!--
984 <div style="clear:both" ></div>
985 <div style="float: right; overflow: hidden" id="extra"><button onClick="showCollocatorSOM()"> </button></div>
986 -->
Marc Kupietz66bfd952017-12-11 09:59:45 +0100987 </div>
Marc Kupietz58270662017-12-04 12:10:06 +0100988 </div>
989 </div> <!-- topwrapper -->
990 <div style="clear: both;"></div>
991 </div>
Marc Kupietzebea4702018-01-12 09:16:09 +0100992 % if($training_args && (@$lists)[0]) {
993 <div class="info">
994 % if($training_args =~ /-type\s*3/) {
995 Calculations are based on a word embedding model trained with an extension of <a href="https://github.com/wlin12/wang2vec/">wang2vec</a> using the following parameters: <%= $training_args %>
996 % } else {
997 Calculations are based on a word embedding model trained with <a href="https://code.google.com/p/word2vec/">word2vec</a> using the following parameters: <%= $training_args %>
998 % }
999 </div>
Marc Kupietz83305222016-04-28 09:57:22 +02001000 % }
Marc Kupietz58270662017-12-04 12:10:06 +01001001 </body>
Marc Kupietz83305222016-04-28 09:57:22 +02001002</html>