-
Daniel authored1098b891
morfeusz.js 45.34 KiB
function Morfeusz(data) {
this.data = data;
console.log(data);
}
Morfeusz.baseMap = {
"subst":"rzeczownik", "depr":"rzeczownik/forma deprecjatywna", "ger":"czasownik/odsłownik", "fin":"czasownik", "inf":"czasownik/bezokolicznik", "adj":"przymiotnik", "adja":"przymiotnik przyprzymiotnikowy", "adv":"przysłówek odprzymiotnikowy i/lub stopniowalny",
"sg":"pojedyncza", "pl":"mnoga",
"acc":"mianownik", "dat":"dopełniacz", "gen":"celownik", "inst":"biernik", "loc":"narzędnik", "nom":"miejscownik", "voc":"wołacz",
"m":"męski", "m1":"męski osobowy", "m2":"męski zwierzęcy", "m3":"męski rzeczowy", "mo":"męskoosobowy", "ż":"żeński", "n1":"nijaki pierwszy", "n2":"nijaki drugi", "p1":"przymnogi osobowy", "p2":"przymnogi drugi", "p3":"przymnogi trzeci",
"pos":"równy", "com":"wyższy", "sup":"najwyższy",
"imperf":"niedokonany",
"neg":"zanegowana",
"aff":"niezanegowana"
};
getBaseData = function(data) {
let result = new Array();
$(data).each(function(index, element) {
let resultData = '';
if (element.indexOf('.' > -1)) {
let arr = element.split('.');
$(arr).each(function(index2, element2) {
if (element2 in Morfeusz.baseMap) {
index2 != arr.length - 1 ? resultData += Morfeusz.baseMap[element2] + ", " : resultData += Morfeusz.baseMap[element2];
}
});
result.push(resultData);
} else {
element in Morfeusz.baseMap ? result.push(Morfeusz.baseMap[element]) : result.push('-');
}
});
return result;
}
Morfeusz.prototype.showBaseForm = function(data) {
// console.log(data);
if (window.location.href.split("/")[3] == 'orth') {
if (data[0].length > 0) {
let originalForm = $('#phrase').val(),
baseForm = data[0][1],
tableData = '',
language = window.location.href.split("/")[4];
$(data).each(function(index, element) {
let dataArr = element[2].split(':'),
entries = getBaseData(dataArr),
grammarCases = '',
type = '',
aspect = '',
negation = '';
if (entries[2] != '' && entries[2] != undefined && entries[2] != null) {
grammarCases = '<p class="tag-entry"><strong>Przypadek: </strong>' + entries[2] + '</p>';
}
if (entries[3] != '' && entries[3] != undefined && entries[4] != null) {
type = '<p class="tag-entry type"><strong>Rodzaj: </strong>' + entries[3] + '</p>';
}
if (entries[4] != '' && entries[4] != undefined && entries[4] != null) {
aspect = '<p class="tag-entry"><strong>Aspekt: </strong>' + entries[4] + '</p>';
}
if (entries[5] != '' && entries[5] != undefined && entries[5] != null) {
negation = '<p class="tag-entry"><strong>Zanegowanie: </strong>' + entries[5] + '</p>';
}
tableData +=
'<tr>' +
'<td>' + element[0] + '</td>' +
'<td><a href="/lemma/' + language + '/' + element[1] + '">' + element[1] + '</a></td>' +
'<td>' + element[2] + '</td>' +
'<td>' +
'<p class="tag-entry"><strong>Leksem/fleksem: </strong>' + entries[0] + '</p>' +
'<p class="tag-entry"><strong>Liczba: </strong>' + entries[1] + '</p>' +
grammarCases +
type +
aspect +
negation +
'</td>' +
'</tr>';
});
let tableContent =
'<div class="table-container">' +
'<h2><span lang="pl">Forma tekstowa</span><span lang="en">Text form</span></h2>' +
'<table class="table table-striped table-styling">' +
'<thead>' +
'<tr>' +
'<th class="border-left"><span lang="pl">Forma wyrazowa</span><span lang="en">Word form</span></th>' +
'<th><span lang="pl">Forma bazowa</span><span lang="en">Base form</span></th>' +
'<th>Tag</th>' +
'<th><span lang="pl">Znaczenie tagu</span><span lang="en">Description of tag</span></th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
tableData
'</tbody>' +
'</table>' +
'</div>';
if (tableData == '') {
return false;
}
$('#lexpelement_morfeusz').append(tableContent);
return true;
}
}
return false;
}
Morfeusz.prototype.showIndicativePresent = function(data) {
// Step 1 - get table of only fin elements
let table = new Array
lang = $('#lang').val();
data.map(function(element, index) {
if (element[2].indexOf('fin:') > -1) {
table.push(element);
}
});
// Step 2 - prepare data
let singularOne = '-', singularTwo = '-', singularThree = '-', pluralOne = '-', pluralTwo = '-', pluralThree = '-';
table.map(function(element, index) {
if (element[2].indexOf('sg:pri') > -1) { singularOne = element[0]; }
if (element[2].indexOf('sg:sec') > -1) { singularTwo = element[0]; }
if (element[2].indexOf('sg:ter') > -1) { singularThree = element[0]; }
if (element[2].indexOf('pl:pri') > -1) { pluralOne = element[0]; }
if (element[2].indexOf('pl:sec') > -1) { pluralTwo = element[0]; }
if (element[2].indexOf('pl:ter') > -1) { pluralThree = element[0]; }
});
// Step 3 - draw table
let tableContent =
'<div class="table-container">' +
'<h2><span lang="pl">Tryb oznajmujący - czas teraźniejszy</span><span lang="en">Declarative mode - present tense</span></h2>' +
'<table class="table table-striped table-styling">' +
'<thead>' +
'<tr>' +
'<th class="no-background"></th>' +
'<th class="border-left"><span lang="pl">l.p.</span><span lang="en">Singular</span></th>' +
'<th><span lang="pl">l.m.</span><span lang="en">Plural</span></th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">1 os.</span><span lang="en">1 p.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularOne + '">' + singularOne + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralOne + '">' + pluralOne + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">2 os.</span><span lang="en">2 p.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularTwo + '">' + singularTwo + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralTwo + '">' + pluralTwo + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">3 os.</span><span lang="en">3 p.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularThree + '">' + singularThree + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralThree + '">' + pluralThree + '</a></td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>';
if (singularOne != '-' || singularTwo != '-' || singularThree != '-' || pluralOne != '-' || pluralTwo != '-' || pluralThree != '-') {
$('#lexpelement_morfeusz').append(tableContent);
return true;
}
return false;
}
Morfeusz.prototype.showIndicativePast = function(data) {
// Step 1 - get table of only praet | imps elements
let table = new Array,
lang = $('#lang').val();
data.map(function(element, index) {
if (element[2].indexOf('praet:') > -1 || element[2].indexOf('imps:') > -1) {
table.push(element);
}
});
// Step 2 - prepare data
let bezosobnik = '-', singularThreeM = '-', singularThreeF = '-', singularThreeN = '-', singularThreeMO = '-', singularThreeMO2 = '-';
table.map(function(element, index) {
if (element[2].indexOf('imps:imperf') > -1) { bezosobnik = element[0]; }
if (element[2].indexOf('sg:m1.m2.m3') > -1) { singularThreeM = element[0]; }
if (element[2].indexOf('sg:f') > -1) { singularThreeF = element[0]; }
if (element[2].indexOf('sg:n1.n2') > -1) { singularThreeN = element[0]; }
if (element[2].indexOf('pl:m1.p1') > -1) { singularThreeMO = element[0]; }
if (element[2].indexOf('pl:m2.m3.f.n1.n2.p2.p3') > -1) { singularThreeMO2 = element[0]; }
});
// Step 3 - draw table
let tableContent =
'<div class="table-container">' +
'<h2><span lang="pl">Tryb oznajmujący - czas przeszły</span><span lang="en">Declarative mode - past tense</span></h2>' +
'<table class="table table-striped table-styling">' +
'<thead>' +
'<tr>' +
'<th class="no-background"></th>' +
'<th class="border-left" colspan="3"><span lang="pl">l.p.</span><span lang="en">Singular</span></th>' +
'<th colspan="2"><span lang="pl">l.m.</span><span lang="en">Plural</span></th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
'<tr>' +
'<td class="border-top-none"></td>' +
'<td class="border-left background"><span lang="pl">m</span><span lang="en">m</span></td>' +
'<td class="background"><span lang="pl">ż</span><span lang="en">f</span></td>' +
'<td class="border-right background"><span lang="pl">n</span><span lang="en">n</span></td>' +
'<td class="background"><span lang="pl">mo</span><span lang="en">mp</span></td>' +
'<td class="background"><span lang="pl">-mo</span><span lang="en">-mp</span></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">3 os.</span><span lang="en">3 p.</span></td>' +
'<td class="border-left"><a href="/orth/' + lang + '/' + singularThreeM + '">' + singularThreeM + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularThreeF + '">' + singularThreeF + '</a></td>' +
'<td class="border-right"><a href="/orth/' + lang + '/' + singularThreeN + '">' + singularThreeN + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularThreeMO + '">' + singularThreeMO + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularThreeMO2 + '">' + singularThreeMO2 + '</a></td>' +
'</tr>' +
'<tr>' +
'<td></td>' +
'<td class="border-left border-right" colspan="3"><span lang="pl">Bezosobnik</span><span lang="en">Bezosobnik</span></td>' +
'<td colspan="2"><a href="/orth/' + lang + '/' + bezosobnik + '">' + bezosobnik + '</a></td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>';
if (bezosobnik != '-' || singularThreeM != '-' || singularThreeF != '-' || singularThreeN != '-' || singularThreeMO != '-' || singularThreeMO2 != '-') {
$('#lexpelement_morfeusz').append(tableContent);
return true;
}
return false;
}
Morfeusz.prototype.showImperative = function(data) {
// Step 1 - get table of only impt elements
let table = new Array,
lang = $('#lang').val();
data.map(function(element, index) {
if (element[2].indexOf('impt:') > -1) {
table.push(element);
}
});
// Step 2 - prepare data
let singularOne = '-', singularTwo = '-', pluralOne = '-', pluralTwo = '-';
table.map(function(element, index) {
if (element[2].indexOf('sg:pri') > -1) { singularOne = element[0]; }
if (element[2].indexOf('sg:sec') > -1) { singularTwo = element[0]; }
if (element[2].indexOf('pl:pri') > -1) { pluralOne = element[0]; }
if (element[2].indexOf('pl:sec') > -1) { pluralTwo = element[0]; }
});
// Step 3 - draw table
let tableContent =
'<div class="table-container">' +
'<h2><span lang="pl">Tryb rozkazujący</span><span lang="en">Imperative</span></h2>' +
'<table class="table table-striped table-styling">' +
'<thead>' +
'<tr>' +
'<th class="no-background"></th>' +
'<th class="border-left"><span lang="pl">l.p.</span><span lang="en">Singular</span></th>' +
'<th><span lang="pl">l.m.</span><span lang="en">Plural</span></th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">1 os.</span><span lang="en">1 p.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularOne + '">' + singularOne + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralOne + '">' + pluralOne + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">2 os.</span><span lang="en">2 p.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularTwo + '">' + singularTwo + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralTwo + '">' + pluralTwo + '</a></td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>';
if (singularOne != '-' || singularTwo != '-' || pluralOne != '-' || pluralTwo != '-') {
$('#lexpelement_morfeusz').append(tableContent);
return true;
}
return false;
}
Morfeusz.prototype.showLanguageCase = function(data) {
// Step 1 - get table of only subst elements
let table = new Array,
lang = $('#lang').val();
data.map(function(element, index) {
if (element[2].indexOf('subst:') > -1) {
table.push(element);
}
});
console.log(data)
// Step 2 - prepare data
let singularM = '-', singularD = '-', singularC = '-', singularB = '-', singularN = '-', singularMs = '-', singularW = '-',
pluralM = '-', pluralD = '-', pluralC = '-', pluralB = '-', pluralN = '-', pluralMs = '-', pluralW = '-';
table.map(function(element, index) {
if (element[2].indexOf('sg:acc') > -1) { singularB = element[0]; }
if (element[2].indexOf('sg:dat') > -1) { singularC = element[0]; }
if (element[2].indexOf('sg:gen') > -1) { singularD = element[0]; }
if (element[2].indexOf('sg:inst') > -1) { singularN = element[0]; }
if (element[2].indexOf('sg:loc') > -1) { singularMs = element[0]; }
if (element[2].indexOf('sg:nom') > -1) { singularM = element[0]; }
if (element[2].indexOf('sg:voc') > -1) { singularW = element[0]; }
if (element[2].indexOf('pl:acc') > -1) { pluralB = element[0]; }
if (element[2].indexOf('pl:dat') > -1) { pluralC = element[0]; }
if (element[2].indexOf('pl:gen') > -1) { pluralD = element[0]; }
if (element[2].indexOf('pl:inst') > -1) { pluralN = element[0]; }
if (element[2].indexOf('pl:loc') > -1) { pluralMs = element[0]; }
if (element[2].indexOf('pl:nom') > -1) { pluralM = element[0]; }
if (element[2].indexOf('pl:voc') > -1) { pluralW = element[0]; }
});
// Step 3 - draw table
let tableContent =
'<div class="table-container">' +
'<h2><span lang="pl">Przypadki</span><span lang="en">Cases</span></h2>' +
'<table class="table table-striped table-styling">' +
'<thead>' +
'<tr>' +
'<th class="no-background"></th>' +
'<th class="border-left"><span lang="pl">l.p.</span><span lang="en">Singular</span></th>' +
'<th><span lang="pl">l.m.</span><span lang="en">Plural</span></th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">M.</span><span lang="en">M.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularM + '">' + singularM + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralM + '">' + pluralM + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">D.</span><span lang="en">D.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularD + '">' + singularD + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralD + '">' + pluralD + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">C.</span><span lang="en">C.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularC + '">' + singularC + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralC + '">' + pluralC + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">B.</span><span lang="en">B.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularB + '">' + singularB + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralB + '">' + pluralB + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">N.</span><span lang="en">N.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularN + '">' + singularN + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralN + '">' + pluralN + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">Ms.</span><span lang="en">Ms.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularMs + '">' + singularMs + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralMs + '">' + pluralMs + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">W.</span><span lang="en">W.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularW + '">' + singularW + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralW + '">' + pluralW + '</a></td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>';
if (singularM != '-' || singularD != '-' || singularC != '-' || singularB != '-' || singularN != '-' || singularMs != '-' || singularW != '-' || pluralM != '-' || pluralD != '-' || pluralC != '-' || pluralB != '-' ||
pluralN != '-' || pluralMs != '-' || pluralW != '-') {
$('#lexpelement_morfeusz').append(tableContent);
return true;
}
return false;
}
Morfeusz.prototype.showLanguageCase2 = function(data, negative) {
// Step 1 - get table of only ger elements
let table = new Array,
lang = $('#lang').val();
data.map(function(element, index) {
if (element[2].indexOf('ger:') > -1) {
table.push(element);
}
});
// Step 2 - prepare data
let singularM = '-', singularD = '-', singularC = '-', singularB = '-', singularN = '-', singularMs = '-', singularW = '-',
pluralM = '-', pluralD = '-', pluralC = '-', pluralB = '-', pluralN = '-', pluralMs = '-', pluralW = '-';
table.map(function(element, index) {
let negative2 = true;
if (negative) {
negative2 = element[2].indexOf(':neg') > -1;
}
console.log('na koncu kazdego bylo :aff, ale usunalem bo :neg nie dzialalo - mozna porobic lancuch z tego easy - todo poniedzialek');
if ((element[2].indexOf('sg:nom.acc:n2') > -1) && (negative2)) { singularM = element[0]; }
if ((element[2].indexOf('sg:gen:n2') > -1) && (negative2)) { singularD = element[0]; }
if ((element[2].indexOf('sg:dat.loc:n2') > -1) && (negative2)) { singularC = element[0]; }
if ((element[2].indexOf('sg:nom.acc:n2') > -1) && (negative2)) { singularB = element[0]; }
if ((element[2].indexOf('sg:inst:n2') > -1) && (negative2)) { singularN = element[0]; }
if ((element[2].indexOf('sg:dat.loc:n2') > -1) && (negative2)) { singularMs = element[0]; }
if ((element[2].indexOf('sg:nom.acc:n2') > -1) && (negative2)) { singularW = element[0]; }
if ((element[2].indexOf('pl:nom.acc:n2') > -1) && (negative2)) { pluralM = element[0]; }
if ((element[2].indexOf('pl:gen:n2') > -1) && (negative2)) { pluralD = element[0]; }
if ((element[2].indexOf('pl:dat.loc:n2') > -1) && (negative2)) { pluralC = element[0]; }
if ((element[2].indexOf('pl:nom.acc:n2') > -1) && (negative2)) { pluralB = element[0]; }
if ((element[2].indexOf('pl:inst:n2') > -1) && (negative2)) { pluralN = element[0]; }
if ((element[2].indexOf('?????????????????????') > -1) && (negative2)) { pluralMs = element[0]; }
if ((element[2].indexOf('pl:nom.acc:n2') > -1) && (negative2)) { pluralW = element[0]; }
});
// Step 3 - draw table
let tableContent =
'<div class="table-container">' +
'<h2><span lang="pl">Przypadki 2</span><span lang="en">Cases 2</span></h2>' +
'<table class="table table-striped table-styling">' +
'<thead>' +
'<tr>' +
'<th class="no-background"></th>' +
'<th class="border-left"><span lang="pl">l.p.</span><span lang="en">Singular</span></th>' +
'<th><span lang="pl">l.m.</span><span lang="en">Plural</span></th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">M.</span><span lang="en">M.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularM + '">' + singularM + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralM + '">' + pluralM + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">D.</span><span lang="en">D.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularD + '">' + singularD + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralD + '">' + pluralD + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">C.</span><span lang="en">C.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularC + '">' + singularC + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralC + '">' + pluralC + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">B.</span><span lang="en">B.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularB + '">' + singularB + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralB + '">' + pluralB + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">N.</span><span lang="en">N.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularN + '">' + singularN + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralN + '">' + pluralN + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">Ms.</span><span lang="en">Ms.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularMs + '">' + singularMs + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralMs + '">' + pluralMs + '</a></td>' +
'</tr>' +
'<tr>' +
'<td><span lang="pl">W.</span><span lang="en">W.</span></td>' +
'<td class="border-left border-right"><a href="/orth/' + lang + '/' + singularW + '">' + singularW + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralW + '">' + pluralW + '</a></td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>';
if (singularM != '-' || singularD != '-' || singularC != '-' || singularB != '-' || singularN != '-' || singularMs != '-' || singularW != '-' || pluralM != '-' ||
pluralD != '-' || pluralC != '-' || pluralB != '-' || pluralN != '-' || pluralMs != '-' || pluralW != '-') {
$('#lexpelement_morfeusz').append(tableContent);
return true;
}
return false;
}
Morfeusz.prototype.showExtendedLanguageCase = function(data, negative) {
// Step 1 - get table of only ppas | imps elements
let table = new Array, advanced = '',
lang = $('#lang').val();
data.map(function(element, index) {
if (element[2].indexOf('ppas:') > -1) {
table.push(element);
}
if (element[2].indexOf('imps:imperf') > -1) {
advanced = element[0];
}
});
// Step 2 - prepare data
let singularMM = '-', singularMN = '-', singularMZ = '-', singularD = '-', singularDZ = '-', singularC = '-', singularCZ = '-', singularBM = '-', singularBM3 = '-', singularBN = '-', singularBZ = '-',
singularN = '-', singularNZ = '-', singularMs = '-', singularMsZ = '-', pluralMPM = '-', pluralMMO = '-', pluralD = '-', pluralC = '-', pluralBPM = '-', pluralBMO = '-', pluralN = '-', pluralMs = '-';
table.map(function(element, index) {
let negative2 = true;
if (negative) {
negative2 = element[2].indexOf(':neg') > -1;
// negative2 = element[2].indexOf(':neg') === -1;
}
if ((element[2].indexOf('sg:acc:m3') > -1) && (negative2)) { singularMM = element[0]; }
if ((element[2].indexOf('sg:nom.acc.voc:n1.n2') > -1) && (negative2)) { singularMN = element[0]; }
if ((element[2].indexOf('sg:nom.voc:f') > -1) && (negative2)) { singularMZ = element[0]; }
if ((element[2].indexOf('pl:nom.voc:m1.p1') > -1) && (negative2)) { pluralMPM = element[0]; }
if ((element[2].indexOf('pl:nom.acc.voc:m2.m3.f.n1.n2.p2.p3') > -1) && (negative2)) { pluralMMO = element[0]; }
if ((element[2].indexOf('sg:acc:m1.m2') > -1) && (negative2)) { singularD = element[0]; }
if ((element[2].indexOf('sg:gen.dat.loc:f') > -1) && (negative2)) { singularDZ = element[0]; }
if ((element[2].indexOf('pl:acc:m1.p1') > -1) && (negative2)) { pluralD = element[0]; }
if ((element[2].indexOf('sg:dat:m1.m2.m3.n1.n2') > -1) && (negative2)) { singularC = element[0]; }
if ((element[2].indexOf('sg:gen.dat.loc:f') > -1) && (negative2)) { singularCZ = element[0]; }
if ((element[2].indexOf('pl:dat:m1.m2.m3.f.n1.n2.p1.p2.p3') > -1) && (negative2)) { pluralC = element[0]; }
if ((element[2].indexOf('sg:acc:m1.m2') > -1) && (negative2)) { singularBM = element[0]; }
if ((element[2].indexOf('sg:acc:m3') > -1) && (negative2)) { singularBM3 = element[0]; }
if ((element[2].indexOf('sg:nom.acc.voc:n1.n2') > -1) && (negative2)) { singularBN = element[0]; }
if ((element[2].indexOf('sg:acc.inst:f') > -1) && (negative2)) { singularBZ = element[0]; }
if ((element[2].indexOf('pl:gen.loc:m1.m2.m3.f.n1.n2.p1.p2.p3') > -1) && (negative2)) { pluralBPM = element[0]; }
if ((element[2].indexOf('pl:nom.acc.voc:m2.m3.f.n1.n2.p2.p3') > -1) && (negative2)) { pluralBMO = element[0]; }
if ((element[2].indexOf('sg:inst.loc:m1.m2.m3.n1.n2') > -1) && (negative2)) { singularN = element[0]; }
if ((element[2].indexOf('sg:acc.inst:f') > -1) && (negative2)) { singularNZ = element[0]; }
if ((element[2].indexOf('pl:inst:m1.m2.m3.f.n1.n2.p1.p2.p3') > -1) && (negative2)) { pluralN = element[0]; }
if ((element[2].indexOf('sg:inst.loc:m1.m2.m3.n1.n2') > -1) && (negative2)) { singularMs = element[0]; }
if ((element[2].indexOf('sg:gen.dat.loc:f') > -1) && (negative2)) { singularMsZ = element[0]; }
if ((element[2].indexOf('pl:gen.loc:m1.m2.m3.f.n1.n2.p1.p2.p3') > -1) && (negative2)) { pluralMs = element[0]; }
});
// Step 3 - draw table
let tableContent =
'<div class="table-container">' +
'<h2><span lang="pl">Przypadki (Z)</span><span lang="en">Cases (A)</span></h2>' +
'<table class="table table-striped table-styling">' +
'<thead>' +
'<tr>' +
'<th class="no-background"></th>' +
'<th colspan="5" class="border-left"><span lang="pl">l.p.</span><span lang="en">Singular</span></th>' +
'<th colspan="4"><span lang="pl">l.m.</span><span lang="en">Plural</span></th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
'<tr>' +
'<td rowspan="2" class="border-top-none"></td>' +
'<td rowspan="2" class="border-left background"><span lang="pl">m1</span><span lang="en">m1</span></td>' +
'<td rowspan="2" class="background"><span lang="pl">m2</span><span lang="en">m2</span></td>' +
'<td rowspan="2" class="background"><span lang="pl">m3</span><span lang="en">m3</span></td>' +
'<td rowspan="2" class="background"><span lang="pl">n1,n2</span><span lang="en">n1,n2</span></td>' +
'<td rowspan="2" class="border-right background"><span lang="pl">ż</span><span lang="en">ż</span></td>' +
'<td rowspan="2" class="background"><span lang="pl">p1</span><span lang="en">p1</span></td>' +
'<td colspan="2" class="background"><span lang="pl">m1</span><span lang="en">m1</span></td>' +
'<td rowspan="2" class="background"><span lang="pl">pozostałe</span><span lang="en">other</span></td>' +
'</tr>' +
'<tr>' +
'<td class="background border-top-none"><span lang="pl">ndepr</span><span lang="en">ndepr</span></td>' +
'<td class="background border-top-none"><span lang="pl">depr</span><span lang="en">depr</span></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">M./(W.)</span><span lang="en">M./(W.)</span></td>' +
'<td colspan="3" class="border-left border-right"><a href="/orth/' + lang + '/' + singularMM + '">' + singularMM + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularMN + '">' + singularMN + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularMZ + '">' + singularMZ + '</a></td>' +
'<td colspan="2"><a href="/orth/' + lang + '/' + pluralMPM + '">' + pluralMPM + '</a></td>' +
'<td colspan="2"><a href="/orth/' + lang + '/' + pluralMMO + '">' + pluralMMO + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">D.</span><span lang="en">D.</span></td>' +
'<td colspan="4" class="border-left border-right"><a href="/orth/' + lang + '/' + singularD + '">' + singularD + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularDZ + '">' + singularDZ + '</a></td>' +
'<td colspan="4"><a href="/orth/' + lang + '/' + pluralD + '">' + pluralD + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">C.</span><span lang="en">C.</span></td>' +
'<td colspan="4" class="border-left border-right"><a href="/orth/' + lang + '/' + singularC + '">' + singularC + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularCZ + '">' + singularCZ + '</a></td>' +
'<td colspan="4"><a href="/orth/' + lang + '/' + pluralC + '">' + pluralC + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">B.</span><span lang="en">B.</span></td>' +
'<td colspan="2" class="border-left border-right"><a href="/orth/' + lang + '/' + singularBM + '">' + singularBM + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularBM3 + '">' + singularBM3 + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularBN + '">' + singularBN + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularBZ + '">' + singularBZ + '</a></td>' +
'<td colspan="2"><a href="/orth/' + lang + '/' + pluralBPM + '">' + pluralBPM + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralBMO + '">' + pluralBMO + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">N.</span><span lang="en">N.</span></td>' +
'<td colspan="4" class="border-left border-right"><a href="/orth/' + lang + '/' + singularN + '">' + singularN + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularNZ + '">' + singularNZ + '</a></td>' +
'<td colspan="4"><a href="/orth/' + lang + '/' + pluralN + '">' + pluralN + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">Ms.</span><span lang="en">Ms.</span></td>' +
'<td colspan="4" class="border-left border-right"><a href="/orth/' + lang + '/' + singularMs + '">' + singularMs + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularMsZ + '">' + singularMsZ + '</a></td>' +
'<td colspan="4"><a href="/orth/' + lang + '/' + pluralMs + '">' + pluralMs + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">Złoż.</span><span lang="en">Złoż.</span></td>' +
'<td colspan="9"><a href="/orth/' + lang + '/' + advanced + '">' + advanced + '</a>+</td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>';
if (singularMM != '-' || singularMN != '-' || singularMZ != '-' || singularD != '-' || singularDZ != '-' || singularC != '-' || singularCZ != '-' || singularBM != '-' || singularBM3 != '-' || singularBN != '-' || singularBZ != '-' ||
singularN != '-' || singularNZ != '-' || singularMs != '-' || singularMsZ != '-' || pluralMPM != '-' || pluralMMO != '-' || pluralD != '-' || pluralC != '-' || pluralBPM != '-' || pluralBMO != '-' || pluralN != '-' || pluralMs != '-') {
$('#lexpelement_morfeusz').append(tableContent);
return true;
}
return false;
}
Morfeusz.prototype.showExtendedLanguageCase2 = function(data, negative) {
// Step 1 - get table of only adj | adja elements
let table = new Array, advanced = '',
lang = $('#lang').val();
data.map(function(element, index) {
if (element[2].indexOf('adj:') > -1) {
table.push(element);
}
if (element[2].indexOf('adja') > -1) {
advanced = element[0];
}
});
// Step 2 - prepare data
let singularMM = '-', singularMN = '-', singularMZ = '-', singularD = '-', singularDZ = '-', singularC = '-', singularCZ = '-', singularBM = '-', singularBM3 = '-', singularBN = '-', singularBZ = '-', singularN = '-',
singularNZ = '-', singularMs = '-', singularMsZ = '-', pluralMPM = '-', pluralMMO = '-', pluralD = '-', pluralC = '-', pluralBPM = '-', pluralBMO = '-', pluralN = '-', pluralMs = '-';
table.map(function(element, index) {
let negative2 = true;
if (negative) {
negative2 = element[2].indexOf(':neg') > -1;
// negative2 = element[2].indexOf(':neg') === -1;
}
if ((element[2].indexOf('sg:nom.voc:m1.m2.m3') > -1) && (negative2)) { singularMM = element[0]; }
if ((element[2].indexOf('sg:nom.voc:n1.n2') > -1) && (negative2)) { singularMN = element[0]; }
if ((element[2].indexOf('sg:nom.voc:f') > -1) && (negative2)) { singularMZ = element[0]; }
if ((element[2].indexOf('pl:nom.voc:m1.p1') > -1) && (negative2)) { pluralMPM = element[0]; }
if ((element[2].indexOf('pl:nom.voc:m2.m3.f.n1.n2.p2.p3') > -1) && (negative2)) { pluralMMO = element[0]; }
if ((element[2].indexOf('sg:gen:m1.m2.m3.n1.n2') > -1) && (negative2)) { singularD = element[0]; }
if ((element[2].indexOf('sg:gen:f') > -1) && (negative2)) { singularDZ = element[0]; }
if ((element[2].indexOf('pl:gen:m1.m2.m3.f.n1.n2.p1.p2.p3') > -1) && (negative2)) { pluralD = element[0]; }
if ((element[2].indexOf('sg:dat:m1.m2.m3.n1.n2') > -1) && (negative2)) { singularC = element[0]; }
if ((element[2].indexOf('sg:dat:f') > -1) && (negative2)) { singularCZ = element[0]; }
if ((element[2].indexOf('pl:dat:m1.m2.m3.f.n1.n2.p1.p2.p3') > -1) && (negative2)) { pluralC = element[0]; }
if ((element[2].indexOf('sg:acc:m1.m2') > -1) && (negative2)) { singularBM = element[0]; }
if ((element[2].indexOf('sg:acc:m3') > -1) && (negative2)) { singularBM3 = element[0]; }
if ((element[2].indexOf('sg:acc:n1.n2') > -1) && (negative2)) { singularBN = element[0]; }
if ((element[2].indexOf('sg:acc:f') > -1) && (negative2)) { singularBZ = element[0]; }
if ((element[2].indexOf('pl:acc:m1.p1') > -1) && (negative2)) { pluralBPM = element[0]; }
if ((element[2].indexOf('pl:acc:m2.m3.f.n1.n2.p2.p3') > -1) && (negative2)) { pluralBMO = element[0]; }
if ((element[2].indexOf('sg:inst:m1.m2.m3.n1.n2') > -1) && (negative2)) { singularN = element[0]; }
if ((element[2].indexOf('sg:inst:f') > -1) && (negative2)) { singularNZ = element[0]; }
if ((element[2].indexOf('pl:inst:m1.m2.m3.f.n1.n2.p1.p2.p3') > -1) && (negative2)) { pluralN = element[0]; }
if ((element[2].indexOf('sg:loc:m1.m2.m3.n1.n2') > -1) && (negative2)) { singularMs = element[0]; }
if ((element[2].indexOf('sg:loc:f') > -1) && (negative2)) { singularMsZ = element[0]; }
if ((element[2].indexOf('pl:loc:m1.m2.m3.f.n1.n2.p1.p2.p3') > -1) && (negative2)) { pluralMs = element[0]; }
});
// Step 3 - draw table
let tableContent =
'<div class="table-container">' +
'<h2><span lang="pl">Przypadki (Z) 2</span><span lang="en">Cases (A) 2</span></h2>' +
'<table class="table table-striped table-styling">' +
'<thead>' +
'<tr>' +
'<th class="no-background"></th>' +
'<th colspan="5" class="border-left"><span lang="pl">l.p.</span><span lang="en">Singular</span></th>' +
'<th colspan="4"><span lang="pl">l.m.</span><span lang="en">Plural</span></th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
'<tr>' +
'<td rowspan="2" class="border-top-none"></td>' +
'<td rowspan="2" class="border-left background"><span lang="pl">m1</span><span lang="en">m1</span></td>' +
'<td rowspan="2" class="background"><span lang="pl">m2</span><span lang="en">m2</span></td>' +
'<td rowspan="2" class="background"><span lang="pl">m3</span><span lang="en">m3</span></td>' +
'<td rowspan="2" class="background"><span lang="pl">n1,n2</span><span lang="en">n1,n2</span></td>' +
'<td rowspan="2" class="border-right background"><span lang="pl">ż</span><span lang="en">ż</span></td>' +
'<td rowspan="2" class="background"><span lang="pl">p1</span><span lang="en">p1</span></td>' +
'<td colspan="2" class="background"><span lang="pl">m1</span><span lang="en">m1</span></td>' +
'<td rowspan="2" class="background"><span lang="pl">pozostałe</span><span lang="en">other</span></td>' +
'</tr>' +
'<tr>' +
'<td class="background border-top-none"><span lang="pl">ndepr</span><span lang="en">ndepr</span></td>' +
'<td class="background border-top-none"><span lang="pl">depr</span><span lang="en">depr</span></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">M./(W.)</span><span lang="en">M./(W.)</span></td>' +
'<td colspan="3" class="border-left border-right"><a href="/orth/' + lang + '/' + singularMM + '">' + singularMM + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularMN + '">' + singularMN + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularMZ + '">' + singularMZ + '</a></td>' +
'<td colspan="2"><a href="/orth/' + lang + '/' + pluralMPM + '">' + pluralMPM + '</a></td>' +
'<td colspan="2"><a href="/orth/' + lang + '/' + pluralMMO + '">' + pluralMMO + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">D.</span><span lang="en">D.</span></td>' +
'<td colspan="4" class="border-left border-right"><a href="/orth/' + lang + '/' + singularD + '">' + singularD + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularDZ + '">' + singularDZ + '</a></td>' +
'<td colspan="4"><a href="/orth/' + lang + '/' + pluralD + '">' + pluralD + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">C.</span><span lang="en">C.</span></td>' +
'<td colspan="4" class="border-left border-right"><a href="/orth/' + lang + '/' + singularC + '">' + singularC + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularCZ + '">' + singularCZ + '</a></td>' +
'<td colspan="4"><a href="/orth/' + lang + '/' + pluralC + '">' + pluralC + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">B.</span><span lang="en">B.</span></td>' +
'<td colspan="2" class="border-left border-right"><a href="/orth/' + lang + '/' + singularBM + '">' + singularBM + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularBM3 + '">' + singularBM3 + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularBN + '">' + singularBN + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularBZ + '">' + singularBZ + '</a></td>' +
'<td colspan="2"><a href="/orth/' + lang + '/' + pluralBPM + '">' + pluralBPM + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + pluralBMO + '">' + pluralBMO + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">N.</span><span lang="en">N.</span></td>' +
'<td colspan="4" class="border-left border-right"><a href="/orth/' + lang + '/' + singularN + '">' + singularN + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularNZ + '">' + singularNZ + '</a></td>' +
'<td colspan="4"><a href="/orth/' + lang + '/' + pluralN + '">' + pluralN + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">Ms.</span><span lang="en">Ms.</span></td>' +
'<td colspan="4" class="border-left border-right"><a href="/orth/' + lang + '/' + singularMs + '">' + singularMs + '</a></td>' +
'<td><a href="/orth/' + lang + '/' + singularMsZ + '">' + singularMsZ + '</a></td>' +
'<td colspan="4"><a href="/orth/' + lang + '/' + pluralMs + '">' + pluralMs + '</a></td>' +
'</tr>' +
'<tr>' +
'<td class="border-top-none"><span lang="pl">Złoż.</span><span lang="en">Złoż.</span></td>' +
'<td colspan="9"><a href="/orth/' + lang + '/' + advanced + '">' + advanced + '</a>+</td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>';
if (singularMM != '-' || singularMN != '-' || singularMZ != '-' || singularD != '-' || singularDZ != '-' || singularC != '-' || singularCZ != '-' || singularBM != '-' || singularBM3 != '-' || singularBN != '-' || singularBZ != '-' ||
singularN != '-' || singularNZ != '-' || singularMs != '-' || singularMsZ != '-' || pluralMPM != '-' || pluralMMO != '-' || pluralD != '-' || pluralC != '-' || pluralBPM != '-' || pluralBMO != '-' || pluralN != '-' || pluralMs != '-') {
$('#lexpelement_morfeusz').append(tableContent);
return true;
}
return false;
}
Morfeusz.prototype.showOthers = function(data) {
// Step 1 - prepare data
let infinitive = '-', contemporaryAdverbialParticiple = '-', lang = $('#lang').val();
data.map(function(element, index) {
if (element[2].indexOf('inf:imperf') > -1) { infinitive = element[0]; }
if (element[2].indexOf('pcon:imperf') > -1) { contemporaryAdverbialParticiple = element[0]; }
});
// Step 2 - draw table
let tableContent =
'<div class="table-container">' +
'<h2><span lang="pl">Pozostałe</span><span lang="en">Others</span></h2>' +
'<table class="table table-striped table-styling">' +
'<tbody>' +
'<tr>' +
'<td class="border-top-none border-right"><span lang="pl">Bezokolicznik</span><span lang="en">Infinitive</span></td>' +
'<td class="border-top-none">' + infinitive + '</td>' +
'</tr>' +
'<tr>' +
'<td class="border-right"><span lang="pl">Imiesłów przysłówkowy współczesny</span><span lang="en">Contemporary adverbial participle</span></td>' +
'<td>' + contemporaryAdverbialParticiple + '</td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>';
if (infinitive != '-' || contemporaryAdverbialParticiple != '-') {
$('#lexpelement_morfeusz').append(tableContent);
return true;
}
return false;
}
Morfeusz.wordClick = function(res) {
Lexp.target = "plwordnet";
Lexp.go2URL(res.getAttribute("href"));
return false;
}
Morfeusz.prototype.showHTML = function(tag) {
let baseForm, others, table1, table2, table3, table4, table5, table6, table7, table8, table9, table10;
if ("analyse" in this.data) {
if ($('#type option:selected').val() != 'orth') {
table1 = this.showIndicativePresent(this.data.analyse);
table2 = this.showIndicativePast(this.data.analyse);
table3 = this.showImperative(this.data.analyse);
table4 = this.showLanguageCase(this.data.analyse);
table5 = this.showLanguageCase2(this.data.analyse, false);
table6 = this.showLanguageCase2(this.data.analyse, true);
table7 = this.showExtendedLanguageCase(this.data.analyse, false);
table8 = this.showExtendedLanguageCase(this.data.analyse, true);
table9 = this.showExtendedLanguageCase2(this.data.analyse, false);
table10 = this.showExtendedLanguageCase2(this.data.analyse, true);
}
others = this.showOthers(this.data.analyse);
baseForm = this.showBaseForm(this.data.analyse);
$('#lexpelement_morfeusz img').hide();
} else {
if ($('#type option:selected').val() != 'orth') {
table1 = this.showIndicativePresent(this.data.generate);
table2 = this.showIndicativePast(this.data.generate);
table3 = this.showImperative(this.data.generate);
table4 = this.showLanguageCase(this.data.generate);
table5 = this.showLanguageCase2(this.data.generate, false);
table6 = this.showLanguageCase2(this.data.generate, true);
table7 = this.showExtendedLanguageCase(this.data.generate, false);
table8 = this.showExtendedLanguageCase(this.data.generate, true);
table9 = this.showExtendedLanguageCase2(this.data.generate, false);
table10 = this.showExtendedLanguageCase2(this.data.generate, true);
}
others = this.showOthers(this.data.generate);
baseForm = this.showBaseForm(this.data.generate);
}
if (!baseForm && !others && !table1 && !table2 && !table3 && !table4 && !table5 && !table6 && !table7 && !table8 && !table9 && !table10) {
$('#lexpelement_morfeusz').append('<h2 class="error"><span lang="pl">Przepraszamy, nie mamy w bazie informacji na temat wybranego lematu</span><span lang="en">We are sorry, we don\'t have information about this lemma in the database</span></h2>');
}
$('#lexpelement_morfeusz img').hide();
}
Morfeusz.id = "morfeusz";
$(function () {
Element.addVisualizer(Morfeusz.id, Morfeusz);
});