blob: bfb8f0207861a0991ce16fbe44d00b6a7d9e8de6 [file] [log] [blame]
Marc Kupietz83305222016-04-28 09:57:22 +02001<!DOCTYPE html>
2<html>
3 <head>
4 <title>DeReKo-Word-Vector-Distances: <%= $word %></title>
Marc Kupietz80bd7b92017-07-04 16:25:54 +02005 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
Marc Kupietz6dbadd12017-11-29 16:43:33 +01006 <link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Condensed" rel="stylesheet">
Marc Kupietz80bd7b92017-07-04 16:25:54 +02007 <script src="http://code.jquery.com/jquery-latest.min.js"></script>
Marc Kupietz4abcd682017-11-28 20:51:08 +01008 <script src = "https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
9 <script src = "https://cdn.datatables.net/fixedcolumns/3.2.3/js/dataTables.fixedColumns.min.js"></script>
10 <link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
Marc Kupietz80bd7b92017-07-04 16:25:54 +020011 <script
Marc Kupietz6dbadd12017-11-29 16:43:33 +010012 src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
13 integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
14 crossorigin="anonymous"></script>
Marc Kupietz80bd7b92017-07-04 16:25:54 +020015 <script>
Marc Kupietz4abcd682017-11-28 20:51:08 +010016 $('#firstable').hide();
17 $(document).ready(function() {
18 $("#xxxtabs").tabs( {
19 "show": function(event, ui) {
20 var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable();
21 if ( oTable.length > 0 ) {
22 oTable.fnAdjustColumnSizing();
23 }
24 }
25 } );
Marc Kupietz694610d2017-11-25 18:30:03 +010026
Marc Kupietzdab9f222017-11-29 14:22:59 +010027 $("input").bind("keydown", function(event) {
28 // track enter key
29 var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
30 if (keycode == 13) { // keycode for enter key
31 // force the 'Enter Key' to implicitly click the Update button
32 document.getElementById('SEARCH').click();
33 return false;
34 } else {
35 return true;
36 }});
37
Marc Kupietz4abcd682017-11-28 20:51:08 +010038 $(".selector").tabs({ active: 1 });
Marc Kupietz0af83e32017-11-27 09:31:37 +010039
Marc Kupietz4abcd682017-11-28 20:51:08 +010040 $('#firsttable').DataTable({
41 "sScrollY": "780px",
42 "bScrollCollapse": true,
43 "bPaginate": false,
44 "bJQueryUI": true,
45 "dom": '<"top">rt<"bottom"flp><"clear">',
46 "aoColumnDefs": [
47 { "sWidth": "10%", "aTargets": [ -1 ] }
48 ]
49 } );
Marc Kupietz0af83e32017-11-27 09:31:37 +010050
51 $('#secondtable').DataTable({
Marc Kupietz4abcd682017-11-28 20:51:08 +010052 "sScrollY": "800px",
53 "bScrollCollapse": true,
54 "bPaginate": false,
55 "bJQueryUI": true,
56 "dom": '<"top">rt<"bottom"flp><"clear">',
57 "aoColumnDefs": [
58 { "sWidth": "10%", "aTargets": [ -1 ] }
59 ]
60 } );
61 });
Marc Kupietz0af83e32017-11-27 09:31:37 +010062
Marc Kupietzdab9f222017-11-29 14:22:59 +010063 $(function(){
64 $("#dropdownoptions").dialog({
65 title: "Options",
66 autoOpen: false,
67 modal: false,
68 draggable: false,
69 height: "auto",
70 width: "auto",
71 resizable: false,
72 buttons: {
73 "Cancel": function() {
74 $( this ).dialog( "close" );
75 },
76 "Apply": function() {
77 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
78 }
79 }
80 });
81 });
82
83 $(function(){
84 $("#SEARCH").click(function() {
85 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
86 });
87 });
88
89 $(function(){
90 $("#showoptions").click(function(){
91 $("#dropdownoptions").dialog("open");
92 var target = $(this);
93 $("#dropdownoptions").dialog("widget").position({
94 my: 'left bottom',
95 at: 'left bottom',
96 of: target
97 });
98 });
99 });
100
Marc Kupietz4abcd682017-11-28 20:51:08 +0100101 $( function() {
Marc Kupietzc1e42c32017-11-29 16:47:56 +0100102 $( "#no_iterations" ).spinner({
Marc Kupietz4abcd682017-11-28 20:51:08 +0100103 spin: function( event, ui ) {
104 if ( ui.value < 1000 ) {
105 $( this ).spinner( "value", 1000 );
106 return false;
107 } else if ( ui.value > 10000 ) {
108 $( this ).spinner( "value", 10000 );
109 return false;
110 }
111 }
112 });
113 } );
Marc Kupietz3305b0a2017-11-27 10:46:20 +0100114
Marc Kupietz4abcd682017-11-28 20:51:08 +0100115 $( function() {
116 $( "#neighbours" ).spinner({
117 spin: function( event, ui ) {
118 if ( ui.value < 0 ) {
119 $( this ).spinner( "value", 0 );
120 return false;
121 } else if ( ui.value > 200 ) {
122 $( this ).spinner( "value", 200 );
123 return false;
124 }
125 }
126 });
127 } );
128
129 $( function() {
130 $( "#cutoff" ).spinner({
131 spin: function( event, ui ) {
132 if ( ui.value < 100000 ) {
133 $( this ).spinner( "value", 100000 );
134 return false;
135 } else if ( ui.value > 2000000 ) {
136 $( this ).spinner( "value", 2000000 );
137 return false;
138 }
139 }
140 });
141 } );
142
143 $( function() {
Marc Kupietzdf3d4b52017-11-29 16:57:27 +0100144 $( "#tabs" ).tabs().addClass('tabs-min');
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100145 } );
Marc Kupietz4abcd682017-11-28 20:51:08 +0100146
147 $( function() {
148 $( ".controlgroup-vertical" ).controlgroup({
149 "direction": "vertical"
150 });
151 } );
152
153 $(function() {
154 $( document ).tooltip({
155 content: function() {
156 return $(this).attr('title');
157 }}
158 )
Marc Kupietz83305222016-04-28 09:57:22 +0200159 })
Marc Kupietz694610d2017-11-25 18:30:03 +0100160
Marc Kupietz83305222016-04-28 09:57:22 +0200161 </script>
162 <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
Marc Kupietz554aff52017-11-09 14:42:09 +0100163 <script src="/derekovecs/js/tsne.js"></script>
164 <script src="/derekovecs/js/som.js"></script>
165 <script src="/derekovecs/js/labeler.js"></script>
Marc Kupietz83305222016-04-28 09:57:22 +0200166 <style>
167 body, input {
Marc Kupietz6dbadd12017-11-29 16:43:33 +0100168 font-family: Lato, sans-serif;
Marc Kupietz83305222016-04-28 09:57:22 +0200169 font-size: 11pt;
170 }
Marc Kupietz30ca4342017-11-22 21:21:20 +0100171
Marc Kupietz6dbadd12017-11-29 16:43:33 +0100172 h1, h2, h3 {
173 margin: 5px 10px 0 0;
174 color: rgb(246,168,0);
175 font-family: "Univers LT Std 47 Cn Lt", "Univers LT Std 67 Cn Lt", "Roboto Condensed", "Univers LT Std 67 Cn Bold", "UniversLTStd-BoldCn", "Times", 'League Gothic', Impact, sans-serif;
176 font-weight: bold;
177 line-height: 1.35;
178 letter-spacing: normal;
179 text-transform: uppercase;
180 text-shadow: none;
181 word-wrap: break-word;
Marc Kupietz81bf39c2017-11-29 17:04:35 +0100182 showoptions, #SEARCH {
183 margin-left: 10px;
184 margin-right: 10px;
Marc Kupietz6dbadd12017-11-29 16:43:33 +0100185 }
186
Marc Kupietzdab9f222017-11-29 14:22:59 +0100187 .tabs-left-vertical .ui-tabs-nav {
188 position: absolute;
189 width: 21em;
190 transform: translate(-100%,0%) rotate(-90deg);
191 transform-origin: 100% 0%;
192 }
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100193
Marc Kupietzdab9f222017-11-29 14:22:59 +0100194 .tabs-left-vertical .ui-tabs-nav li {
195 float: right;
196 }
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100197
Marc Kupietzdab9f222017-11-29 14:22:59 +0100198 .tabs-left-vertical .ui-tabs-panel {
199 padding-left: 3.5em;
200 }
201
202 .tabs-left-vertical .ui-tabs-panel {
203 height: 20em;
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100204 }
205
Marc Kupietz30ca4342017-11-22 21:21:20 +0100206 .mono {
207 font-family: "DejaVu Sans Mono", Inconsolata, SourceCodePro, Courier;
208 }
209
Marc Kupietz83305222016-04-28 09:57:22 +0200210 .ui-tooltip-content {
211 font-size: 9pt;
212 color: #222222;
213 }
214
215 svg > .ui-tooltip-content {
216 font-size: 8pt;
217 color: #222222;
218 }
219
220 a.merged {
221 color: green;
222 fill: green;
223 }
224
225 #first a {
226 text-decoration: none;
227 }
228
229 a.marked, #first a.marked {
230 text-decoration: underline;
231 }
Marc Kupietzf4b49392016-04-28 10:49:56 +0200232
Marc Kupietz83305222016-04-28 09:57:22 +0200233 a.target {
234 color: red;
235 fill: red;
236 }
Marc Kupietz694610d2017-11-25 18:30:03 +0100237
Marc Kupietz4abcd682017-11-28 20:51:08 +0100238 table.display {
239 width: 40% important!;
240 margin: 1; /* <- works for me this way ****/
241 }
242 table.dataTable thead th, table.dataTable thead td, table.dataTable tbody td {
243 padding: 2px 2px;
244 // border-bottom: 1px solid #111;
245 }
Marc Kupietz83305222016-04-28 09:57:22 +0200246 #collocators {
247 margin-bottom: 15px;
248 }
249
Marc Kupietz4abcd682017-11-28 20:51:08 +0100250 #topwrapper {
Marc Kupietz83305222016-04-28 09:57:22 +0200251 width: 100%;
252 // border: 1px solid red;
253 overflow: hidden; /* will contain if #first is longer than #second */
254 }
Marc Kupietz4abcd682017-11-28 20:51:08 +0100255
256 #wrapper {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100257 // border: 1px solid red;
258 overflow: hidden; /* will contain if #first is longer than #second */
259 }
260
Marc Kupietz81bf39c2017-11-29 17:04:35 +0100261 #header {
262 width: 100%;
263 // border: 1px solid red;
264 overflow: hidden; /* will contain if #first is longer than #second */
265 }
266
267 #pagetitle {
268 max-width: 460px;
269 margin-right: 20px;
270 float: left;
271 overflow: hidden; /* if you don't want #second to wrap below #first */
272 // border: 1px solid green;
273 }
Marc Kupietz4abcd682017-11-28 20:51:08 +0100274
Marc Kupietz83305222016-04-28 09:57:22 +0200275 #first {
276 margin-right: 20px;
277 float: left;
Marc Kupietz4abcd682017-11-28 20:51:08 +0100278 overflow: hidden; /* if you don't want #second to wrap below #first */
Marc Kupietz83305222016-04-28 09:57:22 +0200279 // border: 1px solid green;
280 }
Marc Kupietz4abcd682017-11-28 20:51:08 +0100281 #tabs {
282 margin-right: 20px;
283 overflow: hidden; /* if you don't want #second to wrap below #first */
284 }
285
Marc Kupietz81bf39c2017-11-29 17:04:35 +0100286 #options {
287 float: left;
288 width: 800px;
289 margin: 10px;
290 overflow: hidden; /* if you don't want #second to wrap below #first */
291 }
292
293 #word {
294 width: 50%;
295 }
296
Marc Kupietzdf3d4b52017-11-29 16:57:27 +0100297
298 .tabs-min {
299 background: transparent;
300 border: none;
301 }
302
303 .tabs-min .ui-widget-header {
304 background: transparent;
305 border: none;
306 border-bottom: 1px solid #c0c0c0;
307 -moz-border-radius: 0px;
308 -webkit-border-radius: 0px;
309 border-radius: 0px;
310 }
311
312 .tabs-min .ui-tabs-nav .ui-state-default {
313 background: transparent;
314 border: none;
315 }
316
317 .tabs-min .ui-tabs-nav .ui-state-active {
318 background: transparent url(img/uiTabsArrow.png) no-repeat bottom center;
319 border: none;
320 }
321
322 .tabs-min .ui-tabs-nav .ui-state-default a {
323 color: #c0c0c0;
324 }
325
326 .tabs-min .ui-tabs-nav .ui-state-active a {
327 color: rgb(246,168,0);
328 }
329
Marc Kupietz4abcd682017-11-28 20:51:08 +0100330 #embed {
331 max-width: 802px;
332 border: 1px solid #333;
333 }
334
Marc Kupietz83305222016-04-28 09:57:22 +0200335 #second {
Marc Kupietzb0173f12017-11-29 10:00:23 +0100336 min-width: 800px;
Marc Kupietzdab9f222017-11-29 14:22:59 +0100337 // border: 1px solid #333;
Marc Kupietz83305222016-04-28 09:57:22 +0200338 overflow: hidden; /* if you don't want #second to wrap below #first */
339 }
340 #som2 svg {
341 border: 1px solid #333;
342 }
343
344 #cost {
345 font-size: 8pt;
346 color: #222222;
347 margin-top: 4px;
348 margin-bottom: 12px;
349 }
350
351 #sominfo1, #sominfo {
352 font-size: 8pt;
353 color: #222222;
354 margin-top: 0px;
355 }
356
357 #somcolor1, #somcolor2, #somcolor3 {
358 display: inline-block;
359 height: 10px;
360 width: 10px;
361 }
362
363 #third {
364 border: 1px solid #333;
365 }
366
367 </style>
368 <script>
369
370 var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>},
371 mapWidth = 800, // width map
372 mapHeight = 800,
373 jitterRadius = 7;
374
375 var T = new tsnejs.tSNE(opt); // create a tSNE instance
376
377 var Y;
378
379 var data;
380 var labeler;
381
382 function applyJitter() {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100383 svg.selectAll('.tsnet')
384 .data(labels)
385 .transition()
386 .duration(50)
387 .attr("transform", function(d, i) {
388 T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20;
389 T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20;
390 return "translate(" +
Marc Kupietzdab9f222017-11-29 14:22:59 +0100391 (d.x) + "," +
392 (d.y) + ")";
Marc Kupietz4abcd682017-11-28 20:51:08 +0100393 });
Marc Kupietz83305222016-04-28 09:57:22 +0200394 }
395
396 function updateEmbedding() {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100397 var Y = T.getSolution();
398 svg.selectAll('.tsnet')
399 .data(data.words)
400 .attr("transform", function(d, i) {
401 return "translate(" +
Marc Kupietzdab9f222017-11-29 14:22:59 +0100402 ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
403 ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
Marc Kupietz83305222016-04-28 09:57:22 +0200404 }
405
406 var svg;
407 var labels = [];
408 var anchor_array = [];
409 var text;
410
411 function drawEmbedding() {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100412 $("#embed").empty();
413 var div = d3.select("#embed");
414
415 // get min and max in each column of Y
416 var Y = T.Y;
417
418 svg = div.append("svg") // svg is global
419 .attr("width", mapWidth)
420 .attr("height", mapHeight);
421
422 var g = svg.selectAll(".b")
423 .data(data.words)
424 .enter().append("g")
425 .attr("class", "tsnet");
426
427 g.append("a")
428 .attr("xlink:href", function(word) {
429 return (data.urlprefix+word);})
430 .attr("class", function(d, i) {
431 var res="";
432 if(data.marked[i]) {
433 res="marked ";
434 }
435 if(data.target.indexOf(" "+d+" ") >= 0) {
436 return res+"target";
437 } else if(data.ranks[i] < data.mergedEnd) {
438 return res+"merged";
439 } else {
440 return res;
441 }
442 })
443 .attr("title", function(d, i) {
444 if(data.mergedEnd > 0) {
445 if(data.ranks[i] >= data.mergedEnd) {
446 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
447 } else {
448 return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)";
449 }
450 } else {
451 return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
452 }
453 })
454 .append("text")
455 .attr("text-anchor", "top")
456 .attr("font-size", 12)
457 .text(function(d) { return d; });
458
459 var zoomListener = d3.behavior.zoom()
460 .scaleExtent([0.1, 10])
461 .center([0,0])
462 .on("zoom", zoomHandler);
463 zoomListener(svg);
Marc Kupietz83305222016-04-28 09:57:22 +0200464 }
465
466 var tx=0, ty=0;
467 var ss=1;
468 var iter_id=-1;
469
470 function zoomHandler() {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100471 tx = d3.event.translate[0];
472 ty = d3.event.translate[1];
473 ss = d3.event.scale;
474 updateEmbedding();
Marc Kupietz83305222016-04-28 09:57:22 +0200475 }
476
477 var stepnum = 0;
478
479 function stopStep() {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100480 clearInterval(iter_id);
481 text = svg.selectAll("text");
482
483 // jitter function needs different data and co-ordinate representation
484 labels = d3.range(data.words.length).map(function(i) {
485 var x = (T.Y[i][0]*20*ss + tx) + mapWidth/2;
486 var y = (T.Y[i][1]*20*ss + ty) + mapHeight/2;
487 anchor_array.push({x: x, y: y, r: jitterRadius});
488 return {
489 x: x,
490 y: y,
491 name: data.words[i]
492 };
493 });
494
495 // get the actual label bounding boxes for the jitter function
496 var index = 0;
497 text.each(function() {
498 labels[index].width = this.getBBox().width;
499 labels[index].height = this.getBBox().height;
500 index += 1;
501 });
Marc Kupietz83305222016-04-28 09:57:22 +0200502
Marc Kupietz4abcd682017-11-28 20:51:08 +0100503
504 // setTimeout(updateEmbedding, 1);
505 // setTimeout(
506 labeler = d3.labeler()
507 .label(labels)
508 .anchor(anchor_array)
509 .width(mapWidth)
510 .height(mapHeight)
511 .update(applyJitter);
512 // .start(1000);
Marc Kupietz83305222016-04-28 09:57:22 +0200513
Marc Kupietz4abcd682017-11-28 20:51:08 +0100514 iter_id = setInterval(jitterStep, 1);
Marc Kupietz83305222016-04-28 09:57:22 +0200515 }
516
517 var jitter_i=0;
518
519 function jitterStep() {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100520 if(jitter_i++ > 100) {
521 clearInterval(iter_id);
522 } else {
523 labeler.start2(10);
524 applyJitter();
525 }
Marc Kupietz83305222016-04-28 09:57:22 +0200526 }
527
528 var last_cost=1000;
529
530 function step() {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100531 var i = T.iter;
532
533 if(i > <%= $no_iterations %>) {
534 stopStep();
535 } else {
536 var cost = Math.round(T.step() * 100000) / 100000; // do a few steps
537 $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5));
538 if(i % 250 == 0 && cost >= last_cost) {
539 stopStep();
540 } else {
541 last_cost = cost;
542 updateEmbedding();
543 }
544 }
Marc Kupietz83305222016-04-28 09:57:22 +0200545 }
546
547 function showMap(j) {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100548 data=j;
549 T.iter=0;
550 T.initDataRaw(data.vecs); // init embedding
551 drawEmbedding(); // draw initial embedding
Marc Kupietz78114532017-11-29 17:00:16 +0100552
Marc Kupietz4abcd682017-11-28 20:51:08 +0100553 if(iter_id >= 0) {
554 clearInterval(iter_id);
555 }
556 //T.debugGrad();
557 iter_id = setInterval(step, 1);
Marc Kupietz78114532017-11-29 17:00:16 +0100558 if(true) { // (<%= $show_som %>) {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100559 makeSOM(j, <%= $no_iterations %>);
560 }
Marc Kupietz83305222016-04-28 09:57:22 +0200561 }
Marc Kupietz39179ab2017-07-04 16:28:06 +0200562 var queryword;
563
564 function onload() {
Marc Kupietz4abcd682017-11-28 20:51:08 +0100565 queryword = document.getElementById('word');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200566 }
567
568 function queryKorAP() {
569 window.open('http://korap.ids-mannheim.de/kalamar/?q='+queryword.value, 'KorAP');
570 }
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100571
572 function queryKorAPCII(query) {
573 window.open('http://korap.ids-mannheim.de/kalamar/?ql=cosmas2&q='+query, 'KorAP');
574 }
Marc Kupietz83305222016-04-28 09:57:22 +0200575 </script>
576 </head>
Marc Kupietz39179ab2017-07-04 16:28:06 +0200577 <body onload="onload()">
Marc Kupietz81bf39c2017-11-29 17:04:35 +0100578 <div id="header">
579 <div id="pagetitle">
580 <h1>DeReKo-Vectors</h1>
581 </div>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100582 <div id="options" class="widget">
Marc Kupietzdab9f222017-11-29 14:22:59 +0100583 <form id="queryform">
Marc Kupietz81bf39c2017-11-29 17:04:35 +0100584 <input id="word" type="text" name="word" placeholder="Word(s) to be searched" value="<%= $word %>"
585 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."/>
Marc Kupietzdab9f222017-11-29 14:22:59 +0100586 <input id="SEARCH" type="button" value="SEARCH">
587 <input type="button" id="showoptions" name="showoptions" value="Options" />
588 </form>
589 <div id="dropdownoptions" style="display: hidden">
590 <form id="optionsform">
Marc Kupietz4abcd682017-11-28 20:51:08 +0100591 <div class="controlgroup-vertical">
592 <label for="cutoff">cut-off</label>
593 <input id="cutoff" type="text" name="cutoff" size="10" value="<%= $cutoff %>" title="Only consider the most frequent x word forms.">
594 <label for="dedupe">dedupe</label>
595 <input id="dedupe" type="checkbox" name="dedupe" value="1" <%= ($dedupe ? "checked" : "") %> title="radically filter out any near-duplicates">
596 % if($mergedEnd > 0) {
Marc Kupietz78114532017-11-29 17:00:16 +0100597 <label for="sbf">backw.</label>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100598 <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.">
599 % }
600 <label for="neighbours">max. neighbours:</label>
601 <input id="neighbours" size="4" name="n" value="<%= $no_nbs %>">
Marc Kupietzc1e42c32017-11-29 16:47:56 +0100602 <label for="no_iterations">max. iterations</label>
603 <input id="no_iterations" name="N" size="4" value="<%= $no_iterations %>">
Marc Kupietz78114532017-11-29 17:00:16 +0100604 <!-- <label for="dosom">SOM</label>
605 <input id="dosom" type="checkbox" name="som" value="1" <%= ($show_som ? "checked" : "") %>> -->
Marc Kupietz4abcd682017-11-28 20:51:08 +0100606 % if($collocators) {
607 <label for="sortby">window/sort</label>
608 <select id="sortby" name="sort">
609 <option value="0" <%= ($sort!=1 && $sort!=2? "selected":"") %>>auto focus</option>
610 <option value="1" <%= ($sort==1? "selected":"") %>>any single position</option>
611 <option value="2" <%= ($sort==2? "selected":"") %>>whole window</option>
612 </select>
613 % }
Marc Kupietzdab9f222017-11-29 14:22:59 +0100614 <input type="button" value="→ KorAP" onclick="queryKorAP();" title="query word with KorAP"/>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100615 </div>
Marc Kupietzdab9f222017-11-29 14:22:59 +0100616 </form>
617 </div>
Marc Kupietz0af83e32017-11-27 09:31:37 +0100618 </div>
Marc Kupietz81bf39c2017-11-29 17:04:35 +0100619 </div>
620 <div id="topwrapper">
Marc Kupietz4abcd682017-11-28 20:51:08 +0100621 <div id="tabs">
622 <ul>
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100623 <li><a href="#tabs-1">Semantics (TSNE-map)</a></li>
624 <li><a href="#tabs-2">Semantics (SOM)</a></li>
625 <li><a href="#tabs-3">Syntagmatic (collocators)</a></li>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100626 </ul>
627 <div id="tabs-1">
Marc Kupietzdab9f222017-11-29 14:22:59 +0100628 % if($lists && (@$lists) > 0 && (@$lists)[0]) {
629 <div id="wrapper">
630 <div id="first" style="width:220px">
631 <table class="display compact nowrap" id="firsttable">
632 <thead>
633 <tr>
634 <th align="right">#</th><th align="right">cos</th><th align="left">paradigmatic</th>
635 </tr>
636 </thead>
637 <tbody>
638 % my $j=0; my @words; my @vecs; my @ranks; my @marked;
639 % for my $list (@$lists) {
640 % my $i=0; while($list) {
641 % my $item = (@$list)[$i];
642 % my $c = ($collocators? (@$collocators)[$i] : 0);
643 % last if(!$c && !$item);
644 <tr>
645 <td align="right">
646 <%= ++$i %>.
647 </td>
648 % if($item) {
649 % if(!grep{$_ eq $item->{word}} @words) {
650 % push @vecs, $item->{vector};
651 % push @words, $item->{word};
652 % push @ranks, $item->{rank};
653 % push @marked, ($marked->{$item->{word}}? 1 : 0);
Marc Kupietz4abcd682017-11-28 20:51:08 +0100654 % }
Marc Kupietzdab9f222017-11-29 14:22:59 +0100655 <td align="right">
656 <%= sprintf("%.3f", $item->{dist}) %>
657 </td>
658 <td>
659 % my $class = ($marked->{$item->{word}}? "marked " : "");
660 % my $r = $item->{rank};
661 % if($r < $mergedEnd) {
662 % $class .= "merged";
663 % $r .= " (merged vocab)";
664 % } elsif($mergedEnd!=0 && $r > $mergedEnd) {
665 % $r -= $mergedEnd;
666 % }
667 <a class="<%= $class =%>"
668 title="freq. rank: <%= $r =%>"
669 href="<%= url_with->query([word => $item->{word}]) =%>">
670 <%= $item->{word} =%>
671 </a>
672 </td>
673 % } else {
674 <td colspan="2"/>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100675 % }
Marc Kupietzdab9f222017-11-29 14:22:59 +0100676 </tr>
677 % last if($i >= 100);
678 % }
679 % }
Marc Kupietz4abcd682017-11-28 20:51:08 +0100680 </tbody>
681 </table>
682 </div>
Marc Kupietzdab9f222017-11-29 14:22:59 +0100683 <script>
684 % use Mojo::ByteStream 'b';
685 % my $urlprefix = url_with->query([word=>'']);
686 $(window).load(function() {
687 showMap(<%= b(Mojo::JSON::to_json({target => " $word ", mergedEnd=> $mergedEnd, words => \@words, vecs => \@vecs, ranks => \@ranks, marked => \@marked, urlprefix => $urlprefix})); %>);
688 });
689 </script>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100690 % } else {
691 <div id="wrapper">
692 <p>
693 ERROR: "<%= $word %>" not found in vocabluary.
694 </p>
695 </div>
696 % }
697 <div id="second">
698 <div id="embed">
699 </div>
700 <div id="cost">
701 </div>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100702 </div>
Marc Kupietzdab9f222017-11-29 14:22:59 +0100703 </div>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100704 </div>
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100705 <div id="tabs-2">
706 <div id="som2" style="width: 800; height: 800px">
707 </div>
708 <div id="sominfo1"><span id="somcolor1"> </span> <span id="somword1"> </span> <span id="somcolor2"> </span> <span id="somword2"> </span> <span id="somcolor3"> </span></div>
709 <div id="sominfo">SOM iteration <span id="iterations">0</span></div>
710 </div>
711 <div id="tabs-3">
Marc Kupietz4abcd682017-11-28 20:51:08 +0100712 <div id="second" style="width:500px">
713 <table class="display compact nowrap" id="secondtable">
714 <thead>
715 <tr>
716 % if($collocators) {
Marc Kupietzdab9f222017-11-29 14:22:59 +0100717 <th>#</th>
718 <th align="right" title="The window around the target word that is considered for summation.">w'</th>
719 <th align="right" title="Raw (max.) activation of the collocator in the output layers.">a</th>
720 <th title="Σp(c<sub><small>@</small></sub>) – Sum of the probability approximations that the combination of the target word and the collocator at the relative position @ come from the training corpus. Single approximations can be distorted because of sub-sampling frequent words and the sum cannot itself be interpreted as probability." align="right">Σp</th>
721 <th align="right">Σp/|w|</th>
722 <th title="c" align="left">collocator</th>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100723 % }
724 </tr>
Marc Kupietzdab9f222017-11-29 14:22:59 +0100725 </thead>
726 <tbody>
727 % for(my $i=0; $i < 100; $i++) {
728 % my $c = ($collocators? (@$collocators)[$i] : 0);
729 <tr>
730 <td align="right">
731 <%= $i %>
732 </td>
733 % if($c) {
734 <td align="right">
735 <span class="mono"><%= bitvec2window( $c->{pos} ) %></span>
736 </td>
737 <td align="right">
738 <%= sprintf("%.3f", $c->{dist}) %>
739 </td>
740 <td align="right">
741 <%= sprintf("%.3e", $c->{norm}) %>
742 </td>
743 <td align="right">
744 <%= sprintf("%.3e", $c->{sum}) %>
745 </td>
746 <td align="left">
747 <a onclick="<%= sprintf("queryKorAPCII('%s /w5 %s')", $c->{word}, $word) =%>"
748 title="freq. rank: <%= $c->{rank} =%>">
749 <%= $c->{word} %>
750 </a>
751 </td>
752 % } else {
753 <td colspan="5"/>
754 % }
755 </tr>
756 % }
757 </tbody>
758 </table>
759 </div> <!-- - tab2 -->
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100760 </div> <!-- tabs -->
761 </div>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100762 </div> <!-- topwrapper -->
763 <div style="clear: both;"></div>
Marc Kupietz0af83e32017-11-27 09:31:37 +0100764 </div>
Marc Kupietz4abcd682017-11-28 20:51:08 +0100765 % if($training_args) {
766 <p>
767 Word vector model trained with <a href="https://code.google.com/p/word2vec/">word2vec</a> using the following parameters: <pre><%= $training_args %></pre>
768 </p>
Marc Kupietz83305222016-04-28 09:57:22 +0200769 % }
Marc Kupietz4abcd682017-11-28 20:51:08 +0100770 </body>
Marc Kupietz83305222016-04-28 09:57:22 +0200771</html>