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