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