Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
Marc Kupietz | c053d97 | 2019-01-10 10:41:51 +0100 | [diff] [blame] | 4 | <% my $plain_title = $title; $plain_title=~s/<[^>]+>//g; %> |
Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 5 | <title><%= $plain_title %>:<%= $word %> · IDS word vector analysis</title> |
Marc Kupietz | 80bd7b9 | 2017-07-04 16:25:54 +0200 | [diff] [blame] | 6 | <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] | 7 | <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] | 8 | <script src="http://code.jquery.com/jquery-latest.min.js"></script> |
Marc Kupietz | 5f532b3 | 2019-01-23 10:03:18 +0100 | [diff] [blame] | 9 | <script src = "https://cdn.datatables.net/1.10.18/js/jquery.dataTables.min.js"></script> |
| 10 | <script src = "https://cdn.datatables.net/fixedcolumns/3.2.5/js/dataTables.fixedColumns.min.js"></script> |
| 11 | <script src = "https://cdn.datatables.net/plug-ins/1.10.18/sorting/scientific.js"></script> |
| 12 | <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'></script> |
| 13 | <link rel="stylesheet" href="https://cdn.datatables.net/1.10.18/css/jquery.dataTables.min.css"> |
Marc Kupietz | 4949d23 | 2018-03-19 16:43:18 +0100 | [diff] [blame] | 14 | <link rel="stylesheet" href="/derekovecs/css/derekovecs.css"> |
Marc Kupietz | 80bd7b9 | 2017-07-04 16:25:54 +0200 | [diff] [blame] | 15 | <script |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 16 | src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js" |
| 17 | integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" |
| 18 | crossorigin="anonymous"></script> |
Marc Kupietz | 80bd7b9 | 2017-07-04 16:25:54 +0200 | [diff] [blame] | 19 | <script> |
Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 20 | MathJax.Hub.Config({ |
| 21 | config: ["MMLorHTML.js"], |
| 22 | jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML", "output/PreviewHTML"], |
| 23 | extensions: ["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js", "fast-preview.js", "AssistiveMML.js", "a11y/accessibility-menu.js"], |
| 24 | TeX: { |
| 25 | extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] |
| 26 | } |
| 27 | }); |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 28 | var urlParams = new URLSearchParams(window.location.search); |
Marc Kupietz | b3a2e4f | 2017-12-08 17:25:53 +0100 | [diff] [blame] | 29 | var currentWords = urlParams.get("word"); |
Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 30 | var CIIsearchWords = (currentWords && currentWords.includes(" ") ? '('+currentWords.replace(/ +/g, " oder ")+')' : currentWords); |
Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 31 | var collocatorTable = null; |
Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 32 | var plainTitle ="<%= $plain_title %>" |
Marc Kupietz | 78d7c1a | 2019-02-17 22:31:22 +0100 | [diff] [blame] | 33 | var korapPath="/"; |
| 34 | if (plainTitle.match(/-en/)) { |
| 35 | korapPath="/instance/english"; |
| 36 | } |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 37 | $(document).ready(function() { |
Marc Kupietz | 694610d | 2017-11-25 18:30:03 +0100 | [diff] [blame] | 38 | |
Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 39 | $('#firstable').hide(); |
| 40 | //Set up a callback to hear back when MathJax is done rendering the equations |
| 41 | // it finds |
| 42 | $('#ccd').load( |
| 43 | '@Url.Action("ActionResultMethod","ControllerName",{controller parameters})', |
| 44 | function () { |
| 45 | MathJax.Hub.Queue( |
| 46 | ["Typeset",MathJax.Hub,"ccd"], |
| 47 | function () { |
Marc Kupietz | 7bd5523 | 2019-01-22 15:29:06 +0100 | [diff] [blame] | 48 | $("#mi_tt").attr("title",$("#pmi_ttt").html()); |
Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 49 | $("#lfmd_tt").attr("title",$("#lfmd_ttt").html()); |
Marc Kupietz | 7bd5523 | 2019-01-22 15:29:06 +0100 | [diff] [blame] | 50 | $("#md_tt").attr("title",$("#md_ttt").html()); |
Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 51 | $("#npmi_tt").attr("title",$("#npmi_ttt").html()); |
Marc Kupietz | f19814b | 2019-01-21 16:50:19 +0100 | [diff] [blame] | 52 | $("#ll_tt").attr("title",$("#ll_ttt").html()); |
Marc Kupietz | 7bd5523 | 2019-01-22 15:29:06 +0100 | [diff] [blame] | 53 | $("#logdice_tt").attr("title",$("#logdice_ttt").html()); |
Marc Kupietz | 63b268f | 2019-01-22 22:34:29 +0100 | [diff] [blame] | 54 | $("#logdiceaf_tt").attr("title",$("#logdiceaf_ttt").html()); |
Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 55 | } |
| 56 | ); |
| 57 | }); |
| 58 | |
| 59 | //set things up so that we can shove raw html into what is shown in the tooltip; |
| 60 | // in this case, we will have already put into the title attribute the html that |
| 61 | // contains the MathJax rendered equations (via what we do in the callback). |
| 62 | $(function () { |
| 63 | $(document).tooltip({ |
| 64 | content: function () { |
| 65 | return $(this).prop('title'); |
| 66 | } |
| 67 | }); |
| 68 | }); |
| 69 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 70 | $("input").bind("keydown", function(event) { |
| 71 | // track enter key |
| 72 | var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode)); |
| 73 | if (keycode == 13) { // keycode for enter key |
| 74 | // force the 'Enter Key' to implicitly click the Update button |
| 75 | document.getElementById('SEARCH').click(); |
| 76 | return false; |
| 77 | } else { |
| 78 | return true; |
| 79 | }}); |
Marc Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 80 | |
Marc Kupietz | e871abd | 2018-01-25 16:18:27 +0100 | [diff] [blame] | 81 | var collocatorTable_activated = false; |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 82 | $( "#tabs" ).on( "tabsactivate", function( event, ui ) { |
| 83 | if (localStorage) localStorage['tab'] = ui.newTab.index(); |
Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 84 | if(ui.newTab.index() == 3 && !collocatorTable_activated) { |
Marc Kupietz | e871abd | 2018-01-25 16:18:27 +0100 | [diff] [blame] | 85 | classicCollocatorTable.columns.adjust(); |
| 86 | collocatorTable.columns.adjust(); |
| 87 | collocatorTable_activated = true; |
| 88 | } |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 89 | }); |
| 90 | |
| 91 | $(function(){ |
| 92 | $("#SEARCH").click(function() { |
| 93 | window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self"); |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 94 | }); |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 95 | }); |
Marc Kupietz | 0af83e3 | 2017-11-27 09:31:37 +0100 | [diff] [blame] | 96 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 97 | function changeCharColor(txt, heat, word) { |
| 98 | var newText = ""; |
| 99 | for (var i=0, l=txt.length; i<l; i++) { |
Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 100 | newText += (i == 5 ? txt.charAt(i) : '<a href="http://korap.ids-mannheim.de' + korapPath + '/?ql=cosmas2&q=' + |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 101 | CIIsearchWords + ' /' + (i > 5? '%2B' : '-') + 'w' + |
| 102 | Math.abs(i-5) + ':' + Math.abs(i-5) + ' ' + word + |
| 103 | '" target="korap"><span style="background-color:' + |
| 104 | getHeatColor(heat[i]/maxHeat)+'">'+txt.charAt(i)+'</span></a>'); |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 105 | } |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 106 | return newText; |
| 107 | } |
Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 108 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 109 | function getHeatColor(value) { |
| 110 | var hue=((1-value)*120).toString(10); |
| 111 | return ["hsl(",hue,",90%,70%)"].join(""); |
| 112 | } |
| 113 | |
Marc Kupietz | 29f5bbd | 2019-01-24 15:12:59 +0100 | [diff] [blame] | 114 | function bitmask2window(autofocus, win) { |
| 115 | var af_str = autofocus.toString(2).padStart(10, "0") |
| 116 | .replace(/^([0-9]{5})/, '$1 ') |
| 117 | .replace(/0/g, '·') |
| 118 | .replace(/1/g, '◼'); |
| 119 | var w_str = win.toString(2).padStart(10, "0") |
| 120 | .replace(/^([0-9]{5})/, '$1 ') |
| 121 | .replace(/0/g, '·') |
| 122 | .replace(/1/g, 'o'); |
| 123 | for (var i=0, l=af_str.length; i<l; i++) { |
| 124 | if(af_str.charAt(i) == '·' && w_str.charAt(i) == 'o' ) { |
| 125 | af_str = af_str.substring(0, i) + "◽" + af_str.substring(i+1); |
| 126 | } |
| 127 | } |
| 128 | return af_str; |
Marc Kupietz | 63b268f | 2019-01-22 22:34:29 +0100 | [diff] [blame] | 129 | } |
| 130 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 131 | function bitvec2window(n, heat, word) { |
| 132 | var str = n.toString(2).padStart(10, "0") |
| 133 | .replace(/^([0-9]{5})/, '$1x') |
| 134 | .replace(/0/g, '·') |
| 135 | .replace(/1/g, '+'); |
| 136 | return changeCharColor(str, heat, word); |
| 137 | } |
| 138 | |
Marc Kupietz | 1d96a08 | 2019-02-18 09:29:06 +0100 | [diff] [blame] | 139 | function toFixed(n, d) { |
| 140 | if(typeof n != "number") { |
| 141 | return n; |
| 142 | } else { |
| 143 | return n.toFixed(d); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | function toExponential(n, d) { |
| 148 | if(typeof n != "number") { |
| 149 | return n; |
| 150 | } else { |
| 151 | return n.toExponential(d); |
| 152 | } |
| 153 | } |
| 154 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 155 | % use Mojo::ByteStream 'b'; |
| 156 | var paraResults = <%= b(Mojo::JSON::to_json($lists)) %>; |
| 157 | var urlprefix = new URLSearchParams(window.location.search); |
| 158 | if (paraResults.length > 0 && paraResults[0] != null) { |
| 159 | var nvecs = [], |
| 160 | nwords = [], |
| 161 | nranks = [], |
| 162 | nmarked = []; |
| 163 | for(var i = 0; i < paraResults.length; i++) { |
| 164 | nwords = nwords.concat(paraResults[i].map(function(a){return a.word;})); |
| 165 | nvecs = nvecs.concat(paraResults[i].map(function(a){return a.vector;})); |
| 166 | nranks = nranks.concat(paraResults[i].map(function(a){return a.rank;})); |
| 167 | nmarked = nmarked.concat(paraResults[i].map(function(a){return a.marked;})); |
Marc Kupietz | 0d4c0ca | 2017-12-04 09:18:56 +0100 | [diff] [blame] | 168 | } |
Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 169 | showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked} ); |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 170 | var t = $('#firsttable').DataTable({ |
Marc Kupietz | ee894d5 | 2019-01-09 14:55:14 +0100 | [diff] [blame] | 171 | data: [].concat.apply([], paraResults), |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 172 | "sScrollY": "780px", |
| 173 | "bScrollCollapse": true, |
| 174 | "bPaginate": false, |
| 175 | "bJQueryUI": true, |
| 176 | "dom": '<"top">rt<"bottom"flp><"clear">', |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 177 | "initComplete":function(settings, json) { |
| 178 | $('td.paradigmator a').on('mousedown', function(e) { |
Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 179 | return paradigmatorClick(e, paraResults[0][0].word, this.childNodes["0"].textContent); |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 180 | }); |
| 181 | }, |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 182 | "columns": [ |
| 183 | { "data": "rank", type: "allnumeric" }, |
| 184 | { "data": "dist", render: function ( data, type, row ) {return data.toFixed(3) }}, |
Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 185 | { "data": "word", class: "paradigmator", render: function ( data, type, row ) { |
| 186 | urlprefix.set("word", data); return '<a class="' + getMergedClass(row.rank) + '" href="?' + urlprefix + '">' + data + '</a>' |
| 187 | }} |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 188 | ], |
| 189 | "columnDefs": [ |
| 190 | { className: "dt-right", "targets": [0,1] }, |
| 191 | { "searchable": false, |
| 192 | "orderable": false, |
| 193 | "targets": 0 |
| 194 | }, |
| 195 | { "orderSequence": [ "desc" ], "targets": [ 1 ] }, |
| 196 | { "orderSequence": [ "asc", "desc" ], "targets": [ 2 ] }, |
| 197 | ], |
| 198 | "oLanguage": { |
| 199 | "sSearch": "Filter: " |
| 200 | }, |
| 201 | "order": [[ 1, 'desc' ]], |
| 202 | } ); |
Marc Kupietz | 0d4c0ca | 2017-12-04 09:18:56 +0100 | [diff] [blame] | 203 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 204 | t.on( 'order.dt search.dt', function () { |
| 205 | t.column(0, {order:'applied'}).nodes().each( function (cell, i) { |
| 206 | cell.innerHTML = i+1; |
| 207 | } ); |
| 208 | } ).draw(); |
| 209 | |
| 210 | $( "#first" ).clone().prependTo( "#tabs-2" ); |
| 211 | |
| 212 | } |
| 213 | |
| 214 | |
| 215 | var collocatorData = <%= b(Mojo::JSON::to_json($collocators)) %>; |
| 216 | var maxHeat; // = Math.max.apply(Math,collocatorData.map(function(o){return o.cprob;})) |
| 217 | |
Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 218 | vocabDistanceTable = $('#vocabdistt').DataTable({ |
| 219 | ajax: { |
| 220 | method: "GET", |
| 221 | url: baseURL + '/getBiggestVocabDistances', |
| 222 | dataType: 'json', |
| 223 | dataSrc: function (result) { |
| 224 | return result; |
| 225 | }, |
| 226 | timeout: 30000, |
| 227 | }, |
| 228 | "initComplete":function(settings, json){ |
| 229 | vocabDistanceTable.columns.adjust().draw(); |
| 230 | }, |
| 231 | "createdRow": function (row, data, rowIndex) { |
| 232 | $.each($('td.collocator', row), function (colIndex) { |
| 233 | $(this).attr('title', "f("+data.word+")="+data.f2.toLocaleString("en-GB") + " f1: "+ccResult.f1+ " total: "+ccResult.N); |
| 234 | }); |
| 235 | }, |
| 236 | "sScrollY": "780px", |
| 237 | "bScrollCollapse": true, |
| 238 | "bPaginate": false, |
| 239 | "bJQueryUI": true, |
| 240 | "dom": '<"top">rt<"bottom"flp><"clear">', |
| 241 | "columns": [ |
| 242 | { "data": "rank", type: "allnumeric" }, |
| 243 | { "data": "dist", render: function ( data, type, row ) {return data.toFixed(3) }}, |
| 244 | { "data": "word", class: "paradigmator", render: function ( data, type, row ) { |
| 245 | urlprefix.set("word", data); return '<a class="' + getMergedClass(row.rank) + '" href="?' + urlprefix + '">' + data + '</a>' |
| 246 | }} |
| 247 | ], |
| 248 | "columnDefs": [ |
| 249 | { className: "dt-right", "targets": [0,1] }, |
| 250 | { "searchable": false, |
| 251 | "orderable": false, |
| 252 | "targets": 0 |
| 253 | }, |
| 254 | { "orderSequence": [ "desc" ], "targets": [ 1 ] }, |
| 255 | { "orderSequence": [ "asc", "desc" ], "targets": [ 2 ] }, |
| 256 | ], |
| 257 | "oLanguage": { |
| 258 | "sSearch": "Filter: " |
| 259 | }, |
| 260 | "order": [[ 1, 'desc' ]] |
| 261 | }); |
| 262 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 263 | if (collocatorData != null) { |
| 264 | maxHeat = Math.max.apply(Math,collocatorData.map(function(o){return Math.max.apply(Math,o.heat);})) |
| 265 | collocatorTable = $('#secondtable').DataTable({ |
| 266 | data: collocatorData, |
| 267 | "sScrollY": "780px", |
| 268 | "bScrollCollapse": true, |
| 269 | "bPaginate": false, |
| 270 | "bJQueryUI": true, |
| 271 | "dom": '<"top">rt<"bottom"flp><"clear">', |
| 272 | "columns": [ |
| 273 | { "data": "rank", type: "allnumeric" }, |
| 274 | { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }}, |
| 275 | { "data": "max", render: function ( data, type, row ) {return data.toFixed(3) }}, |
| 276 | { "data": "average", render: function ( data, type, row ) {return data.toFixed(3) }}, |
| 277 | { "data": "prob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } }, |
| 278 | { "data": "cprob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } }, |
| 279 | { "data": "overall", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } }, |
| 280 | { "data": "word", sClass: "collocator" }, |
| 281 | { "data": "rank", type: "allnumeric" } |
| 282 | ], |
| 283 | "columnDefs": [ |
| 284 | { className: "dt-right", "targets": [0,2,3,4,5,6] }, |
| 285 | { className: "dt-center", "targets": [ 1] }, |
| 286 | { "searchable": false, |
| 287 | "orderable": false, |
| 288 | "targets": [0, 8] |
| 289 | }, |
| 290 | { "type": "scientific", targets: [2,3,4,5,6] }, |
| 291 | { "orderSequence": [ "desc" ], "targets": [ 2, 3, 4, 5, 6 ] }, |
| 292 | { "orderSequence": [ "asc", "desc" ], "targets": [ 1, 7 ] }, |
| 293 | { "targets": [8], "visible": false } |
| 294 | ], |
| 295 | "oLanguage": { |
| 296 | "sSearch": "Filter: " |
| 297 | }, |
| 298 | "order": [[ 4, 'desc' ]], |
| 299 | } ); |
| 300 | $.ajaxSetup({ |
| 301 | type: 'POST', |
| 302 | timeout: 30000, |
| 303 | error: function(xhr) { |
| 304 | $('#display_error') |
| 305 | .html('Error: ' + xhr.status + ' ' + xhr.statusText); |
| 306 | } |
Marc Kupietz | 78b434a | 2018-01-12 22:33:32 +0100 | [diff] [blame] | 307 | }); |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 308 | |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 309 | |
| 310 | if($('#sprofiles').length) { |
| 311 | similarProfileTable = $('#sprofiles').DataTable({ |
| 312 | ajax: { |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 313 | method: "GET", |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 314 | url: '/derekovecs/getSimilarProfiles', |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 315 | dataType: 'json', |
| 316 | dataSrc: "", |
| 317 | timeout: 30000, |
| 318 | data: { w: paraResults[0][0].rank } |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 319 | }, |
| 320 | "initComplete":function(settings, json){ |
| 321 | $('td.paradigmator a').on('mousedown', function(e) { |
| 322 | if (e.which === 2) { |
| 323 | e.preventDefault(); |
| 324 | queryKorAPalternatives(paraResults[0][0].word, this.childNodes["0"].textContent); |
| 325 | return false; |
| 326 | } |
| 327 | }); |
| 328 | }, |
| 329 | "sScrollY": "780px", |
| 330 | "bScrollCollapse": true, |
| 331 | "bPaginate": false, |
| 332 | "bJQueryUI": true, |
| 333 | "dom": '<"top">rt<"bottom"flp><"clear">', |
| 334 | "columns": [ |
| 335 | { "data": "v", render: function ( data, type, row ) {return data.toFixed(3) }}, |
| 336 | { "data": "w", sClass: "paradigmator", render: function ( data, type, row ) {urlprefix.set("word", data); return '<a href="?' + urlprefix + '">' + data + '</a>' } } |
| 337 | ], |
| 338 | "columnDefs": [ |
| 339 | { className: "dt-right", "targets": [0] }, |
| 340 | ], |
| 341 | "oLanguage": { |
| 342 | "sSearch": "Filter: " |
| 343 | }, |
| 344 | "order": [[ 0, 'desc' ]], |
| 345 | }); |
| 346 | } |
Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 347 | |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 348 | // var filterQuot = /(^quot?=[A-Z])|(quot$)/g; |
| 349 | var filterQuot = /^quot/; |
Marc Kupietz | 4784fae | 2019-02-04 12:32:12 +0100 | [diff] [blame] | 350 | var ccResult; |
Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 351 | var baseURL = window.location.pathname.replace(/[/]$/, '') |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 352 | classicCollocatorTable = $('#classicoloctable').DataTable({ |
| 353 | ajax: { |
| 354 | method: "GET", |
Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 355 | url: baseURL + '/getClassicCollocators', |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 356 | dataType: 'json', |
Marc Kupietz | 4784fae | 2019-02-04 12:32:12 +0100 | [diff] [blame] | 357 | dataSrc: function (result) { |
| 358 | ccResult = result; |
| 359 | $("#rawfreq_tt").attr("title", "Raw frequencies of the co-occurence.\n" |
| 360 | + "f(" + ccResult.w1+")=" + ccResult.f1.toLocaleString("en-GB") + ";\n" |
| 361 | + "N=" + ccResult.N.toLocaleString("en-GB")); |
| 362 | return result.collocates; |
| 363 | }, |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 364 | timeout: 30000, |
| 365 | data: { w: paraResults[0][0].rank } |
Marc Kupietz | 78b434a | 2018-01-12 22:33:32 +0100 | [diff] [blame] | 366 | }, |
Marc Kupietz | ad78372 | 2018-01-13 17:45:21 +0100 | [diff] [blame] | 367 | "initComplete":function(settings, json){ |
| 368 | $("td.collocator").click(function(){ |
| 369 | queryKorAPCII(this.textContent + " /w5 " + CIIsearchWords); |
| 370 | }); |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 371 | classicCollocatorTable.columns(".detail").visible(false); |
Marc Kupietz | 63b268f | 2019-01-22 22:34:29 +0100 | [diff] [blame] | 372 | $("#ccd").css('width', '680px'); |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 373 | classicCollocatorTable.columns.adjust().draw(); |
Marc Kupietz | ad78372 | 2018-01-13 17:45:21 +0100 | [diff] [blame] | 374 | }, |
Marc Kupietz | 9c1a3d2 | 2019-01-23 10:04:18 +0100 | [diff] [blame] | 375 | "createdRow": function (row, data, rowIndex) { |
| 376 | $.each($('td.collocator', row), function (colIndex) { |
Marc Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 377 | $(this).attr('title', "f("+data.word+")="+data.f2.toLocaleString("en-GB") + " f1: "+ccResult.f1+ " total: "+ccResult.N); |
Marc Kupietz | 9c1a3d2 | 2019-01-23 10:04:18 +0100 | [diff] [blame] | 378 | }); |
| 379 | }, |
Marc Kupietz | 78b434a | 2018-01-12 22:33:32 +0100 | [diff] [blame] | 380 | "sScrollY": "780px", |
| 381 | "bScrollCollapse": true, |
| 382 | "bPaginate": false, |
| 383 | "bJQueryUI": true, |
| 384 | "dom": '<"top">rt<"bottom"flp><"clear">', |
| 385 | "columns": [ |
| 386 | // { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }}, |
Marc Kupietz | 1d96a08 | 2019-02-18 09:29:06 +0100 | [diff] [blame] | 387 | { "data": "llr", render: function ( data, type, row ) {return toFixed(data, 0) }}, |
| 388 | { "data": "pmi", render: function ( data, type, row ) {return toFixed(data, 2) }}, |
| 389 | { "data": "md", render: function ( data, type, row ) {return toFixed(data, 2) }}, |
| 390 | { "data": "lfmd", render: function ( data, type, row ) {return toFixed(data, 2) }}, |
Marc Kupietz | 1acb317 | 2018-02-17 09:41:26 +0100 | [diff] [blame] | 391 | // { "data": "fpmi", type: "scientific", render: function ( data, type, row ) {return data.toExponential(2) } }, |
Marc Kupietz | 1d96a08 | 2019-02-18 09:29:06 +0100 | [diff] [blame] | 392 | { "data": "npmi", render: function ( data, type, row ) {return toFixed(data, 3) }}, |
| 393 | { "data": "dice", render: function ( data, type, row ) {return toExponential(data, 2) }}, |
| 394 | { "data": "ld", render: function ( data, type, row ) {return toFixed(data, 2) }}, |
| 395 | { "data": "af", render: function ( data, type, row ) {return toFixed(data, 2) }}, |
| 396 | { "data": "delta", render: function ( data, type, row ) {return toFixed(data, 2) }}, |
Marc Kupietz | 29f5bbd | 2019-01-24 15:12:59 +0100 | [diff] [blame] | 397 | { "data": "afwin", width: "auto", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitmask2window(data, row.win) }}, |
Marc Kupietz | 1d96a08 | 2019-02-18 09:29:06 +0100 | [diff] [blame] | 398 | { "data": "llfmd", render: function ( data, type, row ) {return toFixed(data, 1) }}, |
| 399 | { "data": "rlfmd", render: function ( data, type, row ) {return toFixed(data, 1) }}, |
| 400 | { "data": "lnpmi", render: function ( data, type, row ) {return toFixed(data, 2) }}, |
| 401 | { "data": "rnpmi", render: function ( data, type, row ) {return toFixed(data, 2) }}, |
Marc Kupietz | b4b53ca | 2018-01-25 08:57:11 +0100 | [diff] [blame] | 402 | { "data": "f" }, |
Marc Kupietz | 78b434a | 2018-01-12 22:33:32 +0100 | [diff] [blame] | 403 | { "data": "word", sClass: "collocator" } |
| 404 | ], |
| 405 | "columnDefs": [ |
Marc Kupietz | 78d7c1a | 2019-02-17 22:31:22 +0100 | [diff] [blame] | 406 | { className: "dt-right", "targets": [0,1,2,3,4,5,6,7,8,10,11,12,13,14] }, |
| 407 | { className: "dt-right detail", "targets": [5,10,11,12,13] }, |
Marc Kupietz | 78b434a | 2018-01-12 22:33:32 +0100 | [diff] [blame] | 408 | { "searchable": false, |
| 409 | "orderable": false, |
| 410 | "targets": [] |
| 411 | }, |
Marc Kupietz | 78d7c1a | 2019-02-17 22:31:22 +0100 | [diff] [blame] | 412 | { "orderSequence": [ "desc" ], "targets": [0,1,2,3,4,5,6,7,10,11,12,13,14] }, |
| 413 | { "orderSequence": [ "asc", "desc" ], "targets": [8,9,15] }, |
Marc Kupietz | 78b434a | 2018-01-12 22:33:32 +0100 | [diff] [blame] | 414 | ], |
| 415 | "oLanguage": { |
| 416 | "sSearch": "Filter: " |
| 417 | }, |
Marc Kupietz | 63b268f | 2019-01-22 22:34:29 +0100 | [diff] [blame] | 418 | "order": [[ 7, 'desc' ]], |
Marc Kupietz | 78b434a | 2018-01-12 22:33:32 +0100 | [diff] [blame] | 419 | }); |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 420 | |
Marc Kupietz | 1acb317 | 2018-02-17 09:41:26 +0100 | [diff] [blame] | 421 | $('#show-details').change(function (e) { |
| 422 | var columns = classicCollocatorTable.columns(".detail"); |
| 423 | if(this.checked) { |
| 424 | columns.visible(true); |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 425 | $("#ccd").css('width', 'auto'); |
Marc Kupietz | 1acb317 | 2018-02-17 09:41:26 +0100 | [diff] [blame] | 426 | } else { |
| 427 | columns.visible(false); |
Marc Kupietz | 08bfd40 | 2019-01-23 10:05:17 +0100 | [diff] [blame] | 428 | $("#ccd").css('width', '680px'); |
Marc Kupietz | 1acb317 | 2018-02-17 09:41:26 +0100 | [diff] [blame] | 429 | } |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 430 | classicCollocatorTable.columns.adjust().draw(); |
Marc Kupietz | 1acb317 | 2018-02-17 09:41:26 +0100 | [diff] [blame] | 431 | } ); |
| 432 | |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 433 | $("td.collocator").click(function(){ |
| 434 | queryKorAPCII(this.textContent + " /w5 " + CIIsearchWords); |
Marc Kupietz | ad78372 | 2018-01-13 17:45:21 +0100 | [diff] [blame] | 435 | }); |
| 436 | |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 437 | collocatorTable.on( 'order.dt search.dt', function () { |
| 438 | collocatorTable.column(0, {order:'applied'}).nodes().each( function (cell, i) { |
| 439 | cell.innerHTML = i+1; |
| 440 | } ); |
| 441 | }).draw(); |
| 442 | } |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 443 | |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 444 | if (localStorage && !window.location.hash) { // let's not crash if some user has IE7 |
| 445 | var index = parseInt(localStorage['tab']||'0'); |
| 446 | $("#tabs").tabs({ active: index }); |
| 447 | } |
| 448 | $("#tabs").css("visibility", "visible"); // now we can show the tabs |
| 449 | }); |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 450 | |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 451 | $(function(){ |
| 452 | $("#dropdownoptions").dialog({ |
| 453 | title: "Options", |
| 454 | autoOpen: false, |
| 455 | modal: false, |
| 456 | draggable: false, |
| 457 | height: "auto", |
| 458 | width: "auto", |
| 459 | resizable: false, |
| 460 | buttons: { |
| 461 | "Cancel": function() { |
| 462 | $( this ).dialog( "close" ); |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 463 | }, |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 464 | "Apply": function() { |
| 465 | window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self"); |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 466 | } |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 467 | } |
| 468 | }); |
| 469 | }); |
| 470 | |
| 471 | $(function(){ |
| 472 | $("#showoptions").click(function(){ |
| 473 | $("#dropdownoptions").dialog("open"); |
| 474 | var target = $(this); |
| 475 | $("#dropdownoptions").dialog("widget").position({ |
| 476 | my: 'left bottom', |
| 477 | at: 'left bottom', |
| 478 | of: target |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 479 | }); |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 480 | }); |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 481 | }); |
| 482 | |
| 483 | $( function() { |
| 484 | $( "#no_iterations" ).spinner({ |
| 485 | spin: function( event, ui ) { |
| 486 | if ( ui.value < 1000 ) { |
| 487 | $( this ).spinner( "value", 1000 ); |
| 488 | return false; |
| 489 | } else if ( ui.value > 10000 ) { |
| 490 | $( this ).spinner( "value", 10000 ); |
| 491 | return false; |
| 492 | } |
| 493 | } |
| 494 | }); |
| 495 | } ); |
| 496 | |
| 497 | $( function() { |
| 498 | $( "#neighbours" ).spinner({ |
| 499 | spin: function( event, ui ) { |
| 500 | if ( ui.value < 0 ) { |
| 501 | $( this ).spinner( "value", 0 ); |
| 502 | return false; |
| 503 | } else if ( ui.value > 200 ) { |
| 504 | $( this ).spinner( "value", 200 ); |
| 505 | return false; |
| 506 | } |
| 507 | } |
| 508 | }); |
| 509 | } ); |
| 510 | |
| 511 | $( function() { |
| 512 | $( "#cutoff" ).spinner({ |
| 513 | spin: function( event, ui ) { |
| 514 | if ( ui.value < 100000 ) { |
| 515 | $( this ).spinner( "value", 100000 ); |
| 516 | return false; |
| 517 | } else if ( ui.value > 2000000 ) { |
| 518 | $( this ).spinner( "value", 2000000 ); |
| 519 | return false; |
| 520 | } |
| 521 | } |
| 522 | }); |
| 523 | } ); |
| 524 | |
| 525 | $( function() { |
| 526 | $( "#tabs" ).tabs().addClass('tabs-min'); |
| 527 | } ); |
| 528 | |
| 529 | $( function() { |
| 530 | $( ".controlgroup-vertical" ).controlgroup({ |
| 531 | "direction": "vertical" |
| 532 | }); |
| 533 | } ); |
| 534 | |
| 535 | $(function() { |
| 536 | $( document ).tooltip({ |
| 537 | content: function() { |
| 538 | return $(this).attr('title'); |
| 539 | }} |
| 540 | ) |
| 541 | }); |
| 542 | |
| 543 | $(function () { |
| 544 | $(document).tooltip({ |
| 545 | content: function () { |
| 546 | return $(this).prop('title'); |
| 547 | }, |
| 548 | show: null, |
| 549 | close: function (event, ui) { |
| 550 | ui.tooltip.hover( |
| 551 | function () { |
| 552 | $(this).stop(true).fadeTo(400, 1); |
| 553 | }, |
| 554 | function () { |
| 555 | $(this).fadeOut("400", function () { |
| 556 | $(this).remove(); |
| 557 | }) |
| 558 | }); |
| 559 | } |
| 560 | }); |
| 561 | }); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 562 | </script> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 563 | <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script> |
| 564 | <script src="/derekovecs/js/tsne.js"></script> |
| 565 | <script src="/derekovecs/js/som.js"></script> |
| 566 | <script src="/derekovecs/js/labeler.js"></script> |
Marc Kupietz | cdd5130 | 2018-03-19 16:36:54 +0100 | [diff] [blame] | 567 | <script src="/derekovecs/js/derekovcs.js"></script> |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 568 | <script> |
| 569 | |
| 570 | var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>}, |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 571 | mapWidth = 800, // width map |
| 572 | mapHeight = 800, |
| 573 | jitterRadius = 7; |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 574 | |
| 575 | var T = new tsnejs.tSNE(opt); // create a tSNE instance |
| 576 | |
| 577 | var Y; |
| 578 | |
| 579 | var data; |
| 580 | var labeler; |
| 581 | |
| 582 | function applyJitter() { |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 583 | svg.selectAll('.tsnet') |
| 584 | .data(labels) |
| 585 | .transition() |
| 586 | .duration(50) |
| 587 | .attr("transform", function(d, i) { |
| 588 | T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20; |
| 589 | T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20; |
| 590 | return "translate(" + |
Marc Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 591 | (d.x) + "," + |
| 592 | (d.y) + ")"; |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 593 | }); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 594 | } |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 595 | |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 596 | function updateEmbedding() { |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 597 | var Y = T.getSolution(); |
| 598 | svg.selectAll('.tsnet') |
| 599 | .data(data.words) |
| 600 | .attr("transform", function(d, i) { |
| 601 | return "translate(" + |
Marc Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 602 | ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," + |
| 603 | ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; }); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | var svg; |
| 607 | var labels = []; |
| 608 | var anchor_array = []; |
| 609 | var text; |
| 610 | |
Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 611 | function getMergedClass(i) { |
Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 612 | if(typeof data !== 'undefined' && i > data.mergedEnd) { |
Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 613 | return " merged" |
| 614 | } else { |
| 615 | return ""; |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | function getRankTooltip(i) { |
| 620 | if(data.mergedEnd) { |
| 621 | if(data.ranks[i] < data.mergedEnd) { |
| 622 | return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
| 623 | } else { |
| 624 | return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]-data.mergedEnd).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)"; |
| 625 | } |
| 626 | } else { |
| 627 | return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
| 628 | } |
| 629 | } |
| 630 | |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 631 | function drawEmbedding() { |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 632 | var urlprefix = new URLSearchParams(window.location.search); |
| 633 | urlprefix.delete("word"); |
| 634 | urlprefix.append("word",""); |
Marc Kupietz | 8f9c86a | 2017-12-04 17:17:13 +0100 | [diff] [blame] | 635 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 636 | $("#embed").empty(); |
| 637 | var div = d3.select("#embed"); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 638 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 639 | // get min and max in each column of Y |
| 640 | var Y = T.Y; |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 641 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 642 | svg = div.append("svg") // svg is global |
| 643 | .attr("width", mapWidth) |
| 644 | .attr("height", mapHeight); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 645 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 646 | var g = svg.selectAll(".b") |
| 647 | .data(data.words) |
| 648 | .enter().append("g") |
| 649 | .attr("class", "tsnet"); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 650 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 651 | g.append("a") |
| 652 | .attr("xlink:href", function(word) { |
| 653 | return "?"+urlprefix+word; }) |
| 654 | .attr("class", function(d, i) { |
| 655 | var res=""; |
| 656 | if(data.marked[i]) { |
| 657 | res="marked "; |
| 658 | } |
| 659 | if(data.target.indexOf(" "+d+" ") >= 0) { |
Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 660 | res += "target"; |
| 661 | } |
| 662 | if(data.mergedEnd && data.ranks[i] >= data.mergedEnd) { |
| 663 | return res+" merged"; |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 664 | } else { |
| 665 | return res; |
| 666 | } |
| 667 | }) |
| 668 | .attr("title", function(d, i) { |
Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 669 | return getRankTooltip(i); |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 670 | }) |
| 671 | .append("text") |
| 672 | .attr("text-anchor", "top") |
| 673 | .attr("font-size", 12) |
| 674 | .text(function(d) { return d; }); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 675 | |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 676 | g.append("svg:title") |
| 677 | .text(function(d, i) { |
Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 678 | return getRankTooltip(i); |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 679 | }); |
| 680 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 681 | var zoomListener = d3.behavior.zoom() |
| 682 | .scaleExtent([0.1, 10]) |
| 683 | .center([0,0]) |
| 684 | .on("zoom", zoomHandler); |
| 685 | zoomListener(svg); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 686 | } |
| 687 | |
| 688 | var tx=0, ty=0; |
| 689 | var ss=1; |
| 690 | var iter_id=-1; |
| 691 | |
| 692 | function zoomHandler() { |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 693 | tx = d3.event.translate[0]; |
| 694 | ty = d3.event.translate[1]; |
| 695 | ss = d3.event.scale; |
| 696 | updateEmbedding(); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | var stepnum = 0; |
| 700 | |
| 701 | function stopStep() { |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 702 | clearInterval(iter_id); |
| 703 | text = svg.selectAll("text"); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 704 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 705 | // jitter function needs different data and co-ordinate representation |
| 706 | labels = d3.range(data.words.length).map(function(i) { |
| 707 | var x = (T.Y[i][0]*20*ss + tx) + mapWidth/2; |
| 708 | var y = (T.Y[i][1]*20*ss + ty) + mapHeight/2; |
| 709 | anchor_array.push({x: x, y: y, r: jitterRadius}); |
| 710 | return { |
| 711 | x: x, |
| 712 | y: y, |
| 713 | name: data.words[i] |
| 714 | }; |
| 715 | }); |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 716 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 717 | // get the actual label bounding boxes for the jitter function |
| 718 | var index = 0; |
| 719 | text.each(function() { |
| 720 | labels[index].width = this.getBBox().width; |
| 721 | labels[index].height = this.getBBox().height; |
| 722 | index += 1; |
| 723 | }); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 724 | |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 725 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 726 | // setTimeout(updateEmbedding, 1); |
| 727 | // setTimeout( |
| 728 | labeler = d3.labeler() |
| 729 | .label(labels) |
| 730 | .anchor(anchor_array) |
| 731 | .width(mapWidth) |
| 732 | .height(mapHeight) |
| 733 | .update(applyJitter); |
| 734 | // .start(1000); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 735 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 736 | iter_id = setInterval(jitterStep, 1); |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | var jitter_i=0; |
| 740 | |
| 741 | function jitterStep() { |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 742 | if(jitter_i++ > 100) { |
| 743 | clearInterval(iter_id); |
| 744 | } else { |
| 745 | labeler.start2(10); |
| 746 | applyJitter(); |
| 747 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | var last_cost=1000; |
| 751 | |
| 752 | function step() { |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 753 | var i = T.iter; |
Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 754 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 755 | if(i > <%= $no_iterations %>) { |
| 756 | stopStep(); |
| 757 | } else { |
| 758 | var cost = Math.round(T.step() * 100000) / 100000; // do a few steps |
| 759 | $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5)); |
| 760 | if(i % 250 == 0 && cost >= last_cost) { |
| 761 | stopStep(); |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 762 | } else { |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 763 | last_cost = cost; |
| 764 | updateEmbedding(); |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 765 | } |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 766 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | function showMap(j) { |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 770 | data=j; |
| 771 | T.iter=0; |
| 772 | iter_id = -1; |
| 773 | last_cost=1000; |
| 774 | T.initDataRaw(data.vecs); // init embedding |
| 775 | drawEmbedding(); // draw initial embedding |
Marc Kupietz | 7811453 | 2017-11-29 17:00:16 +0100 | [diff] [blame] | 776 | |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 777 | if(iter_id >= 0) { |
| 778 | clearInterval(iter_id); |
| 779 | } |
| 780 | //T.debugGrad(); |
| 781 | iter_id = setInterval(step, 1); |
| 782 | if(true) { // (<%= $show_som %>) { |
| 783 | makeSOM(j, <%= $no_iterations %>); |
| 784 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 785 | } |
Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 786 | var queryword; |
| 787 | |
Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 788 | function showCollocatorSOM() { |
Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 789 | var baseURL = window.location.pathname.replace(/[/]$/, '') |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 790 | if (collocatorTable) { |
| 791 | var ctableData = collocatorTable.rows().data(); |
| 792 | var nwords = [], |
| 793 | nranks = []; |
| 794 | for (var i=0; i < ctableData.length && i < 100; i++) { |
| 795 | nranks.push(ctableData[i].rank); |
| 796 | nwords.push(ctableData[i].word); |
Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 797 | } |
Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 798 | $.post(baseURL+'/getVecsByRanks', |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 799 | JSON.stringify(nranks), |
| 800 | function(data, status){ |
Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 801 | showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: data, ranks: nranks, marked: Array(100).fill(false)} ); |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 802 | }, 'json'); |
| 803 | } |
Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 804 | } |
| 805 | |
Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 806 | function onload() { |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 807 | queryword = document.getElementById('word'); |
Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | function queryKorAP() { |
Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 811 | window.open('http://korap.ids-mannheim.de' + korapPath + '?q='+queryword.value, 'KorAP'); |
Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 812 | } |
Marc Kupietz | 4dc270c | 2017-11-24 10:17:12 +0100 | [diff] [blame] | 813 | |
| 814 | function queryKorAPCII(query) { |
Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 815 | window.open('http://korap.ids-mannheim.de' +korapPath + '?ql=cosmas2&q='+query, 'KorAP'); |
Marc Kupietz | 4dc270c | 2017-11-24 10:17:12 +0100 | [diff] [blame] | 816 | } |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 817 | </script> |
| 818 | </head> |
Marc Kupietz | 7b0e5de | 2019-01-31 12:49:32 +0100 | [diff] [blame] | 819 | <body onload="onload()"> <div style="display:none;" id="pmi_ttt">Pointwise mutual information: $$\text{MI}=\text{MI}=\log_2\frac{p(w_1,w_2)}{p(w_1) p(w_2)}$$<p class="citation">Church, K. W. and Hanks, P. (1990): Word association norms, mutual information, and lexicography. Comput. Linguist. 16, 1 (March 1990), 22-29.</p></div> |
| 820 | <div style="display:none;" id="md_ttt">Pointwise mutual information squared [1], also called mutual dependency [2]: $$\text{MI}^2=\text{MD}=\log_2\frac{p^2(w_1,w_2)}{p(w_1) p(w_2)}$$<p class="citation">[1] Daille, B. (1994): <a href="http://www.bdaille.com/index.php?option=com_docman&task=doc_download&gid=8&Itemid=">Approche mixte pour l’extraction automatique de terminologie: statistiques lexicales et filtres linguistiques</a>. PhD thesis, Université Paris 7.</p><p class="citation">[2] Thanopoulos, A., Fakotakis, N., Kokkinakis, G. (2002): <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.11.8101&rep=rep1&type=pdf">Comparative evaluation of collocation extraction metrics</a>. In: Proc. of LREC 2002: 620–625.</p></div> |
| 821 | <div style="display:none;" id="lfmd_ttt">Pointwise mutual information cubed [1], also called log-frequency biased mutual dependency [2]: $$\text{MI}^3=\text{LFMD}=\log_2\frac{p^3(w_1,w_2)}{p(w_1) p(w_2)}$$<p class="citation">[1] Daille, B. (1994): <a href="http://www.bdaille.com/index.php?option=com_docman&task=doc_download&gid=8&Itemid=">Approche mixte pour l’extraction automatique de terminologie: statistiques lexicales et filtres linguistiques</a>. PhD thesis, Université Paris 7.</p><p class="citation">[2] Thanopoulos, A., Fakotakis, N., Kokkinakis, G. (2002): <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.11.8101&rep=rep1&type=pdf">Comparative evaluation of collocation extraction metrics</a>. In: Proc. of LREC 2002: 620–625.</p></div> |
| 822 | <div style="display:none;" id="npmi_ttt">Normalized pointwise mutual information: $$\frac{\log_2\frac{p(w_1,w_2)}{p(w_1)p(w_2)}}{-\log_2(p(w_1,w_2))}$$<p class="citation">Bouma, Gerlof (2009): <a href="https://svn.spraakdata.gu.se/repos/gerlof/pub/www/Docs/npmi-pfd.pdf">Normalized (pointwise) mutual information in collocation extraction</a>. In Proceedings of GSCL.</p></div> |
| 823 | <div style="display:none;" id="ll_ttt">Log-likelihood: $$2\sum_{ij}O_{ij}\log\frac{O_{ij}}{E_{ij}}$$<p class="citation">Dunning, T. (1993): Accurate methods for the statistics of surprise and coincidence. Comput. Linguist. 19, 1 (March 1993), 61-74.</p> |
| 824 | <p class="citation">Evert, Stefan (2004): <a href="http://purl.org/stefan.evert/PUB/Evert2004phd.pdf">The Statistics of Word Cooccurrences: Word Pairs and Collocations.</a> PhD dissertation, IMS, University of Stuttgart. Published in 2005, URN urn:nbn:de:bsz:93-opus-23714.</p></div> |
| 825 | <div style="display:none;" id="logdice_ttt">Log-Dice: $$14 + \log_2 \frac{2f_{1,2}}{f_1 + f_2}$$<p class="citation">Rychlý, Pavel (2008): <a href="http://www.fi.muni.cz/usr/sojka/download/raslan2008/13.pdf">A lexicographer-friendly association score.</a> In Proceedings of Recent Advances in Slavonic Natural Language Processing, RASLAN, 6–9, 2008</p></div> |
| 826 | <div style="display:none;" id="logdiceaf_ttt">Log-Dice using "auto-focus", i.e. the window that yields the highest score.</div> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 827 | <div id="header"> |
| 828 | <div id="pagetitle"> |
Marc Kupietz | c053d97 | 2019-01-10 10:41:51 +0100 | [diff] [blame] | 829 | <h1>DeReKoVecs</h1> |
| 830 | <h2><%== $title %></h2> |
Marc Kupietz | 4fcda0c | 2017-11-29 09:00:31 +0100 | [diff] [blame] | 831 | </div> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 832 | <div id="options" class="widget"> |
| 833 | <form id="queryform"> |
| 834 | <input id="word" type="text" name="word" placeholder="Word(s) to be searched" value="<%= $word %>" |
| 835 | 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."/> |
| 836 | <input id="SEARCH" type="button" value="SEARCH"> |
| 837 | <input type="button" id="showoptions" name="showoptions" value="Options" /> |
| 838 | </form> |
| 839 | <div id="dropdownoptions" style="display: none"> |
| 840 | <form id="optionsform"> |
| 841 | <div class="controlgroup-vertical"> |
| 842 | <label for="cutoff">cut-off</label> |
| 843 | <input id="cutoff" type="text" name="cutoff" size="10" value="<%= $cutoff %>" title="Only consider the most frequent x word forms."> |
| 844 | <label for="dedupe">dedupe</label> |
| 845 | <input id="dedupe" type="checkbox" name="dedupe" value="1" <%= ($dedupe ? "checked" : "") %> title="radically filter out any near-duplicates"> |
| 846 | % if($mergedEnd > 0) { |
| 847 | <label for="sbf">backw.</label> |
| 848 | <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."> |
| 849 | % } |
| 850 | <label for="neighbours">max. neighbours:</label> |
| 851 | <input id="neighbours" size="4" name="n" value="<%= $no_nbs %>"> |
| 852 | <label for="no_iterations">max. iterations</label> |
| 853 | <input id="no_iterations" name="N" size="4" value="<%= $no_iterations %>"> |
| 854 | <!-- <label for="dosom">SOM</label> |
| 855 | <input id="dosom" type="checkbox" name="som" value="1" <%= ($show_som ? "checked" : "") %>> --> |
| 856 | % if($collocators) { |
| 857 | <label for="sortby">window/sort</label> |
| 858 | <select id="sortby" name="sort"> |
| 859 | <option value="0" <%= ($sort!=1 && $sort!=2? "selected":"") %>>auto focus</option> |
| 860 | <!-- <option value="1" <%= ($sort==1? "selected":"") %>>any single position</option> |
| 861 | <option value="2" <%= ($sort==2? "selected":"") %>>whole window</option> --> |
| 862 | </select> |
| 863 | % } |
| 864 | <input type="button" value="→ KorAP" onclick="queryKorAP();" title="query word with KorAP"/> |
Marc Kupietz | 1acb317 | 2018-02-17 09:41:26 +0100 | [diff] [blame] | 865 | <input id="show-details" type="checkbox" name="show-details" value="1" > |
| 866 | <label for="show-details"> |
| 867 | Show details |
| 868 | </label> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 869 | </div> |
| 870 | </form> |
| 871 | </div> |
| 872 | </div> |
| 873 | </div> |
| 874 | <div id="topwrapper"> |
| 875 | <div style="visibility: hidden;" id="tabs"> |
| 876 | <ul> |
Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 877 | % if($distantWords) { |
| 878 | <li><a href="#tabs-0" title="Cos offsets of the words furthest away from their position in the reference corpus."">Offsets</a></li> |
| 879 | % } |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 880 | <li><a href="#tabs-1">Semantics (TSNE-map)</a></li> |
| 881 | <li><a href="#tabs-2">Semantics (SOM)</a></li> |
Marc Kupietz | bb3da6a | 2019-01-22 15:21:38 +0100 | [diff] [blame] | 882 | <li><a href="#tabs-3">Syntagmatic (collocates)</a></li> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 883 | </ul> |
Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 884 | <div id="tabs-0" style="display: flex; padding: 5px; flex-flow: row wrap;"> |
| 885 | <div id="vocabdist" style="width: 230px; margin-bottom: 15px;"> |
| 886 | <table class="display compact nowrap" id="vocabdistt"> |
| 887 | <thead> |
| 888 | <tr> |
| 889 | <th align="right">#</th><th align="right">cos</th><th align="left">word</th> |
| 890 | </tr> |
| 891 | </thead> |
| 892 | <tbody> |
| 893 | <tr> |
| 894 | <td align="right"> |
| 895 | </td> |
| 896 | <td align="right"> |
| 897 | </td> |
| 898 | <td></td> |
| 899 | </tr> |
| 900 | </tbody> |
| 901 | </table> |
| 902 | </div> |
| 903 | </div> |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 904 | <div id="tabs-1" style="display: flex; padding: 5px; flex-flow: row wrap;"> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 905 | % if($lists && (@$lists) > 0 && (@$lists)[0]) { |
| 906 | <div id="wrapper"> |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 907 | <div id="first" style="width: 230px; margin-bottom: 15px;"> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 908 | <table class="display compact nowrap" id="firsttable"> |
| 909 | <thead> |
| 910 | <tr> |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 911 | <th align="right">#</th><th align="right">cos</th><th align="left">similars by w2v</th> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 912 | </tr> |
| 913 | </thead> |
| 914 | <tbody> |
| 915 | <tr> |
| 916 | <td align="right"> |
| 917 | </td> |
| 918 | <td align="right"> |
| 919 | </td> |
| 920 | <td></td> |
| 921 | </tr> |
| 922 | </tbody> |
| 923 | </table> |
| 924 | </div> |
Marc Kupietz | a55a09a | 2018-07-06 13:30:30 +0200 | [diff] [blame] | 925 | % if(0 && $haveSProfiles) { |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 926 | <div id="sprofilesdiv" style="width: 200px; padding-right: 10px;"> |
| 927 | <table class="display compact nowrap" id="sprofiles"> |
| 928 | <thead> |
| 929 | <tr> |
| 930 | <th align="right">cos</th><th align="left">similars by coll. profile</th> |
| 931 | </tr> |
| 932 | </thead> |
| 933 | <tbody> |
| 934 | <tr> |
| 935 | <td align="right"> |
| 936 | </td> |
| 937 | <td></td> |
| 938 | </tr> |
| 939 | </tbody> |
| 940 | </table> |
| 941 | </div> |
| 942 | %} |
Marc Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 943 | <div id="second"> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 944 | <div id="embed"> |
| 945 | </div> |
| 946 | <div id="cost"> |
| 947 | </div> |
| 948 | </div> |
| 949 | </div> |
Marc Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 950 | % } elsif($word !~ /^\s*$/) { |
| 951 | <div id="wrapper"> |
| 952 | <div id="not-found-dialog" title="Not found"> |
| 953 | <p>ERROR: "<%= $word %>" not found in vocabluary.</p> |
| 954 | <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> |
| 955 | </div> |
| 956 | <script> |
| 957 | $( function() { |
| 958 | $( "#not-found-dialog" ).dialog({ |
| 959 | autoOpen: true, |
| 960 | modal: true, |
| 961 | draggable: false, |
| 962 | height: "auto", |
| 963 | width: "auto", |
| 964 | resizable: false, |
| 965 | buttons: { |
| 966 | "OK": function() { |
| 967 | $( this ).dialog( "close" ); |
| 968 | }, |
| 969 | "Apply": function() { |
| 970 | window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self"); |
| 971 | } |
| 972 | } |
| 973 | }); |
| 974 | }); |
| 975 | </script> |
| 976 | </div> |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 977 | % } |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 978 | </div> |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 979 | <div id="tabs-2" style="display: flex; padding: 5px; flex-flow: row wrap;"> |
Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 980 | <div id="som2" style="width: 800;"> |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 981 | <div id="sominfo1"><span id="somcolor1"> </span> <span id="somword1"> </span> <span id="somcolor2"> </span> <span id="somword2"> </span> <span id="somcolor3"> </span></div> |
| 982 | <div id="sominfo" style="text-align: right">SOM iteration <span id="iterations">0</span></div> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 983 | </div> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 984 | </div> |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 985 | <div id="tabs-3" style="display: flex; padding:5px; flex-flow: row wrap;"> |
| 986 | <div style="margin-right: 20px; margin-bottom: 10px;" id="secondt"> |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 987 | <table class="display compact nowrap" id="secondtable"> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 988 | <thead> |
| 989 | <tr> |
| 990 | % if($collocators) { |
| 991 | <th>#</th> |
Marc Kupietz | 4116b43 | 2017-12-06 14:15:32 +0100 | [diff] [blame] | 992 | <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> |
| 993 | <th align="right" title="Maximum activation of the collocator anywhere in the output layer.">max(a)</th> |
| 994 | <th title="Average raw activation of the collocator in the columns selected by auto-focus." align="right">⟨a⟩</th> |
| 995 | <th title="Sum of activations over the selected colunns normalized by the total activation sum of the selected columns." align="right">Σa/Σw'</th> |
| 996 | <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] | 997 | <th title="Sum of the activations over the whole window normalized by the total window sum (no auto-focus)." align="right">Σa/Σw</th> |
Marc Kupietz | bb3da6a | 2019-01-22 15:21:38 +0100 | [diff] [blame] | 998 | <th align="left">collocate (by w2v)</th> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 999 | % } |
| 1000 | </tr> |
| 1001 | </thead> |
| 1002 | <tbody> |
| 1003 | <tr> |
| 1004 | <td align="right"> |
| 1005 | </td> |
| 1006 | <td align="right"> |
| 1007 | </td> |
| 1008 | <td align="right"> |
| 1009 | </td> |
| 1010 | <td align="right"> |
| 1011 | </td> |
| 1012 | <td align="right"> |
| 1013 | </td> |
| 1014 | <td align="right"> |
| 1015 | </td> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 1016 | </tr> |
| 1017 | </tbody> |
| 1018 | </table> |
Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 1019 | </div> |
Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 1020 | <div id="ccd" style=""> |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 1021 | <table class="display compact nowrap" id="classicoloctable"> |
| 1022 | <thead> |
Marc Kupietz | cd136e2 | 2018-01-29 09:18:12 +0100 | [diff] [blame] | 1023 | % if($collocators) { |
| 1024 | <tr> |
Marc Kupietz | f19814b | 2019-01-21 16:50:19 +0100 | [diff] [blame] | 1025 | <th id="ll_tt">LL</th> |
Marc Kupietz | fab14a7 | 2019-01-22 16:20:29 +0100 | [diff] [blame] | 1026 | <th id="mi_tt">MI</th> |
| 1027 | <th id="md_tt">MI²</th> |
Marc Kupietz | f19814b | 2019-01-21 16:50:19 +0100 | [diff] [blame] | 1028 | <th id="lfmd_tt">MI³</th> |
Marc Kupietz | fab14a7 | 2019-01-22 16:20:29 +0100 | [diff] [blame] | 1029 | <th id="npmi_tt">nPMI</th> |
| 1030 | <th id="dice_tt">dice</th> |
Marc Kupietz | 63b268f | 2019-01-22 22:34:29 +0100 | [diff] [blame] | 1031 | <th id="logdice_tt">LD</th> |
| 1032 | <th id="logdiceaf_tt">LDaf</th> |
Marc Kupietz | 001bffd | 2019-02-21 08:52:41 +0100 | [diff] [blame] | 1033 | <th id="delta_tt" title="Delta to log-Dice score in reference corpus. ⚠: If the collocate is not within the top 200 of the reference corpus, a reference value of min(lD)-0.1 is assumed.">Δ</th> |
Marc Kupietz | 7b0e5de | 2019-01-31 12:49:32 +0100 | [diff] [blame] | 1034 | <th id="af_win" title="Positions around the target word that are selected by the auto-focus function are marked with ◾. Positions at which the collocate appears at least once are marked with ◽.">af-window</th> |
Marc Kupietz | 5a7f9ac | 2018-01-30 11:22:44 +0100 | [diff] [blame] | 1035 | <th title="PMI³ restricted to left neighbour">l-PMI³</th> |
| 1036 | <th title="PMI³ restricted to right neighbour">r-PMI³</th> |
| 1037 | <th title="nPMI restricted to left neighbour">l-nPMI</th> |
| 1038 | <th title="nPMI restricted to right neighbour">r-nPMI</th> |
Marc Kupietz | 4784fae | 2019-02-04 12:32:12 +0100 | [diff] [blame] | 1039 | <th id="rawfreq_tt" title="raw frequency sum of collocation within window">raw</th> |
Marc Kupietz | bb3da6a | 2019-01-22 15:21:38 +0100 | [diff] [blame] | 1040 | <th>collocate (by CA)</th> |
Marc Kupietz | cd136e2 | 2018-01-29 09:18:12 +0100 | [diff] [blame] | 1041 | </tr> |
Marc Kupietz | 1acb317 | 2018-02-17 09:41:26 +0100 | [diff] [blame] | 1042 | % } |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 1043 | </thead> |
| 1044 | <tbody> |
| 1045 | <tr> |
Marc Kupietz | 63b268f | 2019-01-22 22:34:29 +0100 | [diff] [blame] | 1046 | <td align="right"></td> |
| 1047 | <td align="right"></td> |
| 1048 | <td align="right"></td> |
Marc Kupietz | b4b53ca | 2018-01-25 08:57:11 +0100 | [diff] [blame] | 1049 | <td align="right"></td> |
Marc Kupietz | 78d7c1a | 2019-02-17 22:31:22 +0100 | [diff] [blame] | 1050 | <td align="right"></td> |
| 1051 | <td align="right"></td> |
| 1052 | <td align="right"></td> |
| 1053 | <td align="right"></td> |
| 1054 | <td align="right"></td> |
| 1055 | <td align="left"> </td> |
| 1056 | <td align="right"></td> |
| 1057 | <td align="right"></td> |
| 1058 | <td align="right"></td> |
| 1059 | <td align="right"></td> |
| 1060 | <td align="left"> </td> |
Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 1061 | </tr> |
| 1062 | </tbody> |
| 1063 | </table> |
| 1064 | </div> |
Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 1065 | <!-- |
| 1066 | <div style="clear:both" ></div> |
| 1067 | <div style="float: right; overflow: hidden" id="extra"><button onClick="showCollocatorSOM()"> </button></div> |
| 1068 | --> |
Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 1069 | </div> |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 1070 | </div> |
| 1071 | </div> <!-- topwrapper --> |
| 1072 | <div style="clear: both;"></div> |
| 1073 | </div> |
Marc Kupietz | ebea470 | 2018-01-12 09:16:09 +0100 | [diff] [blame] | 1074 | % if($training_args && (@$lists)[0]) { |
| 1075 | <div class="info"> |
| 1076 | % if($training_args =~ /-type\s*3/) { |
| 1077 | 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 %> |
| 1078 | % } else { |
| 1079 | 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 %> |
| 1080 | % } |
| 1081 | </div> |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 1082 | % } |
Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 1083 | </body> |
Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 1084 | </html> |