blob: ba2dde57b56956420fe86c79841ffa373e15576f [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) }},
Marc Kupietz21fcd5f2026-09-06 13:17:29 +0200254 %# Display rounding only; the sort needs the unrounded value.
255 { "data": "dot", render: function ( data, type, row ) {return type === 'display' ? data.toFixed(3) : data } },
Marc Kupietze6a7a732018-01-12 09:21:08 +0100256 { "data": "average", render: function ( data, type, row ) {return data.toFixed(3) }},
257 { "data": "prob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
258 { "data": "cprob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
259 { "data": "overall", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
260 { "data": "word", sClass: "collocator" },
261 { "data": "rank", type: "allnumeric" }
262 ],
263 "columnDefs": [
Marc Kupietz21fcd5f2026-09-06 13:17:29 +0200264 { className: "dt-right", "targets": [0,2,3,4,5,6,7] },
Marc Kupietze6a7a732018-01-12 09:21:08 +0100265 { className: "dt-center", "targets": [ 1] },
266 { "searchable": false,
267 "orderable": false,
Marc Kupietz21fcd5f2026-09-06 13:17:29 +0200268 "targets": [0, 9]
Marc Kupietze6a7a732018-01-12 09:21:08 +0100269 },
270 { "type": "scientific", targets: [2,3,4,5,6] },
Marc Kupietz21fcd5f2026-09-06 13:17:29 +0200271 { "orderSequence": [ "desc" ], "targets": [ 2, 3, 4, 5, 6, 7 ] },
272 { "orderSequence": [ "asc", "desc" ], "targets": [ 1, 8 ] },
273 { "targets": [9], "visible": false }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100274 ],
275 "oLanguage": {
276 "sSearch": "Filter: "
277 },
Marc Kupietz21fcd5f2026-09-06 13:17:29 +0200278 "order": [[ 5, 'desc' ]],
Marc Kupietze6a7a732018-01-12 09:21:08 +0100279 } );
280 $.ajaxSetup({
281 type: 'POST',
282 timeout: 30000,
283 error: function(xhr) {
284 $('#display_error')
285 .html('Error: ' + xhr.status + ' ' + xhr.statusText);
286 }
Marc Kupietz78b434a2018-01-12 22:33:32 +0100287 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100288
Marc Kupietz384c9132018-03-19 16:45:24 +0100289
290 if($('#sprofiles').length) {
291 similarProfileTable = $('#sprofiles').DataTable({
292 ajax: {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100293 method: "GET",
Marc Kupietz384c9132018-03-19 16:45:24 +0100294 url: '/derekovecs/getSimilarProfiles',
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100295 dataType: 'json',
296 dataSrc: "",
297 timeout: 30000,
298 data: { w: paraResults[0][0].rank }
Marc Kupietz384c9132018-03-19 16:45:24 +0100299 },
300 "initComplete":function(settings, json){
301 $('td.paradigmator a').on('mousedown', function(e) {
302 if (e.which === 2) {
303 e.preventDefault();
304 queryKorAPalternatives(paraResults[0][0].word, this.childNodes["0"].textContent);
305 return false;
306 }
307 });
308 },
309 "sScrollY": "780px",
310 "bScrollCollapse": true,
311 "bPaginate": false,
312 "bJQueryUI": true,
313 "dom": '<"top">rt<"bottom"flp><"clear">',
Marc Kupietz898e5482024-02-20 15:03:07 +0100314 "columns": [
Marc Kupietz384c9132018-03-19 16:45:24 +0100315 { "data": "v", render: function ( data, type, row ) {return data.toFixed(3) }},
316 { "data": "w", sClass: "paradigmator", render: function ( data, type, row ) {urlprefix.set("word", data); return '<a href="?' + urlprefix + '">' + data + '</a>' } }
317 ],
318 "columnDefs": [
319 { className: "dt-right", "targets": [0] },
320 ],
321 "oLanguage": {
322 "sSearch": "Filter: "
323 },
324 "order": [[ 0, 'desc' ]],
325 });
326 }
Marc Kupietzd7760b42019-02-21 09:01:44 +0100327
Marc Kupietz384c9132018-03-19 16:45:24 +0100328 // var filterQuot = /(^quot?=[A-Z])|(quot$)/g;
329 var filterQuot = /^quot/;
Marc Kupietz4784fae2019-02-04 12:32:12 +0100330 var ccResult;
Marc Kupietz86b50292019-02-17 21:03:59 +0100331 var baseURL = window.location.pathname.replace(/[/]$/, '')
Marc Kupietz565274e2026-09-06 13:17:17 +0200332 // Only for a one word query: the node of a count based profile is a
333 // word, and paraResults[0][0] is the nearest word to the query
334 // vector, which is not what was asked for.
335 if (singleWord) {
336 classicCollocatorTable = makeClassicCollocatorTable('#classicoloctable', baseURL, paraResults[0][0].rank)
Marc Kupietze6a7a732018-01-12 09:21:08 +0100337
Marc Kupietz565274e2026-09-06 13:17:17 +0200338 $('#show-details').change(function (e) {
339 var columns = classicCollocatorTable.columns(".detail");
340 if(this.checked) {
341 columns.visible(true);
342 $("#ccd").css('width', 'auto');
343 } else {
344 columns.visible(false);
345 $("#ccd").css('width', '680px');
346 }
347 classicCollocatorTable.columns.adjust().draw();
348 } );
349 }
Marc Kupietz1acb3172018-02-17 09:41:26 +0100350
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100351 $("td.collocator").click(function(){
Rainer Perkuhnd5010ec2024-07-30 14:38:25 +0200352 queryKorAPCII(this.textContent + " /w1:5,s0 " + CIIsearchWords);
Marc Kupietzad783722018-01-13 17:45:21 +0100353 });
354
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100355 collocatorTable.on( 'order.dt search.dt', function () {
356 collocatorTable.column(0, {order:'applied'}).nodes().each( function (cell, i) {
357 cell.innerHTML = i+1;
358 } );
359 }).draw();
360 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100361
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100362 if (localStorage && !window.location.hash) { // let's not crash if some user has IE7
363 var index = parseInt(localStorage['tab']||'0');
364 $("#tabs").tabs({ active: index });
365 }
366 $("#tabs").css("visibility", "visible"); // now we can show the tabs
367 });
Marc Kupietz58270662017-12-04 12:10:06 +0100368
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100369 $(function(){
370 $("#dropdownoptions").dialog({
Marc Kupietz95104512019-12-05 10:13:05 +0100371 title: "<%= loc 'Options' %>",
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100372 autoOpen: false,
373 modal: false,
374 draggable: false,
375 height: "auto",
376 width: "auto",
377 resizable: false,
378 buttons: {
Marc Kupietz95104512019-12-05 10:13:05 +0100379 "<%= loc 'Cancel'%>": function() {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100380 $( this ).dialog( "close" );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100381 },
Marc Kupietz95104512019-12-05 10:13:05 +0100382 "<%= loc 'Apply' %>": function() {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100383 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietze6a7a732018-01-12 09:21:08 +0100384 }
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100385 }
386 });
387 });
388
389 $(function(){
390 $("#showoptions").click(function(){
391 $("#dropdownoptions").dialog("open");
392 var target = $(this);
393 $("#dropdownoptions").dialog("widget").position({
394 my: 'left bottom',
395 at: 'left bottom',
396 of: target
Marc Kupietz58270662017-12-04 12:10:06 +0100397 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100398 });
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100399 });
400
401 $( function() {
402 $( "#no_iterations" ).spinner({
403 spin: function( event, ui ) {
404 if ( ui.value < 1000 ) {
405 $( this ).spinner( "value", 1000 );
406 return false;
407 } else if ( ui.value > 10000 ) {
408 $( this ).spinner( "value", 10000 );
409 return false;
410 }
411 }
412 });
413 } );
414
415 $( function() {
416 $( "#neighbours" ).spinner({
417 spin: function( event, ui ) {
418 if ( ui.value < 0 ) {
419 $( this ).spinner( "value", 0 );
420 return false;
421 } else if ( ui.value > 200 ) {
422 $( this ).spinner( "value", 200 );
423 return false;
424 }
425 }
426 });
427 } );
428
429 $( function() {
430 $( "#cutoff" ).spinner({
431 spin: function( event, ui ) {
432 if ( ui.value < 100000 ) {
433 $( this ).spinner( "value", 100000 );
434 return false;
435 } else if ( ui.value > 2000000 ) {
436 $( this ).spinner( "value", 2000000 );
437 return false;
438 }
439 }
440 });
441 } );
442
443 $( function() {
444 $( "#tabs" ).tabs().addClass('tabs-min');
445 } );
446
447 $( function() {
448 $( ".controlgroup-vertical" ).controlgroup({
449 "direction": "vertical"
450 });
451 } );
452
453 $(function() {
454 $( document ).tooltip({
455 content: function() {
456 return $(this).attr('title');
457 }}
458 )
459 });
460
461 $(function () {
462 $(document).tooltip({
463 content: function () {
464 return $(this).prop('title');
465 },
466 show: null,
467 close: function (event, ui) {
468 ui.tooltip.hover(
469 function () {
470 $(this).stop(true).fadeTo(400, 1);
471 },
472 function () {
473 $(this).fadeOut("400", function () {
474 $(this).remove();
475 })
476 });
477 }
478 });
479 });
Marc Kupietz83305222016-04-28 09:57:22 +0200480 </script>
Marc Kupietz58270662017-12-04 12:10:06 +0100481 <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
Marc Kupietz68e29be2023-11-04 18:37:35 +0100482 <script src="/derekovecs/js/calendar-events.js"></script>
Marc Kupietz58270662017-12-04 12:10:06 +0100483 <script src="/derekovecs/js/tsne.js"></script>
484 <script src="/derekovecs/js/som.js"></script>
485 <script src="/derekovecs/js/labeler.js"></script>
Marc K20476c72021-03-11 12:18:01 +0100486 <script src="/derekovecs/js/derekovecs.js"></script>
Marc Kupietz83305222016-04-28 09:57:22 +0200487 <script>
488
489 var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>},
Marc Kupietz58270662017-12-04 12:10:06 +0100490 mapWidth = 800, // width map
491 mapHeight = 800,
492 jitterRadius = 7;
Marc Kupietz83305222016-04-28 09:57:22 +0200493
494 var T = new tsnejs.tSNE(opt); // create a tSNE instance
495
496 var Y;
497
498 var data;
499 var labeler;
500
501 function applyJitter() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100502 svg.selectAll('.tsnet')
503 .data(labels)
504 .transition()
505 .duration(50)
506 .attr("transform", function(d, i) {
507 T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20;
508 T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20;
509 return "translate(" +
Marc Kupietz78230872019-08-02 15:15:25 +0200510 (d.x) + "," +
511 (d.y) + ")";
Marc Kupietze6a7a732018-01-12 09:21:08 +0100512 });
Marc Kupietz83305222016-04-28 09:57:22 +0200513 }
Marc Kupietz34c08172017-11-29 17:08:47 +0100514
Marc Kupietz83305222016-04-28 09:57:22 +0200515 function updateEmbedding() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100516 var Y = T.getSolution();
517 svg.selectAll('.tsnet')
518 .data(data.words)
519 .attr("transform", function(d, i) {
520 return "translate(" +
Marc Kupietz78230872019-08-02 15:15:25 +0200521 ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
522 ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
Marc Kupietz83305222016-04-28 09:57:22 +0200523 }
524
525 var svg;
526 var labels = [];
527 var anchor_array = [];
528 var text;
529
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100530 function getMergedClass(i) {
Marc Kupietzd7760b42019-02-21 09:01:44 +0100531 if(typeof data !== 'undefined' && i > data.mergedEnd) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100532 return " merged"
533 } else {
534 return "";
535 }
536 }
537
538 function getRankTooltip(i) {
539 if(data.mergedEnd) {
540 if(data.ranks[i] < data.mergedEnd) {
541 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
542 } else {
543 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]-data.mergedEnd).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)";
544 }
545 } else {
546 return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
547 }
548 }
549
Marc Kupietz83305222016-04-28 09:57:22 +0200550 function drawEmbedding() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100551 var urlprefix = new URLSearchParams(window.location.search);
552 urlprefix.delete("word");
553 urlprefix.append("word","");
Marc Kupietz8f9c86a2017-12-04 17:17:13 +0100554
Marc Kupietze6a7a732018-01-12 09:21:08 +0100555 $("#embed").empty();
556 var div = d3.select("#embed");
Marc Kupietz34c08172017-11-29 17:08:47 +0100557
Marc Kupietze6a7a732018-01-12 09:21:08 +0100558 // get min and max in each column of Y
559 var Y = T.Y;
Marc Kupietz34c08172017-11-29 17:08:47 +0100560
Marc Kupietze6a7a732018-01-12 09:21:08 +0100561 svg = div.append("svg") // svg is global
562 .attr("width", mapWidth)
563 .attr("height", mapHeight);
Marc Kupietz34c08172017-11-29 17:08:47 +0100564
Marc Kupietze6a7a732018-01-12 09:21:08 +0100565 var g = svg.selectAll(".b")
566 .data(data.words)
567 .enter().append("g")
568 .attr("class", "tsnet");
Marc Kupietz34c08172017-11-29 17:08:47 +0100569
Marc Kupietze6a7a732018-01-12 09:21:08 +0100570 g.append("a")
571 .attr("xlink:href", function(word) {
572 return "?"+urlprefix+word; })
573 .attr("class", function(d, i) {
574 var res="";
575 if(data.marked[i]) {
576 res="marked ";
577 }
578 if(data.target.indexOf(" "+d+" ") >= 0) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100579 res += "target";
580 }
581 if(data.mergedEnd && data.ranks[i] >= data.mergedEnd) {
582 return res+" merged";
Marc Kupietze6a7a732018-01-12 09:21:08 +0100583 } else {
584 return res;
585 }
586 })
587 .attr("title", function(d, i) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100588 return getRankTooltip(i);
Marc Kupietze6a7a732018-01-12 09:21:08 +0100589 })
590 .append("text")
591 .attr("text-anchor", "top")
592 .attr("font-size", 12)
593 .text(function(d) { return d; });
Marc Kupietz34c08172017-11-29 17:08:47 +0100594
Marc Kupietz384c9132018-03-19 16:45:24 +0100595 g.append("svg:title")
596 .text(function(d, i) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100597 return getRankTooltip(i);
Marc Kupietz384c9132018-03-19 16:45:24 +0100598 });
599
Marc Kupietze6a7a732018-01-12 09:21:08 +0100600 var zoomListener = d3.behavior.zoom()
601 .scaleExtent([0.1, 10])
602 .center([0,0])
603 .on("zoom", zoomHandler);
604 zoomListener(svg);
Marc Kupietz83305222016-04-28 09:57:22 +0200605 }
606
607 var tx=0, ty=0;
608 var ss=1;
609 var iter_id=-1;
610
611 function zoomHandler() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100612 tx = d3.event.translate[0];
613 ty = d3.event.translate[1];
614 ss = d3.event.scale;
615 updateEmbedding();
Marc Kupietz83305222016-04-28 09:57:22 +0200616 }
617
618 var stepnum = 0;
619
620 function stopStep() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100621 clearInterval(iter_id);
622 text = svg.selectAll("text");
Marc Kupietz34c08172017-11-29 17:08:47 +0100623
Marc Kupietze6a7a732018-01-12 09:21:08 +0100624 // jitter function needs different data and co-ordinate representation
625 labels = d3.range(data.words.length).map(function(i) {
626 var x = (T.Y[i][0]*20*ss + tx) + mapWidth/2;
627 var y = (T.Y[i][1]*20*ss + ty) + mapHeight/2;
628 anchor_array.push({x: x, y: y, r: jitterRadius});
629 return {
630 x: x,
631 y: y,
632 name: data.words[i]
633 };
634 });
Marc Kupietz34c08172017-11-29 17:08:47 +0100635
Marc Kupietze6a7a732018-01-12 09:21:08 +0100636 // get the actual label bounding boxes for the jitter function
637 var index = 0;
638 text.each(function() {
639 labels[index].width = this.getBBox().width;
640 labels[index].height = this.getBBox().height;
641 index += 1;
642 });
Marc Kupietz83305222016-04-28 09:57:22 +0200643
Marc Kupietz34c08172017-11-29 17:08:47 +0100644
Marc Kupietze6a7a732018-01-12 09:21:08 +0100645 // setTimeout(updateEmbedding, 1);
646 // setTimeout(
647 labeler = d3.labeler()
648 .label(labels)
649 .anchor(anchor_array)
650 .width(mapWidth)
651 .height(mapHeight)
652 .update(applyJitter);
653 // .start(1000);
Marc Kupietz83305222016-04-28 09:57:22 +0200654
Marc Kupietze6a7a732018-01-12 09:21:08 +0100655 iter_id = setInterval(jitterStep, 1);
Marc Kupietz83305222016-04-28 09:57:22 +0200656 }
657
658 var jitter_i=0;
659
660 function jitterStep() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100661 if(jitter_i++ > 100) {
662 clearInterval(iter_id);
663 } else {
664 labeler.start2(10);
665 applyJitter();
666 }
Marc Kupietz83305222016-04-28 09:57:22 +0200667 }
668
669 var last_cost=1000;
670
671 function step() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100672 var i = T.iter;
Marc Kupietz34c08172017-11-29 17:08:47 +0100673
Marc Kupietze6a7a732018-01-12 09:21:08 +0100674 if(i > <%= $no_iterations %>) {
675 stopStep();
676 } else {
677 var cost = Math.round(T.step() * 100000) / 100000; // do a few steps
678 $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5));
679 if(i % 250 == 0 && cost >= last_cost) {
680 stopStep();
Marc Kupietz58270662017-12-04 12:10:06 +0100681 } else {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100682 last_cost = cost;
683 updateEmbedding();
Marc Kupietz58270662017-12-04 12:10:06 +0100684 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100685 }
Marc Kupietz83305222016-04-28 09:57:22 +0200686 }
687
688 function showMap(j) {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100689 data=j;
690 T.iter=0;
691 iter_id = -1;
692 last_cost=1000;
693 T.initDataRaw(data.vecs); // init embedding
694 drawEmbedding(); // draw initial embedding
Marc Kupietz78114532017-11-29 17:00:16 +0100695
Marc Kupietze6a7a732018-01-12 09:21:08 +0100696 if(iter_id >= 0) {
697 clearInterval(iter_id);
698 }
699 //T.debugGrad();
700 iter_id = setInterval(step, 1);
701 if(true) { // (<%= $show_som %>) {
702 makeSOM(j, <%= $no_iterations %>);
703 }
Marc Kupietz83305222016-04-28 09:57:22 +0200704 }
Marc Kupietz39179ab2017-07-04 16:28:06 +0200705 var queryword;
706
Marc Kupietz66bfd952017-12-11 09:59:45 +0100707 function showCollocatorSOM() {
Marc Kupietz86b50292019-02-17 21:03:59 +0100708 var baseURL = window.location.pathname.replace(/[/]$/, '')
Marc Kupietze6a7a732018-01-12 09:21:08 +0100709 if (collocatorTable) {
710 var ctableData = collocatorTable.rows().data();
711 var nwords = [],
712 nranks = [];
713 for (var i=0; i < ctableData.length && i < 100; i++) {
714 nranks.push(ctableData[i].rank);
715 nwords.push(ctableData[i].word);
Marc Kupietz66bfd952017-12-11 09:59:45 +0100716 }
Marc Kupietz86b50292019-02-17 21:03:59 +0100717 $.post(baseURL+'/getVecsByRanks',
Marc Kupietze6a7a732018-01-12 09:21:08 +0100718 JSON.stringify(nranks),
719 function(data, status){
Marc Kupietz565274e2026-09-06 13:17:17 +0200720 showMap({target: targetWords, mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: data, ranks: nranks, marked: Array(100).fill(false)} );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100721 }, 'json');
722 }
Marc Kupietz66bfd952017-12-11 09:59:45 +0100723 }
724
Marc Kupietz39179ab2017-07-04 16:28:06 +0200725 function onload() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100726 queryword = document.getElementById('word');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200727 }
728
729 function queryKorAP() {
Marc Kupietz49c5cf02024-08-06 10:30:44 +0200730 window.open("<%= $korap_url %>" + korapPath + '?q='+queryword.value+korapVC, 'KorAP');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200731 }
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100732
733 function queryKorAPCII(query) {
Marc Kupietz49c5cf02024-08-06 10:30:44 +0200734 window.open("<%= $korap_url %>" +korapPath + '?ql=cosmas2&q='+query+korapVC, 'KorAP');
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100735 }
Marc Kupietz49c5cf02024-08-06 10:30:44 +0200736
Marc Kupietz83305222016-04-28 09:57:22 +0200737 </script>
738 </head>
Marc Kupietz7b0e5de2019-01-31 12:49:32 +0100739 <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>
740 <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>
741 <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>
742 <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>
743 <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>
744 <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>
745 <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 +0200746 <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 +0100747 <div id="ids_logo">
748 <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>
749 </div>
750 <div id="header">
Marc Kupietz58270662017-12-04 12:10:06 +0100751 <div id="pagetitle">
Marc Kupietzc053d972019-01-10 10:41:51 +0100752 <h1>DeReKoVecs</h1>
753 <h2><%== $title %></h2>
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100754 </div>
Marc Kupietz58270662017-12-04 12:10:06 +0100755 <div id="options" class="widget">
756 <form id="queryform">
Marc Kupietz95104512019-12-05 10:13:05 +0100757 <input id="word" type="text" name="word" placeholder="<%= loc 'words_to_be_searched' %>" value="<%= $word %>"
758 title="<%= loc 'search_description' %>"/>
759 <input id="SEARCH" type="button" value="<%= loc 'SEARCH' %>">
760 <input type="button" id="showoptions" name="showoptions" value="<%= loc 'Options' %>" />
Marc Kupietz58270662017-12-04 12:10:06 +0100761 </form>
762 <div id="dropdownoptions" style="display: none">
763 <form id="optionsform">
764 <div class="controlgroup-vertical">
765 <label for="cutoff">cut-off</label>
766 <input id="cutoff" type="text" name="cutoff" size="10" value="<%= $cutoff %>" title="Only consider the most frequent x word forms.">
767 <label for="dedupe">dedupe</label>
768 <input id="dedupe" type="checkbox" name="dedupe" value="1" <%= ($dedupe ? "checked" : "") %> title="radically filter out any near-duplicates">
769 % if($mergedEnd > 0) {
770 <label for="sbf">backw.</label>
771 <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.">
772 % }
773 <label for="neighbours">max. neighbours:</label>
774 <input id="neighbours" size="4" name="n" value="<%= $no_nbs %>">
775 <label for="no_iterations">max. iterations</label>
776 <input id="no_iterations" name="N" size="4" value="<%= $no_iterations %>">
777 <!-- <label for="dosom">SOM</label>
778 <input id="dosom" type="checkbox" name="som" value="1" <%= ($show_som ? "checked" : "") %>> -->
779 % if($collocators) {
780 <label for="sortby">window/sort</label>
781 <select id="sortby" name="sort">
782 <option value="0" <%= ($sort!=1 && $sort!=2? "selected":"") %>>auto focus</option>
783 <!-- <option value="1" <%= ($sort==1? "selected":"") %>>any single position</option>
784 <option value="2" <%= ($sort==2? "selected":"") %>>whole window</option> -->
785 </select>
786 % }
787 <input type="button" value="→ KorAP" onclick="queryKorAP();" title="query word with KorAP"/>
Marc Kupietz1acb3172018-02-17 09:41:26 +0100788 <input id="show-details" type="checkbox" name="show-details" value="1" >
789 <label for="show-details">
790 Show details
791 </label>
Marc Kupietz58270662017-12-04 12:10:06 +0100792 </div>
793 </form>
794 </div>
795 </div>
796 </div>
Marc Kupietz565274e2026-09-06 13:17:17 +0200797 %# Operands that are not in the vocabulary are dropped from the query
798 %# vector, which for an expression like "König - Mannn + Frau" would
799 %# otherwise silently answer a different question.
800 % if($unknown ne '' && $have_results) {
801 <div id="unknownwords"><%= loc 'not_in_vocabulary' %> <span class="mono"><%= $unknown %></span></div>
802 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100803 <div id="topwrapper">
804 <div style="visibility: hidden;" id="tabs">
805 <ul>
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100806 % if (defined $word && $word ne '') {
807 % if($mergedEnd && $distantWords) {
808 <li><a href="#tabs-0" title="Cos offsets of the words furthest away from their position in the reference corpus."">Offsets</a></li>
809 % }
810 <li><a href="#tabs-1"><%= loc 'paradigmatic_tsne' %></a></li>
811 <li><a href="#tabs-2"><%= loc 'paradigmatic_som' %></a></li>
Marc Kupietz565274e2026-09-06 13:17:17 +0200812 %# No syntagmatic tab for a model without a .net file, i.e. without
813 %# the output weights the predictive collocators are read from.
814 % if($collocators) {
815 <li><a href="#tabs-3"><%= loc 'syntagmatic' %></a></li>
816 % }
Marc Kupietzd7760b42019-02-21 09:01:44 +0100817 % }
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100818 <li><a href="#tabs-4">Info</a></li>
Marc Kupietz58270662017-12-04 12:10:06 +0100819 </ul>
Marc Kupietzb6514dc2019-06-26 11:47:56 +0200820 % if($mergedEnd && $distantWords) {
Marc Kupietzd7760b42019-02-21 09:01:44 +0100821 <div id="tabs-0" style="display: flex; padding: 5px; flex-flow: row wrap;">
822 <div id="vocabdist" style="width: 230px; margin-bottom: 15px;">
823 <table class="display compact nowrap" id="vocabdistt">
824 <thead>
825 <tr>
Marc Kupietz95977002019-02-26 09:09:59 +0100826 <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 +0100827 </tr>
828 </thead>
829 <tbody>
830 <tr>
831 <td align="right">
Marc Kupietz95977002019-02-26 09:09:59 +0100832 </td>
Marc Kupietzd7760b42019-02-21 09:01:44 +0100833 <td align="right">
834 </td>
835 <td></td>
836 </tr>
837 </tbody>
838 </table>
839 </div>
840 </div>
Marc Kupietzb6514dc2019-06-26 11:47:56 +0200841 % }
Marc Kupietz384c9132018-03-19 16:45:24 +0100842 <div id="tabs-1" style="display: flex; padding: 5px; flex-flow: row wrap;">
Marc Kupietz565274e2026-09-06 13:17:17 +0200843 % if($have_results) {
Marc Kupietz58270662017-12-04 12:10:06 +0100844 <div id="wrapper">
Marc Kupietz384c9132018-03-19 16:45:24 +0100845 <div id="first" style="width: 230px; margin-bottom: 15px;">
Marc Kupietz58270662017-12-04 12:10:06 +0100846 <table class="display compact nowrap" id="firsttable">
847 <thead>
848 <tr>
Marc Kupietz95977002019-02-26 09:09:59 +0100849 <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 +0100850 </tr>
851 </thead>
852 <tbody>
853 <tr>
854 <td align="right">
855 </td>
856 <td align="right">
857 </td>
858 <td></td>
859 </tr>
860 </tbody>
861 </table>
862 </div>
Marc Kupietza55a09a2018-07-06 13:30:30 +0200863 % if(0 && $haveSProfiles) {
Marc Kupietz384c9132018-03-19 16:45:24 +0100864 <div id="sprofilesdiv" style="width: 200px; padding-right: 10px;">
865 <table class="display compact nowrap" id="sprofiles">
866 <thead>
867 <tr>
868 <th align="right">cos</th><th align="left">similars by coll. profile</th>
869 </tr>
870 </thead>
871 <tbody>
872 <tr>
873 <td align="right">
874 </td>
875 <td></td>
876 </tr>
877 </tbody>
878 </table>
879 </div>
880 %}
Marc Kupietz81aeed22019-02-17 21:22:45 +0100881 <div id="second">
Marc Kupietz58270662017-12-04 12:10:06 +0100882 <div id="embed">
883 </div>
884 <div id="cost">
885 </div>
886 </div>
887 </div>
Marc Kupietz81aeed22019-02-17 21:22:45 +0100888 % } elsif($word !~ /^\s*$/) {
889 <div id="wrapper">
Marc Kupietz81aeed22019-02-17 21:22:45 +0100890 <script>
891 $( function() {
Marc Kupietzce6490b2019-12-06 11:05:40 +0100892 $( "<%== loc 'notfounddialog' %>").dialog({
Marc Kupietz81aeed22019-02-17 21:22:45 +0100893 autoOpen: true,
894 modal: true,
895 draggable: false,
896 height: "auto",
897 width: "auto",
898 resizable: false,
899 buttons: {
900 "OK": function() {
901 $( this ).dialog( "close" );
Marc Kupietzce6490b2019-12-06 11:05:40 +0100902 } /* ,
Marc Kupietz81aeed22019-02-17 21:22:45 +0100903 "Apply": function() {
904 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietzce6490b2019-12-06 11:05:40 +0100905 } */
Marc Kupietz81aeed22019-02-17 21:22:45 +0100906 }
907 });
908 });
909 </script>
Marc Kupietzce6490b2019-12-06 11:05:40 +0100910 <div id="not-found-dialog_de" style="display: none" title="Nicht gefunden">
911 <p>FEHLER: Konnte "<%= $word %>" nicht finden.</p>
912 <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>
913 </div>
914 <div id="not-found-dialog_en" style="display: none" title="Not found">
915 <p>ERROR: "<%= $word %>" not found in vocabluary.</p>
916 <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>
917 </div>
Marc Kupietz81aeed22019-02-17 21:22:45 +0100918 </div>
Marc Kupietz384c9132018-03-19 16:45:24 +0100919 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100920 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100921 <div id="tabs-2" style="display: flex; padding: 5px; flex-flow: row wrap;">
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100922 % if(defined $word && $word ne "") {
923 <div id="som2" style="width: 800;">
924 <div id="sominfo1"><span id="somcolor1"> </span> <span id="somword1"> </span> <span id="somcolor2"> </span> <span id="somword2"> </span> <span id="somcolor3"> </span></div>
925 <div id="sominfo" style="text-align: right">SOM iteration <span id="iterations">0</span></div>
926 </div>
927 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100928 </div>
Marc Kupietz565274e2026-09-06 13:17:17 +0200929 % if($collocators) {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100930 <div id="tabs-3" style="display: flex; padding:5px; flex-flow: row wrap;">
931 <div style="margin-right: 20px; margin-bottom: 10px;" id="secondt">
Marc Kupietze6a7a732018-01-12 09:21:08 +0100932 <table class="display compact nowrap" id="secondtable">
Marc Kupietz58270662017-12-04 12:10:06 +0100933 <thead>
934 <tr>
935 % if($collocators) {
936 <th>#</th>
Marc Kupietz4116b432017-12-06 14:15:32 +0100937 <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>
938 <th align="right" title="Maximum activation of the collocator anywhere in the output layer.">max(a)</th>
Marc Kupietz21fcd5f2026-09-06 13:17:29 +0200939 <th align="right" title="Maximum activation of the collocator before the sigmoid: max(a) = σ(max(z)). Unquantized and uncapped, and therefore able to order collocators of equal max(a).">max(z)</th>
Marc Kupietz4116b432017-12-06 14:15:32 +0100940 <th title="Average raw activation of the collocator in the columns selected by auto-focus." align="right">⟨a⟩</th>
941 <th title="Sum of activations over the selected colunns normalized by the total activation sum of the selected columns." align="right">Σa/Σw'</th>
942 <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 +0100943 <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 +0100944 <th align="left"><%= loc 'collocate_w2v' %></th>
Marc Kupietz58270662017-12-04 12:10:06 +0100945 % }
946 </tr>
947 </thead>
948 <tbody>
949 <tr>
950 <td align="right">
951 </td>
952 <td align="right">
953 </td>
954 <td align="right">
955 </td>
956 <td align="right">
957 </td>
958 <td align="right">
959 </td>
960 <td align="right">
961 </td>
Marc Kupietz58270662017-12-04 12:10:06 +0100962 </tr>
963 </tbody>
964 </table>
Marc Kupietz66bfd952017-12-11 09:59:45 +0100965 </div>
Marc Kupietz565274e2026-09-06 13:17:17 +0200966 % if(!$single_word) {
967 <div id="ccd" class="notice"><%= loc 'ca_single_word_only' %></div>
968 % } else {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100969 <div id="ccd" style="">
Marc Kupietze6a7a732018-01-12 09:21:08 +0100970 <table class="display compact nowrap" id="classicoloctable">
971 <thead>
Marc Kupietzcd136e22018-01-29 09:18:12 +0100972 % if($collocators) {
973 <tr>
Marc Kupietzf19814b2019-01-21 16:50:19 +0100974 <th id="ll_tt">LL</th>
Marc Kupietzfab14a72019-01-22 16:20:29 +0100975 <th id="mi_tt">MI</th>
976 <th id="md_tt">MI²</th>
Marc Kupietzf19814b2019-01-21 16:50:19 +0100977 <th id="lfmd_tt">MI³</th>
Marc Kupietzfab14a72019-01-22 16:20:29 +0100978 <th id="npmi_tt">nPMI</th>
979 <th id="dice_tt">dice</th>
Marc Kupietz63b268f2019-01-22 22:34:29 +0100980 <th id="logdice_tt">LD</th>
981 <th id="logdiceaf_tt">LDaf</th>
Marc Kupietz001bffd2019-02-21 08:52:41 +0100982 <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 +0200983 <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 +0100984 <th title="PMI³ restricted to left neighbour">l-PMI³</th>
985 <th title="PMI³ restricted to right neighbour">r-PMI³</th>
986 <th title="nPMI restricted to left neighbour">l-nPMI</th>
987 <th title="nPMI restricted to right neighbour">r-nPMI</th>
Marc Kupietz4784fae2019-02-04 12:32:12 +0100988 <th id="rawfreq_tt" title="raw frequency sum of collocation within window">raw</th>
Marc Kupietz95104512019-12-05 10:13:05 +0100989 <th><%= loc 'collocate_ca' %></th>
Marc Kupietzcd136e22018-01-29 09:18:12 +0100990 </tr>
Marc Kupietz1acb3172018-02-17 09:41:26 +0100991 % }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100992 </thead>
993 <tbody>
994 <tr>
Marc Kupietz63b268f2019-01-22 22:34:29 +0100995 <td align="right"></td>
996 <td align="right"></td>
997 <td align="right"></td>
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100998 <td align="right"></td>
Marc Kupietz78d7c1a2019-02-17 22:31:22 +0100999 <td align="right"></td>
1000 <td align="right"></td>
1001 <td align="right"></td>
1002 <td align="right"></td>
1003 <td align="right"></td>
1004 <td align="left"> </td>
1005 <td align="right"></td>
1006 <td align="right"></td>
1007 <td align="right"></td>
1008 <td align="right"></td>
1009 <td align="left"> </td>
Marc Kupietze6a7a732018-01-12 09:21:08 +01001010 </tr>
1011 </tbody>
1012 </table>
1013 </div>
Marc Kupietz565274e2026-09-06 13:17:17 +02001014 % }
Marc Kupietz384c9132018-03-19 16:45:24 +01001015 <!--
1016 <div style="clear:both" ></div>
1017 <div style="float: right; overflow: hidden" id="extra"><button onClick="showCollocatorSOM()"> </button></div>
1018 -->
Marc Kupietz66bfd952017-12-11 09:59:45 +01001019 </div>
Marc Kupietz565274e2026-09-06 13:17:17 +02001020 % }
Marc Kupietzd6dfdf02019-12-06 09:53:34 +01001021 <div id="tabs-4" style="display: flex; padding:5px; flex-flow: row wrap;">
1022 <div id="info">
1023 <h3><%== loc 'about' %></h3>
1024 %= include(loc('abouttext'))
1025 % if($training_args && (@$lists)[0]) {
1026 <h3><%= loc 'training_parameters' %></h3>
1027 % if($training_args =~ /-type\s*3/) {
1028 <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>
1029 <div class="mono"><%= $training_args %></div>
1030 % } else {
1031 <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>
1032 <div class="mono"><%= $training_args %></div>
1033 % }
Marc Kupietz2133bd12022-05-19 09:24:42 +02001034 % }
1035 <h3>Source Code</h3>
1036 <ul>
Marc Kupietz5b8aaf72026-09-04 19:21:22 +02001037 <li><a href="https://github.com/kupietz/dereko2vec">dereko2vec</a></li>
1038 <li><a href="https://github.com/kupietz/collocatordb">collocatordb</a></li>
Marc Kupietz2133bd12022-05-19 09:24:42 +02001039 <li><a href="https://korap.ids-mannheim.de/gerrit/plugins/gitiles/ids-kl/derekovecs">derekovecs</a></li>
1040 </ul>
Marc Kupietzd6dfdf02019-12-06 09:53:34 +01001041 <h3><%== loc 'references' %></h3>
1042 %= include 'references'
1043 </div>
1044 </div>
1045 </div> <!-- tabs -->
Marc Kupietz58270662017-12-04 12:10:06 +01001046 </div> <!-- topwrapper -->
1047 <div style="clear: both;"></div>
1048 </div>
Marc Kupietzd6dfdf02019-12-06 09:53:34 +01001049 <div class="footer">
1050 <span class="footertext">
1051 %= include(loc('footer'))
1052 </span>
Marc Kupietzebea4702018-01-12 09:16:09 +01001053 </div>
Marc Kupietz58270662017-12-04 12:10:06 +01001054 </body>
Marc Kupietz83305222016-04-28 09:57:22 +02001055</html>