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