blob: 2b4d1bcdec62bee6d2b252be0e0408aff7eab82e [file] [log] [blame]
function queryKorAPalternatives(alt1, alt2) {
queryKorAP("{1:[orth="+ alt1 +"]} | {2:[orth=" + alt2 +"]}");
}
function paradigmatorClick(e, target, paradigmator) {
if (e.which === 2) {
e.preventDefault();
queryKorAPalternatives(target, paradigmator);
return false;
}
}
function makeVocabDistanceTable(id, baseURL) {
var urlprefix = new URLSearchParams(window.location.search);
return $(id).DataTable({
ajax: {
method: "GET",
url: baseURL + '/getBiggestVocabDistances',
dataType: 'json',
dataSrc: function (result) {
return result;
},
timeout: 30000,
},
"initComplete":function(settings, json){
vocabDistanceTable.columns.adjust().draw();
},
"createdRow": function (row, data, rowIndex) {
$.each($('td.collocator', row), function (colIndex) {
$(this).attr('title', "f("+data.word+")="+data.f2.toLocaleString("en-GB") + " f1: "+ccResult.f1+ " total: "+ccResult.N);
});
},
"sScrollY": "780px",
"bScrollCollapse": true,
"bPaginate": false,
"bJQueryUI": true,
"dom": '<"top">rt<"bottom"flpB><"clear">',
buttons: [
{ extend: 'copyHtml5', text: '<i class="fa fa-files-o"></i>', titleAttr: 'Copy' },
{ extend: 'csvHtml5', text: '<i class="fa fa-file-text-o"></i>', titleAttr: 'CSV', filename: currentWords+'_syn_neighbours' },
{ extend: 'excelHtml5', text: '<i class="fa fa-file-excel-o"></i>', titleAttr: 'Excel', filename: currentWords+'_sny_neighbours',
}
],
"columns": [
{ "data": "rank", type: "allnumeric" },
{ "data": "dist", render: function ( data, type, row ) {return data.toFixed(3) }},
{ "data": "word", class: "paradigmator", render: function ( data, type, row ) {
urlprefix.set("word", data); return '<a class="' + getMergedClass(row.rank) + '" href="?' + urlprefix + '">' + data + '</a>'
}}
],
"columnDefs": [
{ className: "dt-right", "targets": [0,1] },
{ "searchable": false,
"orderable": false,
"targets": 0
},
{ "orderSequence": [ "desc" ], "targets": [ 1 ] },
{ "orderSequence": [ "asc", "desc" ], "targets": [ 2 ] },
],
"oLanguage": {
"sSearch": "Filter: "
},
"order": [[ 1, 'desc' ]]
});
}
function toFixed(n, d) {
if(typeof n != "number") {
return n;
} else {
return n.toFixed(d);
}
}
function toExponential(n, d) {
if(typeof n != "number") {
return n;
} else {
return n.toExponential(d);
}
}
function bitmask2window(autofocus, win) {
var af_str = autofocus.toString(2).padStart(10, "0")
.replace(/^([0-9]{5})/, '$1 ')
.replace(/0/g, '·')
.replace(/1/g, '◼');
var w_str = win.toString(2).padStart(10, "0")
.replace(/^([0-9]{5})/, '$1 ')
.replace(/0/g, '·')
.replace(/1/g, 'o');
for (var i=0, l=af_str.length; i<l; i++) {
if(af_str.charAt(i) == '·' && w_str.charAt(i) == 'o' ) {
af_str = af_str.substring(0, i) + "◽" + af_str.substring(i+1);
}
}
return af_str;
}
function makeClassicCollocatorTable(id, baseURL, wordIndex) {
$.fn.dataTable.ext.errMode = 'throw';
var classicCollocatorTable = $('#classicoloctable').DataTable({
ajax: {
method: "GET",
url: baseURL + '/getClassicCollocators',
dataType: 'json',
dataSrc: function (result) {
ccResult = result;
$("#rawfreq_tt").attr("title", "Raw frequencies of the co-occurence.\n"
+ "f(" + ccResult.w1+")=" + ccResult.f1.toLocaleString("en-GB") + ";\n"
+ "N=" + ccResult.N.toLocaleString("en-GB"));
return result.collocates;
},
warning: function (request, error) {
},
timeout: 30000,
data: { w: wordIndex }
},
"initComplete":function(settings, json){
$("td.collocator").click(function(){
queryKorAPCII(this.textContent + " /w1:5,s0 " + CIIsearchWords);
});
classicCollocatorTable.columns(".detail").visible(false);
$("#ccd").css('width', '680px');
classicCollocatorTable.columns.adjust().draw();
},
"createdRow": function (row, data, rowIndex) {
$.each($('td.collocator', row), function (colIndex) {
$(this).attr('title', "f("+data.word+")="+data.f2.toLocaleString("en-GB") + " f1: "+ccResult.f1+ " total: "+ccResult.N);
});
},
"sScrollY": "780px",
"bScrollCollapse": true,
"bPaginate": false,
"bJQueryUI": true,
"dom": '<"top">rt<"bottom"flpB><"clear">',
buttons: [
{ extend: 'copyHtml5', text: '<i class="fa fa-files-o"></i>', titleAttr: 'Copy' },
{ extend: 'csvHtml5', text: '<i class="fa fa-file-text-o"></i>', titleAttr: 'CSV', filename: currentWords+'_collocates' },
{ extend: 'excelHtml5', text: '<i class="fa fa-file-excel-o"></i>', titleAttr: 'Excel', filename: currentWords+'_collocates', exportOptions: { columns: ':visible' } ,
}
],
"columns": [
// { "data": "pos", width: "7%", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitvec2window(data, row.heat, row.word) }},
{ "data": "llr", render: function ( data, type, row ) {return toFixed(data, 0) }},
{ "data": "pmi", render: function ( data, type, row ) {return toFixed(data, 2) }},
{ "data": "md", render: function ( data, type, row ) {return toFixed(data, 2) }},
{ "data": "lfmd", render: function ( data, type, row ) {return toFixed(data, 2) }},
// { "data": "fpmi", type: "scientific", render: function ( data, type, row ) {return data.toExponential(2) } },
{ "data": "npmi", render: function ( data, type, row ) {return toFixed(data, 3) }},
{ "data": "dice", render: function ( data, type, row ) {return toExponential(data, 2) }},
{ "data": "ld", render: function ( data, type, row ) {return toFixed(data, 2) }},
{ "data": "ldaf", render: function ( data, type, row ) {return toFixed(data, 2) }},
{ "data": "delta", render: function ( data, type, row ) {return toFixed(data, 2) }},
{ "data": "afwin", width: "auto", sClass: "dt-center mono compact", render: function ( data, type, row ) {return bitmask2window(data, row.win) }},
{ "data": "ln_count", render: function ( data, type, row ) {return toFixed(data, 1) }},
{ "data": "rn_count", render: function ( data, type, row ) {return toFixed(data, 1) }},
{ "data": "ln_pmi", render: function ( data, type, row ) {return toFixed(data, 2) }},
{ "data": "rn_pmi", render: function ( data, type, row ) {return toFixed(data, 2) }},
{ "data": "f" },
{ "data": "word", sClass: "collocator" }
],
"columnDefs": [
{ className: "dt-right", "targets": [0,1,2,3,4,5,6,7,8,10,11,12,13,14] },
{ className: "dt-right detail", "targets": [5,10,11,12,13] },
{ "searchable": false,
"orderable": false,
"targets": []
},
{ "orderSequence": [ "desc" ], "targets": [0,1,2,3,4,5,6,7,10,11,12,13,14] },
{ "orderSequence": [ "asc", "desc" ], "targets": [8,9,15] },
],
"oLanguage": {
"sSearch": "Filter: "
},
"order": [[ 7, 'desc' ]],
});
return classicCollocatorTable;
}