blob: ce385369d3debad2ba7a67dc9252d815f7b96f4a [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; %>
Marc Kupietz565274e2026-09-06 13:17:17 +02005%# Whether the query was answered at all: not found, and an expression whose
6%# operands cancel each other out, both leave the first list empty.
7% my $have_results = ($lists && @$lists > 0 && $lists->[0] && @{$lists->[0]} > 0);
8%# The count based collocators come out of the co-occurrence database, which is
9%# keyed by one node word, so they have no answer for a query of several
10%# operands. The predictive ones do, see getCollocators().
11% my $single_word = ($operands == 1);
Marc Kupietz86b50292019-02-17 21:03:59 +010012 <title><%= $plain_title %>:<%= $word %> · IDS word vector analysis</title>
Marc Kupietzb3cd59f2026-08-21 10:47:45 +020013%# Result pages are computed for one word each and there is one for every
14%# word of the vocabulary, so they are not something to index or to follow.
15% if (stash 'noindex') {
16 <meta name="robots" content="noindex, nofollow">
17% }
Marc Kupietz80bd7b92017-07-04 16:25:54 +020018 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
Marc Kupietz58270662017-12-04 12:10:06 +010019 <link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Condensed" rel="stylesheet">
Marc Kupietz42e6d092023-04-18 19:29:12 +020020 <script src="https://code.jquery.com/jquery-latest.min.js"></script>
Marc Kupietz898e5482024-02-20 15:03:07 +010021 <script src = "https://cdn.datatables.net/1.13.10/js/jquery.dataTables.min.js"></script>
Marc Kupietz5f532b32019-01-23 10:03:18 +010022 <script src = "https://cdn.datatables.net/fixedcolumns/3.2.5/js/dataTables.fixedColumns.min.js"></script>
Marc Kupietz898e5482024-02-20 15:03:07 +010023 <script src = "https://cdn.datatables.net/plug-ins/1.13.10/sorting/scientific.js"></script>
Marc Kupietz5f532b32019-01-23 10:03:18 +010024 <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'></script>
Marc Kupietz898e5482024-02-20 15:03:07 +010025 <script src="https://cdn.datatables.net/buttons/2.3.6/js/dataTables.buttons.min.js"></script>
26 <script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.print.min.js"></script>
27 <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
28 <script src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.html5.min.js"></script>
29
Marc Kupietz9ae184c2023-11-04 18:21:54 +010030 <script src="https://cdnjs.cloudflare.com/ajax/libs/ical.js/1.5.0/ical.js"
31 integrity="sha512-UxWd2RMDGpYwYuDeU2Fs+nd51gw4ZLQY0D9wWZ3NuanNSk6QQmWCZ6C+rvI0lJ/b/nZtBQ8RVESA9DN9r65dUg=="
32 crossorigin="anonymous" referrerpolicy="no-referrer"></script>
33 <script
34 src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js"
35 integrity="sha512-42PE0rd+wZ2hNXftlM78BSehIGzezNeQuzihiBCvUEB3CVxHvsShF86wBWwQORNxNINlBPuq7rG4WWhNiTVHFg=="
36 crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Marc Kupietz898e5482024-02-20 15:03:07 +010037 <link rel="stylesheet" href="https://cdn.datatables.net/1.13.10/css/jquery.dataTables.min.css">
Marc Kupietz4949d232018-03-19 16:43:18 +010038 <link rel="stylesheet" href="/derekovecs/css/derekovecs.css">
Marc Kupietz80bd7b92017-07-04 16:25:54 +020039 <script
Marc Kupietz42e6d092023-04-18 19:29:12 +020040 src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
Marc Kupietze6a7a732018-01-12 09:21:08 +010041 integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
42 crossorigin="anonymous"></script>
Marc Kupietz80bd7b92017-07-04 16:25:54 +020043 <script>
Marc Kupietza0ffb392018-01-25 08:53:43 +010044 MathJax.Hub.Config({
45 config: ["MMLorHTML.js"],
46 jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML", "output/PreviewHTML"],
47 extensions: ["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js", "fast-preview.js", "AssistiveMML.js", "a11y/accessibility-menu.js"],
48 TeX: {
49 extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
50 }
51 });
Marc Kupietz58270662017-12-04 12:10:06 +010052 var urlParams = new URLSearchParams(window.location.search);
Marc Kupietzb3a2e4f2017-12-08 17:25:53 +010053 var currentWords = urlParams.get("word");
Marc Kupietz565274e2026-09-06 13:17:17 +020054 % use Mojo::ByteStream 'b';
55 // The vocabulary entries the query vector was built from, as the server
56 // resolved them. A query can be a vector expression, "König - Mann +
57 // Frau", and the subtracted operands are deliberately not in here: they
58 // are not marked in the maps, and not part of the KorAP queries built
59 // from the result.
60 var searchedWords = <%= b(Mojo::JSON::to_json($added // '')) %>;
61 var targetWords = " " + searchedWords + " ";
62 var CIIsearchWords = (searchedWords.includes(" ") ? '('+searchedWords.replace(/\s+/g, " oder ")+')' : searchedWords);
Marc Kupietz66bfd952017-12-11 09:59:45 +010063 var collocatorTable = null;
Marc Kupietz565274e2026-09-06 13:17:17 +020064 var classicCollocatorTable = null;
65 var singleWord = <%= $single_word ? 'true' : 'false' %>;
Marc Kupietz86b50292019-02-17 21:03:59 +010066 var plainTitle ="<%= $plain_title %>"
Marc Kupietz78d7c1a2019-02-17 22:31:22 +010067 var korapPath="/";
68 if (plainTitle.match(/-en/)) {
69 korapPath="/instance/english";
70 }
Marc Kupietz78230872019-08-02 15:15:25 +020071 var korapVC="";
72 if (plainTitle.match(/WUDD/i)) {
73 korapVC="&collection=corpusSigle+%3D+%2FW%5BDU%5DD17%2F";
74 korapPath="/instance/test";
75 }
76
Marc Kupietz58270662017-12-04 12:10:06 +010077 $(document).ready(function() {
Marc Kupietz5b8aaf72026-09-04 19:21:22 +020078 insertCalendarEvents(document.getElementById('downtimes'), '/derekovecs/getDowntimeCalendar', 7);
Marc Kupietz694610d2017-11-25 18:30:03 +010079
Marc Kupietza0ffb392018-01-25 08:53:43 +010080 $('#firstable').hide();
81 //Set up a callback to hear back when MathJax is done rendering the equations
82 // it finds
83 $('#ccd').load(
84 '@Url.Action("ActionResultMethod","ControllerName",{controller parameters})',
85 function () {
86 MathJax.Hub.Queue(
87 ["Typeset",MathJax.Hub,"ccd"],
Marc Kupietz95977002019-02-26 09:09:59 +010088 function () {
Marc Kupietz7bd55232019-01-22 15:29:06 +010089 $("#mi_tt").attr("title",$("#pmi_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010090 $("#lfmd_tt").attr("title",$("#lfmd_ttt").html());
Marc Kupietz7bd55232019-01-22 15:29:06 +010091 $("#md_tt").attr("title",$("#md_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010092 $("#npmi_tt").attr("title",$("#npmi_ttt").html());
Marc Kupietzf19814b2019-01-21 16:50:19 +010093 $("#ll_tt").attr("title",$("#ll_ttt").html());
Marc Kupietz7bd55232019-01-22 15:29:06 +010094 $("#logdice_tt").attr("title",$("#logdice_ttt").html());
Marc Kupietz63b268f2019-01-22 22:34:29 +010095 $("#logdiceaf_tt").attr("title",$("#logdiceaf_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010096 }
97 );
98 });
99
100 //set things up so that we can shove raw html into what is shown in the tooltip;
101 // in this case, we will have already put into the title attribute the html that
102 // contains the MathJax rendered equations (via what we do in the callback).
103 $(function () {
104 $(document).tooltip({
105 content: function () {
106 return $(this).prop('title');
107 }
108 });
109 });
110
Marc Kupietze6a7a732018-01-12 09:21:08 +0100111 $("input").bind("keydown", function(event) {
112 // track enter key
113 var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
114 if (keycode == 13) { // keycode for enter key
115 // force the 'Enter Key' to implicitly click the Update button
116 document.getElementById('SEARCH').click();
117 return false;
118 } else {
119 return true;
120 }});
Marc Kupietzdab9f222017-11-29 14:22:59 +0100121
Marc Kupietze871abd2018-01-25 16:18:27 +0100122 var collocatorTable_activated = false;
Marc Kupietze6a7a732018-01-12 09:21:08 +0100123 $( "#tabs" ).on( "tabsactivate", function( event, ui ) {
124 if (localStorage) localStorage['tab'] = ui.newTab.index();
Marc Kupietz565274e2026-09-06 13:17:17 +0200125 if(ui.newTab.index() == 3 && !collocatorTable_activated && collocatorTable) {
126 if (classicCollocatorTable) classicCollocatorTable.columns.adjust();
Marc Kupietze871abd2018-01-25 16:18:27 +0100127 collocatorTable.columns.adjust();
128 collocatorTable_activated = true;
129 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100130 });
131
132 $(function(){
133 $("#SEARCH").click(function() {
134 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietz58270662017-12-04 12:10:06 +0100135 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100136 });
Marc Kupietz0af83e32017-11-27 09:31:37 +0100137
Marc Kupietze6a7a732018-01-12 09:21:08 +0100138 function changeCharColor(txt, heat, word) {
139 var newText = "";
140 for (var i=0, l=txt.length; i<l; i++) {
Marc Kupietz49c5cf02024-08-06 10:30:44 +0200141 newText += (i == 5 ? txt.charAt(i) : "<a href=\"<%= $korap_url %>" + korapPath + '/?ql=cosmas2&q=' +
Marc Kupietze6a7a732018-01-12 09:21:08 +0100142 CIIsearchWords + ' /' + (i > 5? '%2B' : '-') + 'w' +
Rainer Perkuhne58a7492024-07-30 15:17:52 +0200143 Math.abs(i-5) + ':' + Math.abs(i-5) + ',s0 ' + word + korapVC +
Marc Kupietze6a7a732018-01-12 09:21:08 +0100144 '" target="korap"><span style="background-color:' +
145 getHeatColor(heat[i]/maxHeat)+'">'+txt.charAt(i)+'</span></a>');
Marc Kupietzb6c615d2017-12-02 10:38:20 +0100146 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100147 return newText;
148 }
Marc Kupietzb6c615d2017-12-02 10:38:20 +0100149
Marc Kupietze6a7a732018-01-12 09:21:08 +0100150 function getHeatColor(value) {
151 var hue=((1-value)*120).toString(10);
152 return ["hsl(",hue,",90%,70%)"].join("");
153 }
154
155 function bitvec2window(n, heat, word) {
156 var str = n.toString(2).padStart(10, "0")
157 .replace(/^([0-9]{5})/, '$1x')
158 .replace(/0/g, '·')
159 .replace(/1/g, '+');
160 return changeCharColor(str, heat, word);
161 }
162
Marc Kupietze6a7a732018-01-12 09:21:08 +0100163 var paraResults = <%= b(Mojo::JSON::to_json($lists)) %>;
164 var urlprefix = new URLSearchParams(window.location.search);
Marc Kupietz565274e2026-09-06 13:17:17 +0200165 if (paraResults.length > 0 && paraResults[0] != null && paraResults[0].length > 0) {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100166 var nvecs = [],
167 nwords = [],
168 nranks = [],
169 nmarked = [];
170 for(var i = 0; i < paraResults.length; i++) {
171 nwords = nwords.concat(paraResults[i].map(function(a){return a.word;}));
172 nvecs = nvecs.concat(paraResults[i].map(function(a){return a.vector;}));
173 nranks = nranks.concat(paraResults[i].map(function(a){return a.rank;}));
174 nmarked = nmarked.concat(paraResults[i].map(function(a){return a.marked;}));
Marc Kupietz0d4c0ca2017-12-04 09:18:56 +0100175 }
Marc Kupietz565274e2026-09-06 13:17:17 +0200176 showMap({target: targetWords, mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked} );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100177 var t = $('#firsttable').DataTable({
Marc Kupietzee894d52019-01-09 14:55:14 +0100178 data: [].concat.apply([], paraResults),
Marc Kupietze6a7a732018-01-12 09:21:08 +0100179 "sScrollY": "780px",
180 "bScrollCollapse": true,
181 "bPaginate": false,
182 "bJQueryUI": true,
Marc Kupietz898e5482024-02-20 15:03:07 +0100183 "dom": '<"top">rt<"bottom"flpB><"clear">',
184 buttons: [
185 { extend: 'copyHtml5', text: '<i class="fa fa-files-o"></i>', titleAttr: 'Copy' },
186 { extend: 'csvHtml5', text: '<i class="fa fa-file-text-o"></i>', titleAttr: 'CSV', filename: currentWords+'_para_neighbours' },
187 { extend: 'excelHtml5', text: '<i class="fa fa-file-excel-o"></i>', titleAttr: 'Excel', filename: currentWords+'_para_neighbours', exportOptions: { columns: ':visible' } ,
188 }
189 ],
Marc Kupietz384c9132018-03-19 16:45:24 +0100190 "initComplete":function(settings, json) {
191 $('td.paradigmator a').on('mousedown', function(e) {
Marc Kupietz86b50292019-02-17 21:03:59 +0100192 return paradigmatorClick(e, paraResults[0][0].word, this.childNodes["0"].textContent);
Marc Kupietz384c9132018-03-19 16:45:24 +0100193 });
194 },
Marc Kupietze6a7a732018-01-12 09:21:08 +0100195 "columns": [
196 { "data": "rank", type: "allnumeric" },
197 { "data": "dist", render: function ( data, type, row ) {return data.toFixed(3) }},
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100198 { "data": "word", class: "paradigmator", render: function ( data, type, row ) {
199 urlprefix.set("word", data); return '<a class="' + getMergedClass(row.rank) + '" href="?' + urlprefix + '">' + data + '</a>'
200 }}
Marc Kupietze6a7a732018-01-12 09:21:08 +0100201 ],
202 "columnDefs": [
203 { className: "dt-right", "targets": [0,1] },
204 { "searchable": false,
205 "orderable": false,
206 "targets": 0
207 },
208 { "orderSequence": [ "desc" ], "targets": [ 1 ] },
209 { "orderSequence": [ "asc", "desc" ], "targets": [ 2 ] },
210 ],
211 "oLanguage": {
212 "sSearch": "Filter: "
213 },
214 "order": [[ 1, 'desc' ]],
215 } );
Marc Kupietz0d4c0ca2017-12-04 09:18:56 +0100216
Marc Kupietze6a7a732018-01-12 09:21:08 +0100217 t.on( 'order.dt search.dt', function () {
218 t.column(0, {order:'applied'}).nodes().each( function (cell, i) {
219 cell.innerHTML = i+1;
220 } );
221 } ).draw();
222
223 $( "#first" ).clone().prependTo( "#tabs-2" );
224
225 }
226
227
228 var collocatorData = <%= b(Mojo::JSON::to_json($collocators)) %>;
229 var maxHeat; // = Math.max.apply(Math,collocatorData.map(function(o){return o.cprob;}))
230
Marc Kupietzcddc8482019-12-04 08:57:33 +0100231 if(typeof data !== 'undefined' && data.mergedEnd > 0) {
Marc Kupietz78230872019-08-02 15:15:25 +0200232 vocabDistanceTable = makeVocabDistanceTable("#vocabdistt", baseURL);
233 }
Marc Kupietzd7760b42019-02-21 09:01:44 +0100234
Marc Kupietze6a7a732018-01-12 09:21:08 +0100235 if (collocatorData != null) {
236 maxHeat = Math.max.apply(Math,collocatorData.map(function(o){return Math.max.apply(Math,o.heat);}))
237 collocatorTable = $('#secondtable').DataTable({
238 data: collocatorData,
239 "sScrollY": "780px",
240 "bScrollCollapse": true,
241 "bPaginate": false,
242 "bJQueryUI": true,
Marc Kupietz898e5482024-02-20 15:03:07 +0100243 "dom": '<"top">rt<"bottom"flpB><"clear">',
244 buttons: [
245 { extend: 'copyHtml5', text: '<i class="fa fa-files-o"></i>', titleAttr: 'Copy' },
246 { extend: 'csvHtml5', text: '<i class="fa fa-file-text-o"></i>', titleAttr: 'CSV', filename: currentWords+'_syn_neighbours' },
247 { extend: 'excelHtml5', text: '<i class="fa fa-file-excel-o"></i>', titleAttr: 'Excel', filename: currentWords+'_syn_neighbours', exportOptions: { columns: ':visible' } ,
248 }
249 ],
250 "columns": [
Marc Kupietze6a7a732018-01-12 09:21:08 +0100251 { "data": "rank", type: "allnumeric" },
252 { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
253 { "data": "max", render: function ( data, type, row ) {return data.toFixed(3) }},
254 { "data": "average", render: function ( data, type, row ) {return data.toFixed(3) }},
255 { "data": "prob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
256 { "data": "cprob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
257 { "data": "overall", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
258 { "data": "word", sClass: "collocator" },
259 { "data": "rank", type: "allnumeric" }
260 ],
261 "columnDefs": [
262 { className: "dt-right", "targets": [0,2,3,4,5,6] },
263 { className: "dt-center", "targets": [ 1] },
264 { "searchable": false,
265 "orderable": false,
266 "targets": [0, 8]
267 },
268 { "type": "scientific", targets: [2,3,4,5,6] },
269 { "orderSequence": [ "desc" ], "targets": [ 2, 3, 4, 5, 6 ] },
270 { "orderSequence": [ "asc", "desc" ], "targets": [ 1, 7 ] },
271 { "targets": [8], "visible": false }
272 ],
273 "oLanguage": {
274 "sSearch": "Filter: "
275 },
276 "order": [[ 4, 'desc' ]],
277 } );
278 $.ajaxSetup({
279 type: 'POST',
280 timeout: 30000,
281 error: function(xhr) {
282 $('#display_error')
283 .html('Error: ' + xhr.status + ' ' + xhr.statusText);
284 }
Marc Kupietz78b434a2018-01-12 22:33:32 +0100285 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100286
Marc Kupietz384c9132018-03-19 16:45:24 +0100287
288 if($('#sprofiles').length) {
289 similarProfileTable = $('#sprofiles').DataTable({
290 ajax: {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100291 method: "GET",
Marc Kupietz384c9132018-03-19 16:45:24 +0100292 url: '/derekovecs/getSimilarProfiles',
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100293 dataType: 'json',
294 dataSrc: "",
295 timeout: 30000,
296 data: { w: paraResults[0][0].rank }
Marc Kupietz384c9132018-03-19 16:45:24 +0100297 },
298 "initComplete":function(settings, json){
299 $('td.paradigmator a').on('mousedown', function(e) {
300 if (e.which === 2) {
301 e.preventDefault();
302 queryKorAPalternatives(paraResults[0][0].word, this.childNodes["0"].textContent);
303 return false;
304 }
305 });
306 },
307 "sScrollY": "780px",
308 "bScrollCollapse": true,
309 "bPaginate": false,
310 "bJQueryUI": true,
311 "dom": '<"top">rt<"bottom"flp><"clear">',
Marc Kupietz898e5482024-02-20 15:03:07 +0100312 "columns": [
Marc Kupietz384c9132018-03-19 16:45:24 +0100313 { "data": "v", render: function ( data, type, row ) {return data.toFixed(3) }},
314 { "data": "w", sClass: "paradigmator", render: function ( data, type, row ) {urlprefix.set("word", data); return '<a href="?' + urlprefix + '">' + data + '</a>' } }
315 ],
316 "columnDefs": [
317 { className: "dt-right", "targets": [0] },
318 ],
319 "oLanguage": {
320 "sSearch": "Filter: "
321 },
322 "order": [[ 0, 'desc' ]],
323 });
324 }
Marc Kupietzd7760b42019-02-21 09:01:44 +0100325
Marc Kupietz384c9132018-03-19 16:45:24 +0100326 // var filterQuot = /(^quot?=[A-Z])|(quot$)/g;
327 var filterQuot = /^quot/;
Marc Kupietz4784fae2019-02-04 12:32:12 +0100328 var ccResult;
Marc Kupietz86b50292019-02-17 21:03:59 +0100329 var baseURL = window.location.pathname.replace(/[/]$/, '')
Marc Kupietz565274e2026-09-06 13:17:17 +0200330 // Only for a one word query: the node of a count based profile is a
331 // word, and paraResults[0][0] is the nearest word to the query
332 // vector, which is not what was asked for.
333 if (singleWord) {
334 classicCollocatorTable = makeClassicCollocatorTable('#classicoloctable', baseURL, paraResults[0][0].rank)
Marc Kupietze6a7a732018-01-12 09:21:08 +0100335
Marc Kupietz565274e2026-09-06 13:17:17 +0200336 $('#show-details').change(function (e) {
337 var columns = classicCollocatorTable.columns(".detail");
338 if(this.checked) {
339 columns.visible(true);
340 $("#ccd").css('width', 'auto');
341 } else {
342 columns.visible(false);
343 $("#ccd").css('width', '680px');
344 }
345 classicCollocatorTable.columns.adjust().draw();
346 } );
347 }
Marc Kupietz1acb3172018-02-17 09:41:26 +0100348
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100349 $("td.collocator").click(function(){
Rainer Perkuhnd5010ec2024-07-30 14:38:25 +0200350 queryKorAPCII(this.textContent + " /w1:5,s0 " + CIIsearchWords);
Marc Kupietzad783722018-01-13 17:45:21 +0100351 });
352
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100353 collocatorTable.on( 'order.dt search.dt', function () {
354 collocatorTable.column(0, {order:'applied'}).nodes().each( function (cell, i) {
355 cell.innerHTML = i+1;
356 } );
357 }).draw();
358 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100359
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100360 if (localStorage && !window.location.hash) { // let's not crash if some user has IE7
361 var index = parseInt(localStorage['tab']||'0');
362 $("#tabs").tabs({ active: index });
363 }
364 $("#tabs").css("visibility", "visible"); // now we can show the tabs
365 });
Marc Kupietz58270662017-12-04 12:10:06 +0100366
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100367 $(function(){
368 $("#dropdownoptions").dialog({
Marc Kupietz95104512019-12-05 10:13:05 +0100369 title: "<%= loc 'Options' %>",
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100370 autoOpen: false,
371 modal: false,
372 draggable: false,
373 height: "auto",
374 width: "auto",
375 resizable: false,
376 buttons: {
Marc Kupietz95104512019-12-05 10:13:05 +0100377 "<%= loc 'Cancel'%>": function() {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100378 $( this ).dialog( "close" );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100379 },
Marc Kupietz95104512019-12-05 10:13:05 +0100380 "<%= loc 'Apply' %>": function() {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100381 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietze6a7a732018-01-12 09:21:08 +0100382 }
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100383 }
384 });
385 });
386
387 $(function(){
388 $("#showoptions").click(function(){
389 $("#dropdownoptions").dialog("open");
390 var target = $(this);
391 $("#dropdownoptions").dialog("widget").position({
392 my: 'left bottom',
393 at: 'left bottom',
394 of: target
Marc Kupietz58270662017-12-04 12:10:06 +0100395 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100396 });
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100397 });
398
399 $( function() {
400 $( "#no_iterations" ).spinner({
401 spin: function( event, ui ) {
402 if ( ui.value < 1000 ) {
403 $( this ).spinner( "value", 1000 );
404 return false;
405 } else if ( ui.value > 10000 ) {
406 $( this ).spinner( "value", 10000 );
407 return false;
408 }
409 }
410 });
411 } );
412
413 $( function() {
414 $( "#neighbours" ).spinner({
415 spin: function( event, ui ) {
416 if ( ui.value < 0 ) {
417 $( this ).spinner( "value", 0 );
418 return false;
419 } else if ( ui.value > 200 ) {
420 $( this ).spinner( "value", 200 );
421 return false;
422 }
423 }
424 });
425 } );
426
427 $( function() {
428 $( "#cutoff" ).spinner({
429 spin: function( event, ui ) {
430 if ( ui.value < 100000 ) {
431 $( this ).spinner( "value", 100000 );
432 return false;
433 } else if ( ui.value > 2000000 ) {
434 $( this ).spinner( "value", 2000000 );
435 return false;
436 }
437 }
438 });
439 } );
440
441 $( function() {
442 $( "#tabs" ).tabs().addClass('tabs-min');
443 } );
444
445 $( function() {
446 $( ".controlgroup-vertical" ).controlgroup({
447 "direction": "vertical"
448 });
449 } );
450
451 $(function() {
452 $( document ).tooltip({
453 content: function() {
454 return $(this).attr('title');
455 }}
456 )
457 });
458
459 $(function () {
460 $(document).tooltip({
461 content: function () {
462 return $(this).prop('title');
463 },
464 show: null,
465 close: function (event, ui) {
466 ui.tooltip.hover(
467 function () {
468 $(this).stop(true).fadeTo(400, 1);
469 },
470 function () {
471 $(this).fadeOut("400", function () {
472 $(this).remove();
473 })
474 });
475 }
476 });
477 });
Marc Kupietz83305222016-04-28 09:57:22 +0200478 </script>
Marc Kupietz58270662017-12-04 12:10:06 +0100479 <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
Marc Kupietz68e29be2023-11-04 18:37:35 +0100480 <script src="/derekovecs/js/calendar-events.js"></script>
Marc Kupietz58270662017-12-04 12:10:06 +0100481 <script src="/derekovecs/js/tsne.js"></script>
482 <script src="/derekovecs/js/som.js"></script>
483 <script src="/derekovecs/js/labeler.js"></script>
Marc K20476c72021-03-11 12:18:01 +0100484 <script src="/derekovecs/js/derekovecs.js"></script>
Marc Kupietz83305222016-04-28 09:57:22 +0200485 <script>
486
487 var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>},
Marc Kupietz58270662017-12-04 12:10:06 +0100488 mapWidth = 800, // width map
489 mapHeight = 800,
490 jitterRadius = 7;
Marc Kupietz83305222016-04-28 09:57:22 +0200491
492 var T = new tsnejs.tSNE(opt); // create a tSNE instance
493
494 var Y;
495
496 var data;
497 var labeler;
498
499 function applyJitter() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100500 svg.selectAll('.tsnet')
501 .data(labels)
502 .transition()
503 .duration(50)
504 .attr("transform", function(d, i) {
505 T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20;
506 T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20;
507 return "translate(" +
Marc Kupietz78230872019-08-02 15:15:25 +0200508 (d.x) + "," +
509 (d.y) + ")";
Marc Kupietze6a7a732018-01-12 09:21:08 +0100510 });
Marc Kupietz83305222016-04-28 09:57:22 +0200511 }
Marc Kupietz34c08172017-11-29 17:08:47 +0100512
Marc Kupietz83305222016-04-28 09:57:22 +0200513 function updateEmbedding() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100514 var Y = T.getSolution();
515 svg.selectAll('.tsnet')
516 .data(data.words)
517 .attr("transform", function(d, i) {
518 return "translate(" +
Marc Kupietz78230872019-08-02 15:15:25 +0200519 ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
520 ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
Marc Kupietz83305222016-04-28 09:57:22 +0200521 }
522
523 var svg;
524 var labels = [];
525 var anchor_array = [];
526 var text;
527
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100528 function getMergedClass(i) {
Marc Kupietzd7760b42019-02-21 09:01:44 +0100529 if(typeof data !== 'undefined' && i > data.mergedEnd) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100530 return " merged"
531 } else {
532 return "";
533 }
534 }
535
536 function getRankTooltip(i) {
537 if(data.mergedEnd) {
538 if(data.ranks[i] < data.mergedEnd) {
539 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
540 } else {
541 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]-data.mergedEnd).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)";
542 }
543 } else {
544 return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
545 }
546 }
547
Marc Kupietz83305222016-04-28 09:57:22 +0200548 function drawEmbedding() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100549 var urlprefix = new URLSearchParams(window.location.search);
550 urlprefix.delete("word");
551 urlprefix.append("word","");
Marc Kupietz8f9c86a2017-12-04 17:17:13 +0100552
Marc Kupietze6a7a732018-01-12 09:21:08 +0100553 $("#embed").empty();
554 var div = d3.select("#embed");
Marc Kupietz34c08172017-11-29 17:08:47 +0100555
Marc Kupietze6a7a732018-01-12 09:21:08 +0100556 // get min and max in each column of Y
557 var Y = T.Y;
Marc Kupietz34c08172017-11-29 17:08:47 +0100558
Marc Kupietze6a7a732018-01-12 09:21:08 +0100559 svg = div.append("svg") // svg is global
560 .attr("width", mapWidth)
561 .attr("height", mapHeight);
Marc Kupietz34c08172017-11-29 17:08:47 +0100562
Marc Kupietze6a7a732018-01-12 09:21:08 +0100563 var g = svg.selectAll(".b")
564 .data(data.words)
565 .enter().append("g")
566 .attr("class", "tsnet");
Marc Kupietz34c08172017-11-29 17:08:47 +0100567
Marc Kupietze6a7a732018-01-12 09:21:08 +0100568 g.append("a")
569 .attr("xlink:href", function(word) {
570 return "?"+urlprefix+word; })
571 .attr("class", function(d, i) {
572 var res="";
573 if(data.marked[i]) {
574 res="marked ";
575 }
576 if(data.target.indexOf(" "+d+" ") >= 0) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100577 res += "target";
578 }
579 if(data.mergedEnd && data.ranks[i] >= data.mergedEnd) {
580 return res+" merged";
Marc Kupietze6a7a732018-01-12 09:21:08 +0100581 } else {
582 return res;
583 }
584 })
585 .attr("title", function(d, i) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100586 return getRankTooltip(i);
Marc Kupietze6a7a732018-01-12 09:21:08 +0100587 })
588 .append("text")
589 .attr("text-anchor", "top")
590 .attr("font-size", 12)
591 .text(function(d) { return d; });
Marc Kupietz34c08172017-11-29 17:08:47 +0100592
Marc Kupietz384c9132018-03-19 16:45:24 +0100593 g.append("svg:title")
594 .text(function(d, i) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100595 return getRankTooltip(i);
Marc Kupietz384c9132018-03-19 16:45:24 +0100596 });
597
Marc Kupietze6a7a732018-01-12 09:21:08 +0100598 var zoomListener = d3.behavior.zoom()
599 .scaleExtent([0.1, 10])
600 .center([0,0])
601 .on("zoom", zoomHandler);
602 zoomListener(svg);
Marc Kupietz83305222016-04-28 09:57:22 +0200603 }
604
605 var tx=0, ty=0;
606 var ss=1;
607 var iter_id=-1;
608
609 function zoomHandler() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100610 tx = d3.event.translate[0];
611 ty = d3.event.translate[1];
612 ss = d3.event.scale;
613 updateEmbedding();
Marc Kupietz83305222016-04-28 09:57:22 +0200614 }
615
616 var stepnum = 0;
617
618 function stopStep() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100619 clearInterval(iter_id);
620 text = svg.selectAll("text");
Marc Kupietz34c08172017-11-29 17:08:47 +0100621
Marc Kupietze6a7a732018-01-12 09:21:08 +0100622 // jitter function needs different data and co-ordinate representation
623 labels = d3.range(data.words.length).map(function(i) {
624 var x = (T.Y[i][0]*20*ss + tx) + mapWidth/2;
625 var y = (T.Y[i][1]*20*ss + ty) + mapHeight/2;
626 anchor_array.push({x: x, y: y, r: jitterRadius});
627 return {
628 x: x,
629 y: y,
630 name: data.words[i]
631 };
632 });
Marc Kupietz34c08172017-11-29 17:08:47 +0100633
Marc Kupietze6a7a732018-01-12 09:21:08 +0100634 // get the actual label bounding boxes for the jitter function
635 var index = 0;
636 text.each(function() {
637 labels[index].width = this.getBBox().width;
638 labels[index].height = this.getBBox().height;
639 index += 1;
640 });
Marc Kupietz83305222016-04-28 09:57:22 +0200641
Marc Kupietz34c08172017-11-29 17:08:47 +0100642
Marc Kupietze6a7a732018-01-12 09:21:08 +0100643 // setTimeout(updateEmbedding, 1);
644 // setTimeout(
645 labeler = d3.labeler()
646 .label(labels)
647 .anchor(anchor_array)
648 .width(mapWidth)
649 .height(mapHeight)
650 .update(applyJitter);
651 // .start(1000);
Marc Kupietz83305222016-04-28 09:57:22 +0200652
Marc Kupietze6a7a732018-01-12 09:21:08 +0100653 iter_id = setInterval(jitterStep, 1);
Marc Kupietz83305222016-04-28 09:57:22 +0200654 }
655
656 var jitter_i=0;
657
658 function jitterStep() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100659 if(jitter_i++ > 100) {
660 clearInterval(iter_id);
661 } else {
662 labeler.start2(10);
663 applyJitter();
664 }
Marc Kupietz83305222016-04-28 09:57:22 +0200665 }
666
667 var last_cost=1000;
668
669 function step() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100670 var i = T.iter;
Marc Kupietz34c08172017-11-29 17:08:47 +0100671
Marc Kupietze6a7a732018-01-12 09:21:08 +0100672 if(i > <%= $no_iterations %>) {
673 stopStep();
674 } else {
675 var cost = Math.round(T.step() * 100000) / 100000; // do a few steps
676 $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5));
677 if(i % 250 == 0 && cost >= last_cost) {
678 stopStep();
Marc Kupietz58270662017-12-04 12:10:06 +0100679 } else {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100680 last_cost = cost;
681 updateEmbedding();
Marc Kupietz58270662017-12-04 12:10:06 +0100682 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100683 }
Marc Kupietz83305222016-04-28 09:57:22 +0200684 }
685
686 function showMap(j) {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100687 data=j;
688 T.iter=0;
689 iter_id = -1;
690 last_cost=1000;
691 T.initDataRaw(data.vecs); // init embedding
692 drawEmbedding(); // draw initial embedding
Marc Kupietz78114532017-11-29 17:00:16 +0100693
Marc Kupietze6a7a732018-01-12 09:21:08 +0100694 if(iter_id >= 0) {
695 clearInterval(iter_id);
696 }
697 //T.debugGrad();
698 iter_id = setInterval(step, 1);
699 if(true) { // (<%= $show_som %>) {
700 makeSOM(j, <%= $no_iterations %>);
701 }
Marc Kupietz83305222016-04-28 09:57:22 +0200702 }
Marc Kupietz39179ab2017-07-04 16:28:06 +0200703 var queryword;
704
Marc Kupietz66bfd952017-12-11 09:59:45 +0100705 function showCollocatorSOM() {
Marc Kupietz86b50292019-02-17 21:03:59 +0100706 var baseURL = window.location.pathname.replace(/[/]$/, '')
Marc Kupietze6a7a732018-01-12 09:21:08 +0100707 if (collocatorTable) {
708 var ctableData = collocatorTable.rows().data();
709 var nwords = [],
710 nranks = [];
711 for (var i=0; i < ctableData.length && i < 100; i++) {
712 nranks.push(ctableData[i].rank);
713 nwords.push(ctableData[i].word);
Marc Kupietz66bfd952017-12-11 09:59:45 +0100714 }
Marc Kupietz86b50292019-02-17 21:03:59 +0100715 $.post(baseURL+'/getVecsByRanks',
Marc Kupietze6a7a732018-01-12 09:21:08 +0100716 JSON.stringify(nranks),
717 function(data, status){
Marc Kupietz565274e2026-09-06 13:17:17 +0200718 showMap({target: targetWords, mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: data, ranks: nranks, marked: Array(100).fill(false)} );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100719 }, 'json');
720 }
Marc Kupietz66bfd952017-12-11 09:59:45 +0100721 }
722
Marc Kupietz39179ab2017-07-04 16:28:06 +0200723 function onload() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100724 queryword = document.getElementById('word');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200725 }
726
727 function queryKorAP() {
Marc Kupietz49c5cf02024-08-06 10:30:44 +0200728 window.open("<%= $korap_url %>" + korapPath + '?q='+queryword.value+korapVC, 'KorAP');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200729 }
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100730
731 function queryKorAPCII(query) {
Marc Kupietz49c5cf02024-08-06 10:30:44 +0200732 window.open("<%= $korap_url %>" +korapPath + '?ql=cosmas2&q='+query+korapVC, 'KorAP');
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100733 }
Marc Kupietz49c5cf02024-08-06 10:30:44 +0200734
Marc Kupietz83305222016-04-28 09:57:22 +0200735 </script>
736 </head>
Marc Kupietz7b0e5de2019-01-31 12:49:32 +0100737 <body onload="onload()"> <div style="display:none;" id="pmi_ttt">Pointwise mutual information: $$\text{MI}=\text{MI}=\log_2\frac{p(w_1,w_2)}{p(w_1) p(w_2)}$$<p class="citation">Church, K. W. and Hanks, P. (1990): Word association norms, mutual information, and lexicography. Comput. Linguist. 16, 1 (March 1990), 22-29.</p></div>
738 <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>
739 <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>
740 <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>
741 <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>
742 <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>
743 <div style="display:none;" id="logdice_ttt">Log-Dice: $$14 + \log_2 \frac{2f_{1,2}}{f_1 + f_2}$$<p class="citation">Rychlý, Pavel (2008): <a href="http://www.fi.muni.cz/usr/sojka/download/raslan2008/13.pdf">A lexicographer-friendly association score.</a> In Proceedings of Recent Advances in Slavonic Natural Language Processing, RASLAN, 6–9, 2008</p></div>
Marc Kupietz1e00eb82026-09-04 16:38:30 +0200744 <div style="display:none;" id="logdiceaf_ttt">Log-Dice using "auto-focus", i.e. the highest value reached by any – not necessarily contiguous – selection \(S\) of positions: $$\max_S \left(14 + \log_2 \frac{2f_{1,2}(S)}{f_2 + f_1|S|}\right)$$ Dividing by the width of the selection makes the measure sensitive to how concentrated a pair is, which is what distinguishes actual collocations from words that merely occur in the same contexts. Note that LDaf is therefore not on the same scale as LD and can be higher or lower than it.</div>
Marc Kupietz6d7462c2019-12-05 10:16:38 +0100745 <div id="ids_logo">
746 <a href="http://www.ids-mannheim.de/" target="_blank"><img src="/derekovecs/img/IDS-neu_farbig.svg" alt="Leibniz-Institut für Deutsche Sprache"/></a>
747 </div>
748 <div id="header">
Marc Kupietz58270662017-12-04 12:10:06 +0100749 <div id="pagetitle">
Marc Kupietzc053d972019-01-10 10:41:51 +0100750 <h1>DeReKoVecs</h1>
751 <h2><%== $title %></h2>
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100752 </div>
Marc Kupietz58270662017-12-04 12:10:06 +0100753 <div id="options" class="widget">
754 <form id="queryform">
Marc Kupietz95104512019-12-05 10:13:05 +0100755 <input id="word" type="text" name="word" placeholder="<%= loc 'words_to_be_searched' %>" value="<%= $word %>"
756 title="<%= loc 'search_description' %>"/>
757 <input id="SEARCH" type="button" value="<%= loc 'SEARCH' %>">
758 <input type="button" id="showoptions" name="showoptions" value="<%= loc 'Options' %>" />
Marc Kupietz58270662017-12-04 12:10:06 +0100759 </form>
760 <div id="dropdownoptions" style="display: none">
761 <form id="optionsform">
762 <div class="controlgroup-vertical">
763 <label for="cutoff">cut-off</label>
764 <input id="cutoff" type="text" name="cutoff" size="10" value="<%= $cutoff %>" title="Only consider the most frequent x word forms.">
765 <label for="dedupe">dedupe</label>
766 <input id="dedupe" type="checkbox" name="dedupe" value="1" <%= ($dedupe ? "checked" : "") %> title="radically filter out any near-duplicates">
767 % if($mergedEnd > 0) {
768 <label for="sbf">backw.</label>
769 <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.">
770 % }
771 <label for="neighbours">max. neighbours:</label>
772 <input id="neighbours" size="4" name="n" value="<%= $no_nbs %>">
773 <label for="no_iterations">max. iterations</label>
774 <input id="no_iterations" name="N" size="4" value="<%= $no_iterations %>">
775 <!-- <label for="dosom">SOM</label>
776 <input id="dosom" type="checkbox" name="som" value="1" <%= ($show_som ? "checked" : "") %>> -->
777 % if($collocators) {
778 <label for="sortby">window/sort</label>
779 <select id="sortby" name="sort">
780 <option value="0" <%= ($sort!=1 && $sort!=2? "selected":"") %>>auto focus</option>
781 <!-- <option value="1" <%= ($sort==1? "selected":"") %>>any single position</option>
782 <option value="2" <%= ($sort==2? "selected":"") %>>whole window</option> -->
783 </select>
784 % }
785 <input type="button" value="→ KorAP" onclick="queryKorAP();" title="query word with KorAP"/>
Marc Kupietz1acb3172018-02-17 09:41:26 +0100786 <input id="show-details" type="checkbox" name="show-details" value="1" >
787 <label for="show-details">
788 Show details
789 </label>
Marc Kupietz58270662017-12-04 12:10:06 +0100790 </div>
791 </form>
792 </div>
793 </div>
794 </div>
Marc Kupietz565274e2026-09-06 13:17:17 +0200795 %# Operands that are not in the vocabulary are dropped from the query
796 %# vector, which for an expression like "König - Mannn + Frau" would
797 %# otherwise silently answer a different question.
798 % if($unknown ne '' && $have_results) {
799 <div id="unknownwords"><%= loc 'not_in_vocabulary' %> <span class="mono"><%= $unknown %></span></div>
800 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100801 <div id="topwrapper">
802 <div style="visibility: hidden;" id="tabs">
803 <ul>
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100804 % if (defined $word && $word ne '') {
805 % if($mergedEnd && $distantWords) {
806 <li><a href="#tabs-0" title="Cos offsets of the words furthest away from their position in the reference corpus."">Offsets</a></li>
807 % }
808 <li><a href="#tabs-1"><%= loc 'paradigmatic_tsne' %></a></li>
809 <li><a href="#tabs-2"><%= loc 'paradigmatic_som' %></a></li>
Marc Kupietz565274e2026-09-06 13:17:17 +0200810 %# No syntagmatic tab for a model without a .net file, i.e. without
811 %# the output weights the predictive collocators are read from.
812 % if($collocators) {
813 <li><a href="#tabs-3"><%= loc 'syntagmatic' %></a></li>
814 % }
Marc Kupietzd7760b42019-02-21 09:01:44 +0100815 % }
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100816 <li><a href="#tabs-4">Info</a></li>
Marc Kupietz58270662017-12-04 12:10:06 +0100817 </ul>
Marc Kupietzb6514dc2019-06-26 11:47:56 +0200818 % if($mergedEnd && $distantWords) {
Marc Kupietzd7760b42019-02-21 09:01:44 +0100819 <div id="tabs-0" style="display: flex; padding: 5px; flex-flow: row wrap;">
820 <div id="vocabdist" style="width: 230px; margin-bottom: 15px;">
821 <table class="display compact nowrap" id="vocabdistt">
822 <thead>
823 <tr>
Marc Kupietz95977002019-02-26 09:09:59 +0100824 <th align="right">#</th><th id="cosD" align="right">D<sub>cos</sub></th><th align="left">word</th>
Marc Kupietzd7760b42019-02-21 09:01:44 +0100825 </tr>
826 </thead>
827 <tbody>
828 <tr>
829 <td align="right">
Marc Kupietz95977002019-02-26 09:09:59 +0100830 </td>
Marc Kupietzd7760b42019-02-21 09:01:44 +0100831 <td align="right">
832 </td>
833 <td></td>
834 </tr>
835 </tbody>
836 </table>
837 </div>
838 </div>
Marc Kupietzb6514dc2019-06-26 11:47:56 +0200839 % }
Marc Kupietz384c9132018-03-19 16:45:24 +0100840 <div id="tabs-1" style="display: flex; padding: 5px; flex-flow: row wrap;">
Marc Kupietz565274e2026-09-06 13:17:17 +0200841 % if($have_results) {
Marc Kupietz58270662017-12-04 12:10:06 +0100842 <div id="wrapper">
Marc Kupietz384c9132018-03-19 16:45:24 +0100843 <div id="first" style="width: 230px; margin-bottom: 15px;">
Marc Kupietz58270662017-12-04 12:10:06 +0100844 <table class="display compact nowrap" id="firsttable">
845 <thead>
846 <tr>
Marc Kupietz95977002019-02-26 09:09:59 +0100847 <th align="right">#</th><th align="right">S<sub>cos</sub></th><th align="left">similars by w2v</th>
Marc Kupietz58270662017-12-04 12:10:06 +0100848 </tr>
849 </thead>
850 <tbody>
851 <tr>
852 <td align="right">
853 </td>
854 <td align="right">
855 </td>
856 <td></td>
857 </tr>
858 </tbody>
859 </table>
860 </div>
Marc Kupietza55a09a2018-07-06 13:30:30 +0200861 % if(0 && $haveSProfiles) {
Marc Kupietz384c9132018-03-19 16:45:24 +0100862 <div id="sprofilesdiv" style="width: 200px; padding-right: 10px;">
863 <table class="display compact nowrap" id="sprofiles">
864 <thead>
865 <tr>
866 <th align="right">cos</th><th align="left">similars by coll. profile</th>
867 </tr>
868 </thead>
869 <tbody>
870 <tr>
871 <td align="right">
872 </td>
873 <td></td>
874 </tr>
875 </tbody>
876 </table>
877 </div>
878 %}
Marc Kupietz81aeed22019-02-17 21:22:45 +0100879 <div id="second">
Marc Kupietz58270662017-12-04 12:10:06 +0100880 <div id="embed">
881 </div>
882 <div id="cost">
883 </div>
884 </div>
885 </div>
Marc Kupietz81aeed22019-02-17 21:22:45 +0100886 % } elsif($word !~ /^\s*$/) {
887 <div id="wrapper">
Marc Kupietz81aeed22019-02-17 21:22:45 +0100888 <script>
889 $( function() {
Marc Kupietzce6490b2019-12-06 11:05:40 +0100890 $( "<%== loc 'notfounddialog' %>").dialog({
Marc Kupietz81aeed22019-02-17 21:22:45 +0100891 autoOpen: true,
892 modal: true,
893 draggable: false,
894 height: "auto",
895 width: "auto",
896 resizable: false,
897 buttons: {
898 "OK": function() {
899 $( this ).dialog( "close" );
Marc Kupietzce6490b2019-12-06 11:05:40 +0100900 } /* ,
Marc Kupietz81aeed22019-02-17 21:22:45 +0100901 "Apply": function() {
902 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietzce6490b2019-12-06 11:05:40 +0100903 } */
Marc Kupietz81aeed22019-02-17 21:22:45 +0100904 }
905 });
906 });
907 </script>
Marc Kupietzce6490b2019-12-06 11:05:40 +0100908 <div id="not-found-dialog_de" style="display: none" title="Nicht gefunden">
909 <p>FEHLER: Konnte "<%= $word %>" nicht finden.</p>
910 <p>Wenn Sie der Meinung sind, dass es Vokabluar enthalten sein sollte, können Sie versuchen den Cut-Off-Parameter in den Optionen zu erhöhen.</p>
911 </div>
912 <div id="not-found-dialog_en" style="display: none" title="Not found">
913 <p>ERROR: "<%= $word %>" not found in vocabluary.</p>
914 <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>
915 </div>
Marc Kupietz81aeed22019-02-17 21:22:45 +0100916 </div>
Marc Kupietz384c9132018-03-19 16:45:24 +0100917 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100918 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100919 <div id="tabs-2" style="display: flex; padding: 5px; flex-flow: row wrap;">
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100920 % if(defined $word && $word ne "") {
921 <div id="som2" style="width: 800;">
922 <div id="sominfo1"><span id="somcolor1"> </span> <span id="somword1"> </span> <span id="somcolor2"> </span> <span id="somword2"> </span> <span id="somcolor3"> </span></div>
923 <div id="sominfo" style="text-align: right">SOM iteration <span id="iterations">0</span></div>
924 </div>
925 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100926 </div>
Marc Kupietz565274e2026-09-06 13:17:17 +0200927 % if($collocators) {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100928 <div id="tabs-3" style="display: flex; padding:5px; flex-flow: row wrap;">
929 <div style="margin-right: 20px; margin-bottom: 10px;" id="secondt">
Marc Kupietze6a7a732018-01-12 09:21:08 +0100930 <table class="display compact nowrap" id="secondtable">
Marc Kupietz58270662017-12-04 12:10:06 +0100931 <thead>
932 <tr>
933 % if($collocators) {
934 <th>#</th>
Marc Kupietz4116b432017-12-06 14:15:32 +0100935 <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>
936 <th align="right" title="Maximum activation of the collocator anywhere in the output layer.">max(a)</th>
937 <th title="Average raw activation of the collocator in the columns selected by auto-focus." align="right">⟨a⟩</th>
938 <th title="Sum of activations over the selected colunns normalized by the total activation sum of the selected columns." align="right">Σa/Σw'</th>
939 <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 +0100940 <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 Kupietz95104512019-12-05 10:13:05 +0100941 <th align="left"><%= loc 'collocate_w2v' %></th>
Marc Kupietz58270662017-12-04 12:10:06 +0100942 % }
943 </tr>
944 </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>
955 <td align="right">
956 </td>
957 <td align="right">
958 </td>
Marc Kupietz58270662017-12-04 12:10:06 +0100959 </tr>
960 </tbody>
961 </table>
Marc Kupietz66bfd952017-12-11 09:59:45 +0100962 </div>
Marc Kupietz565274e2026-09-06 13:17:17 +0200963 % if(!$single_word) {
964 <div id="ccd" class="notice"><%= loc 'ca_single_word_only' %></div>
965 % } else {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100966 <div id="ccd" style="">
Marc Kupietze6a7a732018-01-12 09:21:08 +0100967 <table class="display compact nowrap" id="classicoloctable">
968 <thead>
Marc Kupietzcd136e22018-01-29 09:18:12 +0100969 % if($collocators) {
970 <tr>
Marc Kupietzf19814b2019-01-21 16:50:19 +0100971 <th id="ll_tt">LL</th>
Marc Kupietzfab14a72019-01-22 16:20:29 +0100972 <th id="mi_tt">MI</th>
973 <th id="md_tt">MI²</th>
Marc Kupietzf19814b2019-01-21 16:50:19 +0100974 <th id="lfmd_tt">MI³</th>
Marc Kupietzfab14a72019-01-22 16:20:29 +0100975 <th id="npmi_tt">nPMI</th>
976 <th id="dice_tt">dice</th>
Marc Kupietz63b268f2019-01-22 22:34:29 +0100977 <th id="logdice_tt">LD</th>
978 <th id="logdiceaf_tt">LDaf</th>
Marc Kupietz001bffd2019-02-21 08:52:41 +0100979 <th id="delta_tt" title="Delta to log-Dice score in reference corpus. ⚠: If the collocate is not within the top 200 of the reference corpus, a reference value of min(lD)-0.1 is assumed.">Δ</th>
Marc Kupietz1e00eb82026-09-04 16:38:30 +0200980 <th id="af_win" title="Positions around the target word that are selected by the auto-focus function are marked with ◾. Positions at which the collocate appears at least once are marked with ◽. LL, MI, MI², MI³ and nPMI are computed over all positions marked here, the attested ones, rather than over the whole context window, so that a collocate occurring in few positions is rated higher than one spread over many. LD does not depend on any window; LDaf is the auto-focus score of the ◾ positions and is not on the same scale as LD."><span class="regular"><%= loc 'af_window' %></span></th>
Marc Kupietz5a7f9ac2018-01-30 11:22:44 +0100981 <th title="PMI³ restricted to left neighbour">l-PMI³</th>
982 <th title="PMI³ restricted to right neighbour">r-PMI³</th>
983 <th title="nPMI restricted to left neighbour">l-nPMI</th>
984 <th title="nPMI restricted to right neighbour">r-nPMI</th>
Marc Kupietz4784fae2019-02-04 12:32:12 +0100985 <th id="rawfreq_tt" title="raw frequency sum of collocation within window">raw</th>
Marc Kupietz95104512019-12-05 10:13:05 +0100986 <th><%= loc 'collocate_ca' %></th>
Marc Kupietzcd136e22018-01-29 09:18:12 +0100987 </tr>
Marc Kupietz1acb3172018-02-17 09:41:26 +0100988 % }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100989 </thead>
990 <tbody>
991 <tr>
Marc Kupietz63b268f2019-01-22 22:34:29 +0100992 <td align="right"></td>
993 <td align="right"></td>
994 <td align="right"></td>
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100995 <td align="right"></td>
Marc Kupietz78d7c1a2019-02-17 22:31:22 +0100996 <td align="right"></td>
997 <td align="right"></td>
998 <td align="right"></td>
999 <td align="right"></td>
1000 <td align="right"></td>
1001 <td align="left"> </td>
1002 <td align="right"></td>
1003 <td align="right"></td>
1004 <td align="right"></td>
1005 <td align="right"></td>
1006 <td align="left"> </td>
Marc Kupietze6a7a732018-01-12 09:21:08 +01001007 </tr>
1008 </tbody>
1009 </table>
1010 </div>
Marc Kupietz565274e2026-09-06 13:17:17 +02001011 % }
Marc Kupietz384c9132018-03-19 16:45:24 +01001012 <!--
1013 <div style="clear:both" ></div>
1014 <div style="float: right; overflow: hidden" id="extra"><button onClick="showCollocatorSOM()"> </button></div>
1015 -->
Marc Kupietz66bfd952017-12-11 09:59:45 +01001016 </div>
Marc Kupietz565274e2026-09-06 13:17:17 +02001017 % }
Marc Kupietzd6dfdf02019-12-06 09:53:34 +01001018 <div id="tabs-4" style="display: flex; padding:5px; flex-flow: row wrap;">
1019 <div id="info">
1020 <h3><%== loc 'about' %></h3>
1021 %= include(loc('abouttext'))
1022 % if($training_args && (@$lists)[0]) {
1023 <h3><%= loc 'training_parameters' %></h3>
1024 % if($training_args =~ /-type\s*3/) {
1025 <p>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:</p>
1026 <div class="mono"><%= $training_args %></div>
1027 % } else {
1028 <p>Calculations are based on a word embedding model trained with <a href="https://code.google.com/p/word2vec/">word2vec</a> using the following parameters:</p>
1029 <div class="mono"><%= $training_args %></div>
1030 % }
Marc Kupietz2133bd12022-05-19 09:24:42 +02001031 % }
1032 <h3>Source Code</h3>
1033 <ul>
Marc Kupietz5b8aaf72026-09-04 19:21:22 +02001034 <li><a href="https://github.com/kupietz/dereko2vec">dereko2vec</a></li>
1035 <li><a href="https://github.com/kupietz/collocatordb">collocatordb</a></li>
Marc Kupietz2133bd12022-05-19 09:24:42 +02001036 <li><a href="https://korap.ids-mannheim.de/gerrit/plugins/gitiles/ids-kl/derekovecs">derekovecs</a></li>
1037 </ul>
Marc Kupietzd6dfdf02019-12-06 09:53:34 +01001038 <h3><%== loc 'references' %></h3>
1039 %= include 'references'
1040 </div>
1041 </div>
1042 </div> <!-- tabs -->
Marc Kupietz58270662017-12-04 12:10:06 +01001043 </div> <!-- topwrapper -->
1044 <div style="clear: both;"></div>
1045 </div>
Marc Kupietzd6dfdf02019-12-06 09:53:34 +01001046 <div class="footer">
1047 <span class="footertext">
1048 %= include(loc('footer'))
1049 </span>
Marc Kupietzebea4702018-01-12 09:16:09 +01001050 </div>
Marc Kupietz58270662017-12-04 12:10:06 +01001051 </body>
Marc Kupietz83305222016-04-28 09:57:22 +02001052</html>