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