Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>DeReKo-Word-Vector-Distances: <%= $word %></title> |
Marc Kupietz | 80bd7b9 | 2017-07-04 16:25:54 +0200 | [diff] [blame] | 5 | <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> |
Marc Kupietz | 6dbadd1 | 2017-11-29 16:43:33 +0100 | [diff] [blame] | 6 | <link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Condensed" rel="stylesheet"> |
Marc Kupietz | 80bd7b9 | 2017-07-04 16:25:54 +0200 | [diff] [blame] | 7 | <script src="http://code.jquery.com/jquery-latest.min.js"></script> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 8 | <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> |
Marc Kupietz | 2279614 | 2017-12-01 13:19:15 +0100 | [diff] [blame] | 10 | <script src = "https://cdn.datatables.net/plug-ins/1.10.16/sorting/scientific.js"></script> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 11 | <link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"> |
Marc Kupietz | 80bd7b9 | 2017-07-04 16:25:54 +0200 | [diff] [blame] | 12 | <script |
Marc Kupietz | 6dbadd1 | 2017-11-29 16:43:33 +0100 | [diff] [blame] | 13 | src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js" |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 14 | integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" |
| 15 | crossorigin="anonymous"></script> |
Marc Kupietz | 80bd7b9 | 2017-07-04 16:25:54 +0200 | [diff] [blame] | 16 | <script> |
Marc Kupietz | a6e08f0 | 2017-12-01 22:06:21 +0100 | [diff] [blame] | 17 | var urlParams = new URLSearchParams(window.location.search); |
| 18 | |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 19 | $('#firstable').hide(); |
| 20 | $(document).ready(function() { |
Marc Kupietz | 694610d | 2017-11-25 18:30:03 +0100 | [diff] [blame] | 21 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 22 | $("input").bind("keydown", function(event) { |
| 23 | // track enter key |
| 24 | var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode)); |
| 25 | if (keycode == 13) { // keycode for enter key |
| 26 | // force the 'Enter Key' to implicitly click the Update button |
| 27 | document.getElementById('SEARCH').click(); |
| 28 | return false; |
| 29 | } else { |
| 30 | return true; |
| 31 | }}); |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 32 | |
Marc Kupietz | b2b7aa6 | 2017-12-02 14:41:46 +0100 | [diff] [blame] | 33 | if (localStorage) { // let's not crash if some user has IE7 |
| 34 | var index = parseInt(localStorage['tab']||'0'); |
| 35 | $("#tabs").tabs({ active: index }); |
| 36 | } |
| 37 | |
| 38 | $( "#tabs" ).on( "tabsactivate", function( event, ui ) { |
| 39 | if (localStorage) localStorage['tab'] = ui.newTab.index(); |
| 40 | }); |
Marc Kupietz | 0af83e3 | 2017-11-27 09:31:37 +0100 | [diff] [blame] | 41 | |
Marc Kupietz | 896c909 | 2017-12-02 14:40:43 +0100 | [diff] [blame] | 42 | $(function(){ |
| 43 | $("#SEARCH").click(function() { |
| 44 | window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self"); |
| 45 | }); |
| 46 | }); |
Marc Kupietz | 2f6b74a | 2017-12-01 13:20:21 +0100 | [diff] [blame] | 47 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 48 | $('#firsttable').DataTable({ |
| 49 | "sScrollY": "780px", |
| 50 | "bScrollCollapse": true, |
| 51 | "bPaginate": false, |
| 52 | "bJQueryUI": true, |
| 53 | "dom": '<"top">rt<"bottom"flp><"clear">', |
| 54 | "aoColumnDefs": [ |
| 55 | { "sWidth": "10%", "aTargets": [ -1 ] } |
| 56 | ] |
| 57 | } ); |
| 58 | |
| 59 | $( "#first" ).clone().prependTo( "#tabs-2" ); |
| 60 | |
| 61 | function changeCharColor(txt, heat) { |
| 62 | var newText = ""; |
| 63 | for (var i=0, l=txt.length; i<l; i++) { |
Marc Kupietz | 728b8ed | 2017-12-02 11:13:49 +0100 | [diff] [blame] | 64 | newText += (i == 5 ? txt.charAt(i) : '<span style="background-color:'+getHeatColor(heat[i]/maxHeat)+'">'+txt.charAt(i)+'</span>'); |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 65 | } |
| 66 | return newText; |
| 67 | } |
| 68 | |
| 69 | function getHeatColor(value) { |
| 70 | var hue=((1-value)*120).toString(10); |
Marc Kupietz | 728b8ed | 2017-12-02 11:13:49 +0100 | [diff] [blame] | 71 | return ["hsl(",hue,",90%,70%)"].join(""); |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | function bitvec2window(n, heat) { |
| 75 | var str = n.toString(2).padStart(10, "0") |
| 76 | .replace(/^([0-9]{5})/, '$1x') |
| 77 | .replace(/0/g, '·') |
| 78 | .replace(/1/g, '+'); |
| 79 | return changeCharColor(str, heat); |
| 80 | } |
| 81 | |
| 82 | var collocatorData = <%= b(Mojo::JSON::to_json($collocators)) %>; |
| 83 | var maxHeat; // = Math.max.apply(Math,collocatorData.map(function(o){return o.cprob;})) |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 84 | |
| 85 | if (collocatorData != null) { |
Marc Kupietz | 896c909 | 2017-12-02 14:40:43 +0100 | [diff] [blame] | 86 | maxHeat = Math.max.apply(Math,collocatorData.map(function(o){return Math.max.apply(Math,o.heat);})) |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 87 | var t = $('#secondtable').DataTable({ |
| 88 | data: collocatorData, |
| 89 | "sScrollY": "800px", |
| 90 | "bScrollCollapse": true, |
| 91 | "bPaginate": false, |
| 92 | "bJQueryUI": true, |
| 93 | "dom": '<"top">rt<"bottom"flp><"clear">', |
| 94 | "columns": [ |
| 95 | { "data": "rank", type: "allnumeric" }, |
| 96 | { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat) }}, |
| 97 | { "data": "max", render: function ( data, type, row ) {return data.toFixed(3) }}, |
| 98 | { "data": "conorm", render: function ( data, type, row ) {return data.toFixed(3) }}, |
| 99 | { "data": "prob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } }, |
| 100 | { "data": "cprob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } }, |
| 101 | { "data": "overall", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } }, |
| 102 | { "data": "word", sClass: "collocator" } |
| 103 | ], |
| 104 | "columnDefs": [ |
| 105 | { className: "dt-right", "targets": [0,2,3,4,5,6] }, |
| 106 | { className: "dt-center", "targets": [ 1] }, |
| 107 | { "searchable": false, |
| 108 | "orderable": false, |
| 109 | "targets": 0 |
| 110 | }, |
| 111 | { "type": "scientific", targets: [2,3,4,5,6] }, |
| 112 | { "orderSequence": [ "desc" ], "targets": [ 2, 3, 4, 5, 6 ] }, |
| 113 | { "orderSequence": [ "asc", "desc" ], "targets": [ 1, 7 ] }, |
| 114 | ], |
| 115 | "order": [[ 4, 'desc' ]], |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 116 | } ); |
Marc Kupietz | 0af83e3 | 2017-11-27 09:31:37 +0100 | [diff] [blame] | 117 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 118 | t.on( 'order.dt search.dt', function () { |
| 119 | t.column(0, {order:'applied'}).nodes().each( function (cell, i) { |
| 120 | cell.innerHTML = i+1; |
| 121 | } ); |
| 122 | } ).draw(); |
| 123 | } |
| 124 | $("#tabs").css("visibility", "visible"); // now we can show the tabs |
Marc Kupietz | 6e2fc10 | 2017-12-01 22:07:23 +0100 | [diff] [blame] | 125 | |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 126 | }); |
Marc Kupietz | 6e2fc10 | 2017-12-01 22:07:23 +0100 | [diff] [blame] | 127 | |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 128 | $(function(){ |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 129 | $("#dropdownoptions").dialog({ |
| 130 | title: "Options", |
| 131 | autoOpen: false, |
| 132 | modal: false, |
| 133 | draggable: false, |
| 134 | height: "auto", |
| 135 | width: "auto", |
| 136 | resizable: false, |
| 137 | buttons: { |
| 138 | "Cancel": function() { |
| 139 | $( this ).dialog( "close" ); |
| 140 | }, |
| 141 | "Apply": function() { |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 142 | window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self"); |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | }); |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 146 | }); |
| 147 | |
| 148 | $(function(){ |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 149 | $("td.collocator").click(function(){ |
| 150 | queryKorAPCII(this.textContent + " /w5 " + urlParams.get('word')); |
| 151 | }); |
| 152 | }); |
| 153 | |
| 154 | $(function(){ |
| 155 | $("#showoptions").click(function(){ |
| 156 | $("#dropdownoptions").dialog("open"); |
| 157 | var target = $(this); |
| 158 | $("#dropdownoptions").dialog("widget").position({ |
| 159 | my: 'left bottom', |
| 160 | at: 'left bottom', |
| 161 | of: target |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 162 | }); |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 163 | }); |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 164 | }); |
| 165 | |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 166 | $( function() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 167 | $( "#no_iterations" ).spinner({ |
| 168 | spin: function( event, ui ) { |
| 169 | if ( ui.value < 1000 ) { |
| 170 | $( this ).spinner( "value", 1000 ); |
| 171 | return false; |
| 172 | } else if ( ui.value > 10000 ) { |
| 173 | $( this ).spinner( "value", 10000 ); |
| 174 | return false; |
| 175 | } |
| 176 | } |
| 177 | }); |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 178 | } ); |
Marc Kupietz | 3305b0a | 2017-11-27 10:46:20 +0100 | [diff] [blame] | 179 | |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 180 | $( function() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 181 | $( "#neighbours" ).spinner({ |
| 182 | spin: function( event, ui ) { |
| 183 | if ( ui.value < 0 ) { |
| 184 | $( this ).spinner( "value", 0 ); |
| 185 | return false; |
| 186 | } else if ( ui.value > 200 ) { |
| 187 | $( this ).spinner( "value", 200 ); |
| 188 | return false; |
| 189 | } |
| 190 | } |
| 191 | }); |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 192 | } ); |
| 193 | |
| 194 | $( function() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 195 | $( "#cutoff" ).spinner({ |
| 196 | spin: function( event, ui ) { |
| 197 | if ( ui.value < 100000 ) { |
| 198 | $( this ).spinner( "value", 100000 ); |
| 199 | return false; |
| 200 | } else if ( ui.value > 2000000 ) { |
| 201 | $( this ).spinner( "value", 2000000 ); |
| 202 | return false; |
| 203 | } |
| 204 | } |
| 205 | }); |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 206 | } ); |
| 207 | |
| 208 | $( function() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 209 | $( "#tabs" ).tabs().addClass('tabs-min'); |
Marc Kupietz | 4fcda0c | 2017-11-29 09:00:31 +0100 | [diff] [blame] | 210 | } ); |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 211 | |
| 212 | $( function() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 213 | $( ".controlgroup-vertical" ).controlgroup({ |
| 214 | "direction": "vertical" |
| 215 | }); |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 216 | } ); |
| 217 | |
| 218 | $(function() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 219 | $( document ).tooltip({ |
| 220 | content: function() { |
| 221 | return $(this).attr('title'); |
| 222 | }} |
| 223 | ) |
Marc Kupietz | 6e2fc10 | 2017-12-01 22:07:23 +0100 | [diff] [blame] | 224 | }) |
Marc Kupietz | 694610d | 2017-11-25 18:30:03 +0100 | [diff] [blame] | 225 | |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 226 | </script> |
| 227 | <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script> |
Marc Kupietz | 554aff5 | 2017-11-09 14:42:09 +0100 | [diff] [blame] | 228 | <script src="/derekovecs/js/tsne.js"></script> |
| 229 | <script src="/derekovecs/js/som.js"></script> |
| 230 | <script src="/derekovecs/js/labeler.js"></script> |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 231 | <style> |
| 232 | body, input { |
Marc Kupietz | 6dbadd1 | 2017-11-29 16:43:33 +0100 | [diff] [blame] | 233 | font-family: Lato, sans-serif; |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 234 | font-size: 11pt; |
| 235 | } |
Marc Kupietz | 30ca434 | 2017-11-22 21:21:20 +0100 | [diff] [blame] | 236 | |
Marc Kupietz | 6dbadd1 | 2017-11-29 16:43:33 +0100 | [diff] [blame] | 237 | h1, h2, h3 { |
| 238 | margin: 5px 10px 0 0; |
| 239 | color: rgb(246,168,0); |
| 240 | 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; |
| 241 | font-weight: bold; |
| 242 | line-height: 1.35; |
| 243 | letter-spacing: normal; |
| 244 | text-transform: uppercase; |
| 245 | text-shadow: none; |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 246 | word-wrap: break-word; |
| 247 | } |
| 248 | |
| 249 | |
Marc Kupietz | 81bf39c | 2017-11-29 17:04:35 +0100 | [diff] [blame] | 250 | showoptions, #SEARCH { |
| 251 | margin-left: 10px; |
| 252 | margin-right: 10px; |
Marc Kupietz | 6dbadd1 | 2017-11-29 16:43:33 +0100 | [diff] [blame] | 253 | } |
| 254 | |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 255 | .tabs-left-vertical .ui-tabs-nav { |
| 256 | position: absolute; |
| 257 | width: 21em; |
| 258 | transform: translate(-100%,0%) rotate(-90deg); |
| 259 | transform-origin: 100% 0%; |
| 260 | } |
Marc Kupietz | 4fcda0c | 2017-11-29 09:00:31 +0100 | [diff] [blame] | 261 | |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 262 | .tabs-left-vertical .ui-tabs-nav li { |
| 263 | float: right; |
| 264 | } |
Marc Kupietz | 4fcda0c | 2017-11-29 09:00:31 +0100 | [diff] [blame] | 265 | |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 266 | .tabs-left-vertical .ui-tabs-panel { |
| 267 | padding-left: 3.5em; |
| 268 | } |
| 269 | |
| 270 | .tabs-left-vertical .ui-tabs-panel { |
| 271 | height: 20em; |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 272 | } |
Marc Kupietz | 4fcda0c | 2017-11-29 09:00:31 +0100 | [diff] [blame] | 273 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 274 | .mono { |
| 275 | font-family: "DejaVu Sans Mono", Inconsolata, SourceCodePro, Courier; |
| 276 | } |
Marc Kupietz | 30ca434 | 2017-11-22 21:21:20 +0100 | [diff] [blame] | 277 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 278 | .ui-tooltip-content { |
| 279 | font-size: 9pt; |
| 280 | color: #222222; |
| 281 | } |
Marc Kupietz | f4b4939 | 2016-04-28 10:49:56 +0200 | [diff] [blame] | 282 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 283 | svg > .ui-tooltip-content { |
| 284 | font-size: 8pt; |
| 285 | color: #222222; |
| 286 | } |
| 287 | |
| 288 | a.merged { |
| 289 | color: green; |
| 290 | fill: green; |
| 291 | } |
| 292 | |
| 293 | #first a { |
| 294 | text-decoration: none; |
| 295 | } |
| 296 | |
| 297 | a.marked, #first a.marked { |
| 298 | text-decoration: underline; |
| 299 | } |
| 300 | |
| 301 | a.target { |
| 302 | color: red; |
| 303 | fill: red; |
| 304 | } |
Marc Kupietz | 694610d | 2017-11-25 18:30:03 +0100 | [diff] [blame] | 305 | |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 306 | table.display { |
| 307 | width: 40% important!; |
| 308 | margin: 1; /* <- works for me this way ****/ |
| 309 | } |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 310 | |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 311 | table.dataTable thead th, table.dataTable thead td, table.dataTable tbody td { |
| 312 | padding: 2px 2px; |
| 313 | // border-bottom: 1px solid #111; |
| 314 | } |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 315 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 316 | #collocators { |
| 317 | margin-bottom: 15px; |
| 318 | } |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 319 | |
Marc Kupietz | 81bf39c | 2017-11-29 17:04:35 +0100 | [diff] [blame] | 320 | #header { |
| 321 | width: 100%; |
| 322 | // border: 1px solid red; |
| 323 | overflow: hidden; /* will contain if #first is longer than #second */ |
| 324 | } |
| 325 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 326 | #topwrapper { |
| 327 | width: 100%; |
| 328 | // border: 1px solid red; |
| 329 | overflow: hidden; /* will contain if #first is longer than #second */ |
| 330 | } |
| 331 | |
| 332 | #wrapper { |
| 333 | // border: 1px solid red; |
| 334 | overflow: hidden; /* will contain if #first is longer than #second */ |
| 335 | } |
| 336 | |
Marc Kupietz | 81bf39c | 2017-11-29 17:04:35 +0100 | [diff] [blame] | 337 | #pagetitle { |
| 338 | max-width: 460px; |
| 339 | margin-right: 20px; |
| 340 | float: left; |
| 341 | overflow: hidden; /* if you don't want #second to wrap below #first */ |
| 342 | // border: 1px solid green; |
| 343 | } |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 344 | |
Marc Kupietz | 81bf39c | 2017-11-29 17:04:35 +0100 | [diff] [blame] | 345 | #options { |
| 346 | float: left; |
| 347 | width: 800px; |
| 348 | margin: 10px; |
| 349 | overflow: hidden; /* if you don't want #second to wrap below #first */ |
| 350 | } |
| 351 | |
| 352 | #word { |
| 353 | width: 50%; |
| 354 | } |
| 355 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 356 | #first { |
| 357 | margin-right: 20px; |
| 358 | float: left; |
| 359 | overflow: hidden; /* if you don't want #second to wrap below #first */ |
| 360 | // border: 1px solid green; |
| 361 | } |
| 362 | #tabs { |
| 363 | margin-right: 20px; |
| 364 | overflow: hidden; /* if you don't want #second to wrap below #first */ |
| 365 | } |
Marc Kupietz | df3d4b5 | 2017-11-29 16:57:27 +0100 | [diff] [blame] | 366 | |
| 367 | .tabs-min { |
| 368 | background: transparent; |
| 369 | border: none; |
| 370 | } |
| 371 | |
| 372 | .tabs-min .ui-widget-header { |
| 373 | background: transparent; |
| 374 | border: none; |
| 375 | border-bottom: 1px solid #c0c0c0; |
| 376 | -moz-border-radius: 0px; |
| 377 | -webkit-border-radius: 0px; |
| 378 | border-radius: 0px; |
| 379 | } |
| 380 | |
| 381 | .tabs-min .ui-tabs-nav .ui-state-default { |
| 382 | background: transparent; |
| 383 | border: none; |
| 384 | } |
| 385 | |
| 386 | .tabs-min .ui-tabs-nav .ui-state-active { |
| 387 | background: transparent url(img/uiTabsArrow.png) no-repeat bottom center; |
| 388 | border: none; |
| 389 | } |
| 390 | |
| 391 | .tabs-min .ui-tabs-nav .ui-state-default a { |
| 392 | color: #c0c0c0; |
| 393 | } |
| 394 | |
| 395 | .tabs-min .ui-tabs-nav .ui-state-active a { |
| 396 | color: rgb(246,168,0); |
| 397 | } |
| 398 | |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 399 | #embed { |
| 400 | max-width: 802px; |
| 401 | border: 1px solid #333; |
| 402 | } |
| 403 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 404 | #second { |
| 405 | min-width: 800px; |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 406 | // border: 1px solid #333; |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 407 | overflow: hidden; /* if you don't want #second to wrap below #first */ |
| 408 | } |
| 409 | #som2 svg { |
| 410 | border: 1px solid #333; |
| 411 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 412 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 413 | #cost { |
| 414 | font-size: 8pt; |
| 415 | color: #222222; |
| 416 | margin-top: 4px; |
| 417 | margin-bottom: 12px; |
| 418 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 419 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 420 | #sominfo1, #sominfo { |
| 421 | font-size: 8pt; |
| 422 | color: #222222; |
| 423 | margin-top: 0px; |
| 424 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 425 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 426 | #somcolor1, #somcolor2, #somcolor3 { |
| 427 | display: inline-block; |
| 428 | height: 10px; |
| 429 | width: 10px; |
| 430 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 431 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 432 | #third { |
| 433 | border: 1px solid #333; |
| 434 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 435 | |
| 436 | </style> |
| 437 | <script> |
| 438 | |
| 439 | var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>}, |
| 440 | mapWidth = 800, // width map |
| 441 | mapHeight = 800, |
| 442 | jitterRadius = 7; |
| 443 | |
| 444 | var T = new tsnejs.tSNE(opt); // create a tSNE instance |
| 445 | |
| 446 | var Y; |
| 447 | |
| 448 | var data; |
| 449 | var labeler; |
| 450 | |
| 451 | function applyJitter() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 452 | svg.selectAll('.tsnet') |
| 453 | .data(labels) |
| 454 | .transition() |
| 455 | .duration(50) |
| 456 | .attr("transform", function(d, i) { |
| 457 | T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20; |
| 458 | T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20; |
| 459 | return "translate(" + |
| 460 | (d.x) + "," + |
| 461 | (d.y) + ")"; |
| 462 | }); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 463 | } |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 464 | |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 465 | function updateEmbedding() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 466 | var Y = T.getSolution(); |
| 467 | svg.selectAll('.tsnet') |
| 468 | .data(data.words) |
| 469 | .attr("transform", function(d, i) { |
| 470 | return "translate(" + |
| 471 | ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," + |
| 472 | ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; }); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | var svg; |
| 476 | var labels = []; |
| 477 | var anchor_array = []; |
| 478 | var text; |
| 479 | |
| 480 | function drawEmbedding() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 481 | $("#embed").empty(); |
| 482 | var div = d3.select("#embed"); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 483 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 484 | // get min and max in each column of Y |
| 485 | var Y = T.Y; |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 486 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 487 | svg = div.append("svg") // svg is global |
| 488 | .attr("width", mapWidth) |
| 489 | .attr("height", mapHeight); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 490 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 491 | var g = svg.selectAll(".b") |
| 492 | .data(data.words) |
| 493 | .enter().append("g") |
| 494 | .attr("class", "tsnet"); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 495 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 496 | g.append("a") |
| 497 | .attr("xlink:href", function(word) { |
| 498 | return (data.urlprefix+word);}) |
| 499 | .attr("class", function(d, i) { |
| 500 | var res=""; |
| 501 | if(data.marked[i]) { |
| 502 | res="marked "; |
| 503 | } |
| 504 | if(data.target.indexOf(" "+d+" ") >= 0) { |
| 505 | return res+"target"; |
| 506 | } else if(data.ranks[i] < data.mergedEnd) { |
| 507 | return res+"merged"; |
| 508 | } else { |
| 509 | return res; |
| 510 | } |
| 511 | }) |
| 512 | .attr("title", function(d, i) { |
| 513 | if(data.mergedEnd > 0) { |
| 514 | if(data.ranks[i] >= data.mergedEnd) { |
| 515 | return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
| 516 | } else { |
| 517 | return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)"; |
| 518 | } |
| 519 | } else { |
| 520 | return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
| 521 | } |
| 522 | }) |
| 523 | .append("text") |
| 524 | .attr("text-anchor", "top") |
| 525 | .attr("font-size", 12) |
| 526 | .text(function(d) { return d; }); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 527 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 528 | var zoomListener = d3.behavior.zoom() |
| 529 | .scaleExtent([0.1, 10]) |
| 530 | .center([0,0]) |
| 531 | .on("zoom", zoomHandler); |
| 532 | zoomListener(svg); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | var tx=0, ty=0; |
| 536 | var ss=1; |
| 537 | var iter_id=-1; |
| 538 | |
| 539 | function zoomHandler() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 540 | tx = d3.event.translate[0]; |
| 541 | ty = d3.event.translate[1]; |
| 542 | ss = d3.event.scale; |
| 543 | updateEmbedding(); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | var stepnum = 0; |
| 547 | |
| 548 | function stopStep() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 549 | clearInterval(iter_id); |
| 550 | text = svg.selectAll("text"); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 551 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 552 | // jitter function needs different data and co-ordinate representation |
| 553 | labels = d3.range(data.words.length).map(function(i) { |
| 554 | var x = (T.Y[i][0]*20*ss + tx) + mapWidth/2; |
| 555 | var y = (T.Y[i][1]*20*ss + ty) + mapHeight/2; |
| 556 | anchor_array.push({x: x, y: y, r: jitterRadius}); |
| 557 | return { |
| 558 | x: x, |
| 559 | y: y, |
| 560 | name: data.words[i] |
| 561 | }; |
| 562 | }); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 563 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 564 | // get the actual label bounding boxes for the jitter function |
| 565 | var index = 0; |
| 566 | text.each(function() { |
| 567 | labels[index].width = this.getBBox().width; |
| 568 | labels[index].height = this.getBBox().height; |
| 569 | index += 1; |
| 570 | }); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 571 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 572 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 573 | // setTimeout(updateEmbedding, 1); |
| 574 | // setTimeout( |
| 575 | labeler = d3.labeler() |
| 576 | .label(labels) |
| 577 | .anchor(anchor_array) |
| 578 | .width(mapWidth) |
| 579 | .height(mapHeight) |
| 580 | .update(applyJitter); |
| 581 | // .start(1000); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 582 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 583 | iter_id = setInterval(jitterStep, 1); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | var jitter_i=0; |
| 587 | |
| 588 | function jitterStep() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 589 | if(jitter_i++ > 100) { |
| 590 | clearInterval(iter_id); |
| 591 | } else { |
| 592 | labeler.start2(10); |
| 593 | applyJitter(); |
| 594 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | var last_cost=1000; |
| 598 | |
| 599 | function step() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 600 | var i = T.iter; |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 601 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 602 | if(i > <%= $no_iterations %>) { |
| 603 | stopStep(); |
| 604 | } else { |
| 605 | var cost = Math.round(T.step() * 100000) / 100000; // do a few steps |
| 606 | $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5)); |
| 607 | if(i % 250 == 0 && cost >= last_cost) { |
| 608 | stopStep(); |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 609 | } else { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 610 | last_cost = cost; |
| 611 | updateEmbedding(); |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 612 | } |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 613 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | function showMap(j) { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 617 | data=j; |
| 618 | T.iter=0; |
| 619 | T.initDataRaw(data.vecs); // init embedding |
| 620 | drawEmbedding(); // draw initial embedding |
Marc Kupietz | 7811453 | 2017-11-29 17:00:16 +0100 | [diff] [blame] | 621 | |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 622 | if(iter_id >= 0) { |
| 623 | clearInterval(iter_id); |
| 624 | } |
| 625 | //T.debugGrad(); |
| 626 | iter_id = setInterval(step, 1); |
| 627 | if(true) { // (<%= $show_som %>) { |
| 628 | makeSOM(j, <%= $no_iterations %>); |
| 629 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 630 | } |
Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 631 | var queryword; |
| 632 | |
| 633 | function onload() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 634 | queryword = document.getElementById('word'); |
Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | function queryKorAP() { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 638 | window.open('http://korap.ids-mannheim.de/kalamar/?q='+queryword.value, 'KorAP'); |
Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 639 | } |
Marc Kupietz | 4dc270c | 2017-11-24 10:17:12 +0100 | [diff] [blame] | 640 | |
| 641 | function queryKorAPCII(query) { |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 642 | window.open('http://korap.ids-mannheim.de/kalamar/?ql=cosmas2&q='+query, 'KorAP'); |
Marc Kupietz | 4dc270c | 2017-11-24 10:17:12 +0100 | [diff] [blame] | 643 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 644 | </script> |
| 645 | </head> |
Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 646 | <body onload="onload()"> |
Marc Kupietz | 81bf39c | 2017-11-29 17:04:35 +0100 | [diff] [blame] | 647 | <div id="header"> |
| 648 | <div id="pagetitle"> |
| 649 | <h1>DeReKo-Vectors</h1> |
| 650 | </div> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 651 | <div id="options" class="widget"> |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 652 | <form id="queryform"> |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 653 | <input id="word" type="text" name="word" placeholder="Word(s) to be searched" value="<%= $word %>" |
Marc Kupietz | 81bf39c | 2017-11-29 17:04:35 +0100 | [diff] [blame] | 654 | 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 Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 655 | <input id="SEARCH" type="button" value="SEARCH"> |
| 656 | <input type="button" id="showoptions" name="showoptions" value="Options" /> |
| 657 | </form> |
Marc Kupietz | 6e2fc10 | 2017-12-01 22:07:23 +0100 | [diff] [blame] | 658 | <div id="dropdownoptions" style="display: none"> |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 659 | <form id="optionsform"> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 660 | <div class="controlgroup-vertical"> |
| 661 | <label for="cutoff">cut-off</label> |
| 662 | <input id="cutoff" type="text" name="cutoff" size="10" value="<%= $cutoff %>" title="Only consider the most frequent x word forms."> |
| 663 | <label for="dedupe">dedupe</label> |
| 664 | <input id="dedupe" type="checkbox" name="dedupe" value="1" <%= ($dedupe ? "checked" : "") %> title="radically filter out any near-duplicates"> |
| 665 | % if($mergedEnd > 0) { |
Marc Kupietz | 7811453 | 2017-11-29 17:00:16 +0100 | [diff] [blame] | 666 | <label for="sbf">backw.</label> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 667 | <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."> |
| 668 | % } |
| 669 | <label for="neighbours">max. neighbours:</label> |
| 670 | <input id="neighbours" size="4" name="n" value="<%= $no_nbs %>"> |
Marc Kupietz | c1e42c3 | 2017-11-29 16:47:56 +0100 | [diff] [blame] | 671 | <label for="no_iterations">max. iterations</label> |
| 672 | <input id="no_iterations" name="N" size="4" value="<%= $no_iterations %>"> |
Marc Kupietz | 7811453 | 2017-11-29 17:00:16 +0100 | [diff] [blame] | 673 | <!-- <label for="dosom">SOM</label> |
| 674 | <input id="dosom" type="checkbox" name="som" value="1" <%= ($show_som ? "checked" : "") %>> --> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 675 | % if($collocators) { |
| 676 | <label for="sortby">window/sort</label> |
| 677 | <select id="sortby" name="sort"> |
| 678 | <option value="0" <%= ($sort!=1 && $sort!=2? "selected":"") %>>auto focus</option> |
Marc Kupietz | a77acce | 2017-11-30 16:59:07 +0100 | [diff] [blame] | 679 | <!-- <option value="1" <%= ($sort==1? "selected":"") %>>any single position</option> |
| 680 | <option value="2" <%= ($sort==2? "selected":"") %>>whole window</option> --> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 681 | </select> |
| 682 | % } |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 683 | <input type="button" value="→ KorAP" onclick="queryKorAP();" title="query word with KorAP"/> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 684 | </div> |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 685 | </form> |
| 686 | </div> |
Marc Kupietz | 0af83e3 | 2017-11-27 09:31:37 +0100 | [diff] [blame] | 687 | </div> |
Marc Kupietz | 81bf39c | 2017-11-29 17:04:35 +0100 | [diff] [blame] | 688 | </div> |
| 689 | <div id="topwrapper"> |
Marc Kupietz | 6e2fc10 | 2017-12-01 22:07:23 +0100 | [diff] [blame] | 690 | <div style="visibility: hidden;" id="tabs"> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 691 | <ul> |
Marc Kupietz | 4fcda0c | 2017-11-29 09:00:31 +0100 | [diff] [blame] | 692 | <li><a href="#tabs-1">Semantics (TSNE-map)</a></li> |
| 693 | <li><a href="#tabs-2">Semantics (SOM)</a></li> |
| 694 | <li><a href="#tabs-3">Syntagmatic (collocators)</a></li> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 695 | </ul> |
| 696 | <div id="tabs-1"> |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 697 | % if($lists && (@$lists) > 0 && (@$lists)[0]) { |
| 698 | <div id="wrapper"> |
Marc Kupietz | aaae015 | 2017-12-01 23:31:56 +0100 | [diff] [blame] | 699 | <div id="first" style="width: 320px"> |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 700 | <table class="display compact nowrap" id="firsttable"> |
| 701 | <thead> |
| 702 | <tr> |
Marc Kupietz | aaae015 | 2017-12-01 23:31:56 +0100 | [diff] [blame] | 703 | <th align="right">#</th><th align="right">cos</th><th align="left">similars</th> |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 704 | </tr> |
| 705 | </thead> |
| 706 | <tbody> |
| 707 | % my $j=0; my @words; my @vecs; my @ranks; my @marked; |
| 708 | % for my $list (@$lists) { |
| 709 | % my $i=0; while($list) { |
| 710 | % my $item = (@$list)[$i]; |
| 711 | % my $c = ($collocators? (@$collocators)[$i] : 0); |
| 712 | % last if(!$c && !$item); |
| 713 | <tr> |
| 714 | <td align="right"> |
| 715 | <%= ++$i %>. |
| 716 | </td> |
| 717 | % if($item) { |
| 718 | % if(!grep{$_ eq $item->{word}} @words) { |
| 719 | % push @vecs, $item->{vector}; |
| 720 | % push @words, $item->{word}; |
| 721 | % push @ranks, $item->{rank}; |
| 722 | % push @marked, ($marked->{$item->{word}}? 1 : 0); |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 723 | % } |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 724 | <td align="right"> |
| 725 | <%= sprintf("%.3f", $item->{dist}) %> |
| 726 | </td> |
| 727 | <td> |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 728 | % my $class = ($marked->{$item->{word}}? "marked " : ""); |
| 729 | % my $r = $item->{rank}; |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 730 | % if($r < $mergedEnd) { |
| 731 | % $class .= "merged"; |
| 732 | % $r .= " (merged vocab)"; |
| 733 | % } elsif($mergedEnd!=0 && $r > $mergedEnd) { |
| 734 | % $r -= $mergedEnd; |
| 735 | % } |
| 736 | <a class="<%= $class =%>" |
| 737 | title="freq. rank: <%= $r =%>" |
| 738 | href="<%= url_with->query([word => $item->{word}]) =%>"> |
| 739 | <%= $item->{word} =%> |
| 740 | </a> |
| 741 | </td> |
| 742 | % } else { |
| 743 | <td colspan="2"/> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 744 | % } |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 745 | </tr> |
Marc Kupietz | aaae015 | 2017-12-01 23:31:56 +0100 | [diff] [blame] | 746 | % last if($i >= $no_nbs); |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 747 | % } |
| 748 | % } |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 749 | </tbody> |
| 750 | </table> |
| 751 | </div> |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 752 | <script> |
| 753 | % use Mojo::ByteStream 'b'; |
| 754 | % my $urlprefix = url_with->query([word=>'']); |
| 755 | $(window).load(function() { |
Marc Kupietz | 52a3ec7 | 2017-12-02 16:59:56 +0100 | [diff] [blame^] | 756 | var result = <%= b(Mojo::JSON::to_json($lists)) %>; |
| 757 | var nvecs = [], |
| 758 | nwords = [], |
| 759 | nranks = [], |
| 760 | nmarked = []; |
| 761 | for(var i = 0; i < result.length; i++) { |
| 762 | nwords = nwords.concat(result[i].map(function(a){return a.word;})); |
| 763 | nvecs = nvecs.concat(result[i].map(function(a){return a.vector;})); |
| 764 | nranks = nranks.concat(result[i].map(function(a){return a.rank;})); |
| 765 | nmarked = nmarked.concat(result[i].map(function(a){return a.marked;})); |
| 766 | } |
| 767 | var urlprefix = new URLSearchParams(window.location.search); |
| 768 | urlprefix.set("word",""); |
| 769 | showMap({target: " "+urlParams.get('word')+" ", mergedEnd: 0, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked, urlprefix: "?"+urlprefix} ); |
| 770 | // showMap(<%= b(Mojo::JSON::to_json({target => " $word ", mergedEnd=> $mergedEnd, words => \@words, vecs => \@vecs, ranks => \@ranks, marked => \@marked, urlprefix => "?"+$urlprefix})); %>); |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 771 | }); |
| 772 | </script> |
Marc Kupietz | 896c909 | 2017-12-02 14:40:43 +0100 | [diff] [blame] | 773 | <div id="second"> |
| 774 | <div id="embed"> |
| 775 | </div> |
| 776 | <div id="cost"> |
| 777 | </div> |
| 778 | </div> |
| 779 | </div> |
| 780 | % } elsif($word !~ /^\s*$/) { |
| 781 | <div id="wrapper"> |
| 782 | <div id="not-found-dialog" title="Not found"> |
| 783 | <p>ERROR: "<%= $word %>" not found in vocabluary.</p> |
| 784 | <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> |
| 785 | </div> |
| 786 | <script> |
| 787 | $( function() { |
| 788 | $( "#not-found-dialog" ).dialog({ |
| 789 | autoOpen: true, |
| 790 | modal: true, |
| 791 | draggable: false, |
| 792 | height: "auto", |
| 793 | width: "auto", |
| 794 | resizable: false, |
| 795 | buttons: { |
| 796 | "OK": function() { |
| 797 | $( this ).dialog( "close" ); |
| 798 | }, |
| 799 | "Apply": function() { |
| 800 | window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self"); |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 801 | } |
Marc Kupietz | 896c909 | 2017-12-02 14:40:43 +0100 | [diff] [blame] | 802 | } |
Marc Kupietz | 2f6b74a | 2017-12-01 13:20:21 +0100 | [diff] [blame] | 803 | }); |
Marc Kupietz | 896c909 | 2017-12-02 14:40:43 +0100 | [diff] [blame] | 804 | }); |
| 805 | </script> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 806 | </div> |
| 807 | % } |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 808 | </div> |
Marc Kupietz | 4fcda0c | 2017-11-29 09:00:31 +0100 | [diff] [blame] | 809 | <div id="tabs-2"> |
| 810 | <div id="som2" style="width: 800; height: 800px"> |
| 811 | </div> |
| 812 | <div id="sominfo1"><span id="somcolor1"> </span> <span id="somword1"> </span> <span id="somcolor2"> </span> <span id="somword2"> </span> <span id="somcolor3"> </span></div> |
| 813 | <div id="sominfo">SOM iteration <span id="iterations">0</span></div> |
| 814 | </div> |
| 815 | <div id="tabs-3"> |
Marc Kupietz | 6e2fc10 | 2017-12-01 22:07:23 +0100 | [diff] [blame] | 816 | <div style="width: 800px" id="secondt"> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 817 | <table class="display compact nowrap" id="secondtable"> |
| 818 | <thead> |
| 819 | <tr> |
| 820 | % if($collocators) { |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 821 | <th>#</th> |
Marc Kupietz | 2279614 | 2017-12-01 13:19:15 +0100 | [diff] [blame] | 822 | <th align="center" title="The columns (c) around the target are considered for summation are marked with *.">w'</th> |
Marc Kupietz | d64f3f2 | 2017-11-30 12:07:42 +0100 | [diff] [blame] | 823 | <th align="right" title="Raw (max.) activation of the collocator in the output layers.">max(a)</th> |
Marc Kupietz | a77acce | 2017-11-30 16:59:07 +0100 | [diff] [blame] | 824 | <th title="Co-normalized raw activation sum of the collocator in the selected columns." align="right">⊥Σa</th> |
| 825 | <th title="Sum of activations over the selected colunns normalized by the total activation sum of the selected columns." align="right">Σa/Σc</th> |
| 826 | <th title="Sum of the column normalized activations over the selected colunns." align="right">Σ(a/c)</th> |
| 827 | <th title="Sum of the activations over the whole window normalized by the total window sum (no auto-focus)." align="right">Σa/Σw</th> |
| 828 | <th align="left">collocator</th> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 829 | % } |
| 830 | </tr> |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 831 | </thead> |
| 832 | <tbody> |
Marc Kupietz | 2279614 | 2017-12-01 13:19:15 +0100 | [diff] [blame] | 833 | <tr> |
| 834 | <td align="right"> |
| 835 | </td> |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 836 | <td align="right"> |
| 837 | </td> |
| 838 | <td align="right"> |
| 839 | </td> |
| 840 | <td align="right"> |
| 841 | </td> |
| 842 | <td align="right"> |
| 843 | </td> |
| 844 | <td align="right"> |
| 845 | </td> |
| 846 | <td align="right"> |
| 847 | </td> |
| 848 | <td align="left"> |
| 849 | </td> |
Marc Kupietz | 2279614 | 2017-12-01 13:19:15 +0100 | [diff] [blame] | 850 | </tr> |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 851 | </tbody> |
| 852 | </table> |
| 853 | </div> <!-- - tab2 --> |
Marc Kupietz | 4fcda0c | 2017-11-29 09:00:31 +0100 | [diff] [blame] | 854 | </div> <!-- tabs --> |
| 855 | </div> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 856 | </div> <!-- topwrapper --> |
| 857 | <div style="clear: both;"></div> |
Marc Kupietz | 0af83e3 | 2017-11-27 09:31:37 +0100 | [diff] [blame] | 858 | </div> |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 859 | % if($training_args) { |
| 860 | <p> |
| 861 | Word vector model trained with <a href="https://code.google.com/p/word2vec/">word2vec</a> using the following parameters: <pre><%= $training_args %></pre> |
| 862 | </p> |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 863 | % } |
Marc Kupietz | 4abcd68 | 2017-11-28 20:51:08 +0100 | [diff] [blame] | 864 | </body> |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 865 | </html> |