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