blob: 37117537bdd5c9f7809ed639de2f58da1894a73d [file] [log] [blame]
Marc Kupietz83305222016-04-28 09:57:22 +02001<!DOCTYPE html>
2<html>
3 <head>
Marc Kupietzc053d972019-01-10 10:41:51 +01004 <% my $plain_title = $title; $plain_title=~s/<[^>]+>//g; %>
5 <title><%= $plain_title %>:<%= $word %> DeReKo-Word-Vector-Distances</title>
Marc Kupietz80bd7b92017-07-04 16:25:54 +02006 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
Marc Kupietz58270662017-12-04 12:10:06 +01007 <link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Condensed" rel="stylesheet">
Marc Kupietz80bd7b92017-07-04 16:25:54 +02008 <script src="http://code.jquery.com/jquery-latest.min.js"></script>
Marc Kupietz5f532b32019-01-23 10:03:18 +01009 <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 Kupietz4949d232018-03-19 16:43:18 +010014 <link rel="stylesheet" href="/derekovecs/css/derekovecs.css">
Marc Kupietz80bd7b92017-07-04 16:25:54 +020015 <script
Marc Kupietze6a7a732018-01-12 09:21:08 +010016 src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
17 integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
18 crossorigin="anonymous"></script>
Marc Kupietz80bd7b92017-07-04 16:25:54 +020019 <script>
Marc Kupietza0ffb392018-01-25 08:53:43 +010020 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 Kupietz58270662017-12-04 12:10:06 +010028 var urlParams = new URLSearchParams(window.location.search);
Marc Kupietzb3a2e4f2017-12-08 17:25:53 +010029 var currentWords = urlParams.get("word");
Marc Kupietza0ffb392018-01-25 08:53:43 +010030 var CIIsearchWords = (currentWords && currentWords.includes(" ") ? '('+currentWords.replace(/ +/g, " oder ")+')' : currentWords);
Marc Kupietz66bfd952017-12-11 09:59:45 +010031 var collocatorTable = null;
Marc Kupietza6e08f02017-12-01 22:06:21 +010032
Marc Kupietz58270662017-12-04 12:10:06 +010033 $(document).ready(function() {
Marc Kupietz694610d2017-11-25 18:30:03 +010034
Marc Kupietza0ffb392018-01-25 08:53:43 +010035 $('#firstable').hide();
36 //Set up a callback to hear back when MathJax is done rendering the equations
37 // it finds
38 $('#ccd').load(
39 '@Url.Action("ActionResultMethod","ControllerName",{controller parameters})',
40 function () {
41 MathJax.Hub.Queue(
42 ["Typeset",MathJax.Hub,"ccd"],
43 function () {
Marc Kupietz7bd55232019-01-22 15:29:06 +010044 $("#mi_tt").attr("title",$("#pmi_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010045 $("#lfmd_tt").attr("title",$("#lfmd_ttt").html());
Marc Kupietz7bd55232019-01-22 15:29:06 +010046 $("#md_tt").attr("title",$("#md_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010047 $("#npmi_tt").attr("title",$("#npmi_ttt").html());
Marc Kupietzf19814b2019-01-21 16:50:19 +010048 $("#ll_tt").attr("title",$("#ll_ttt").html());
Marc Kupietz7bd55232019-01-22 15:29:06 +010049 $("#logdice_tt").attr("title",$("#logdice_ttt").html());
Marc Kupietz63b268f2019-01-22 22:34:29 +010050 $("#logdiceaf_tt").attr("title",$("#logdiceaf_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010051 }
52 );
53 });
54
55 //set things up so that we can shove raw html into what is shown in the tooltip;
56 // in this case, we will have already put into the title attribute the html that
57 // contains the MathJax rendered equations (via what we do in the callback).
58 $(function () {
59 $(document).tooltip({
60 content: function () {
61 return $(this).prop('title');
62 }
63 });
64 });
65
Marc Kupietze6a7a732018-01-12 09:21:08 +010066 $("input").bind("keydown", function(event) {
67 // track enter key
68 var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
69 if (keycode == 13) { // keycode for enter key
70 // force the 'Enter Key' to implicitly click the Update button
71 document.getElementById('SEARCH').click();
72 return false;
73 } else {
74 return true;
75 }});
Marc Kupietzdab9f222017-11-29 14:22:59 +010076
Marc Kupietze871abd2018-01-25 16:18:27 +010077 var collocatorTable_activated = false;
Marc Kupietze6a7a732018-01-12 09:21:08 +010078 $( "#tabs" ).on( "tabsactivate", function( event, ui ) {
79 if (localStorage) localStorage['tab'] = ui.newTab.index();
Marc Kupietze871abd2018-01-25 16:18:27 +010080 if(ui.newTab.index() == 2 && !collocatorTable_activated) {
81 classicCollocatorTable.columns.adjust();
82 collocatorTable.columns.adjust();
83 collocatorTable_activated = true;
84 }
Marc Kupietze6a7a732018-01-12 09:21:08 +010085 });
86
87 $(function(){
88 $("#SEARCH").click(function() {
89 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietz58270662017-12-04 12:10:06 +010090 });
Marc Kupietze6a7a732018-01-12 09:21:08 +010091 });
Marc Kupietz0af83e32017-11-27 09:31:37 +010092
Marc Kupietze6a7a732018-01-12 09:21:08 +010093 function changeCharColor(txt, heat, word) {
94 var newText = "";
95 for (var i=0, l=txt.length; i<l; i++) {
96 newText += (i == 5 ? txt.charAt(i) : '<a href="http://korap.ids-mannheim.de/kalamar/?ql=cosmas2&q=' +
97 CIIsearchWords + ' /' + (i > 5? '%2B' : '-') + 'w' +
98 Math.abs(i-5) + ':' + Math.abs(i-5) + ' ' + word +
99 '" target="korap"><span style="background-color:' +
100 getHeatColor(heat[i]/maxHeat)+'">'+txt.charAt(i)+'</span></a>');
Marc Kupietzb6c615d2017-12-02 10:38:20 +0100101 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100102 return newText;
103 }
Marc Kupietzb6c615d2017-12-02 10:38:20 +0100104
Marc Kupietze6a7a732018-01-12 09:21:08 +0100105 function getHeatColor(value) {
106 var hue=((1-value)*120).toString(10);
107 return ["hsl(",hue,",90%,70%)"].join("");
108 }
109
Marc Kupietz29f5bbd2019-01-24 15:12:59 +0100110 function bitmask2window(autofocus, win) {
111 var af_str = autofocus.toString(2).padStart(10, "0")
112 .replace(/^([0-9]{5})/, '$1 ')
113 .replace(/0/g, '·')
114 .replace(/1/g, '◼');
115 var w_str = win.toString(2).padStart(10, "0")
116 .replace(/^([0-9]{5})/, '$1 ')
117 .replace(/0/g, '·')
118 .replace(/1/g, 'o');
119 for (var i=0, l=af_str.length; i<l; i++) {
120 if(af_str.charAt(i) == '·' && w_str.charAt(i) == 'o' ) {
121 af_str = af_str.substring(0, i) + "◽" + af_str.substring(i+1);
122 }
123 }
124 return af_str;
Marc Kupietz63b268f2019-01-22 22:34:29 +0100125 }
126
Marc Kupietze6a7a732018-01-12 09:21:08 +0100127 function bitvec2window(n, heat, word) {
128 var str = n.toString(2).padStart(10, "0")
129 .replace(/^([0-9]{5})/, '$1x')
130 .replace(/0/g, '·')
131 .replace(/1/g, '+');
132 return changeCharColor(str, heat, word);
133 }
134
135 % use Mojo::ByteStream 'b';
136 var paraResults = <%= b(Mojo::JSON::to_json($lists)) %>;
137 var urlprefix = new URLSearchParams(window.location.search);
138 if (paraResults.length > 0 && paraResults[0] != null) {
139 var nvecs = [],
140 nwords = [],
141 nranks = [],
142 nmarked = [];
143 for(var i = 0; i < paraResults.length; i++) {
144 nwords = nwords.concat(paraResults[i].map(function(a){return a.word;}));
145 nvecs = nvecs.concat(paraResults[i].map(function(a){return a.vector;}));
146 nranks = nranks.concat(paraResults[i].map(function(a){return a.rank;}));
147 nmarked = nmarked.concat(paraResults[i].map(function(a){return a.marked;}));
Marc Kupietz0d4c0ca2017-12-04 09:18:56 +0100148 }
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100149 showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked} );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100150 var t = $('#firsttable').DataTable({
Marc Kupietzee894d52019-01-09 14:55:14 +0100151 data: [].concat.apply([], paraResults),
Marc Kupietze6a7a732018-01-12 09:21:08 +0100152 "sScrollY": "780px",
153 "bScrollCollapse": true,
154 "bPaginate": false,
155 "bJQueryUI": true,
156 "dom": '<"top">rt<"bottom"flp><"clear">',
Marc Kupietz384c9132018-03-19 16:45:24 +0100157 "initComplete":function(settings, json) {
158 $('td.paradigmator a').on('mousedown', function(e) {
159 return paradigmatorClick(e, paraResults[0][0].word, this.childNodes["0"].textContent);
160 });
161 },
Marc Kupietze6a7a732018-01-12 09:21:08 +0100162 "columns": [
163 { "data": "rank", type: "allnumeric" },
164 { "data": "dist", render: function ( data, type, row ) {return data.toFixed(3) }},
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100165 { "data": "word", class: "paradigmator", render: function ( data, type, row ) {
166 urlprefix.set("word", data); return '<a class="' + getMergedClass(row.rank) + '" href="?' + urlprefix + '">' + data + '</a>'
167 }}
Marc Kupietze6a7a732018-01-12 09:21:08 +0100168 ],
169 "columnDefs": [
170 { className: "dt-right", "targets": [0,1] },
171 { "searchable": false,
172 "orderable": false,
173 "targets": 0
174 },
175 { "orderSequence": [ "desc" ], "targets": [ 1 ] },
176 { "orderSequence": [ "asc", "desc" ], "targets": [ 2 ] },
177 ],
178 "oLanguage": {
179 "sSearch": "Filter: "
180 },
181 "order": [[ 1, 'desc' ]],
182 } );
Marc Kupietz0d4c0ca2017-12-04 09:18:56 +0100183
Marc Kupietze6a7a732018-01-12 09:21:08 +0100184 t.on( 'order.dt search.dt', function () {
185 t.column(0, {order:'applied'}).nodes().each( function (cell, i) {
186 cell.innerHTML = i+1;
187 } );
188 } ).draw();
189
190 $( "#first" ).clone().prependTo( "#tabs-2" );
191
192 }
193
194
195 var collocatorData = <%= b(Mojo::JSON::to_json($collocators)) %>;
196 var maxHeat; // = Math.max.apply(Math,collocatorData.map(function(o){return o.cprob;}))
197
198 if (collocatorData != null) {
199 maxHeat = Math.max.apply(Math,collocatorData.map(function(o){return Math.max.apply(Math,o.heat);}))
200 collocatorTable = $('#secondtable').DataTable({
201 data: collocatorData,
202 "sScrollY": "780px",
203 "bScrollCollapse": true,
204 "bPaginate": false,
205 "bJQueryUI": true,
206 "dom": '<"top">rt<"bottom"flp><"clear">',
207 "columns": [
208 { "data": "rank", type: "allnumeric" },
209 { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
210 { "data": "max", render: function ( data, type, row ) {return data.toFixed(3) }},
211 { "data": "average", render: function ( data, type, row ) {return data.toFixed(3) }},
212 { "data": "prob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
213 { "data": "cprob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
214 { "data": "overall", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
215 { "data": "word", sClass: "collocator" },
216 { "data": "rank", type: "allnumeric" }
217 ],
218 "columnDefs": [
219 { className: "dt-right", "targets": [0,2,3,4,5,6] },
220 { className: "dt-center", "targets": [ 1] },
221 { "searchable": false,
222 "orderable": false,
223 "targets": [0, 8]
224 },
225 { "type": "scientific", targets: [2,3,4,5,6] },
226 { "orderSequence": [ "desc" ], "targets": [ 2, 3, 4, 5, 6 ] },
227 { "orderSequence": [ "asc", "desc" ], "targets": [ 1, 7 ] },
228 { "targets": [8], "visible": false }
229 ],
230 "oLanguage": {
231 "sSearch": "Filter: "
232 },
233 "order": [[ 4, 'desc' ]],
234 } );
235 $.ajaxSetup({
236 type: 'POST',
237 timeout: 30000,
238 error: function(xhr) {
239 $('#display_error')
240 .html('Error: ' + xhr.status + ' ' + xhr.statusText);
241 }
Marc Kupietz78b434a2018-01-12 22:33:32 +0100242 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100243
Marc Kupietz384c9132018-03-19 16:45:24 +0100244
245 if($('#sprofiles').length) {
246 similarProfileTable = $('#sprofiles').DataTable({
247 ajax: {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100248 method: "GET",
Marc Kupietz384c9132018-03-19 16:45:24 +0100249 url: '/derekovecs/getSimilarProfiles',
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100250 dataType: 'json',
251 dataSrc: "",
252 timeout: 30000,
253 data: { w: paraResults[0][0].rank }
Marc Kupietz384c9132018-03-19 16:45:24 +0100254 },
255 "initComplete":function(settings, json){
256 $('td.paradigmator a').on('mousedown', function(e) {
257 if (e.which === 2) {
258 e.preventDefault();
259 queryKorAPalternatives(paraResults[0][0].word, this.childNodes["0"].textContent);
260 return false;
261 }
262 });
263 },
264 "sScrollY": "780px",
265 "bScrollCollapse": true,
266 "bPaginate": false,
267 "bJQueryUI": true,
268 "dom": '<"top">rt<"bottom"flp><"clear">',
269 "columns": [
270 { "data": "v", render: function ( data, type, row ) {return data.toFixed(3) }},
271 { "data": "w", sClass: "paradigmator", render: function ( data, type, row ) {urlprefix.set("word", data); return '<a href="?' + urlprefix + '">' + data + '</a>' } }
272 ],
273 "columnDefs": [
274 { className: "dt-right", "targets": [0] },
275 ],
276 "oLanguage": {
277 "sSearch": "Filter: "
278 },
279 "order": [[ 0, 'desc' ]],
280 });
281 }
282 // var filterQuot = /(^quot?=[A-Z])|(quot$)/g;
283 var filterQuot = /^quot/;
284 classicCollocatorTable = $('#classicoloctable').DataTable({
285 ajax: {
286 method: "GET",
287 url: '/derekovecs/getClassicCollocators',
288 dataType: 'json',
289 dataSrc: "",
290 timeout: 30000,
291 data: { w: paraResults[0][0].rank }
Marc Kupietz78b434a2018-01-12 22:33:32 +0100292 },
Marc Kupietzad783722018-01-13 17:45:21 +0100293 "initComplete":function(settings, json){
294 $("td.collocator").click(function(){
295 queryKorAPCII(this.textContent + " /w5 " + CIIsearchWords);
296 });
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100297 classicCollocatorTable.columns(".detail").visible(false);
Marc Kupietz63b268f2019-01-22 22:34:29 +0100298 $("#ccd").css('width', '680px');
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100299 classicCollocatorTable.columns.adjust().draw();
Marc Kupietzad783722018-01-13 17:45:21 +0100300 },
Marc Kupietz9c1a3d22019-01-23 10:04:18 +0100301 "createdRow": function (row, data, rowIndex) {
302 $.each($('td.collocator', row), function (colIndex) {
303 $(this).attr('title', "f("+data.word+")="+data.f2.toLocaleString("en-GB"));
304 });
305 },
Marc Kupietz78b434a2018-01-12 22:33:32 +0100306 "sScrollY": "780px",
307 "bScrollCollapse": true,
308 "bPaginate": false,
309 "bJQueryUI": true,
310 "dom": '<"top">rt<"bottom"flp><"clear">',
311 "columns": [
312 // { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100313 { "data": "llr", render: function ( data, type, row ) {return data.toFixed(0) }},
Marc Kupietz7bd55232019-01-22 15:29:06 +0100314 { "data": "pmi", render: function ( data, type, row ) {return data.toFixed(2) }},
315 { "data": "md", render: function ( data, type, row ) {return data.toFixed(2) }},
316 { "data": "lfmd", render: function ( data, type, row ) {return data.toFixed(2) }},
Marc Kupietz1acb3172018-02-17 09:41:26 +0100317 // { "data": "fpmi", type: "scientific", render: function ( data, type, row ) {return data.toExponential(2) } },
Marc Kupietz7bd55232019-01-22 15:29:06 +0100318 { "data": "npmi", render: function ( data, type, row ) {return data.toFixed(3) }},
319 { "data": "dice", render: function ( data, type, row ) {return data.toExponential(2) }},
320 { "data": "ld", render: function ( data, type, row ) {return data.toFixed(2) }},
Marc Kupietz63b268f2019-01-22 22:34:29 +0100321 { "data": "af", render: function ( data, type, row ) {return data.toFixed(2) }},
Marc Kupietz29f5bbd2019-01-24 15:12:59 +0100322 { "data": "afwin", width: "auto", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitmask2window(data, row.win) }},
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100323 { "data": "llfmd", render: function ( data, type, row ) {return data.toFixed(1) }},
324 { "data": "rlfmd", render: function ( data, type, row ) {return data.toFixed(1) }},
325 { "data": "lnpmi", render: function ( data, type, row ) {return data.toFixed(2) }},
326 { "data": "rnpmi", render: function ( data, type, row ) {return data.toFixed(2) }},
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100327 { "data": "f" },
Marc Kupietz78b434a2018-01-12 22:33:32 +0100328 { "data": "word", sClass: "collocator" }
329 ],
330 "columnDefs": [
Marc Kupietz63b268f2019-01-22 22:34:29 +0100331 { className: "dt-right", "targets": [0,1,2,3,4,5,6,7,9,10,11,12,13] },
332 { className: "dt-right detail", "targets": [5,9,10,11,12] },
Marc Kupietz78b434a2018-01-12 22:33:32 +0100333 { "searchable": false,
334 "orderable": false,
335 "targets": []
336 },
Marc Kupietz63b268f2019-01-22 22:34:29 +0100337 { "orderSequence": [ "desc" ], "targets": [0,1,2,3,4,5,6,7,9,10,11,12,13] },
338 { "orderSequence": [ "asc", "desc" ], "targets": [8,14] },
Marc Kupietz78b434a2018-01-12 22:33:32 +0100339 ],
340 "oLanguage": {
341 "sSearch": "Filter: "
342 },
Marc Kupietz63b268f2019-01-22 22:34:29 +0100343 "order": [[ 7, 'desc' ]],
Marc Kupietz78b434a2018-01-12 22:33:32 +0100344 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100345
Marc Kupietz1acb3172018-02-17 09:41:26 +0100346
347 $('#show-details').change(function (e) {
348 var columns = classicCollocatorTable.columns(".detail");
349 if(this.checked) {
350 columns.visible(true);
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100351 $("#ccd").css('width', 'auto');
Marc Kupietz1acb3172018-02-17 09:41:26 +0100352 } else {
353 columns.visible(false);
Marc Kupietz08bfd402019-01-23 10:05:17 +0100354 $("#ccd").css('width', '680px');
Marc Kupietz1acb3172018-02-17 09:41:26 +0100355 }
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100356 classicCollocatorTable.columns.adjust().draw();
Marc Kupietz1acb3172018-02-17 09:41:26 +0100357 } );
358
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100359 $("td.collocator").click(function(){
360 queryKorAPCII(this.textContent + " /w5 " + CIIsearchWords);
Marc Kupietzad783722018-01-13 17:45:21 +0100361 });
362
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100363 collocatorTable.on( 'order.dt search.dt', function () {
364 collocatorTable.column(0, {order:'applied'}).nodes().each( function (cell, i) {
365 cell.innerHTML = i+1;
366 } );
367 }).draw();
368 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100369
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100370 if (localStorage && !window.location.hash) { // let's not crash if some user has IE7
371 var index = parseInt(localStorage['tab']||'0');
372 $("#tabs").tabs({ active: index });
373 }
374 $("#tabs").css("visibility", "visible"); // now we can show the tabs
375 });
Marc Kupietz58270662017-12-04 12:10:06 +0100376
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100377 $(function(){
378 $("#dropdownoptions").dialog({
379 title: "Options",
380 autoOpen: false,
381 modal: false,
382 draggable: false,
383 height: "auto",
384 width: "auto",
385 resizable: false,
386 buttons: {
387 "Cancel": function() {
388 $( this ).dialog( "close" );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100389 },
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100390 "Apply": function() {
391 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietze6a7a732018-01-12 09:21:08 +0100392 }
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100393 }
394 });
395 });
396
397 $(function(){
398 $("#showoptions").click(function(){
399 $("#dropdownoptions").dialog("open");
400 var target = $(this);
401 $("#dropdownoptions").dialog("widget").position({
402 my: 'left bottom',
403 at: 'left bottom',
404 of: target
Marc Kupietz58270662017-12-04 12:10:06 +0100405 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100406 });
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100407 });
408
409 $( function() {
410 $( "#no_iterations" ).spinner({
411 spin: function( event, ui ) {
412 if ( ui.value < 1000 ) {
413 $( this ).spinner( "value", 1000 );
414 return false;
415 } else if ( ui.value > 10000 ) {
416 $( this ).spinner( "value", 10000 );
417 return false;
418 }
419 }
420 });
421 } );
422
423 $( function() {
424 $( "#neighbours" ).spinner({
425 spin: function( event, ui ) {
426 if ( ui.value < 0 ) {
427 $( this ).spinner( "value", 0 );
428 return false;
429 } else if ( ui.value > 200 ) {
430 $( this ).spinner( "value", 200 );
431 return false;
432 }
433 }
434 });
435 } );
436
437 $( function() {
438 $( "#cutoff" ).spinner({
439 spin: function( event, ui ) {
440 if ( ui.value < 100000 ) {
441 $( this ).spinner( "value", 100000 );
442 return false;
443 } else if ( ui.value > 2000000 ) {
444 $( this ).spinner( "value", 2000000 );
445 return false;
446 }
447 }
448 });
449 } );
450
451 $( function() {
452 $( "#tabs" ).tabs().addClass('tabs-min');
453 } );
454
455 $( function() {
456 $( ".controlgroup-vertical" ).controlgroup({
457 "direction": "vertical"
458 });
459 } );
460
461 $(function() {
462 $( document ).tooltip({
463 content: function() {
464 return $(this).attr('title');
465 }}
466 )
467 });
468
469 $(function () {
470 $(document).tooltip({
471 content: function () {
472 return $(this).prop('title');
473 },
474 show: null,
475 close: function (event, ui) {
476 ui.tooltip.hover(
477 function () {
478 $(this).stop(true).fadeTo(400, 1);
479 },
480 function () {
481 $(this).fadeOut("400", function () {
482 $(this).remove();
483 })
484 });
485 }
486 });
487 });
Marc Kupietz83305222016-04-28 09:57:22 +0200488 </script>
Marc Kupietz58270662017-12-04 12:10:06 +0100489 <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
490 <script src="/derekovecs/js/tsne.js"></script>
491 <script src="/derekovecs/js/som.js"></script>
492 <script src="/derekovecs/js/labeler.js"></script>
Marc Kupietzcdd51302018-03-19 16:36:54 +0100493 <script src="/derekovecs/js/derekovcs.js"></script>
Marc Kupietz83305222016-04-28 09:57:22 +0200494 <script>
495
496 var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>},
Marc Kupietz58270662017-12-04 12:10:06 +0100497 mapWidth = 800, // width map
498 mapHeight = 800,
499 jitterRadius = 7;
Marc Kupietz83305222016-04-28 09:57:22 +0200500
501 var T = new tsnejs.tSNE(opt); // create a tSNE instance
502
503 var Y;
504
505 var data;
506 var labeler;
507
508 function applyJitter() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100509 svg.selectAll('.tsnet')
510 .data(labels)
511 .transition()
512 .duration(50)
513 .attr("transform", function(d, i) {
514 T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20;
515 T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20;
516 return "translate(" +
Marc Kupietz384c9132018-03-19 16:45:24 +0100517 (d.x) + "," +
518 (d.y) + ")";
Marc Kupietze6a7a732018-01-12 09:21:08 +0100519 });
Marc Kupietz83305222016-04-28 09:57:22 +0200520 }
Marc Kupietz34c08172017-11-29 17:08:47 +0100521
Marc Kupietz83305222016-04-28 09:57:22 +0200522 function updateEmbedding() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100523 var Y = T.getSolution();
524 svg.selectAll('.tsnet')
525 .data(data.words)
526 .attr("transform", function(d, i) {
527 return "translate(" +
Marc Kupietz384c9132018-03-19 16:45:24 +0100528 ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
529 ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
Marc Kupietz83305222016-04-28 09:57:22 +0200530 }
531
532 var svg;
533 var labels = [];
534 var anchor_array = [];
535 var text;
536
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100537 function getMergedClass(i) {
538 if(data.mergedEnd && i > data.mergedEnd) {
539 return " merged"
540 } else {
541 return "";
542 }
543 }
544
545 function getRankTooltip(i) {
546 if(data.mergedEnd) {
547 if(data.ranks[i] < data.mergedEnd) {
548 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
549 } else {
550 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]-data.mergedEnd).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)";
551 }
552 } else {
553 return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
554 }
555 }
556
Marc Kupietz83305222016-04-28 09:57:22 +0200557 function drawEmbedding() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100558 var urlprefix = new URLSearchParams(window.location.search);
559 urlprefix.delete("word");
560 urlprefix.append("word","");
Marc Kupietz8f9c86a2017-12-04 17:17:13 +0100561
Marc Kupietze6a7a732018-01-12 09:21:08 +0100562 $("#embed").empty();
563 var div = d3.select("#embed");
Marc Kupietz34c08172017-11-29 17:08:47 +0100564
Marc Kupietze6a7a732018-01-12 09:21:08 +0100565 // get min and max in each column of Y
566 var Y = T.Y;
Marc Kupietz34c08172017-11-29 17:08:47 +0100567
Marc Kupietze6a7a732018-01-12 09:21:08 +0100568 svg = div.append("svg") // svg is global
569 .attr("width", mapWidth)
570 .attr("height", mapHeight);
Marc Kupietz34c08172017-11-29 17:08:47 +0100571
Marc Kupietze6a7a732018-01-12 09:21:08 +0100572 var g = svg.selectAll(".b")
573 .data(data.words)
574 .enter().append("g")
575 .attr("class", "tsnet");
Marc Kupietz34c08172017-11-29 17:08:47 +0100576
Marc Kupietze6a7a732018-01-12 09:21:08 +0100577 g.append("a")
578 .attr("xlink:href", function(word) {
579 return "?"+urlprefix+word; })
580 .attr("class", function(d, i) {
581 var res="";
582 if(data.marked[i]) {
583 res="marked ";
584 }
585 if(data.target.indexOf(" "+d+" ") >= 0) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100586 res += "target";
587 }
588 if(data.mergedEnd && data.ranks[i] >= data.mergedEnd) {
589 return res+" merged";
Marc Kupietze6a7a732018-01-12 09:21:08 +0100590 } else {
591 return res;
592 }
593 })
594 .attr("title", function(d, i) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100595 return getRankTooltip(i);
Marc Kupietze6a7a732018-01-12 09:21:08 +0100596 })
597 .append("text")
598 .attr("text-anchor", "top")
599 .attr("font-size", 12)
600 .text(function(d) { return d; });
Marc Kupietz34c08172017-11-29 17:08:47 +0100601
Marc Kupietz384c9132018-03-19 16:45:24 +0100602 g.append("svg:title")
603 .text(function(d, i) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100604 return getRankTooltip(i);
Marc Kupietz384c9132018-03-19 16:45:24 +0100605 });
606
Marc Kupietze6a7a732018-01-12 09:21:08 +0100607 var zoomListener = d3.behavior.zoom()
608 .scaleExtent([0.1, 10])
609 .center([0,0])
610 .on("zoom", zoomHandler);
611 zoomListener(svg);
Marc Kupietz83305222016-04-28 09:57:22 +0200612 }
613
614 var tx=0, ty=0;
615 var ss=1;
616 var iter_id=-1;
617
618 function zoomHandler() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100619 tx = d3.event.translate[0];
620 ty = d3.event.translate[1];
621 ss = d3.event.scale;
622 updateEmbedding();
Marc Kupietz83305222016-04-28 09:57:22 +0200623 }
624
625 var stepnum = 0;
626
627 function stopStep() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100628 clearInterval(iter_id);
629 text = svg.selectAll("text");
Marc Kupietz34c08172017-11-29 17:08:47 +0100630
Marc Kupietze6a7a732018-01-12 09:21:08 +0100631 // jitter function needs different data and co-ordinate representation
632 labels = d3.range(data.words.length).map(function(i) {
633 var x = (T.Y[i][0]*20*ss + tx) + mapWidth/2;
634 var y = (T.Y[i][1]*20*ss + ty) + mapHeight/2;
635 anchor_array.push({x: x, y: y, r: jitterRadius});
636 return {
637 x: x,
638 y: y,
639 name: data.words[i]
640 };
641 });
Marc Kupietz34c08172017-11-29 17:08:47 +0100642
Marc Kupietze6a7a732018-01-12 09:21:08 +0100643 // get the actual label bounding boxes for the jitter function
644 var index = 0;
645 text.each(function() {
646 labels[index].width = this.getBBox().width;
647 labels[index].height = this.getBBox().height;
648 index += 1;
649 });
Marc Kupietz83305222016-04-28 09:57:22 +0200650
Marc Kupietz34c08172017-11-29 17:08:47 +0100651
Marc Kupietze6a7a732018-01-12 09:21:08 +0100652 // setTimeout(updateEmbedding, 1);
653 // setTimeout(
654 labeler = d3.labeler()
655 .label(labels)
656 .anchor(anchor_array)
657 .width(mapWidth)
658 .height(mapHeight)
659 .update(applyJitter);
660 // .start(1000);
Marc Kupietz83305222016-04-28 09:57:22 +0200661
Marc Kupietze6a7a732018-01-12 09:21:08 +0100662 iter_id = setInterval(jitterStep, 1);
Marc Kupietz83305222016-04-28 09:57:22 +0200663 }
664
665 var jitter_i=0;
666
667 function jitterStep() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100668 if(jitter_i++ > 100) {
669 clearInterval(iter_id);
670 } else {
671 labeler.start2(10);
672 applyJitter();
673 }
Marc Kupietz83305222016-04-28 09:57:22 +0200674 }
675
676 var last_cost=1000;
677
678 function step() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100679 var i = T.iter;
Marc Kupietz34c08172017-11-29 17:08:47 +0100680
Marc Kupietze6a7a732018-01-12 09:21:08 +0100681 if(i > <%= $no_iterations %>) {
682 stopStep();
683 } else {
684 var cost = Math.round(T.step() * 100000) / 100000; // do a few steps
685 $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5));
686 if(i % 250 == 0 && cost >= last_cost) {
687 stopStep();
Marc Kupietz58270662017-12-04 12:10:06 +0100688 } else {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100689 last_cost = cost;
690 updateEmbedding();
Marc Kupietz58270662017-12-04 12:10:06 +0100691 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100692 }
Marc Kupietz83305222016-04-28 09:57:22 +0200693 }
694
695 function showMap(j) {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100696 data=j;
697 T.iter=0;
698 iter_id = -1;
699 last_cost=1000;
700 T.initDataRaw(data.vecs); // init embedding
701 drawEmbedding(); // draw initial embedding
Marc Kupietz78114532017-11-29 17:00:16 +0100702
Marc Kupietze6a7a732018-01-12 09:21:08 +0100703 if(iter_id >= 0) {
704 clearInterval(iter_id);
705 }
706 //T.debugGrad();
707 iter_id = setInterval(step, 1);
708 if(true) { // (<%= $show_som %>) {
709 makeSOM(j, <%= $no_iterations %>);
710 }
Marc Kupietz83305222016-04-28 09:57:22 +0200711 }
Marc Kupietz39179ab2017-07-04 16:28:06 +0200712 var queryword;
713
Marc Kupietz66bfd952017-12-11 09:59:45 +0100714 function showCollocatorSOM() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100715 if (collocatorTable) {
716 var ctableData = collocatorTable.rows().data();
717 var nwords = [],
718 nranks = [];
719 for (var i=0; i < ctableData.length && i < 100; i++) {
720 nranks.push(ctableData[i].rank);
721 nwords.push(ctableData[i].word);
Marc Kupietz66bfd952017-12-11 09:59:45 +0100722 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100723 $.post('/derekovecs/getVecsByRanks',
724 JSON.stringify(nranks),
725 function(data, status){
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100726 showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: data, ranks: nranks, marked: Array(100).fill(false)} );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100727 }, 'json');
728 }
Marc Kupietz66bfd952017-12-11 09:59:45 +0100729 }
730
Marc Kupietz39179ab2017-07-04 16:28:06 +0200731 function onload() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100732 queryword = document.getElementById('word');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200733 }
734
735 function queryKorAP() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100736 window.open('http://korap.ids-mannheim.de/kalamar/?q='+queryword.value, 'KorAP');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200737 }
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100738
739 function queryKorAPCII(query) {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100740 window.open('http://korap.ids-mannheim.de/kalamar/?ql=cosmas2&q='+query, 'KorAP');
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100741 }
Marc Kupietz83305222016-04-28 09:57:22 +0200742 </script>
743 </head>
Marc Kupietz39179ab2017-07-04 16:28:06 +0200744 <body onload="onload()">
Marc Kupietz7bd55232019-01-22 15:29:06 +0100745 <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>
746 <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>
747 <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>
Marc Kupietza0ffb392018-01-25 08:53:43 +0100748 <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 Kupietz9f732f02019-01-22 16:19:51 +0100749 <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>
750<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>
Marc Kupietz7bd55232019-01-22 15:29:06 +0100751 <div style="display:none;" id="logdice_ttt">Log-Dice: $$14 + log_2 \frac{2*(f_{12}+ε)}{(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>
Marc Kupietz58270662017-12-04 12:10:06 +0100752 <div id="header">
753 <div id="pagetitle">
Marc Kupietzc053d972019-01-10 10:41:51 +0100754 <h1>DeReKoVecs</h1>
755 <h2><%== $title %></h2>
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100756 </div>
Marc Kupietz58270662017-12-04 12:10:06 +0100757 <div id="options" class="widget">
758 <form id="queryform">
759 <input id="word" type="text" name="word" placeholder="Word(s) to be searched" value="<%= $word %>"
760 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."/>
761 <input id="SEARCH" type="button" value="SEARCH">
762 <input type="button" id="showoptions" name="showoptions" value="Options" />
763 </form>
764 <div id="dropdownoptions" style="display: none">
765 <form id="optionsform">
766 <div class="controlgroup-vertical">
767 <label for="cutoff">cut-off</label>
768 <input id="cutoff" type="text" name="cutoff" size="10" value="<%= $cutoff %>" title="Only consider the most frequent x word forms.">
769 <label for="dedupe">dedupe</label>
770 <input id="dedupe" type="checkbox" name="dedupe" value="1" <%= ($dedupe ? "checked" : "") %> title="radically filter out any near-duplicates">
771 % if($mergedEnd > 0) {
772 <label for="sbf">backw.</label>
773 <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.">
774 % }
775 <label for="neighbours">max. neighbours:</label>
776 <input id="neighbours" size="4" name="n" value="<%= $no_nbs %>">
777 <label for="no_iterations">max. iterations</label>
778 <input id="no_iterations" name="N" size="4" value="<%= $no_iterations %>">
779 <!-- <label for="dosom">SOM</label>
780 <input id="dosom" type="checkbox" name="som" value="1" <%= ($show_som ? "checked" : "") %>> -->
781 % if($collocators) {
782 <label for="sortby">window/sort</label>
783 <select id="sortby" name="sort">
784 <option value="0" <%= ($sort!=1 && $sort!=2? "selected":"") %>>auto focus</option>
785 <!-- <option value="1" <%= ($sort==1? "selected":"") %>>any single position</option>
786 <option value="2" <%= ($sort==2? "selected":"") %>>whole window</option> -->
787 </select>
788 % }
789 <input type="button" value="→ KorAP" onclick="queryKorAP();" title="query word with KorAP"/>
Marc Kupietz1acb3172018-02-17 09:41:26 +0100790 <input id="show-details" type="checkbox" name="show-details" value="1" >
791 <label for="show-details">
792 Show details
793 </label>
Marc Kupietz58270662017-12-04 12:10:06 +0100794 </div>
795 </form>
796 </div>
797 </div>
798 </div>
799 <div id="topwrapper">
800 <div style="visibility: hidden;" id="tabs">
801 <ul>
802 <li><a href="#tabs-1">Semantics (TSNE-map)</a></li>
803 <li><a href="#tabs-2">Semantics (SOM)</a></li>
Marc Kupietzbb3da6a2019-01-22 15:21:38 +0100804 <li><a href="#tabs-3">Syntagmatic (collocates)</a></li>
Marc Kupietz58270662017-12-04 12:10:06 +0100805 </ul>
Marc Kupietz384c9132018-03-19 16:45:24 +0100806 <div id="tabs-1" style="display: flex; padding: 5px; flex-flow: row wrap;">
Marc Kupietz58270662017-12-04 12:10:06 +0100807 % if($lists && (@$lists) > 0 && (@$lists)[0]) {
808 <div id="wrapper">
Marc Kupietz384c9132018-03-19 16:45:24 +0100809 <div id="first" style="width: 230px; margin-bottom: 15px;">
Marc Kupietz58270662017-12-04 12:10:06 +0100810 <table class="display compact nowrap" id="firsttable">
811 <thead>
812 <tr>
Marc Kupietz384c9132018-03-19 16:45:24 +0100813 <th align="right">#</th><th align="right">cos</th><th align="left">similars by w2v</th>
Marc Kupietz58270662017-12-04 12:10:06 +0100814 </tr>
815 </thead>
816 <tbody>
817 <tr>
818 <td align="right">
819 </td>
820 <td align="right">
821 </td>
822 <td></td>
823 </tr>
824 </tbody>
825 </table>
826 </div>
Marc Kupietza55a09a2018-07-06 13:30:30 +0200827 % if(0 && $haveSProfiles) {
Marc Kupietz384c9132018-03-19 16:45:24 +0100828 <div id="sprofilesdiv" style="width: 200px; padding-right: 10px;">
829 <table class="display compact nowrap" id="sprofiles">
830 <thead>
831 <tr>
832 <th align="right">cos</th><th align="left">similars by coll. profile</th>
833 </tr>
834 </thead>
835 <tbody>
836 <tr>
837 <td align="right">
838 </td>
839 <td></td>
840 </tr>
841 </tbody>
842 </table>
843 </div>
844 %}
845 <div id="second">
Marc Kupietz58270662017-12-04 12:10:06 +0100846 <div id="embed">
847 </div>
848 <div id="cost">
849 </div>
850 </div>
851 </div>
Marc Kupietz384c9132018-03-19 16:45:24 +0100852 % } elsif($word !~ /^\s*$/) {
853 <div id="wrapper">
854 <div id="not-found-dialog" title="Not found">
855 <p>ERROR: "<%= $word %>" not found in vocabluary.</p>
856 <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>
857 </div>
858 <script>
859 $( function() {
860 $( "#not-found-dialog" ).dialog({
861 autoOpen: true,
862 modal: true,
863 draggable: false,
864 height: "auto",
865 width: "auto",
866 resizable: false,
867 buttons: {
868 "OK": function() {
869 $( this ).dialog( "close" );
870 },
871 "Apply": function() {
872 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
873 }
874 }
875 });
876 });
877 </script>
878 </div>
879 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100880 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100881 <div id="tabs-2" style="display: flex; padding: 5px; flex-flow: row wrap;">
Marc Kupietz66bfd952017-12-11 09:59:45 +0100882 <div id="som2" style="width: 800;">
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100883 <div id="sominfo1"><span id="somcolor1"> </span> <span id="somword1"> </span> <span id="somcolor2"> </span> <span id="somword2"> </span> <span id="somcolor3"> </span></div>
884 <div id="sominfo" style="text-align: right">SOM iteration <span id="iterations">0</span></div>
Marc Kupietz58270662017-12-04 12:10:06 +0100885 </div>
Marc Kupietz58270662017-12-04 12:10:06 +0100886 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100887 <div id="tabs-3" style="display: flex; padding:5px; flex-flow: row wrap;">
888 <div style="margin-right: 20px; margin-bottom: 10px;" id="secondt">
Marc Kupietze6a7a732018-01-12 09:21:08 +0100889 <table class="display compact nowrap" id="secondtable">
Marc Kupietz58270662017-12-04 12:10:06 +0100890 <thead>
891 <tr>
892 % if($collocators) {
893 <th>#</th>
Marc Kupietz4116b432017-12-06 14:15:32 +0100894 <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>
895 <th align="right" title="Maximum activation of the collocator anywhere in the output layer.">max(a)</th>
896 <th title="Average raw activation of the collocator in the columns selected by auto-focus." align="right">⟨a⟩</th>
897 <th title="Sum of activations over the selected colunns normalized by the total activation sum of the selected columns." align="right">Σa/Σw'</th>
898 <th title="Co-norm of the column-normalized activations over the colunns selected by the auto-focus." align="right">⊥(a/c)</th>
Marc Kupietz58270662017-12-04 12:10:06 +0100899 <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 Kupietzbb3da6a2019-01-22 15:21:38 +0100900 <th align="left">collocate (by w2v)</th>
Marc Kupietz58270662017-12-04 12:10:06 +0100901 % }
902 </tr>
903 </thead>
904 <tbody>
905 <tr>
906 <td align="right">
907 </td>
908 <td align="right">
909 </td>
910 <td align="right">
911 </td>
912 <td align="right">
913 </td>
914 <td align="right">
915 </td>
916 <td align="right">
917 </td>
Marc Kupietz58270662017-12-04 12:10:06 +0100918 </tr>
919 </tbody>
920 </table>
Marc Kupietz66bfd952017-12-11 09:59:45 +0100921 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100922 <div id="ccd" style="">
Marc Kupietze6a7a732018-01-12 09:21:08 +0100923 <table class="display compact nowrap" id="classicoloctable">
924 <thead>
Marc Kupietzcd136e22018-01-29 09:18:12 +0100925 % if($collocators) {
926 <tr>
Marc Kupietzf19814b2019-01-21 16:50:19 +0100927 <th id="ll_tt">LL</th>
Marc Kupietzfab14a72019-01-22 16:20:29 +0100928 <th id="mi_tt">MI</th>
929 <th id="md_tt">MI²</th>
Marc Kupietzf19814b2019-01-21 16:50:19 +0100930 <th id="lfmd_tt">MI³</th>
Marc Kupietzfab14a72019-01-22 16:20:29 +0100931 <th id="npmi_tt">nPMI</th>
932 <th id="dice_tt">dice</th>
Marc Kupietz63b268f2019-01-22 22:34:29 +0100933 <th id="logdice_tt">LD</th>
934 <th id="logdiceaf_tt">LDaf</th>
935 <th id="af_win">af-window</th>
Marc Kupietz5a7f9ac2018-01-30 11:22:44 +0100936 <th title="PMI³ restricted to left neighbour">l-PMI³</th>
937 <th title="PMI³ restricted to right neighbour">r-PMI³</th>
938 <th title="nPMI restricted to left neighbour">l-nPMI</th>
939 <th title="nPMI restricted to right neighbour">r-nPMI</th>
Marc Kupietzbb3da6a2019-01-22 15:21:38 +0100940 <th title="raw frequency sum of collocation within window">raw</th>
941 <th>collocate (by CA)</th>
Marc Kupietzcd136e22018-01-29 09:18:12 +0100942 </tr>
Marc Kupietz1acb3172018-02-17 09:41:26 +0100943 % }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100944 </thead>
945 <tbody>
946 <tr>
947 <td align="right">
948 </td>
949 <td align="right">
950 </td>
951 <td align="right">
952 </td>
953 <td align="right">
954 </td>
Marc Kupietzcfcdcfc2018-01-24 09:51:26 +0100955 <td align="right">
956 </td>
957 <td align="right">
958 </td>
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100959 <td align="right"></td>
Marc Kupietz63b268f2019-01-22 22:34:29 +0100960 <td align="left"></td>
961 <td align="right"></td>
962 <td align="right"></td>
963 <td align="right"></td>
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100964 <td align="right"></td>
965 <td align="left"></td>
Marc Kupietze6a7a732018-01-12 09:21:08 +0100966 </tr>
967 </tbody>
968 </table>
969 </div>
Marc Kupietz384c9132018-03-19 16:45:24 +0100970 <!--
971 <div style="clear:both" ></div>
972 <div style="float: right; overflow: hidden" id="extra"><button onClick="showCollocatorSOM()"> </button></div>
973 -->
Marc Kupietz66bfd952017-12-11 09:59:45 +0100974 </div>
Marc Kupietz58270662017-12-04 12:10:06 +0100975 </div>
976 </div> <!-- topwrapper -->
977 <div style="clear: both;"></div>
978 </div>
Marc Kupietzebea4702018-01-12 09:16:09 +0100979 % if($training_args && (@$lists)[0]) {
980 <div class="info">
981 % if($training_args =~ /-type\s*3/) {
982 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 %>
983 % } else {
984 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 %>
985 % }
986 </div>
Marc Kupietz83305222016-04-28 09:57:22 +0200987 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100988 </body>
Marc Kupietz83305222016-04-28 09:57:22 +0200989</html>