<!DOCTYPE html>
<html>
  <head>
		<% my $plain_title = $title; $plain_title=~s/<[^>]+>//g; %>
    <title><%= $plain_title  %>:<%= $word %> DeReKo-Word-Vector-Distances</title>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Condensed" rel="stylesheet">
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src = "https://cdn.datatables.net/1.10.18/js/jquery.dataTables.min.js"></script>
    <script src = "https://cdn.datatables.net/fixedcolumns/3.2.5/js/dataTables.fixedColumns.min.js"></script>
    <script src = "https://cdn.datatables.net/plug-ins/1.10.18/sorting/scientific.js"></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'></script>
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.18/css/jquery.dataTables.min.css">
    <link rel="stylesheet" href="/derekovecs/css/derekovecs.css">
    <script
      src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
      integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
      crossorigin="anonymous"></script>
    <script>
     MathJax.Hub.Config({
       config: ["MMLorHTML.js"],
       jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML", "output/PreviewHTML"],
       extensions: ["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js", "fast-preview.js", "AssistiveMML.js", "a11y/accessibility-menu.js"],
       TeX: {
         extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
       }
     });     
     var urlParams = new URLSearchParams(window.location.search);
     var currentWords = urlParams.get("word");
     var CIIsearchWords = (currentWords && currentWords.includes(" ") ? '('+currentWords.replace(/ +/g, " oder ")+')' : currentWords);
     var collocatorTable = null;

     $(document).ready(function() {

       $('#firstable').hide();
       //Set up a callback to hear back when MathJax is done rendering the equations
       //  it finds
       $('#ccd').load(
         '@Url.Action("ActionResultMethod","ControllerName",{controller parameters})', 
         function () {
           MathJax.Hub.Queue(
             ["Typeset",MathJax.Hub,"ccd"],
             function () {                
               $("#mi_tt").attr("title",$("#pmi_ttt").html());
               $("#lfmd_tt").attr("title",$("#lfmd_ttt").html());
               $("#md_tt").attr("title",$("#md_ttt").html());
               $("#npmi_tt").attr("title",$("#npmi_ttt").html());
               $("#ll_tt").attr("title",$("#ll_ttt").html());
               $("#logdice_tt").attr("title",$("#logdice_ttt").html());
               $("#logdiceaf_tt").attr("title",$("#logdiceaf_ttt").html());
             }
           );
         });          

       //set things up so that we can shove raw html into what is shown in the tooltip; 
       //  in this case, we will have already put into the title attribute the html that 
       //  contains the MathJax rendered equations (via what we do in the callback).
       $(function () {
         $(document).tooltip({
           content: function () {
             return $(this).prop('title');
           }
         });
       });

       $("input").bind("keydown", function(event) {
         // track enter key
         var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
         if (keycode == 13) { // keycode for enter key
           // force the 'Enter Key' to implicitly click the Update button
           document.getElementById('SEARCH').click();
           return false;
         } else  {
           return true;
         }});

       var collocatorTable_activated = false;
       $( "#tabs" ).on( "tabsactivate", function( event, ui ) {
         if (localStorage) localStorage['tab'] = ui.newTab.index();
         if(ui.newTab.index() == 2 && !collocatorTable_activated) {
           classicCollocatorTable.columns.adjust();
           collocatorTable.columns.adjust();
           collocatorTable_activated = true;
         }
       });

       $(function(){
         $("#SEARCH").click(function() {
           window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
         });
       });

       function changeCharColor(txt, heat, word) {
         var newText = "";
         for (var i=0, l=txt.length; i<l; i++) {
           newText += (i == 5 ? txt.charAt(i) : '<a href="http://korap.ids-mannheim.de/kalamar/?ql=cosmas2&q=' +
                                                CIIsearchWords + ' /' +  (i > 5? '%2B' : '-') + 'w' +
                                                Math.abs(i-5) + ':' +  Math.abs(i-5) + ' ' + word +
                                                '" target="korap"><span style="background-color:' +
                                                getHeatColor(heat[i]/maxHeat)+'">'+txt.charAt(i)+'</span></a>');
         }
         return newText;
       }

       function getHeatColor(value) {
         var hue=((1-value)*120).toString(10);
         return ["hsl(",hue,",90%,70%)"].join("");
       }

       function bitmask2window(n) {
         var str = n.toString(2).padStart(10, "0")
                    .replace(/^([0-9]{5})/, '$1 ')
                    .replace(/0/g, '·')
                    .replace(/1/g, '+');
         return str;
       }

       function bitvec2window(n, heat, word) {
         var str = n.toString(2).padStart(10, "0")
                    .replace(/^([0-9]{5})/, '$1x')
                    .replace(/0/g, '·')
                    .replace(/1/g, '+');
         return changeCharColor(str, heat, word);
       }

       % use Mojo::ByteStream 'b';
       var paraResults = <%= b(Mojo::JSON::to_json($lists)) %>;
       var urlprefix =  new URLSearchParams(window.location.search);
       if (paraResults.length > 0  && paraResults[0] != null) {
         var nvecs = [],
             nwords = [],
             nranks = [],
             nmarked = [];
         for(var i = 0; i < paraResults.length; i++) {
           nwords = nwords.concat(paraResults[i].map(function(a){return a.word;}));
           nvecs = nvecs.concat(paraResults[i].map(function(a){return a.vector;}));
           nranks = nranks.concat(paraResults[i].map(function(a){return a.rank;}));
           nmarked = nmarked.concat(paraResults[i].map(function(a){return a.marked;}));
         }
         showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked} );
         var t = $('#firsttable').DataTable({
           data: [].concat.apply([], paraResults),
           "sScrollY": "780px",
           "bScrollCollapse": true,
           "bPaginate": false,
           "bJQueryUI": true,
           "dom": '<"top">rt<"bottom"flp><"clear">',
           "initComplete":function(settings, json) {
             $('td.paradigmator a').on('mousedown', function(e) {
                 return paradigmatorClick(e, paraResults[0][0].word, this.childNodes["0"].textContent);
             });
           },
           "columns": [
             { "data": "rank", type: "allnumeric" },
             { "data": "dist",  render: function ( data, type, row ) {return data.toFixed(3) }},
             { "data": "word",  class: "paradigmator", render: function ( data, type, row ) {
               urlprefix.set("word", data); return  '<a class="' + getMergedClass(row.rank) + '" href="?' + urlprefix + '">' + data + '</a>' 
             }}
           ],
           "columnDefs": [
             { className: "dt-right", "targets": [0,1] },
             { "searchable": false,
               "orderable": false,
               "targets": 0
             },
             { "orderSequence": [ "desc" ], "targets": [ 1 ] },
             { "orderSequence": [ "asc", "desc" ], "targets": [ 2 ] },
           ],
           "oLanguage": {
             "sSearch": "Filter: "
           },
           "order": [[ 1, 'desc' ]],
         } );

         t.on( 'order.dt search.dt', function () {
           t.column(0, {order:'applied'}).nodes().each( function (cell, i) {
             cell.innerHTML = i+1;
           } );
         } ).draw();

         $( "#first" ).clone().prependTo( "#tabs-2" );

       }


       var collocatorData = <%= b(Mojo::JSON::to_json($collocators)) %>;
       var maxHeat; // = Math.max.apply(Math,collocatorData.map(function(o){return o.cprob;}))

       if (collocatorData != null) {
         maxHeat = Math.max.apply(Math,collocatorData.map(function(o){return Math.max.apply(Math,o.heat);}))
         collocatorTable = $('#secondtable').DataTable({
           data: collocatorData,
           "sScrollY": "780px",
           "bScrollCollapse": true,
           "bPaginate": false,
           "bJQueryUI": true,
           "dom": '<"top">rt<"bottom"flp><"clear">',
           "columns": [
             { "data": "rank", type: "allnumeric" },
             { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
             { "data": "max",  render: function ( data, type, row ) {return data.toFixed(3) }},
             { "data": "average", render: function ( data, type, row ) {return data.toFixed(3) }},
             { "data": "prob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) }  },
             { "data": "cprob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) }  },
             { "data": "overall", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
             { "data": "word",  sClass: "collocator" },
             { "data": "rank", type: "allnumeric" }
           ],
           "columnDefs": [
             { className: "dt-right", "targets": [0,2,3,4,5,6] },
             { className: "dt-center", "targets": [ 1] },
             { "searchable": false,
               "orderable": false,
               "targets": [0, 8]
             },
             { "type": "scientific", targets: [2,3,4,5,6] },
             { "orderSequence": [ "desc" ], "targets": [ 2, 3, 4, 5, 6 ] },
             { "orderSequence": [ "asc", "desc" ], "targets": [ 1, 7 ] },
             { "targets": [8], "visible": false }
           ],
           "oLanguage": {
             "sSearch": "Filter: "
           },
           "order": [[ 4, 'desc' ]],
         } );
         $.ajaxSetup({
           type: 'POST',
           timeout: 30000,
           error: function(xhr) {
             $('#display_error')
               .html('Error: ' + xhr.status + ' ' + xhr.statusText);
           }
         });


         if($('#sprofiles').length) {
           similarProfileTable = $('#sprofiles').DataTable({
             ajax: {
               method: "GET",
               url: '/derekovecs/getSimilarProfiles',
               dataType: 'json',
               dataSrc: "",
               timeout: 30000,
               data: { w: paraResults[0][0].rank }
             },
             "initComplete":function(settings, json){
               $('td.paradigmator a').on('mousedown', function(e) {
                 if (e.which === 2) {
                   e.preventDefault();
                   queryKorAPalternatives(paraResults[0][0].word, this.childNodes["0"].textContent);
                   return false;
                 }
               });
             },
             "sScrollY": "780px",
             "bScrollCollapse": true,
             "bPaginate": false,
             "bJQueryUI": true,
             "dom": '<"top">rt<"bottom"flp><"clear">',
             "columns": [
               { "data": "v",  render: function ( data, type, row ) {return data.toFixed(3) }},
               { "data": "w",  sClass: "paradigmator", render: function ( data, type, row ) {urlprefix.set("word", data); return  '<a href="?' + urlprefix + '">' + data + '</a>' } }
             ],
             "columnDefs": [
               { className: "dt-right", "targets": [0] },
             ],
             "oLanguage": {
               "sSearch": "Filter: "
             },
             "order": [[ 0, 'desc' ]],
           });
         }
         //         var filterQuot = /(^quot?=[A-Z])|(quot$)/g;
         var filterQuot = /^quot/;
         classicCollocatorTable = $('#classicoloctable').DataTable({
           ajax: {
             method: "GET",
             url: '/derekovecs/getClassicCollocators',
             dataType: 'json',
             dataSrc: "",
             timeout: 30000,
             data: { w: paraResults[0][0].rank }
           },
           "initComplete":function(settings, json){
             $("td.collocator").click(function(){
               queryKorAPCII(this.textContent + " /w5 " + CIIsearchWords);
             });
             classicCollocatorTable.columns(".detail").visible(false);
             $("#ccd").css('width', '680px');
             classicCollocatorTable.columns.adjust().draw();
           },
           "sScrollY": "780px",
           "bScrollCollapse": true,
           "bPaginate": false,
           "bJQueryUI": true,
           "dom": '<"top">rt<"bottom"flp><"clear">',
           "columns": [
             //                      { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
             { "data": "llr",  render: function ( data, type, row ) {return data.toFixed(0) }},
             { "data": "pmi", render: function ( data, type, row ) {return data.toFixed(2) }},
             { "data": "md", render: function ( data, type, row ) {return data.toFixed(2) }},
             { "data": "lfmd", render: function ( data, type, row ) {return data.toFixed(2) }},
             //             { "data": "fpmi", type: "scientific", render: function ( data, type, row ) {return data.toExponential(2) }  },
             { "data": "npmi", render: function ( data, type, row ) {return data.toFixed(3) }},
             { "data": "dice", render: function ( data, type, row ) {return data.toExponential(2) }},
             { "data": "ld", render: function ( data, type, row ) {return data.toFixed(2) }},
             { "data": "af", render: function ( data, type, row ) {return data.toFixed(2) }},
             { "data": "win", width: "auto", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitmask2window(data) }},
             { "data": "llfmd", render: function ( data, type, row ) {return data.toFixed(1) }},
             { "data": "rlfmd", render: function ( data, type, row ) {return data.toFixed(1) }},
             { "data": "lnpmi", render: function ( data, type, row ) {return data.toFixed(2) }},
             { "data": "rnpmi", render: function ( data, type, row ) {return data.toFixed(2) }},
             { "data": "f" },
             { "data": "word",  sClass: "collocator" }
           ],
           "columnDefs": [
             { className: "dt-right", "targets": [0,1,2,3,4,5,6,7,9,10,11,12,13] },
             { className: "dt-right detail", "targets": [5,9,10,11,12] },
             { "searchable": false,
               "orderable": false,
               "targets": []
             },
             { "orderSequence": [ "desc" ], "targets": [0,1,2,3,4,5,6,7,9,10,11,12,13] },
             { "orderSequence": [ "asc", "desc" ], "targets": [8,14] },
           ],
           "oLanguage": {
             "sSearch": "Filter: "
           },
           "order": [[ 7, 'desc' ]],
         });


         $('#show-details').change(function (e) {
           var columns = classicCollocatorTable.columns(".detail");
           if(this.checked) {
             columns.visible(true);
             $("#ccd").css('width', 'auto');
           } else {
             columns.visible(false);
             $("#ccd").css('width', '450px');
           }
           classicCollocatorTable.columns.adjust().draw();
         } );

         $("td.collocator").click(function(){
           queryKorAPCII(this.textContent + " /w5 " + CIIsearchWords);
         });

         collocatorTable.on( 'order.dt search.dt', function () {
           collocatorTable.column(0, {order:'applied'}).nodes().each( function (cell, i) {
             cell.innerHTML = i+1;
           } );
         }).draw();
       }

       if (localStorage && !window.location.hash) { // let's not crash if some user has IE7
         var index = parseInt(localStorage['tab']||'0');
         $("#tabs").tabs({ active: index });
       }
       $("#tabs").css("visibility", "visible"); // now we can show the tabs
     });

     $(function(){
       $("#dropdownoptions").dialog({
         title: "Options",
         autoOpen: false,
         modal: false,
         draggable: false,
         height: "auto",
         width: "auto",
         resizable: false,
         buttons: {
           "Cancel": function() {
             $( this ).dialog( "close" );
           },
           "Apply": function() {
             window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
           }
         }
       });
     });

     $(function(){
       $("#showoptions").click(function(){
         $("#dropdownoptions").dialog("open");
         var target = $(this);
         $("#dropdownoptions").dialog("widget").position({
           my: 'left bottom',
           at: 'left bottom',
           of: target
         });
       });
     });

     $( function() {
       $( "#no_iterations" ).spinner({
         spin: function( event, ui ) {
           if ( ui.value < 1000 ) {
             $( this ).spinner( "value", 1000 );
             return false;
           } else if ( ui.value > 10000 ) {
             $( this ).spinner( "value", 10000 );
             return false;
           }
         }
       });
     } );

     $( function() {
       $( "#neighbours" ).spinner({
         spin: function( event, ui ) {
           if ( ui.value < 0 ) {
             $( this ).spinner( "value", 0 );
             return false;
           } else if ( ui.value > 200 ) {
             $( this ).spinner( "value", 200 );
             return false;
           }
         }
       });
     } );

     $( function() {
       $( "#cutoff" ).spinner({
         spin: function( event, ui ) {
           if ( ui.value < 100000 ) {
             $( this ).spinner( "value", 100000 );
             return false;
           } else if ( ui.value > 2000000 ) {
             $( this ).spinner( "value", 2000000 );
             return false;
           }
         }
       });
     } );

     $( function() {
       $( "#tabs" ).tabs().addClass('tabs-min');
     } );

     $( function() {
       $( ".controlgroup-vertical" ).controlgroup({
         "direction": "vertical"
       });
     } );

     $(function() {
       $( document ).tooltip({
         content: function() {
           return $(this).attr('title');
         }}
       )
     });

     $(function () {
       $(document).tooltip({
         content: function () {
           return $(this).prop('title');
         },
         show: null, 
         close: function (event, ui) {
           ui.tooltip.hover(
             function () {
               $(this).stop(true).fadeTo(400, 1);
             },    
             function () {
               $(this).fadeOut("400", function () {
                 $(this).remove();
               })
             });
         }
       });
     });
    </script>
    <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
    <script src="/derekovecs/js/tsne.js"></script>
    <script src="/derekovecs/js/som.js"></script>
    <script src="/derekovecs/js/labeler.js"></script>
    <script src="/derekovecs/js/derekovcs.js"></script>
    <script>

     var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>},
         mapWidth = 800, // width map
         mapHeight = 800,
         jitterRadius = 7;

     var T = new tsnejs.tSNE(opt); // create a tSNE instance

     var Y;

     var data;
     var labeler;

     function applyJitter() {
       svg.selectAll('.tsnet')
          .data(labels)
          .transition()
          .duration(50)
          .attr("transform", function(d, i) {
            T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20;
            T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20;
            return "translate(" +
                                                               (d.x) + "," +
                                                               (d.y) + ")";
          });
     }

     function updateEmbedding() {
       var Y = T.getSolution();
       svg.selectAll('.tsnet')
          .data(data.words)
          .attr("transform", function(d, i) {
            return "translate(" +
                                                                ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
                                                                ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
     }

     var svg;
     var labels = [];
     var anchor_array = [];
     var text;

     function getMergedClass(i) {
       if(data.mergedEnd && i > data.mergedEnd) {
         return " merged"
       } else {
         return "";
       }
     }

     function getRankTooltip(i) {
       if(data.mergedEnd) {
         if(data.ranks[i] < data.mergedEnd) {
           return "rank: "+i +"  "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
         } else {
           return "rank: "+i +"  "+"freq. rank: "+(data.ranks[i]-data.mergedEnd).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)";
         }
       } else {
         return "rank: "+i +"  "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
       }
     }

     function drawEmbedding() {
       var urlprefix =  new URLSearchParams(window.location.search);
       urlprefix.delete("word");
       urlprefix.append("word","");

       $("#embed").empty();
       var div = d3.select("#embed");

       // get min and max in each column of Y
       var Y = T.Y;

       svg = div.append("svg") // svg is global
                .attr("width", mapWidth)
                .attr("height", mapHeight);

       var g = svg.selectAll(".b")
                  .data(data.words)
                  .enter().append("g")
                  .attr("class", "tsnet");

       g.append("a")
        .attr("xlink:href", function(word) {
          return "?"+urlprefix+word; })
        .attr("class", function(d, i) {
          var res="";
          if(data.marked[i]) {
            res="marked ";
          }
          if(data.target.indexOf(" "+d+" ") >= 0) {
            res += "target";
          } 
          if(data.mergedEnd && data.ranks[i] >= data.mergedEnd) {
            return res+" merged";
          } else {
            return res;
          }
        })
        .attr("title", function(d, i) {
          return getRankTooltip(i);
        })
        .append("text")
        .attr("text-anchor", "top")
        .attr("font-size", 12)
        .text(function(d) { return d; });

       g.append("svg:title")
        .text(function(d, i) {
		      return getRankTooltip(i);
	      });

       var zoomListener = d3.behavior.zoom()
                            .scaleExtent([0.1, 10])
                            .center([0,0])
                            .on("zoom", zoomHandler);
       zoomListener(svg);
     }

     var tx=0, ty=0;
     var ss=1;
     var iter_id=-1;

     function zoomHandler() {
       tx = d3.event.translate[0];
       ty = d3.event.translate[1];
       ss = d3.event.scale;
       updateEmbedding();
     }

     var stepnum = 0;

     function stopStep() {
       clearInterval(iter_id);
       text = svg.selectAll("text");

       // jitter function needs different data and co-ordinate representation
       labels = d3.range(data.words.length).map(function(i) {
         var x = (T.Y[i][0]*20*ss + tx) + mapWidth/2;
         var y = (T.Y[i][1]*20*ss + ty) + mapHeight/2;
         anchor_array.push({x: x, y: y, r: jitterRadius});
         return {
           x: x,
           y: y,
           name: data.words[i]
         };
       });

       // get the actual label bounding boxes for the jitter function
       var index = 0;
       text.each(function() {
         labels[index].width = this.getBBox().width;
         labels[index].height = this.getBBox().height;
         index += 1;
       });


       //  setTimeout(updateEmbedding, 1);
       //  setTimeout(
       labeler =   d3.labeler()
                     .label(labels)
                     .anchor(anchor_array)
                     .width(mapWidth)
                     .height(mapHeight)
                     .update(applyJitter);
       //         .start(1000);

       iter_id = setInterval(jitterStep, 1);
     }

     var jitter_i=0;

     function jitterStep() {
       if(jitter_i++ > 100) {
         clearInterval(iter_id);
       } else {
         labeler.start2(10);
         applyJitter();
       }
     }

     var last_cost=1000;

     function step() {
       var i = T.iter;

       if(i > <%= $no_iterations %>) {
         stopStep();
       } else {
         var cost = Math.round(T.step() * 100000) / 100000; // do a few steps
         $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5));
         if(i % 250 == 0 && cost >= last_cost) {
           stopStep();
         } else {
           last_cost = cost;
           updateEmbedding();
         }
       }
     }

     function showMap(j) {
       data=j;
       T.iter=0;
       iter_id = -1;
       last_cost=1000;
       T.initDataRaw(data.vecs); // init embedding
       drawEmbedding(); // draw initial embedding

       if(iter_id >= 0) {
         clearInterval(iter_id);
       }
       //T.debugGrad();
       iter_id = setInterval(step, 1);
       if(true) { // (<%= $show_som %>) {
         makeSOM(j, <%= $no_iterations %>);
       }
     }
     var queryword;

     function showCollocatorSOM() {
       if (collocatorTable) {
         var ctableData = collocatorTable.rows().data();
         var nwords = [],
             nranks = [];
         for (var i=0; i < ctableData.length && i < 100; i++) {
           nranks.push(ctableData[i].rank);
           nwords.push(ctableData[i].word);
         }
         $.post('/derekovecs/getVecsByRanks',
                JSON.stringify(nranks),
                function(data, status){
                  showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: data, ranks: nranks, marked: Array(100).fill(false)} );
                }, 'json');
       }
     }

     function onload() {
       queryword = document.getElementById('word');
     }

     function queryKorAP() {
       window.open('http://korap.ids-mannheim.de/kalamar/?q='+queryword.value, 'KorAP');
     }

     function queryKorAPCII(query) {
       window.open('http://korap.ids-mannheim.de/kalamar/?ql=cosmas2&q='+query, 'KorAP');
     }
    </script>
  </head>
  <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>
    <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>
    <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>
    <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>
    <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>
<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>
    <div style="display:none;" id="logdice_ttt">Log-Dice: $$14 + log_2 \frac{2*(f_{12}+ε)}{(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>
    <div id="header">
      <div id="pagetitle">
        <h1>DeReKoVecs</h1>
        <h2><%== $title %></h2>
      </div>
      <div id="options"  class="widget">
        <form id="queryform">
          <input id="word" type="text" name="word"  placeholder="Word(s) to be searched" value="<%= $word %>"
                 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."/>
          <input id="SEARCH" type="button" value="SEARCH">
          <input type="button" id="showoptions" name="showoptions" value="Options" />
        </form>
        <div id="dropdownoptions" style="display: none">
          <form id="optionsform">
            <div class="controlgroup-vertical">
              <label for="cutoff">cut-off</label>
              <input id="cutoff" type="text" name="cutoff" size="10"  value="<%= $cutoff %>" title="Only consider the most frequent x word forms.">
              <label for="dedupe">dedupe</label>
              <input id="dedupe" type="checkbox" name="dedupe" value="1" <%= ($dedupe ? "checked" : "") %> title="radically filter out any near-duplicates">
              % if($mergedEnd > 0) {
                <label for="sbf">backw.</label>
                <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.">
              % }
              <label for="neighbours">max. neighbours:</label>
              <input id="neighbours" size="4" name="n" value="<%= $no_nbs %>">
              <label for="no_iterations">max. iterations</label>
              <input id="no_iterations" name="N" size="4" value="<%= $no_iterations %>">
              <!-- <label for="dosom">SOM</label>
                   <input id="dosom" type="checkbox" name="som" value="1" <%= ($show_som ? "checked" : "") %>> -->
              % if($collocators) {
                <label for="sortby">window/sort</label>
                <select id="sortby" name="sort">
                  <option value="0"  <%= ($sort!=1 && $sort!=2? "selected":"") %>>auto focus</option>
                  <!-- <option value="1"  <%= ($sort==1? "selected":"") %>>any single position</option>
                       <option value="2" <%= ($sort==2? "selected":"") %>>whole window</option> -->
                </select>
              % }
              <input type="button" value="→ KorAP" onclick="queryKorAP();" title="query word with KorAP"/>
              <input id="show-details" type="checkbox" name="show-details" value="1" >
              <label for="show-details">
                Show details
              </label>
            </div>
          </form>
        </div>
      </div>
    </div>
    <div id="topwrapper">
      <div style="visibility: hidden;" id="tabs">
        <ul>
          <li><a href="#tabs-1">Semantics (TSNE-map)</a></li>
          <li><a href="#tabs-2">Semantics (SOM)</a></li>
          <li><a href="#tabs-3">Syntagmatic (collocates)</a></li>
        </ul>
        <div id="tabs-1" style="display: flex;  padding: 5px; flex-flow: row wrap;">
          % if($lists && (@$lists) > 0 && (@$lists)[0]) {
            <div id="wrapper">
              <div id="first" style="width: 230px; margin-bottom: 15px;">
                <table class="display compact nowrap" id="firsttable">
                  <thead>
                    <tr>
                      <th align="right">#</th><th align="right">cos</th><th align="left">similars by w2v</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td align="right">
                      </td>
                      <td align="right">
                      </td>
                      <td></td>
                    </tr>
                  </tbody>
                </table>
              </div>
              % if(0 && $haveSProfiles) {
                <div id="sprofilesdiv" style="width: 200px; padding-right: 10px;"> 
                  <table class="display compact nowrap" id="sprofiles">
                    <thead>
                      <tr>
                        <th align="right">cos</th><th align="left">similars by coll. profile</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr>
                        <td align="right">
                        </td>
                        <td></td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              %}
            <div id="second">
                <div id="embed">
                </div>
                <div id="cost">
                </div>
              </div>
            </div>
                % } elsif($word !~ /^\s*$/) {
                <div id="wrapper">
                  <div id="not-found-dialog" title="Not found">
                    <p>ERROR: "<%= $word %>" not found in vocabluary.</p>
                    <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>
                  </div>
                  <script>
                   $( function() {
                     $( "#not-found-dialog" ).dialog({
                       autoOpen: true,
                       modal: true,
                       draggable: false,
                       height: "auto",
                       width: "auto",
                       resizable: false,
                       buttons: {
                         "OK": function() {
                           $( this ).dialog( "close" );
                         },
                         "Apply": function() {
                           window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
                         }
                       }
                     });
                   });
                  </script>
                </div>
          % }
        </div>
        <div id="tabs-2" style="display: flex;  padding: 5px; flex-flow: row wrap;">
          <div id="som2" style="width: 800;">
            <div id="sominfo1"><span id="somcolor1">   </span> <span id="somword1"> </span> <span id="somcolor2">   </span> <span id="somword2"> </span> <span id="somcolor3">   </span></div>
            <div id="sominfo" style="text-align: right">SOM iteration <span id="iterations">0</span></div>
          </div>
        </div>
        <div id="tabs-3" style="display: flex;  padding:5px; flex-flow: row wrap;">
          <div style="margin-right: 20px; margin-bottom: 10px;" id="secondt">
            <table class="display compact nowrap"  id="secondtable">
              <thead>
                <tr>
                  % if($collocators) {
                    <th>#</th>
                    <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>
                    <th align="right" title="Maximum activation of the collocator anywhere in the output layer.">max(a)</th>
                    <th title="Average raw activation of the collocator in the columns selected by auto-focus." align="right">⟨a⟩</th>
                    <th title="Sum of activations over the selected colunns normalized by the total activation sum of the selected columns." align="right">Σa/Σw'</th>
                    <th title="Co-norm of the column-normalized activations over the colunns selected by the auto-focus." align="right">⊥(a/c)</th>
                    <th title="Sum of the activations over the whole window normalized by the total window sum (no auto-focus)." align="right">Σa/Σw</th>
                    <th align="left">collocate (by w2v)</th>
                  % }
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td align="right">
                  </td>
                  <td align="right">
                  </td>
                  <td align="right">
                  </td>
                  <td align="right">
                  </td>
                  <td align="right">
                  </td>
                  <td align="right">
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <div id="ccd" style="">
            <table class="display compact nowrap" id="classicoloctable">
              <thead>
                % if($collocators) {
                  <tr>
                    <th id="ll_tt">LL</th>
                    <th id="mi_tt">MI</th>
                    <th id="md_tt">MI²</th>
                    <th id="lfmd_tt">MI³</th>
                    <th id="npmi_tt">nPMI</th>
                    <th id="dice_tt">dice</th>
                    <th id="logdice_tt">LD</th>
                    <th id="logdiceaf_tt">LDaf</th>
                    <th id="af_win">af-window</th>
                    <th title="PMI³ restricted to left neighbour">l-PMI³</th>
                    <th title="PMI³ restricted to right neighbour">r-PMI³</th>
                    <th title="nPMI restricted to left neighbour">l-nPMI</th>
                    <th title="nPMI restricted to right neighbour">r-nPMI</th>
                    <th title="raw frequency sum of collocation within window">raw</th>
                    <th>collocate (by CA)</th>
                  </tr>
                % }
              </thead>
              <tbody>
                <tr>
                  <td align="right">
                  </td>
                  <td align="right">
                  </td>
                  <td align="right">
                  </td>
                  <td align="right">
                  </td>
                  <td align="right">
                  </td>
                  <td align="right">
                  </td>
                  <td align="right"></td>
                  <td align="left"></td>
                  <td align="right"></td>
                  <td align="right"></td>
                  <td align="right"></td>
                  <td align="right"></td>
                  <td align="left"></td>
                </tr>
              </tbody>
            </table>
          </div>
          <!--
               <div style="clear:both" ></div>
               <div style="float: right; overflow: hidden" id="extra"><button onClick="showCollocatorSOM()"> </button></div>
          -->
        </div>
      </div>
    </div> <!-- topwrapper  -->
    <div style="clear: both;"></div>
    </div>
    % if($training_args && (@$lists)[0]) {
      <div class="info">
        % if($training_args =~ /-type\s*3/) {
          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 %>
        % } else {
          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 %>
        % }
      </div>
    % }
  </body>
</html>
