blob: 4597a19526efd8e41687e4ca6aeccc833b011c80 [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 Kupietz86b50292019-02-17 21:03:59 +01005 <title><%= $plain_title %>:<%= $word %> · IDS word vector analysis</title>
Marc Kupietz80bd7b92017-07-04 16:25:54 +02006 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
Marc Kupietz58270662017-12-04 12:10:06 +01007 <link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Condensed" rel="stylesheet">
Marc Kupietz42e6d092023-04-18 19:29:12 +02008 <script src="https://code.jquery.com/jquery-latest.min.js"></script>
Marc Kupietz5f532b32019-01-23 10:03:18 +01009 <script src = "https://cdn.datatables.net/1.10.18/js/jquery.dataTables.min.js"></script>
10 <script src = "https://cdn.datatables.net/fixedcolumns/3.2.5/js/dataTables.fixedColumns.min.js"></script>
11 <script src = "https://cdn.datatables.net/plug-ins/1.10.18/sorting/scientific.js"></script>
12 <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'></script>
Marc Kupietz9ae184c2023-11-04 18:21:54 +010013 <script src="https://cdnjs.cloudflare.com/ajax/libs/ical.js/1.5.0/ical.js"
14 integrity="sha512-UxWd2RMDGpYwYuDeU2Fs+nd51gw4ZLQY0D9wWZ3NuanNSk6QQmWCZ6C+rvI0lJ/b/nZtBQ8RVESA9DN9r65dUg=="
15 crossorigin="anonymous" referrerpolicy="no-referrer"></script>
16 <script
17 src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js"
18 integrity="sha512-42PE0rd+wZ2hNXftlM78BSehIGzezNeQuzihiBCvUEB3CVxHvsShF86wBWwQORNxNINlBPuq7rG4WWhNiTVHFg=="
19 crossorigin="anonymous" referrerpolicy="no-referrer"></script>
20 <script src="js/calendar-events.js"></script>
Marc Kupietz5f532b32019-01-23 10:03:18 +010021 <link rel="stylesheet" href="https://cdn.datatables.net/1.10.18/css/jquery.dataTables.min.css">
Marc Kupietz4949d232018-03-19 16:43:18 +010022 <link rel="stylesheet" href="/derekovecs/css/derekovecs.css">
Marc Kupietz80bd7b92017-07-04 16:25:54 +020023 <script
Marc Kupietz42e6d092023-04-18 19:29:12 +020024 src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
Marc Kupietze6a7a732018-01-12 09:21:08 +010025 integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
26 crossorigin="anonymous"></script>
Marc Kupietz80bd7b92017-07-04 16:25:54 +020027 <script>
Marc Kupietza0ffb392018-01-25 08:53:43 +010028 MathJax.Hub.Config({
29 config: ["MMLorHTML.js"],
30 jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML", "output/PreviewHTML"],
31 extensions: ["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js", "fast-preview.js", "AssistiveMML.js", "a11y/accessibility-menu.js"],
32 TeX: {
33 extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
34 }
35 });
Marc Kupietz58270662017-12-04 12:10:06 +010036 var urlParams = new URLSearchParams(window.location.search);
Marc Kupietzb3a2e4f2017-12-08 17:25:53 +010037 var currentWords = urlParams.get("word");
Marc Kupietza0ffb392018-01-25 08:53:43 +010038 var CIIsearchWords = (currentWords && currentWords.includes(" ") ? '('+currentWords.replace(/ +/g, " oder ")+')' : currentWords);
Marc Kupietz66bfd952017-12-11 09:59:45 +010039 var collocatorTable = null;
Marc Kupietz86b50292019-02-17 21:03:59 +010040 var plainTitle ="<%= $plain_title %>"
Marc Kupietz78d7c1a2019-02-17 22:31:22 +010041 var korapPath="/";
42 if (plainTitle.match(/-en/)) {
43 korapPath="/instance/english";
44 }
Marc Kupietz78230872019-08-02 15:15:25 +020045 var korapVC="";
46 if (plainTitle.match(/WUDD/i)) {
47 korapVC="&collection=corpusSigle+%3D+%2FW%5BDU%5DD17%2F";
48 korapPath="/instance/test";
49 }
50
Marc Kupietz58270662017-12-04 12:10:06 +010051 $(document).ready(function() {
Marc Kupietz9ae184c2023-11-04 18:21:54 +010052 insertCalendarEvents(document.getElementById('downtimes'), "<%= $downtime_calendar_url %>");
Marc Kupietz694610d2017-11-25 18:30:03 +010053
Marc Kupietza0ffb392018-01-25 08:53:43 +010054 $('#firstable').hide();
55 //Set up a callback to hear back when MathJax is done rendering the equations
56 // it finds
57 $('#ccd').load(
58 '@Url.Action("ActionResultMethod","ControllerName",{controller parameters})',
59 function () {
60 MathJax.Hub.Queue(
61 ["Typeset",MathJax.Hub,"ccd"],
Marc Kupietz95977002019-02-26 09:09:59 +010062 function () {
Marc Kupietz7bd55232019-01-22 15:29:06 +010063 $("#mi_tt").attr("title",$("#pmi_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010064 $("#lfmd_tt").attr("title",$("#lfmd_ttt").html());
Marc Kupietz7bd55232019-01-22 15:29:06 +010065 $("#md_tt").attr("title",$("#md_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010066 $("#npmi_tt").attr("title",$("#npmi_ttt").html());
Marc Kupietzf19814b2019-01-21 16:50:19 +010067 $("#ll_tt").attr("title",$("#ll_ttt").html());
Marc Kupietz7bd55232019-01-22 15:29:06 +010068 $("#logdice_tt").attr("title",$("#logdice_ttt").html());
Marc Kupietz63b268f2019-01-22 22:34:29 +010069 $("#logdiceaf_tt").attr("title",$("#logdiceaf_ttt").html());
Marc Kupietza0ffb392018-01-25 08:53:43 +010070 }
71 );
72 });
73
74 //set things up so that we can shove raw html into what is shown in the tooltip;
75 // in this case, we will have already put into the title attribute the html that
76 // contains the MathJax rendered equations (via what we do in the callback).
77 $(function () {
78 $(document).tooltip({
79 content: function () {
80 return $(this).prop('title');
81 }
82 });
83 });
84
Marc Kupietze6a7a732018-01-12 09:21:08 +010085 $("input").bind("keydown", function(event) {
86 // track enter key
87 var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
88 if (keycode == 13) { // keycode for enter key
89 // force the 'Enter Key' to implicitly click the Update button
90 document.getElementById('SEARCH').click();
91 return false;
92 } else {
93 return true;
94 }});
Marc Kupietzdab9f222017-11-29 14:22:59 +010095
Marc Kupietze871abd2018-01-25 16:18:27 +010096 var collocatorTable_activated = false;
Marc Kupietze6a7a732018-01-12 09:21:08 +010097 $( "#tabs" ).on( "tabsactivate", function( event, ui ) {
98 if (localStorage) localStorage['tab'] = ui.newTab.index();
Marc Kupietzd7760b42019-02-21 09:01:44 +010099 if(ui.newTab.index() == 3 && !collocatorTable_activated) {
Marc Kupietze871abd2018-01-25 16:18:27 +0100100 classicCollocatorTable.columns.adjust();
101 collocatorTable.columns.adjust();
102 collocatorTable_activated = true;
103 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100104 });
105
106 $(function(){
107 $("#SEARCH").click(function() {
108 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietz58270662017-12-04 12:10:06 +0100109 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100110 });
Marc Kupietz0af83e32017-11-27 09:31:37 +0100111
Marc Kupietze6a7a732018-01-12 09:21:08 +0100112 function changeCharColor(txt, heat, word) {
113 var newText = "";
114 for (var i=0, l=txt.length; i<l; i++) {
Marc Kupietz86b50292019-02-17 21:03:59 +0100115 newText += (i == 5 ? txt.charAt(i) : '<a href="http://korap.ids-mannheim.de' + korapPath + '/?ql=cosmas2&q=' +
Marc Kupietze6a7a732018-01-12 09:21:08 +0100116 CIIsearchWords + ' /' + (i > 5? '%2B' : '-') + 'w' +
Marc Kupietz78230872019-08-02 15:15:25 +0200117 Math.abs(i-5) + ':' + Math.abs(i-5) + ' ' + word + korapVC +
Marc Kupietze6a7a732018-01-12 09:21:08 +0100118 '" target="korap"><span style="background-color:' +
119 getHeatColor(heat[i]/maxHeat)+'">'+txt.charAt(i)+'</span></a>');
Marc Kupietzb6c615d2017-12-02 10:38:20 +0100120 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100121 return newText;
122 }
Marc Kupietzb6c615d2017-12-02 10:38:20 +0100123
Marc Kupietze6a7a732018-01-12 09:21:08 +0100124 function getHeatColor(value) {
125 var hue=((1-value)*120).toString(10);
126 return ["hsl(",hue,",90%,70%)"].join("");
127 }
128
129 function bitvec2window(n, heat, word) {
130 var str = n.toString(2).padStart(10, "0")
131 .replace(/^([0-9]{5})/, '$1x')
132 .replace(/0/g, '·')
133 .replace(/1/g, '+');
134 return changeCharColor(str, heat, word);
135 }
136
137 % use Mojo::ByteStream 'b';
138 var paraResults = <%= b(Mojo::JSON::to_json($lists)) %>;
139 var urlprefix = new URLSearchParams(window.location.search);
140 if (paraResults.length > 0 && paraResults[0] != null) {
141 var nvecs = [],
142 nwords = [],
143 nranks = [],
144 nmarked = [];
145 for(var i = 0; i < paraResults.length; i++) {
146 nwords = nwords.concat(paraResults[i].map(function(a){return a.word;}));
147 nvecs = nvecs.concat(paraResults[i].map(function(a){return a.vector;}));
148 nranks = nranks.concat(paraResults[i].map(function(a){return a.rank;}));
149 nmarked = nmarked.concat(paraResults[i].map(function(a){return a.marked;}));
Marc Kupietz0d4c0ca2017-12-04 09:18:56 +0100150 }
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100151 showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked} );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100152 var t = $('#firsttable').DataTable({
Marc Kupietzee894d52019-01-09 14:55:14 +0100153 data: [].concat.apply([], paraResults),
Marc Kupietze6a7a732018-01-12 09:21:08 +0100154 "sScrollY": "780px",
155 "bScrollCollapse": true,
156 "bPaginate": false,
157 "bJQueryUI": true,
158 "dom": '<"top">rt<"bottom"flp><"clear">',
Marc Kupietz384c9132018-03-19 16:45:24 +0100159 "initComplete":function(settings, json) {
160 $('td.paradigmator a').on('mousedown', function(e) {
Marc Kupietz86b50292019-02-17 21:03:59 +0100161 return paradigmatorClick(e, paraResults[0][0].word, this.childNodes["0"].textContent);
Marc Kupietz384c9132018-03-19 16:45:24 +0100162 });
163 },
Marc Kupietze6a7a732018-01-12 09:21:08 +0100164 "columns": [
165 { "data": "rank", type: "allnumeric" },
166 { "data": "dist", render: function ( data, type, row ) {return data.toFixed(3) }},
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100167 { "data": "word", class: "paradigmator", render: function ( data, type, row ) {
168 urlprefix.set("word", data); return '<a class="' + getMergedClass(row.rank) + '" href="?' + urlprefix + '">' + data + '</a>'
169 }}
Marc Kupietze6a7a732018-01-12 09:21:08 +0100170 ],
171 "columnDefs": [
172 { className: "dt-right", "targets": [0,1] },
173 { "searchable": false,
174 "orderable": false,
175 "targets": 0
176 },
177 { "orderSequence": [ "desc" ], "targets": [ 1 ] },
178 { "orderSequence": [ "asc", "desc" ], "targets": [ 2 ] },
179 ],
180 "oLanguage": {
181 "sSearch": "Filter: "
182 },
183 "order": [[ 1, 'desc' ]],
184 } );
Marc Kupietz0d4c0ca2017-12-04 09:18:56 +0100185
Marc Kupietze6a7a732018-01-12 09:21:08 +0100186 t.on( 'order.dt search.dt', function () {
187 t.column(0, {order:'applied'}).nodes().each( function (cell, i) {
188 cell.innerHTML = i+1;
189 } );
190 } ).draw();
191
192 $( "#first" ).clone().prependTo( "#tabs-2" );
193
194 }
195
196
197 var collocatorData = <%= b(Mojo::JSON::to_json($collocators)) %>;
198 var maxHeat; // = Math.max.apply(Math,collocatorData.map(function(o){return o.cprob;}))
199
Marc Kupietzcddc8482019-12-04 08:57:33 +0100200 if(typeof data !== 'undefined' && data.mergedEnd > 0) {
Marc Kupietz78230872019-08-02 15:15:25 +0200201 vocabDistanceTable = makeVocabDistanceTable("#vocabdistt", baseURL);
202 }
Marc Kupietzd7760b42019-02-21 09:01:44 +0100203
Marc Kupietze6a7a732018-01-12 09:21:08 +0100204 if (collocatorData != null) {
205 maxHeat = Math.max.apply(Math,collocatorData.map(function(o){return Math.max.apply(Math,o.heat);}))
206 collocatorTable = $('#secondtable').DataTable({
207 data: collocatorData,
208 "sScrollY": "780px",
209 "bScrollCollapse": true,
210 "bPaginate": false,
211 "bJQueryUI": true,
212 "dom": '<"top">rt<"bottom"flp><"clear">',
213 "columns": [
214 { "data": "rank", type: "allnumeric" },
215 { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
216 { "data": "max", render: function ( data, type, row ) {return data.toFixed(3) }},
217 { "data": "average", render: function ( data, type, row ) {return data.toFixed(3) }},
218 { "data": "prob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
219 { "data": "cprob", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
220 { "data": "overall", type: "scientific", render: function ( data, type, row ) {return data.toExponential(3) } },
221 { "data": "word", sClass: "collocator" },
222 { "data": "rank", type: "allnumeric" }
223 ],
224 "columnDefs": [
225 { className: "dt-right", "targets": [0,2,3,4,5,6] },
226 { className: "dt-center", "targets": [ 1] },
227 { "searchable": false,
228 "orderable": false,
229 "targets": [0, 8]
230 },
231 { "type": "scientific", targets: [2,3,4,5,6] },
232 { "orderSequence": [ "desc" ], "targets": [ 2, 3, 4, 5, 6 ] },
233 { "orderSequence": [ "asc", "desc" ], "targets": [ 1, 7 ] },
234 { "targets": [8], "visible": false }
235 ],
236 "oLanguage": {
237 "sSearch": "Filter: "
238 },
239 "order": [[ 4, 'desc' ]],
240 } );
241 $.ajaxSetup({
242 type: 'POST',
243 timeout: 30000,
244 error: function(xhr) {
245 $('#display_error')
246 .html('Error: ' + xhr.status + ' ' + xhr.statusText);
247 }
Marc Kupietz78b434a2018-01-12 22:33:32 +0100248 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100249
Marc Kupietz384c9132018-03-19 16:45:24 +0100250
251 if($('#sprofiles').length) {
252 similarProfileTable = $('#sprofiles').DataTable({
253 ajax: {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100254 method: "GET",
Marc Kupietz384c9132018-03-19 16:45:24 +0100255 url: '/derekovecs/getSimilarProfiles',
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100256 dataType: 'json',
257 dataSrc: "",
258 timeout: 30000,
259 data: { w: paraResults[0][0].rank }
Marc Kupietz384c9132018-03-19 16:45:24 +0100260 },
261 "initComplete":function(settings, json){
262 $('td.paradigmator a').on('mousedown', function(e) {
263 if (e.which === 2) {
264 e.preventDefault();
265 queryKorAPalternatives(paraResults[0][0].word, this.childNodes["0"].textContent);
266 return false;
267 }
268 });
269 },
270 "sScrollY": "780px",
271 "bScrollCollapse": true,
272 "bPaginate": false,
273 "bJQueryUI": true,
274 "dom": '<"top">rt<"bottom"flp><"clear">',
275 "columns": [
276 { "data": "v", render: function ( data, type, row ) {return data.toFixed(3) }},
277 { "data": "w", sClass: "paradigmator", render: function ( data, type, row ) {urlprefix.set("word", data); return '<a href="?' + urlprefix + '">' + data + '</a>' } }
278 ],
279 "columnDefs": [
280 { className: "dt-right", "targets": [0] },
281 ],
282 "oLanguage": {
283 "sSearch": "Filter: "
284 },
285 "order": [[ 0, 'desc' ]],
286 });
287 }
Marc Kupietzd7760b42019-02-21 09:01:44 +0100288
Marc Kupietz384c9132018-03-19 16:45:24 +0100289 // var filterQuot = /(^quot?=[A-Z])|(quot$)/g;
290 var filterQuot = /^quot/;
Marc Kupietz4784fae2019-02-04 12:32:12 +0100291 var ccResult;
Marc Kupietz86b50292019-02-17 21:03:59 +0100292 var baseURL = window.location.pathname.replace(/[/]$/, '')
Marc Kupietz95977002019-02-26 09:09:59 +0100293 classicCollocatorTable = makeClassicCollocatorTable('#classicoloctable', baseURL, paraResults[0][0].rank)
Marc Kupietze6a7a732018-01-12 09:21:08 +0100294
Marc Kupietz1acb3172018-02-17 09:41:26 +0100295 $('#show-details').change(function (e) {
296 var columns = classicCollocatorTable.columns(".detail");
297 if(this.checked) {
298 columns.visible(true);
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100299 $("#ccd").css('width', 'auto');
Marc Kupietz1acb3172018-02-17 09:41:26 +0100300 } else {
301 columns.visible(false);
Marc Kupietz08bfd402019-01-23 10:05:17 +0100302 $("#ccd").css('width', '680px');
Marc Kupietz1acb3172018-02-17 09:41:26 +0100303 }
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100304 classicCollocatorTable.columns.adjust().draw();
Marc Kupietz1acb3172018-02-17 09:41:26 +0100305 } );
306
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100307 $("td.collocator").click(function(){
308 queryKorAPCII(this.textContent + " /w5 " + CIIsearchWords);
Marc Kupietzad783722018-01-13 17:45:21 +0100309 });
310
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100311 collocatorTable.on( 'order.dt search.dt', function () {
312 collocatorTable.column(0, {order:'applied'}).nodes().each( function (cell, i) {
313 cell.innerHTML = i+1;
314 } );
315 }).draw();
316 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100317
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100318 if (localStorage && !window.location.hash) { // let's not crash if some user has IE7
319 var index = parseInt(localStorage['tab']||'0');
320 $("#tabs").tabs({ active: index });
321 }
322 $("#tabs").css("visibility", "visible"); // now we can show the tabs
323 });
Marc Kupietz58270662017-12-04 12:10:06 +0100324
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100325 $(function(){
326 $("#dropdownoptions").dialog({
Marc Kupietz95104512019-12-05 10:13:05 +0100327 title: "<%= loc 'Options' %>",
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100328 autoOpen: false,
329 modal: false,
330 draggable: false,
331 height: "auto",
332 width: "auto",
333 resizable: false,
334 buttons: {
Marc Kupietz95104512019-12-05 10:13:05 +0100335 "<%= loc 'Cancel'%>": function() {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100336 $( this ).dialog( "close" );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100337 },
Marc Kupietz95104512019-12-05 10:13:05 +0100338 "<%= loc 'Apply' %>": function() {
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100339 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietze6a7a732018-01-12 09:21:08 +0100340 }
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100341 }
342 });
343 });
344
345 $(function(){
346 $("#showoptions").click(function(){
347 $("#dropdownoptions").dialog("open");
348 var target = $(this);
349 $("#dropdownoptions").dialog("widget").position({
350 my: 'left bottom',
351 at: 'left bottom',
352 of: target
Marc Kupietz58270662017-12-04 12:10:06 +0100353 });
Marc Kupietze6a7a732018-01-12 09:21:08 +0100354 });
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100355 });
356
357 $( function() {
358 $( "#no_iterations" ).spinner({
359 spin: function( event, ui ) {
360 if ( ui.value < 1000 ) {
361 $( this ).spinner( "value", 1000 );
362 return false;
363 } else if ( ui.value > 10000 ) {
364 $( this ).spinner( "value", 10000 );
365 return false;
366 }
367 }
368 });
369 } );
370
371 $( function() {
372 $( "#neighbours" ).spinner({
373 spin: function( event, ui ) {
374 if ( ui.value < 0 ) {
375 $( this ).spinner( "value", 0 );
376 return false;
377 } else if ( ui.value > 200 ) {
378 $( this ).spinner( "value", 200 );
379 return false;
380 }
381 }
382 });
383 } );
384
385 $( function() {
386 $( "#cutoff" ).spinner({
387 spin: function( event, ui ) {
388 if ( ui.value < 100000 ) {
389 $( this ).spinner( "value", 100000 );
390 return false;
391 } else if ( ui.value > 2000000 ) {
392 $( this ).spinner( "value", 2000000 );
393 return false;
394 }
395 }
396 });
397 } );
398
399 $( function() {
400 $( "#tabs" ).tabs().addClass('tabs-min');
401 } );
402
403 $( function() {
404 $( ".controlgroup-vertical" ).controlgroup({
405 "direction": "vertical"
406 });
407 } );
408
409 $(function() {
410 $( document ).tooltip({
411 content: function() {
412 return $(this).attr('title');
413 }}
414 )
415 });
416
417 $(function () {
418 $(document).tooltip({
419 content: function () {
420 return $(this).prop('title');
421 },
422 show: null,
423 close: function (event, ui) {
424 ui.tooltip.hover(
425 function () {
426 $(this).stop(true).fadeTo(400, 1);
427 },
428 function () {
429 $(this).fadeOut("400", function () {
430 $(this).remove();
431 })
432 });
433 }
434 });
435 });
Marc Kupietz83305222016-04-28 09:57:22 +0200436 </script>
Marc Kupietz58270662017-12-04 12:10:06 +0100437 <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
438 <script src="/derekovecs/js/tsne.js"></script>
439 <script src="/derekovecs/js/som.js"></script>
440 <script src="/derekovecs/js/labeler.js"></script>
Marc K20476c72021-03-11 12:18:01 +0100441 <script src="/derekovecs/js/derekovecs.js"></script>
Marc Kupietz83305222016-04-28 09:57:22 +0200442 <script>
443
444 var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>},
Marc Kupietz58270662017-12-04 12:10:06 +0100445 mapWidth = 800, // width map
446 mapHeight = 800,
447 jitterRadius = 7;
Marc Kupietz83305222016-04-28 09:57:22 +0200448
449 var T = new tsnejs.tSNE(opt); // create a tSNE instance
450
451 var Y;
452
453 var data;
454 var labeler;
455
456 function applyJitter() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100457 svg.selectAll('.tsnet')
458 .data(labels)
459 .transition()
460 .duration(50)
461 .attr("transform", function(d, i) {
462 T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20;
463 T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20;
464 return "translate(" +
Marc Kupietz78230872019-08-02 15:15:25 +0200465 (d.x) + "," +
466 (d.y) + ")";
Marc Kupietze6a7a732018-01-12 09:21:08 +0100467 });
Marc Kupietz83305222016-04-28 09:57:22 +0200468 }
Marc Kupietz34c08172017-11-29 17:08:47 +0100469
Marc Kupietz83305222016-04-28 09:57:22 +0200470 function updateEmbedding() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100471 var Y = T.getSolution();
472 svg.selectAll('.tsnet')
473 .data(data.words)
474 .attr("transform", function(d, i) {
475 return "translate(" +
Marc Kupietz78230872019-08-02 15:15:25 +0200476 ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
477 ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
Marc Kupietz83305222016-04-28 09:57:22 +0200478 }
479
480 var svg;
481 var labels = [];
482 var anchor_array = [];
483 var text;
484
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100485 function getMergedClass(i) {
Marc Kupietzd7760b42019-02-21 09:01:44 +0100486 if(typeof data !== 'undefined' && i > data.mergedEnd) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100487 return " merged"
488 } else {
489 return "";
490 }
491 }
492
493 function getRankTooltip(i) {
494 if(data.mergedEnd) {
495 if(data.ranks[i] < data.mergedEnd) {
496 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
497 } else {
498 return "rank: "+i +" "+"freq. rank: "+(data.ranks[i]-data.mergedEnd).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " (merged vocab)";
499 }
500 } else {
501 return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
502 }
503 }
504
Marc Kupietz83305222016-04-28 09:57:22 +0200505 function drawEmbedding() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100506 var urlprefix = new URLSearchParams(window.location.search);
507 urlprefix.delete("word");
508 urlprefix.append("word","");
Marc Kupietz8f9c86a2017-12-04 17:17:13 +0100509
Marc Kupietze6a7a732018-01-12 09:21:08 +0100510 $("#embed").empty();
511 var div = d3.select("#embed");
Marc Kupietz34c08172017-11-29 17:08:47 +0100512
Marc Kupietze6a7a732018-01-12 09:21:08 +0100513 // get min and max in each column of Y
514 var Y = T.Y;
Marc Kupietz34c08172017-11-29 17:08:47 +0100515
Marc Kupietze6a7a732018-01-12 09:21:08 +0100516 svg = div.append("svg") // svg is global
517 .attr("width", mapWidth)
518 .attr("height", mapHeight);
Marc Kupietz34c08172017-11-29 17:08:47 +0100519
Marc Kupietze6a7a732018-01-12 09:21:08 +0100520 var g = svg.selectAll(".b")
521 .data(data.words)
522 .enter().append("g")
523 .attr("class", "tsnet");
Marc Kupietz34c08172017-11-29 17:08:47 +0100524
Marc Kupietze6a7a732018-01-12 09:21:08 +0100525 g.append("a")
526 .attr("xlink:href", function(word) {
527 return "?"+urlprefix+word; })
528 .attr("class", function(d, i) {
529 var res="";
530 if(data.marked[i]) {
531 res="marked ";
532 }
533 if(data.target.indexOf(" "+d+" ") >= 0) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100534 res += "target";
535 }
536 if(data.mergedEnd && data.ranks[i] >= data.mergedEnd) {
537 return res+" merged";
Marc Kupietze6a7a732018-01-12 09:21:08 +0100538 } else {
539 return res;
540 }
541 })
542 .attr("title", function(d, i) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100543 return getRankTooltip(i);
Marc Kupietze6a7a732018-01-12 09:21:08 +0100544 })
545 .append("text")
546 .attr("text-anchor", "top")
547 .attr("font-size", 12)
548 .text(function(d) { return d; });
Marc Kupietz34c08172017-11-29 17:08:47 +0100549
Marc Kupietz384c9132018-03-19 16:45:24 +0100550 g.append("svg:title")
551 .text(function(d, i) {
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100552 return getRankTooltip(i);
Marc Kupietz384c9132018-03-19 16:45:24 +0100553 });
554
Marc Kupietze6a7a732018-01-12 09:21:08 +0100555 var zoomListener = d3.behavior.zoom()
556 .scaleExtent([0.1, 10])
557 .center([0,0])
558 .on("zoom", zoomHandler);
559 zoomListener(svg);
Marc Kupietz83305222016-04-28 09:57:22 +0200560 }
561
562 var tx=0, ty=0;
563 var ss=1;
564 var iter_id=-1;
565
566 function zoomHandler() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100567 tx = d3.event.translate[0];
568 ty = d3.event.translate[1];
569 ss = d3.event.scale;
570 updateEmbedding();
Marc Kupietz83305222016-04-28 09:57:22 +0200571 }
572
573 var stepnum = 0;
574
575 function stopStep() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100576 clearInterval(iter_id);
577 text = svg.selectAll("text");
Marc Kupietz34c08172017-11-29 17:08:47 +0100578
Marc Kupietze6a7a732018-01-12 09:21:08 +0100579 // jitter function needs different data and co-ordinate representation
580 labels = d3.range(data.words.length).map(function(i) {
581 var x = (T.Y[i][0]*20*ss + tx) + mapWidth/2;
582 var y = (T.Y[i][1]*20*ss + ty) + mapHeight/2;
583 anchor_array.push({x: x, y: y, r: jitterRadius});
584 return {
585 x: x,
586 y: y,
587 name: data.words[i]
588 };
589 });
Marc Kupietz34c08172017-11-29 17:08:47 +0100590
Marc Kupietze6a7a732018-01-12 09:21:08 +0100591 // get the actual label bounding boxes for the jitter function
592 var index = 0;
593 text.each(function() {
594 labels[index].width = this.getBBox().width;
595 labels[index].height = this.getBBox().height;
596 index += 1;
597 });
Marc Kupietz83305222016-04-28 09:57:22 +0200598
Marc Kupietz34c08172017-11-29 17:08:47 +0100599
Marc Kupietze6a7a732018-01-12 09:21:08 +0100600 // setTimeout(updateEmbedding, 1);
601 // setTimeout(
602 labeler = d3.labeler()
603 .label(labels)
604 .anchor(anchor_array)
605 .width(mapWidth)
606 .height(mapHeight)
607 .update(applyJitter);
608 // .start(1000);
Marc Kupietz83305222016-04-28 09:57:22 +0200609
Marc Kupietze6a7a732018-01-12 09:21:08 +0100610 iter_id = setInterval(jitterStep, 1);
Marc Kupietz83305222016-04-28 09:57:22 +0200611 }
612
613 var jitter_i=0;
614
615 function jitterStep() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100616 if(jitter_i++ > 100) {
617 clearInterval(iter_id);
618 } else {
619 labeler.start2(10);
620 applyJitter();
621 }
Marc Kupietz83305222016-04-28 09:57:22 +0200622 }
623
624 var last_cost=1000;
625
626 function step() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100627 var i = T.iter;
Marc Kupietz34c08172017-11-29 17:08:47 +0100628
Marc Kupietze6a7a732018-01-12 09:21:08 +0100629 if(i > <%= $no_iterations %>) {
630 stopStep();
631 } else {
632 var cost = Math.round(T.step() * 100000) / 100000; // do a few steps
633 $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5));
634 if(i % 250 == 0 && cost >= last_cost) {
635 stopStep();
Marc Kupietz58270662017-12-04 12:10:06 +0100636 } else {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100637 last_cost = cost;
638 updateEmbedding();
Marc Kupietz58270662017-12-04 12:10:06 +0100639 }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100640 }
Marc Kupietz83305222016-04-28 09:57:22 +0200641 }
642
643 function showMap(j) {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100644 data=j;
645 T.iter=0;
646 iter_id = -1;
647 last_cost=1000;
648 T.initDataRaw(data.vecs); // init embedding
649 drawEmbedding(); // draw initial embedding
Marc Kupietz78114532017-11-29 17:00:16 +0100650
Marc Kupietze6a7a732018-01-12 09:21:08 +0100651 if(iter_id >= 0) {
652 clearInterval(iter_id);
653 }
654 //T.debugGrad();
655 iter_id = setInterval(step, 1);
656 if(true) { // (<%= $show_som %>) {
657 makeSOM(j, <%= $no_iterations %>);
658 }
Marc Kupietz83305222016-04-28 09:57:22 +0200659 }
Marc Kupietz39179ab2017-07-04 16:28:06 +0200660 var queryword;
661
Marc Kupietz66bfd952017-12-11 09:59:45 +0100662 function showCollocatorSOM() {
Marc Kupietz86b50292019-02-17 21:03:59 +0100663 var baseURL = window.location.pathname.replace(/[/]$/, '')
Marc Kupietze6a7a732018-01-12 09:21:08 +0100664 if (collocatorTable) {
665 var ctableData = collocatorTable.rows().data();
666 var nwords = [],
667 nranks = [];
668 for (var i=0; i < ctableData.length && i < 100; i++) {
669 nranks.push(ctableData[i].rank);
670 nwords.push(ctableData[i].word);
Marc Kupietz66bfd952017-12-11 09:59:45 +0100671 }
Marc Kupietz86b50292019-02-17 21:03:59 +0100672 $.post(baseURL+'/getVecsByRanks',
Marc Kupietze6a7a732018-01-12 09:21:08 +0100673 JSON.stringify(nranks),
674 function(data, status){
Marc Kupietz2e2e4db2018-12-21 15:07:37 +0100675 showMap({target: " "+urlParams.get('word')+" ", mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: data, ranks: nranks, marked: Array(100).fill(false)} );
Marc Kupietze6a7a732018-01-12 09:21:08 +0100676 }, 'json');
677 }
Marc Kupietz66bfd952017-12-11 09:59:45 +0100678 }
679
Marc Kupietz39179ab2017-07-04 16:28:06 +0200680 function onload() {
Marc Kupietze6a7a732018-01-12 09:21:08 +0100681 queryword = document.getElementById('word');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200682 }
683
684 function queryKorAP() {
Marc Kupietz78230872019-08-02 15:15:25 +0200685 window.open('http://korap.ids-mannheim.de' + korapPath + '?q='+queryword.value+korapVC, 'KorAP');
Marc Kupietz39179ab2017-07-04 16:28:06 +0200686 }
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100687
688 function queryKorAPCII(query) {
Marc Kupietz78230872019-08-02 15:15:25 +0200689 window.open('http://korap.ids-mannheim.de' +korapPath + '?ql=cosmas2&q='+query+korapVC, 'KorAP');
Marc Kupietz4dc270c2017-11-24 10:17:12 +0100690 }
Marc Kupietz83305222016-04-28 09:57:22 +0200691 </script>
692 </head>
Marc Kupietz7b0e5de2019-01-31 12:49:32 +0100693 <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>
694 <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>
695 <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>
696 <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>
697 <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>
698 <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>
699 <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>
700 <div style="display:none;" id="logdiceaf_ttt">Log-Dice using "auto-focus", i.e. the window that yields the highest score.</div>
Marc Kupietz6d7462c2019-12-05 10:16:38 +0100701 <div id="ids_logo">
702 <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>
703 </div>
704 <div id="header">
Marc Kupietz58270662017-12-04 12:10:06 +0100705 <div id="pagetitle">
Marc Kupietzc053d972019-01-10 10:41:51 +0100706 <h1>DeReKoVecs</h1>
707 <h2><%== $title %></h2>
Marc Kupietz4fcda0c2017-11-29 09:00:31 +0100708 </div>
Marc Kupietz58270662017-12-04 12:10:06 +0100709 <div id="options" class="widget">
710 <form id="queryform">
Marc Kupietz95104512019-12-05 10:13:05 +0100711 <input id="word" type="text" name="word" placeholder="<%= loc 'words_to_be_searched' %>" value="<%= $word %>"
712 title="<%= loc 'search_description' %>"/>
713 <input id="SEARCH" type="button" value="<%= loc 'SEARCH' %>">
714 <input type="button" id="showoptions" name="showoptions" value="<%= loc 'Options' %>" />
Marc Kupietz58270662017-12-04 12:10:06 +0100715 </form>
716 <div id="dropdownoptions" style="display: none">
717 <form id="optionsform">
718 <div class="controlgroup-vertical">
719 <label for="cutoff">cut-off</label>
720 <input id="cutoff" type="text" name="cutoff" size="10" value="<%= $cutoff %>" title="Only consider the most frequent x word forms.">
721 <label for="dedupe">dedupe</label>
722 <input id="dedupe" type="checkbox" name="dedupe" value="1" <%= ($dedupe ? "checked" : "") %> title="radically filter out any near-duplicates">
723 % if($mergedEnd > 0) {
724 <label for="sbf">backw.</label>
725 <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.">
726 % }
727 <label for="neighbours">max. neighbours:</label>
728 <input id="neighbours" size="4" name="n" value="<%= $no_nbs %>">
729 <label for="no_iterations">max. iterations</label>
730 <input id="no_iterations" name="N" size="4" value="<%= $no_iterations %>">
731 <!-- <label for="dosom">SOM</label>
732 <input id="dosom" type="checkbox" name="som" value="1" <%= ($show_som ? "checked" : "") %>> -->
733 % if($collocators) {
734 <label for="sortby">window/sort</label>
735 <select id="sortby" name="sort">
736 <option value="0" <%= ($sort!=1 && $sort!=2? "selected":"") %>>auto focus</option>
737 <!-- <option value="1" <%= ($sort==1? "selected":"") %>>any single position</option>
738 <option value="2" <%= ($sort==2? "selected":"") %>>whole window</option> -->
739 </select>
740 % }
741 <input type="button" value="→ KorAP" onclick="queryKorAP();" title="query word with KorAP"/>
Marc Kupietz1acb3172018-02-17 09:41:26 +0100742 <input id="show-details" type="checkbox" name="show-details" value="1" >
743 <label for="show-details">
744 Show details
745 </label>
Marc Kupietz58270662017-12-04 12:10:06 +0100746 </div>
747 </form>
748 </div>
749 </div>
750 </div>
751 <div id="topwrapper">
752 <div style="visibility: hidden;" id="tabs">
753 <ul>
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100754 % if (defined $word && $word ne '') {
755 % if($mergedEnd && $distantWords) {
756 <li><a href="#tabs-0" title="Cos offsets of the words furthest away from their position in the reference corpus."">Offsets</a></li>
757 % }
758 <li><a href="#tabs-1"><%= loc 'paradigmatic_tsne' %></a></li>
759 <li><a href="#tabs-2"><%= loc 'paradigmatic_som' %></a></li>
760 <li><a href="#tabs-3"><%= loc 'syntagmatic' %></a></li>
Marc Kupietzd7760b42019-02-21 09:01:44 +0100761 % }
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100762 <li><a href="#tabs-4">Info</a></li>
Marc Kupietz58270662017-12-04 12:10:06 +0100763 </ul>
Marc Kupietzb6514dc2019-06-26 11:47:56 +0200764 % if($mergedEnd && $distantWords) {
Marc Kupietzd7760b42019-02-21 09:01:44 +0100765 <div id="tabs-0" style="display: flex; padding: 5px; flex-flow: row wrap;">
766 <div id="vocabdist" style="width: 230px; margin-bottom: 15px;">
767 <table class="display compact nowrap" id="vocabdistt">
768 <thead>
769 <tr>
Marc Kupietz95977002019-02-26 09:09:59 +0100770 <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 +0100771 </tr>
772 </thead>
773 <tbody>
774 <tr>
775 <td align="right">
Marc Kupietz95977002019-02-26 09:09:59 +0100776 </td>
Marc Kupietzd7760b42019-02-21 09:01:44 +0100777 <td align="right">
778 </td>
779 <td></td>
780 </tr>
781 </tbody>
782 </table>
783 </div>
784 </div>
Marc Kupietzb6514dc2019-06-26 11:47:56 +0200785 % }
Marc Kupietz384c9132018-03-19 16:45:24 +0100786 <div id="tabs-1" style="display: flex; padding: 5px; flex-flow: row wrap;">
Marc Kupietz58270662017-12-04 12:10:06 +0100787 % if($lists && (@$lists) > 0 && (@$lists)[0]) {
788 <div id="wrapper">
Marc Kupietz384c9132018-03-19 16:45:24 +0100789 <div id="first" style="width: 230px; margin-bottom: 15px;">
Marc Kupietz58270662017-12-04 12:10:06 +0100790 <table class="display compact nowrap" id="firsttable">
791 <thead>
792 <tr>
Marc Kupietz95977002019-02-26 09:09:59 +0100793 <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 +0100794 </tr>
795 </thead>
796 <tbody>
797 <tr>
798 <td align="right">
799 </td>
800 <td align="right">
801 </td>
802 <td></td>
803 </tr>
804 </tbody>
805 </table>
806 </div>
Marc Kupietza55a09a2018-07-06 13:30:30 +0200807 % if(0 && $haveSProfiles) {
Marc Kupietz384c9132018-03-19 16:45:24 +0100808 <div id="sprofilesdiv" style="width: 200px; padding-right: 10px;">
809 <table class="display compact nowrap" id="sprofiles">
810 <thead>
811 <tr>
812 <th align="right">cos</th><th align="left">similars by coll. profile</th>
813 </tr>
814 </thead>
815 <tbody>
816 <tr>
817 <td align="right">
818 </td>
819 <td></td>
820 </tr>
821 </tbody>
822 </table>
823 </div>
824 %}
Marc Kupietz81aeed22019-02-17 21:22:45 +0100825 <div id="second">
Marc Kupietz58270662017-12-04 12:10:06 +0100826 <div id="embed">
827 </div>
828 <div id="cost">
829 </div>
830 </div>
831 </div>
Marc Kupietz81aeed22019-02-17 21:22:45 +0100832 % } elsif($word !~ /^\s*$/) {
833 <div id="wrapper">
Marc Kupietz81aeed22019-02-17 21:22:45 +0100834 <script>
835 $( function() {
Marc Kupietzce6490b2019-12-06 11:05:40 +0100836 $( "<%== loc 'notfounddialog' %>").dialog({
Marc Kupietz81aeed22019-02-17 21:22:45 +0100837 autoOpen: true,
838 modal: true,
839 draggable: false,
840 height: "auto",
841 width: "auto",
842 resizable: false,
843 buttons: {
844 "OK": function() {
845 $( this ).dialog( "close" );
Marc Kupietzce6490b2019-12-06 11:05:40 +0100846 } /* ,
Marc Kupietz81aeed22019-02-17 21:22:45 +0100847 "Apply": function() {
848 window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self");
Marc Kupietzce6490b2019-12-06 11:05:40 +0100849 } */
Marc Kupietz81aeed22019-02-17 21:22:45 +0100850 }
851 });
852 });
853 </script>
Marc Kupietzce6490b2019-12-06 11:05:40 +0100854 <div id="not-found-dialog_de" style="display: none" title="Nicht gefunden">
855 <p>FEHLER: Konnte "<%= $word %>" nicht finden.</p>
856 <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>
857 </div>
858 <div id="not-found-dialog_en" style="display: none" title="Not found">
859 <p>ERROR: "<%= $word %>" not found in vocabluary.</p>
860 <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>
861 </div>
Marc Kupietz81aeed22019-02-17 21:22:45 +0100862 </div>
Marc Kupietz384c9132018-03-19 16:45:24 +0100863 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100864 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100865 <div id="tabs-2" style="display: flex; padding: 5px; flex-flow: row wrap;">
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100866 % if(defined $word && $word ne "") {
867 <div id="som2" style="width: 800;">
868 <div id="sominfo1"><span id="somcolor1"> </span> <span id="somword1"> </span> <span id="somcolor2"> </span> <span id="somword2"> </span> <span id="somcolor3"> </span></div>
869 <div id="sominfo" style="text-align: right">SOM iteration <span id="iterations">0</span></div>
870 </div>
871 % }
Marc Kupietz58270662017-12-04 12:10:06 +0100872 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100873 <div id="tabs-3" style="display: flex; padding:5px; flex-flow: row wrap;">
874 <div style="margin-right: 20px; margin-bottom: 10px;" id="secondt">
Marc Kupietze6a7a732018-01-12 09:21:08 +0100875 <table class="display compact nowrap" id="secondtable">
Marc Kupietz58270662017-12-04 12:10:06 +0100876 <thead>
877 <tr>
878 % if($collocators) {
879 <th>#</th>
Marc Kupietz4116b432017-12-06 14:15:32 +0100880 <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>
881 <th align="right" title="Maximum activation of the collocator anywhere in the output layer.">max(a)</th>
882 <th title="Average raw activation of the collocator in the columns selected by auto-focus." align="right">⟨a⟩</th>
883 <th title="Sum of activations over the selected colunns normalized by the total activation sum of the selected columns." align="right">Σa/Σw'</th>
884 <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 +0100885 <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 +0100886 <th align="left"><%= loc 'collocate_w2v' %></th>
Marc Kupietz58270662017-12-04 12:10:06 +0100887 % }
888 </tr>
889 </thead>
890 <tbody>
891 <tr>
892 <td align="right">
893 </td>
894 <td align="right">
895 </td>
896 <td align="right">
897 </td>
898 <td align="right">
899 </td>
900 <td align="right">
901 </td>
902 <td align="right">
903 </td>
Marc Kupietz58270662017-12-04 12:10:06 +0100904 </tr>
905 </tbody>
906 </table>
Marc Kupietz66bfd952017-12-11 09:59:45 +0100907 </div>
Marc Kupietzdeb8f622018-03-12 09:41:00 +0100908 <div id="ccd" style="">
Marc Kupietze6a7a732018-01-12 09:21:08 +0100909 <table class="display compact nowrap" id="classicoloctable">
910 <thead>
Marc Kupietzcd136e22018-01-29 09:18:12 +0100911 % if($collocators) {
912 <tr>
Marc Kupietzf19814b2019-01-21 16:50:19 +0100913 <th id="ll_tt">LL</th>
Marc Kupietzfab14a72019-01-22 16:20:29 +0100914 <th id="mi_tt">MI</th>
915 <th id="md_tt">MI²</th>
Marc Kupietzf19814b2019-01-21 16:50:19 +0100916 <th id="lfmd_tt">MI³</th>
Marc Kupietzfab14a72019-01-22 16:20:29 +0100917 <th id="npmi_tt">nPMI</th>
918 <th id="dice_tt">dice</th>
Marc Kupietz63b268f2019-01-22 22:34:29 +0100919 <th id="logdice_tt">LD</th>
920 <th id="logdiceaf_tt">LDaf</th>
Marc Kupietz001bffd2019-02-21 08:52:41 +0100921 <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 Kupietz95104512019-12-05 10:13:05 +0100922 <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 ◽."><span class="regular"><%= loc 'af_window' %></span></th>
Marc Kupietz5a7f9ac2018-01-30 11:22:44 +0100923 <th title="PMI³ restricted to left neighbour">l-PMI³</th>
924 <th title="PMI³ restricted to right neighbour">r-PMI³</th>
925 <th title="nPMI restricted to left neighbour">l-nPMI</th>
926 <th title="nPMI restricted to right neighbour">r-nPMI</th>
Marc Kupietz4784fae2019-02-04 12:32:12 +0100927 <th id="rawfreq_tt" title="raw frequency sum of collocation within window">raw</th>
Marc Kupietz95104512019-12-05 10:13:05 +0100928 <th><%= loc 'collocate_ca' %></th>
Marc Kupietzcd136e22018-01-29 09:18:12 +0100929 </tr>
Marc Kupietz1acb3172018-02-17 09:41:26 +0100930 % }
Marc Kupietze6a7a732018-01-12 09:21:08 +0100931 </thead>
932 <tbody>
933 <tr>
Marc Kupietz63b268f2019-01-22 22:34:29 +0100934 <td align="right"></td>
935 <td align="right"></td>
936 <td align="right"></td>
Marc Kupietzb4b53ca2018-01-25 08:57:11 +0100937 <td align="right"></td>
Marc Kupietz78d7c1a2019-02-17 22:31:22 +0100938 <td align="right"></td>
939 <td align="right"></td>
940 <td align="right"></td>
941 <td align="right"></td>
942 <td align="right"></td>
943 <td align="left"> </td>
944 <td align="right"></td>
945 <td align="right"></td>
946 <td align="right"></td>
947 <td align="right"></td>
948 <td align="left"> </td>
Marc Kupietze6a7a732018-01-12 09:21:08 +0100949 </tr>
950 </tbody>
951 </table>
952 </div>
Marc Kupietz384c9132018-03-19 16:45:24 +0100953 <!--
954 <div style="clear:both" ></div>
955 <div style="float: right; overflow: hidden" id="extra"><button onClick="showCollocatorSOM()"> </button></div>
956 -->
Marc Kupietz66bfd952017-12-11 09:59:45 +0100957 </div>
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100958 <div id="tabs-4" style="display: flex; padding:5px; flex-flow: row wrap;">
959 <div id="info">
960 <h3><%== loc 'about' %></h3>
961 %= include(loc('abouttext'))
962 % if($training_args && (@$lists)[0]) {
963 <h3><%= loc 'training_parameters' %></h3>
964 % if($training_args =~ /-type\s*3/) {
965 <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>
966 <div class="mono"><%= $training_args %></div>
967 % } else {
968 <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>
969 <div class="mono"><%= $training_args %></div>
970 % }
Marc Kupietz2133bd12022-05-19 09:24:42 +0200971 % }
972 <h3>Source Code</h3>
973 <ul>
974 <li><a href="https://korap.ids-mannheim.de/gerrit/plugins/gitiles/ids-kl/dereko2vec">dereko2vec</a></li>
975 <li><a href="https://korap.ids-mannheim.de/gerrit/plugins/gitiles/ids-kl/derekovecs">derekovecs</a></li>
976 </ul>
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100977 <h3><%== loc 'references' %></h3>
978 %= include 'references'
979 </div>
980 </div>
981 </div> <!-- tabs -->
Marc Kupietz58270662017-12-04 12:10:06 +0100982 </div> <!-- topwrapper -->
983 <div style="clear: both;"></div>
984 </div>
Marc Kupietzd6dfdf02019-12-06 09:53:34 +0100985 <div class="footer">
986 <span class="footertext">
987 %= include(loc('footer'))
988 </span>
Marc Kupietzebea4702018-01-12 09:16:09 +0100989 </div>
Marc Kupietz58270662017-12-04 12:10:06 +0100990 </body>
Marc Kupietz83305222016-04-28 09:57:22 +0200991</html>