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