| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| Marc Kupietz | c053d97 | 2019-01-10 10:41:51 +0100 | [diff] [blame] | 4 | <% my $plain_title = $title; $plain_title=~s/<[^>]+>//g; %> |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 5 | %# 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 Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 12 | <title><%= $plain_title %>:<%= $word %> · IDS word vector analysis</title> |
| Marc Kupietz | b3cd59f | 2026-08-21 10:47:45 +0200 | [diff] [blame] | 13 | %# 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 Kupietz | 80bd7b9 | 2017-07-04 16:25:54 +0200 | [diff] [blame] | 18 | <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 19 | <link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Condensed" rel="stylesheet"> |
| Marc Kupietz | 42e6d09 | 2023-04-18 19:29:12 +0200 | [diff] [blame] | 20 | <script src="https://code.jquery.com/jquery-latest.min.js"></script> |
| Marc Kupietz | 898e548 | 2024-02-20 15:03:07 +0100 | [diff] [blame] | 21 | <script src = "https://cdn.datatables.net/1.13.10/js/jquery.dataTables.min.js"></script> |
| Marc Kupietz | 5f532b3 | 2019-01-23 10:03:18 +0100 | [diff] [blame] | 22 | <script src = "https://cdn.datatables.net/fixedcolumns/3.2.5/js/dataTables.fixedColumns.min.js"></script> |
| Marc Kupietz | 898e548 | 2024-02-20 15:03:07 +0100 | [diff] [blame] | 23 | <script src = "https://cdn.datatables.net/plug-ins/1.13.10/sorting/scientific.js"></script> |
| Marc Kupietz | 5f532b3 | 2019-01-23 10:03:18 +0100 | [diff] [blame] | 24 | <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'></script> |
| Marc Kupietz | 898e548 | 2024-02-20 15:03:07 +0100 | [diff] [blame] | 25 | <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 Kupietz | 9ae184c | 2023-11-04 18:21:54 +0100 | [diff] [blame] | 30 | <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 Kupietz | 898e548 | 2024-02-20 15:03:07 +0100 | [diff] [blame] | 37 | <link rel="stylesheet" href="https://cdn.datatables.net/1.13.10/css/jquery.dataTables.min.css"> |
| Marc Kupietz | 4949d23 | 2018-03-19 16:43:18 +0100 | [diff] [blame] | 38 | <link rel="stylesheet" href="/derekovecs/css/derekovecs.css"> |
| Marc Kupietz | 80bd7b9 | 2017-07-04 16:25:54 +0200 | [diff] [blame] | 39 | <script |
| Marc Kupietz | 42e6d09 | 2023-04-18 19:29:12 +0200 | [diff] [blame] | 40 | src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 41 | integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" |
| 42 | crossorigin="anonymous"></script> |
| Marc Kupietz | 80bd7b9 | 2017-07-04 16:25:54 +0200 | [diff] [blame] | 43 | <script> |
| Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 44 | 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 Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 52 | var urlParams = new URLSearchParams(window.location.search); |
| Marc Kupietz | b3a2e4f | 2017-12-08 17:25:53 +0100 | [diff] [blame] | 53 | var currentWords = urlParams.get("word"); |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 54 | % 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 Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 63 | var collocatorTable = null; |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 64 | var classicCollocatorTable = null; |
| 65 | var singleWord = <%= $single_word ? 'true' : 'false' %>; |
| Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 66 | var plainTitle ="<%= $plain_title %>" |
| Marc Kupietz | 78d7c1a | 2019-02-17 22:31:22 +0100 | [diff] [blame] | 67 | var korapPath="/"; |
| 68 | if (plainTitle.match(/-en/)) { |
| 69 | korapPath="/instance/english"; |
| 70 | } |
| Marc Kupietz | 7823087 | 2019-08-02 15:15:25 +0200 | [diff] [blame] | 71 | var korapVC=""; |
| 72 | if (plainTitle.match(/WUDD/i)) { |
| 73 | korapVC="&collection=corpusSigle+%3D+%2FW%5BDU%5DD17%2F"; |
| 74 | korapPath="/instance/test"; |
| 75 | } |
| 76 | |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 77 | $(document).ready(function() { |
| Marc Kupietz | 5b8aaf7 | 2026-09-04 19:21:22 +0200 | [diff] [blame] | 78 | insertCalendarEvents(document.getElementById('downtimes'), '/derekovecs/getDowntimeCalendar', 7); |
| Marc Kupietz | 694610d | 2017-11-25 18:30:03 +0100 | [diff] [blame] | 79 | |
| Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 80 | $('#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 Kupietz | 9597700 | 2019-02-26 09:09:59 +0100 | [diff] [blame] | 88 | function () { |
| Marc Kupietz | 7bd5523 | 2019-01-22 15:29:06 +0100 | [diff] [blame] | 89 | $("#mi_tt").attr("title",$("#pmi_ttt").html()); |
| Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 90 | $("#lfmd_tt").attr("title",$("#lfmd_ttt").html()); |
| Marc Kupietz | 7bd5523 | 2019-01-22 15:29:06 +0100 | [diff] [blame] | 91 | $("#md_tt").attr("title",$("#md_ttt").html()); |
| Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 92 | $("#npmi_tt").attr("title",$("#npmi_ttt").html()); |
| Marc Kupietz | f19814b | 2019-01-21 16:50:19 +0100 | [diff] [blame] | 93 | $("#ll_tt").attr("title",$("#ll_ttt").html()); |
| Marc Kupietz | 7bd5523 | 2019-01-22 15:29:06 +0100 | [diff] [blame] | 94 | $("#logdice_tt").attr("title",$("#logdice_ttt").html()); |
| Marc Kupietz | 63b268f | 2019-01-22 22:34:29 +0100 | [diff] [blame] | 95 | $("#logdiceaf_tt").attr("title",$("#logdiceaf_ttt").html()); |
| Marc Kupietz | a0ffb39 | 2018-01-25 08:53:43 +0100 | [diff] [blame] | 96 | } |
| 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 Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 111 | $("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 Kupietz | dab9f22 | 2017-11-29 14:22:59 +0100 | [diff] [blame] | 121 | |
| Marc Kupietz | e871abd | 2018-01-25 16:18:27 +0100 | [diff] [blame] | 122 | var collocatorTable_activated = false; |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 123 | $( "#tabs" ).on( "tabsactivate", function( event, ui ) { |
| 124 | if (localStorage) localStorage['tab'] = ui.newTab.index(); |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 125 | if(ui.newTab.index() == 3 && !collocatorTable_activated && collocatorTable) { |
| 126 | if (classicCollocatorTable) classicCollocatorTable.columns.adjust(); |
| Marc Kupietz | e871abd | 2018-01-25 16:18:27 +0100 | [diff] [blame] | 127 | collocatorTable.columns.adjust(); |
| 128 | collocatorTable_activated = true; |
| 129 | } |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 130 | }); |
| 131 | |
| 132 | $(function(){ |
| 133 | $("#SEARCH").click(function() { |
| 134 | window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self"); |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 135 | }); |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 136 | }); |
| Marc Kupietz | 0af83e3 | 2017-11-27 09:31:37 +0100 | [diff] [blame] | 137 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 138 | function changeCharColor(txt, heat, word) { |
| 139 | var newText = ""; |
| 140 | for (var i=0, l=txt.length; i<l; i++) { |
| Marc Kupietz | 49c5cf0 | 2024-08-06 10:30:44 +0200 | [diff] [blame] | 141 | newText += (i == 5 ? txt.charAt(i) : "<a href=\"<%= $korap_url %>" + korapPath + '/?ql=cosmas2&q=' + |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 142 | CIIsearchWords + ' /' + (i > 5? '%2B' : '-') + 'w' + |
| Rainer Perkuhn | e58a749 | 2024-07-30 15:17:52 +0200 | [diff] [blame] | 143 | Math.abs(i-5) + ':' + Math.abs(i-5) + ',s0 ' + word + korapVC + |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 144 | '" target="korap"><span style="background-color:' + |
| 145 | getHeatColor(heat[i]/maxHeat)+'">'+txt.charAt(i)+'</span></a>'); |
| Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 146 | } |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 147 | return newText; |
| 148 | } |
| Marc Kupietz | b6c615d | 2017-12-02 10:38:20 +0100 | [diff] [blame] | 149 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 150 | 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 Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 163 | var paraResults = <%= b(Mojo::JSON::to_json($lists)) %>; |
| 164 | var urlprefix = new URLSearchParams(window.location.search); |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 165 | if (paraResults.length > 0 && paraResults[0] != null && paraResults[0].length > 0) { |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 166 | 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 Kupietz | 0d4c0ca | 2017-12-04 09:18:56 +0100 | [diff] [blame] | 175 | } |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 176 | showMap({target: targetWords, mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked} ); |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 177 | var t = $('#firsttable').DataTable({ |
| Marc Kupietz | ee894d5 | 2019-01-09 14:55:14 +0100 | [diff] [blame] | 178 | data: [].concat.apply([], paraResults), |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 179 | "sScrollY": "780px", |
| 180 | "bScrollCollapse": true, |
| 181 | "bPaginate": false, |
| 182 | "bJQueryUI": true, |
| Marc Kupietz | 898e548 | 2024-02-20 15:03:07 +0100 | [diff] [blame] | 183 | "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 Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 190 | "initComplete":function(settings, json) { |
| 191 | $('td.paradigmator a').on('mousedown', function(e) { |
| Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 192 | return paradigmatorClick(e, paraResults[0][0].word, this.childNodes["0"].textContent); |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 193 | }); |
| 194 | }, |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 195 | "columns": [ |
| 196 | { "data": "rank", type: "allnumeric" }, |
| 197 | { "data": "dist", render: function ( data, type, row ) {return data.toFixed(3) }}, |
| Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 198 | { "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 Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 201 | ], |
| 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 Kupietz | 0d4c0ca | 2017-12-04 09:18:56 +0100 | [diff] [blame] | 216 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 217 | 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 Kupietz | cddc848 | 2019-12-04 08:57:33 +0100 | [diff] [blame] | 231 | if(typeof data !== 'undefined' && data.mergedEnd > 0) { |
| Marc Kupietz | 7823087 | 2019-08-02 15:15:25 +0200 | [diff] [blame] | 232 | vocabDistanceTable = makeVocabDistanceTable("#vocabdistt", baseURL); |
| 233 | } |
| Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 234 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 235 | 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 Kupietz | 898e548 | 2024-02-20 15:03:07 +0100 | [diff] [blame] | 243 | "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 Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 251 | { "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 Kupietz | 21fcd5f | 2026-09-06 13:17:29 +0200 | [diff] [blame] | 254 | %# 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 Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 256 | { "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 Kupietz | 21fcd5f | 2026-09-06 13:17:29 +0200 | [diff] [blame] | 264 | { className: "dt-right", "targets": [0,2,3,4,5,6,7] }, |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 265 | { className: "dt-center", "targets": [ 1] }, |
| 266 | { "searchable": false, |
| 267 | "orderable": false, |
| Marc Kupietz | 21fcd5f | 2026-09-06 13:17:29 +0200 | [diff] [blame] | 268 | "targets": [0, 9] |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 269 | }, |
| 270 | { "type": "scientific", targets: [2,3,4,5,6] }, |
| Marc Kupietz | 21fcd5f | 2026-09-06 13:17:29 +0200 | [diff] [blame] | 271 | { "orderSequence": [ "desc" ], "targets": [ 2, 3, 4, 5, 6, 7 ] }, |
| 272 | { "orderSequence": [ "asc", "desc" ], "targets": [ 1, 8 ] }, |
| 273 | { "targets": [9], "visible": false } |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 274 | ], |
| 275 | "oLanguage": { |
| 276 | "sSearch": "Filter: " |
| 277 | }, |
| Marc Kupietz | 21fcd5f | 2026-09-06 13:17:29 +0200 | [diff] [blame] | 278 | "order": [[ 5, 'desc' ]], |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 279 | } ); |
| 280 | $.ajaxSetup({ |
| 281 | type: 'POST', |
| 282 | timeout: 30000, |
| 283 | error: function(xhr) { |
| 284 | $('#display_error') |
| 285 | .html('Error: ' + xhr.status + ' ' + xhr.statusText); |
| 286 | } |
| Marc Kupietz | 78b434a | 2018-01-12 22:33:32 +0100 | [diff] [blame] | 287 | }); |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 288 | |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 289 | |
| 290 | if($('#sprofiles').length) { |
| 291 | similarProfileTable = $('#sprofiles').DataTable({ |
| 292 | ajax: { |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 293 | method: "GET", |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 294 | url: '/derekovecs/getSimilarProfiles', |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 295 | dataType: 'json', |
| 296 | dataSrc: "", |
| 297 | timeout: 30000, |
| 298 | data: { w: paraResults[0][0].rank } |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 299 | }, |
| 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 Kupietz | 898e548 | 2024-02-20 15:03:07 +0100 | [diff] [blame] | 314 | "columns": [ |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 315 | { "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 Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 327 | |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 328 | // var filterQuot = /(^quot?=[A-Z])|(quot$)/g; |
| 329 | var filterQuot = /^quot/; |
| Marc Kupietz | 4784fae | 2019-02-04 12:32:12 +0100 | [diff] [blame] | 330 | var ccResult; |
| Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 331 | var baseURL = window.location.pathname.replace(/[/]$/, '') |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 332 | // 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 Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 337 | |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 338 | $('#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 Kupietz | 1acb317 | 2018-02-17 09:41:26 +0100 | [diff] [blame] | 350 | |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 351 | $("td.collocator").click(function(){ |
| Rainer Perkuhn | d5010ec | 2024-07-30 14:38:25 +0200 | [diff] [blame] | 352 | queryKorAPCII(this.textContent + " /w1:5,s0 " + CIIsearchWords); |
| Marc Kupietz | ad78372 | 2018-01-13 17:45:21 +0100 | [diff] [blame] | 353 | }); |
| 354 | |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 355 | 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 Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 361 | |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 362 | 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 Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 368 | |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 369 | $(function(){ |
| 370 | $("#dropdownoptions").dialog({ |
| Marc Kupietz | 9510451 | 2019-12-05 10:13:05 +0100 | [diff] [blame] | 371 | title: "<%= loc 'Options' %>", |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 372 | autoOpen: false, |
| 373 | modal: false, |
| 374 | draggable: false, |
| 375 | height: "auto", |
| 376 | width: "auto", |
| 377 | resizable: false, |
| 378 | buttons: { |
| Marc Kupietz | 9510451 | 2019-12-05 10:13:05 +0100 | [diff] [blame] | 379 | "<%= loc 'Cancel'%>": function() { |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 380 | $( this ).dialog( "close" ); |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 381 | }, |
| Marc Kupietz | 9510451 | 2019-12-05 10:13:05 +0100 | [diff] [blame] | 382 | "<%= loc 'Apply' %>": function() { |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 383 | window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self"); |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 384 | } |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 385 | } |
| 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 Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 397 | }); |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 398 | }); |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 399 | }); |
| 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 Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 480 | </script> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 481 | <script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script> |
| Marc Kupietz | 68e29be | 2023-11-04 18:37:35 +0100 | [diff] [blame] | 482 | <script src="/derekovecs/js/calendar-events.js"></script> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 483 | <script src="/derekovecs/js/tsne.js"></script> |
| 484 | <script src="/derekovecs/js/som.js"></script> |
| 485 | <script src="/derekovecs/js/labeler.js"></script> |
| Marc K | 20476c7 | 2021-03-11 12:18:01 +0100 | [diff] [blame] | 486 | <script src="/derekovecs/js/derekovecs.js"></script> |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 487 | <script> |
| 488 | |
| 489 | var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>}, |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 490 | mapWidth = 800, // width map |
| 491 | mapHeight = 800, |
| 492 | jitterRadius = 7; |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 493 | |
| 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 Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 502 | 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 Kupietz | 7823087 | 2019-08-02 15:15:25 +0200 | [diff] [blame] | 510 | (d.x) + "," + |
| 511 | (d.y) + ")"; |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 512 | }); |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 513 | } |
| Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 514 | |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 515 | function updateEmbedding() { |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 516 | var Y = T.getSolution(); |
| 517 | svg.selectAll('.tsnet') |
| 518 | .data(data.words) |
| 519 | .attr("transform", function(d, i) { |
| 520 | return "translate(" + |
| Marc Kupietz | 7823087 | 2019-08-02 15:15:25 +0200 | [diff] [blame] | 521 | ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," + |
| 522 | ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; }); |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | var svg; |
| 526 | var labels = []; |
| 527 | var anchor_array = []; |
| 528 | var text; |
| 529 | |
| Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 530 | function getMergedClass(i) { |
| Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 531 | if(typeof data !== 'undefined' && i > data.mergedEnd) { |
| Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 532 | 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 Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 550 | function drawEmbedding() { |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 551 | var urlprefix = new URLSearchParams(window.location.search); |
| 552 | urlprefix.delete("word"); |
| 553 | urlprefix.append("word",""); |
| Marc Kupietz | 8f9c86a | 2017-12-04 17:17:13 +0100 | [diff] [blame] | 554 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 555 | $("#embed").empty(); |
| 556 | var div = d3.select("#embed"); |
| Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 557 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 558 | // get min and max in each column of Y |
| 559 | var Y = T.Y; |
| Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 560 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 561 | svg = div.append("svg") // svg is global |
| 562 | .attr("width", mapWidth) |
| 563 | .attr("height", mapHeight); |
| Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 564 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 565 | var g = svg.selectAll(".b") |
| 566 | .data(data.words) |
| 567 | .enter().append("g") |
| 568 | .attr("class", "tsnet"); |
| Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 569 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 570 | 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 Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 579 | res += "target"; |
| 580 | } |
| 581 | if(data.mergedEnd && data.ranks[i] >= data.mergedEnd) { |
| 582 | return res+" merged"; |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 583 | } else { |
| 584 | return res; |
| 585 | } |
| 586 | }) |
| 587 | .attr("title", function(d, i) { |
| Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 588 | return getRankTooltip(i); |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 589 | }) |
| 590 | .append("text") |
| 591 | .attr("text-anchor", "top") |
| 592 | .attr("font-size", 12) |
| 593 | .text(function(d) { return d; }); |
| Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 594 | |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 595 | g.append("svg:title") |
| 596 | .text(function(d, i) { |
| Marc Kupietz | 2e2e4db | 2018-12-21 15:07:37 +0100 | [diff] [blame] | 597 | return getRankTooltip(i); |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 598 | }); |
| 599 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 600 | var zoomListener = d3.behavior.zoom() |
| 601 | .scaleExtent([0.1, 10]) |
| 602 | .center([0,0]) |
| 603 | .on("zoom", zoomHandler); |
| 604 | zoomListener(svg); |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | var tx=0, ty=0; |
| 608 | var ss=1; |
| 609 | var iter_id=-1; |
| 610 | |
| 611 | function zoomHandler() { |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 612 | tx = d3.event.translate[0]; |
| 613 | ty = d3.event.translate[1]; |
| 614 | ss = d3.event.scale; |
| 615 | updateEmbedding(); |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | var stepnum = 0; |
| 619 | |
| 620 | function stopStep() { |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 621 | clearInterval(iter_id); |
| 622 | text = svg.selectAll("text"); |
| Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 623 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 624 | // 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 Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 635 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 636 | // 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 Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 643 | |
| Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 644 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 645 | // 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 Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 654 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 655 | iter_id = setInterval(jitterStep, 1); |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | var jitter_i=0; |
| 659 | |
| 660 | function jitterStep() { |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 661 | if(jitter_i++ > 100) { |
| 662 | clearInterval(iter_id); |
| 663 | } else { |
| 664 | labeler.start2(10); |
| 665 | applyJitter(); |
| 666 | } |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | var last_cost=1000; |
| 670 | |
| 671 | function step() { |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 672 | var i = T.iter; |
| Marc Kupietz | 34c0817 | 2017-11-29 17:08:47 +0100 | [diff] [blame] | 673 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 674 | 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 Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 681 | } else { |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 682 | last_cost = cost; |
| 683 | updateEmbedding(); |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 684 | } |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 685 | } |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 686 | } |
| 687 | |
| 688 | function showMap(j) { |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 689 | 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 Kupietz | 7811453 | 2017-11-29 17:00:16 +0100 | [diff] [blame] | 695 | |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 696 | 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 Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 704 | } |
| Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 705 | var queryword; |
| 706 | |
| Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 707 | function showCollocatorSOM() { |
| Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 708 | var baseURL = window.location.pathname.replace(/[/]$/, '') |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 709 | 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 Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 716 | } |
| Marc Kupietz | 86b5029 | 2019-02-17 21:03:59 +0100 | [diff] [blame] | 717 | $.post(baseURL+'/getVecsByRanks', |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 718 | JSON.stringify(nranks), |
| 719 | function(data, status){ |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 720 | showMap({target: targetWords, mergedEnd: <%= $mergedEnd %>, words: nwords, vecs: data, ranks: nranks, marked: Array(100).fill(false)} ); |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 721 | }, 'json'); |
| 722 | } |
| Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 723 | } |
| 724 | |
| Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 725 | function onload() { |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 726 | queryword = document.getElementById('word'); |
| Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | function queryKorAP() { |
| Marc Kupietz | 49c5cf0 | 2024-08-06 10:30:44 +0200 | [diff] [blame] | 730 | window.open("<%= $korap_url %>" + korapPath + '?q='+queryword.value+korapVC, 'KorAP'); |
| Marc Kupietz | 39179ab | 2017-07-04 16:28:06 +0200 | [diff] [blame] | 731 | } |
| Marc Kupietz | 4dc270c | 2017-11-24 10:17:12 +0100 | [diff] [blame] | 732 | |
| 733 | function queryKorAPCII(query) { |
| Marc Kupietz | 49c5cf0 | 2024-08-06 10:30:44 +0200 | [diff] [blame] | 734 | window.open("<%= $korap_url %>" +korapPath + '?ql=cosmas2&q='+query+korapVC, 'KorAP'); |
| Marc Kupietz | 4dc270c | 2017-11-24 10:17:12 +0100 | [diff] [blame] | 735 | } |
| Marc Kupietz | 49c5cf0 | 2024-08-06 10:30:44 +0200 | [diff] [blame] | 736 | |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 737 | </script> |
| 738 | </head> |
| Marc Kupietz | 7b0e5de | 2019-01-31 12:49:32 +0100 | [diff] [blame] | 739 | <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 Kupietz | 1e00eb8 | 2026-09-04 16:38:30 +0200 | [diff] [blame] | 746 | <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 Kupietz | 6d7462c | 2019-12-05 10:16:38 +0100 | [diff] [blame] | 747 | <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 Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 751 | <div id="pagetitle"> |
| Marc Kupietz | c053d97 | 2019-01-10 10:41:51 +0100 | [diff] [blame] | 752 | <h1>DeReKoVecs</h1> |
| 753 | <h2><%== $title %></h2> |
| Marc Kupietz | 4fcda0c | 2017-11-29 09:00:31 +0100 | [diff] [blame] | 754 | </div> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 755 | <div id="options" class="widget"> |
| 756 | <form id="queryform"> |
| Marc Kupietz | 9510451 | 2019-12-05 10:13:05 +0100 | [diff] [blame] | 757 | <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 Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 761 | </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 Kupietz | 1acb317 | 2018-02-17 09:41:26 +0100 | [diff] [blame] | 788 | <input id="show-details" type="checkbox" name="show-details" value="1" > |
| 789 | <label for="show-details"> |
| 790 | Show details |
| 791 | </label> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 792 | </div> |
| 793 | </form> |
| 794 | </div> |
| 795 | </div> |
| 796 | </div> |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 797 | %# 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 Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 803 | <div id="topwrapper"> |
| 804 | <div style="visibility: hidden;" id="tabs"> |
| 805 | <ul> |
| Marc Kupietz | d6dfdf0 | 2019-12-06 09:53:34 +0100 | [diff] [blame] | 806 | % 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 Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 812 | %# 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 Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 817 | % } |
| Marc Kupietz | d6dfdf0 | 2019-12-06 09:53:34 +0100 | [diff] [blame] | 818 | <li><a href="#tabs-4">Info</a></li> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 819 | </ul> |
| Marc Kupietz | b6514dc | 2019-06-26 11:47:56 +0200 | [diff] [blame] | 820 | % if($mergedEnd && $distantWords) { |
| Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 821 | <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 Kupietz | 9597700 | 2019-02-26 09:09:59 +0100 | [diff] [blame] | 826 | <th align="right">#</th><th id="cosD" align="right">D<sub>cos</sub></th><th align="left">word</th> |
| Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 827 | </tr> |
| 828 | </thead> |
| 829 | <tbody> |
| 830 | <tr> |
| 831 | <td align="right"> |
| Marc Kupietz | 9597700 | 2019-02-26 09:09:59 +0100 | [diff] [blame] | 832 | </td> |
| Marc Kupietz | d7760b4 | 2019-02-21 09:01:44 +0100 | [diff] [blame] | 833 | <td align="right"> |
| 834 | </td> |
| 835 | <td></td> |
| 836 | </tr> |
| 837 | </tbody> |
| 838 | </table> |
| 839 | </div> |
| 840 | </div> |
| Marc Kupietz | b6514dc | 2019-06-26 11:47:56 +0200 | [diff] [blame] | 841 | % } |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 842 | <div id="tabs-1" style="display: flex; padding: 5px; flex-flow: row wrap;"> |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 843 | % if($have_results) { |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 844 | <div id="wrapper"> |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 845 | <div id="first" style="width: 230px; margin-bottom: 15px;"> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 846 | <table class="display compact nowrap" id="firsttable"> |
| 847 | <thead> |
| 848 | <tr> |
| Marc Kupietz | 9597700 | 2019-02-26 09:09:59 +0100 | [diff] [blame] | 849 | <th align="right">#</th><th align="right">S<sub>cos</sub></th><th align="left">similars by w2v</th> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 850 | </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 Kupietz | a55a09a | 2018-07-06 13:30:30 +0200 | [diff] [blame] | 863 | % if(0 && $haveSProfiles) { |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 864 | <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 Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 881 | <div id="second"> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 882 | <div id="embed"> |
| 883 | </div> |
| 884 | <div id="cost"> |
| 885 | </div> |
| 886 | </div> |
| 887 | </div> |
| Marc Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 888 | % } elsif($word !~ /^\s*$/) { |
| 889 | <div id="wrapper"> |
| Marc Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 890 | <script> |
| 891 | $( function() { |
| Marc Kupietz | ce6490b | 2019-12-06 11:05:40 +0100 | [diff] [blame] | 892 | $( "<%== loc 'notfounddialog' %>").dialog({ |
| Marc Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 893 | 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 Kupietz | ce6490b | 2019-12-06 11:05:40 +0100 | [diff] [blame] | 902 | } /* , |
| Marc Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 903 | "Apply": function() { |
| 904 | window.open($(location).attr('pathname')+'?'+$('form').serialize(), "_self"); |
| Marc Kupietz | ce6490b | 2019-12-06 11:05:40 +0100 | [diff] [blame] | 905 | } */ |
| Marc Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 906 | } |
| 907 | }); |
| 908 | }); |
| 909 | </script> |
| Marc Kupietz | ce6490b | 2019-12-06 11:05:40 +0100 | [diff] [blame] | 910 | <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 Kupietz | 81aeed2 | 2019-02-17 21:22:45 +0100 | [diff] [blame] | 918 | </div> |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 919 | % } |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 920 | </div> |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 921 | <div id="tabs-2" style="display: flex; padding: 5px; flex-flow: row wrap;"> |
| Marc Kupietz | d6dfdf0 | 2019-12-06 09:53:34 +0100 | [diff] [blame] | 922 | % 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 Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 928 | </div> |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 929 | % if($collocators) { |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 930 | <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 Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 932 | <table class="display compact nowrap" id="secondtable"> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 933 | <thead> |
| 934 | <tr> |
| 935 | % if($collocators) { |
| 936 | <th>#</th> |
| Marc Kupietz | 4116b43 | 2017-12-06 14:15:32 +0100 | [diff] [blame] | 937 | <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 Kupietz | 21fcd5f | 2026-09-06 13:17:29 +0200 | [diff] [blame] | 939 | <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 Kupietz | 4116b43 | 2017-12-06 14:15:32 +0100 | [diff] [blame] | 940 | <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 Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 943 | <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 Kupietz | 9510451 | 2019-12-05 10:13:05 +0100 | [diff] [blame] | 944 | <th align="left"><%= loc 'collocate_w2v' %></th> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 945 | % } |
| 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 Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 962 | </tr> |
| 963 | </tbody> |
| 964 | </table> |
| Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 965 | </div> |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 966 | % if(!$single_word) { |
| 967 | <div id="ccd" class="notice"><%= loc 'ca_single_word_only' %></div> |
| 968 | % } else { |
| Marc Kupietz | deb8f62 | 2018-03-12 09:41:00 +0100 | [diff] [blame] | 969 | <div id="ccd" style=""> |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 970 | <table class="display compact nowrap" id="classicoloctable"> |
| 971 | <thead> |
| Marc Kupietz | cd136e2 | 2018-01-29 09:18:12 +0100 | [diff] [blame] | 972 | % if($collocators) { |
| 973 | <tr> |
| Marc Kupietz | f19814b | 2019-01-21 16:50:19 +0100 | [diff] [blame] | 974 | <th id="ll_tt">LL</th> |
| Marc Kupietz | fab14a7 | 2019-01-22 16:20:29 +0100 | [diff] [blame] | 975 | <th id="mi_tt">MI</th> |
| 976 | <th id="md_tt">MI²</th> |
| Marc Kupietz | f19814b | 2019-01-21 16:50:19 +0100 | [diff] [blame] | 977 | <th id="lfmd_tt">MI³</th> |
| Marc Kupietz | fab14a7 | 2019-01-22 16:20:29 +0100 | [diff] [blame] | 978 | <th id="npmi_tt">nPMI</th> |
| 979 | <th id="dice_tt">dice</th> |
| Marc Kupietz | 63b268f | 2019-01-22 22:34:29 +0100 | [diff] [blame] | 980 | <th id="logdice_tt">LD</th> |
| 981 | <th id="logdiceaf_tt">LDaf</th> |
| Marc Kupietz | 001bffd | 2019-02-21 08:52:41 +0100 | [diff] [blame] | 982 | <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 Kupietz | 1e00eb8 | 2026-09-04 16:38:30 +0200 | [diff] [blame] | 983 | <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 Kupietz | 5a7f9ac | 2018-01-30 11:22:44 +0100 | [diff] [blame] | 984 | <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 Kupietz | 4784fae | 2019-02-04 12:32:12 +0100 | [diff] [blame] | 988 | <th id="rawfreq_tt" title="raw frequency sum of collocation within window">raw</th> |
| Marc Kupietz | 9510451 | 2019-12-05 10:13:05 +0100 | [diff] [blame] | 989 | <th><%= loc 'collocate_ca' %></th> |
| Marc Kupietz | cd136e2 | 2018-01-29 09:18:12 +0100 | [diff] [blame] | 990 | </tr> |
| Marc Kupietz | 1acb317 | 2018-02-17 09:41:26 +0100 | [diff] [blame] | 991 | % } |
| Marc Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 992 | </thead> |
| 993 | <tbody> |
| 994 | <tr> |
| Marc Kupietz | 63b268f | 2019-01-22 22:34:29 +0100 | [diff] [blame] | 995 | <td align="right"></td> |
| 996 | <td align="right"></td> |
| 997 | <td align="right"></td> |
| Marc Kupietz | b4b53ca | 2018-01-25 08:57:11 +0100 | [diff] [blame] | 998 | <td align="right"></td> |
| Marc Kupietz | 78d7c1a | 2019-02-17 22:31:22 +0100 | [diff] [blame] | 999 | <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 Kupietz | e6a7a73 | 2018-01-12 09:21:08 +0100 | [diff] [blame] | 1010 | </tr> |
| 1011 | </tbody> |
| 1012 | </table> |
| 1013 | </div> |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 1014 | % } |
| Marc Kupietz | 384c913 | 2018-03-19 16:45:24 +0100 | [diff] [blame] | 1015 | <!-- |
| 1016 | <div style="clear:both" ></div> |
| 1017 | <div style="float: right; overflow: hidden" id="extra"><button onClick="showCollocatorSOM()"> </button></div> |
| 1018 | --> |
| Marc Kupietz | 66bfd95 | 2017-12-11 09:59:45 +0100 | [diff] [blame] | 1019 | </div> |
| Marc Kupietz | 565274e | 2026-09-06 13:17:17 +0200 | [diff] [blame] | 1020 | % } |
| Marc Kupietz | d6dfdf0 | 2019-12-06 09:53:34 +0100 | [diff] [blame] | 1021 | <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 Kupietz | 2133bd1 | 2022-05-19 09:24:42 +0200 | [diff] [blame] | 1034 | % } |
| 1035 | <h3>Source Code</h3> |
| 1036 | <ul> |
| Marc Kupietz | 5b8aaf7 | 2026-09-04 19:21:22 +0200 | [diff] [blame] | 1037 | <li><a href="https://github.com/kupietz/dereko2vec">dereko2vec</a></li> |
| 1038 | <li><a href="https://github.com/kupietz/collocatordb">collocatordb</a></li> |
| Marc Kupietz | 2133bd1 | 2022-05-19 09:24:42 +0200 | [diff] [blame] | 1039 | <li><a href="https://korap.ids-mannheim.de/gerrit/plugins/gitiles/ids-kl/derekovecs">derekovecs</a></li> |
| 1040 | </ul> |
| Marc Kupietz | d6dfdf0 | 2019-12-06 09:53:34 +0100 | [diff] [blame] | 1041 | <h3><%== loc 'references' %></h3> |
| 1042 | %= include 'references' |
| 1043 | </div> |
| 1044 | </div> |
| 1045 | </div> <!-- tabs --> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 1046 | </div> <!-- topwrapper --> |
| 1047 | <div style="clear: both;"></div> |
| 1048 | </div> |
| Marc Kupietz | d6dfdf0 | 2019-12-06 09:53:34 +0100 | [diff] [blame] | 1049 | <div class="footer"> |
| 1050 | <span class="footertext"> |
| 1051 | %= include(loc('footer')) |
| 1052 | </span> |
| Marc Kupietz | ebea470 | 2018-01-12 09:16:09 +0100 | [diff] [blame] | 1053 | </div> |
| Marc Kupietz | 5827066 | 2017-12-04 12:10:06 +0100 | [diff] [blame] | 1054 | </body> |
| Marc Kupietz | 8330522 | 2016-04-28 09:57:22 +0200 | [diff] [blame] | 1055 | </html> |